What should I do with the built-in FORTRAN that was not part of the standard?

I am trying to get legacy FORTRAN code by creating it from source using gfortran. I finally was able to build it successfully, but now I get an error beyond when it starts. I used gdb and traced the error to a function that uses the loc () intrinsic property. When I try to print the loc(ae) value, when ae is passed my integer value, I get the error message "No symbol" loc "in current context". I tried compiling with ifort 11.x and debugging with DDT and got the same error. For me, this means that the compiler knows nothing about the internal.

A little reading showed that loc intrinsic was not part of the F77 standard, so maybe this is part of the problem. I have placed the definition of an internal property below, but I do not know how to implement this in my code, so loc () can be used.

Any advice or am I misinterpreting my problem? Since both gfortran and ifort fail in the same place due to an error outside the bounds, but a function using loc () returns the same large number between both compilers. It seems a little strange that loc () will not work if both compilers shoot the same value for loc.

Using:

iaddr = loc (obj)

Where:

An OBJ is a variable, array, function, or subroutine whose address is required. iaddr is an integer with the address "obj". The address is in the same format stored in the LARn instruction.

Description:

LOC is used to get the address of something. The return value is not really useful in Fortran, but may be needed for GMAP routines or very special debugging.

+4
source share
2 answers

Well, no, the fact that it compiles means that loc is known to the compiler; the fact that gdb does not know about this simply means that it is simply not known to the debugger (which probably does not know the built-in matmult ).

loc is a widespread custom extension. I hate them. If you want something standard that should work throughout, c_loc , which is part of the Fortran2003 C ↔ Fortran compatibility standard, is something you can use. It returns a pointer that can be passed to C routines.

How is the value from the loc call used?

+5
source

Gfortran loc seems to work differently with arrays with some other compilers. If you use it, for example, to test instances of an array or such, it is best to use loc of the first element loc (obj (1,1)) or similar. This is equivalent to what I think using intel, but in gfortran it gives a different address instead (so two arrays that have exactly the same memory layout have different search results).

0
source

All Articles