Quantcast
Channel: Intel® Fortran Compiler
Viewing all articles
Browse latest Browse all 3270

Use of %LOC to get address of variable

$
0
0

I am trying to build/run some old Compaq VF in Intel VF and it is failing with the error below however I think the error may be a red-herring, Looking at the FORT.1 file it seems to be in 256 byte blocks (there is an FF every 256 bytes).  I have stepped through the code and the error is thrown by a read statement:

READ(1,REC=IREC1) ( BUFER1(J+IBUFER10), J=1,LREC )

However IBUFFER10 is -1472 and I suspect this is the actual cause of the problem, IBUFFER10 gets set by a call to a subroutine

CALL XXMADDR( BUFER1_1, BUFER1, 1, IBUFER10 )

And the subroutine is

SUBROUTINE XXMADDR( X_1, X, N, IX0 )

C Purpose
C     Find the element IX0 in the dummy array X corresponding to the
C     array X such that X(I+IX0) = X_1(I) for all I.

C Method
C     The function %LOC is used on the VAX, IG2LOC on the IBM.  These
C     find the addresses of X and X_1.
C     X_1, X must be non-character variables on the VAX in particular.

C Input
C  ?*N  X_1(*) - The array that is needed to be referenced via X.
C                 Usually this will have been passed into the previous
C                 subroutine through a dummy ENTRY point.
C  ?*N  X(*)   - Dummy array
C  I*4  N      - No. of bytes for each element of X_1 and X

C Output
C  I*4  IX0 - Location in X such that X(I+IX0) = X_1(I) for all I.

C Programmed by A.Penwill, June '91



      INTEGER  X_1(*), X(*)

      IDIFF = %LOC(X_1) - %LOC(X)

C       Test that the difference between the addresses of X_1 and X is
C       divisible by N.

      IF ( MOD( IDIFF, N ) .NE. 0 ) CALL XXERR( 'XXMADDR1', 26,
     1                                 'Alignment error in XXMADDR', 4 )

      IX0 = IDIFF / N

      RETURN
*     ======>

      END

Stepping though this the address of X is > than the address of X_1 hence the negative result. I have tried swapping the input variables to get a +ve offset but it still fails with the inconsistent record length error. Am I barking up the right tree???

The error, just for info

forrtl: severe (37): inconsistent record length, unit 1, file d:\_work\CAPS\CDMIN_Problem\fort.1
Image              PC        Routine            Line        Source
libifcoremd.dll    0F2519A2  Unknown               Unknown  Unknown
libifcoremd.dll    0F27DA8C  Unknown               Unknown  Unknown
XXSUBS.dll         0FB24A61  _XXWF00                   165  XXWF00.FOR
XXSUBS.dll         0FB3608A  _XXDM00                   228  XXDM00.FOR
XXSUBS.dll         0FB2602D  _XXDBSC                    48  XXDBSC.FOR
XXMJOB.DLL         6C221252  _XXMJOB                   119  XXMJOB.FOR
XXMAIN.EXE         00411DF7  Unknown               Unknown  Unknown
XXMAIN.EXE         004123F8  Unknown               Unknown  Unknown

 


Viewing all articles
Browse latest Browse all 3270

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>