Path: utzoo!attcan!uunet!lll-winken!lll-lcc!mordor!joyce!ames!pasteur!ucbvax!GOLD.BACS.INDIANA.EDU!ijah400%ivax.DECnet From: ijah400%ivax.DECnet@GOLD.BACS.INDIANA.EDU ("IVAX::IJAH400") Newsgroups: comp.os.vms Subject: Re: LIB$GETJPI Message-ID: <8807181443.AA06135@ucbvax.Berkeley.EDU> Date: 13 Jul 88 18:28:00 GMT Sender: usenet@ucbvax.BERKELEY.EDU Organization: The Internet Lines: 44 Christopher Chiesa writes (about passing arguments by reference to library routines): < In article <8807071431.AA22249@ucbvax.Berkeley.EDU>, sysmgr@JALCF.WPAFB.AF.MIL < ("SYSTEM") writes: < ... < [whatever you have to do to put a value in PID, and < invoke LIB$GETJPI...] < < STATUSCODE = LIB$GETJPI( item_code, %LOC PID, .... ) < < The %LOC modifier forces the compiler to code for passing of PID "by < reference," rather than "by value" which is apparently the default. < Like I said, it's been a while; if any more up-to-date FORTRANers < would care to correct me, that's fine! OK, here goes: %LOC is an built-in function that gives the address of its argument as the result. But STATUSCODE = LIB$GETJPI( item_code, %LOC PID, .... ) gives a syntax error, because %LOC(PID) is legal but %LOC PID is not. Furthermore, that isn't what the guy wants, because %LOC(PID) ends up passing the ADDRESS of PID by reference (i.e., the address of a longword containing the address of PID). What he wants is: STATUSCODE = LIB$GETJPI( item_code, %REF(PID), .... ) or STATUSCODE = LIB$GETJPI( item_code, PID, .... ) which generate the same code, as the default argument passing mechanism in VAX FORTRAN is by REFERENCE. The built-in function %REF may be used in actual argument lists to be picky about the fact that you want something passed by reference. VAX FORTRAN also has an built-in function %VAL to specify that an argument be passed by value, %DESCR to pass the address of a descriptor (the default for CHARACTER data, etc., RTFM). Note that the FORTRAN-77 standard does not REQUIRE that arguments be passed by reference; the value-result (copy-in, copy-out) mechanism is OK too. For example, the PDP-10 (TOPS-10 and TOPS-20) FORTRAN compilers use the value-result mechanism for scalar data items. It really only makes a difference if your programmers are doing things prohibited by the FORTRAN standard (like passing a COMMON variable to a routine that refers to it both by the COMMON variable name and the formal argument name). All the other FORTRAN compilers I've ever encountered, including VAX FORTRAN, use the reference mechanism by default. Hope this helps.... James Harvey ijah400@indyvax (bitnet) or ijah400%ivax.decnet@gold.bacs.indiana.edu