[comp.os.vms] Accessing global variable from FORTRAN

tedcrane@batcomputer.tn.cornell.edu (Ted Crane) (05/01/87)

In article <8704300556.AA02237@ucbvax.Berkeley.EDU> KND@DHDMPI5.BITNET writes:
>
>I would like to access a location in a MACRO Subroutine from a FORTRAN
>Main Program and don't want to use a COMMON for that.
>The location in MACRO is defined as follows :
>
>                LABEL:: .WORD   number
>
>The %LOC function in FORTRAN gives me the ADDRESS of 'LABEL'. But how
>can I get the contents of 'LABEL' ?

It is most likely that you will have to write a subroutine or function
to do this:

	subroutine MOVE_GLOBAL(IN,OUT)
	integer*2 IN,OUT
	OUT = IN
	end

and call it:

	call MOVE_GLOBAL(%val(LABEL),RESULT)

(You can extrapolate the function call form of this)

The interesting thing is that using VAX FORTRAN, the global variable
need not be a simple tpye such as <word=integer*2>.  All that is
necessary is to declare the global variable appropriately in the subroutine/
function.  It could be an array or a structure.  You could return any
value at all, whether it is one array element, a field from a structure, or
something calculated.