Operating System - OpenVMS
Showing results for 
Search instead for 
Did you mean: 

parameter/ variable/ argument passing in Fortran 77

Go to solution
Neal Kirby

parameter/ variable/ argument passing in Fortran 77

Can some one provide an example for the falling (Fortran 77):

In a .COM (on OVMS 7.3-2) I want to set a parameter/ variable/ argument etc that will only exist for the life of the .COM script.

This first .COM runs another .COM script. The second .COM runs 2 .FOR(exe) programs. Each of these .FOR(exe) programs must check for the existance of the original parameter/ variable/ argument within a conditional (if) statement. Depending on whether the parameter/ variable/ argument is set or not - the (if) statement executes the relevant code.

I hope someone can decipher my description. Any input would be appreciated.


Karl Rohwedder
Honored Contributor

Re: parameter/ variable/ argument passing in Fortran 77

To get the value of DCL symbols into your FORTRAN programm you may use the LIB$GET_SYMBOL runtime function, e.g.
STATUS=LIB$GET_SYMBOL('symbol', Cstring, Ilength), see HELP RTL LIB$ for help.

regards Kalle
Jan van den Ende
Honored Contributor

Re: parameter/ variable/ argument passing in Fortran 77


and the second part of your question: do the symbol assignment with LOCAL SCOPE;

$ My_symbol = "value_of_my_symbol"

My_symbol is the name of your variable
= is the token for LOCAL SCOPE symbol assignment
" (double quote) is the beginning and ending for string symbol values. Leave them out for integer values.

The value of a LOCAL SYMBOL exests withing the scope of the .COM procedure, and of .COMs called by it. However, IF a called .COM assigns that same symbol name, in the scope of THAT procedure it takes precedence.
Any LOCAL symbols loose ant meaning upon EXIT (impleid or explicit) from the defining .COM
To stress the point: if a called .COM redefines the value of my_suymbol in its scope, upon return into the calling .COM, the value set WITHIN the calling .COM is still valid!

You can also define in GLOBAL SCOPE by using a double ==, which remains in effect until explicitly redefined or deleted, but any existing LOCAL scope symbol always takes precedence. (but again, that CAN be overruled with SET SCOPE/NOLOCAL, which in itself as local scope)



Have one on me.


Don't rust yours pelled jacker to fine doll missed aches.
Joseph Huber_1
Honored Contributor

Re: parameter/ variable/ argument passing in Fortran 77

Neal, in addition to the DCL symbol passing , eventually use command-line arguments in calling the Fortran programs.

There is the VMS RTL routine LIB$GET_FOREIGN
get the whole, unprocessed DCL "foreign" command-line, and parse it's content inside the fortran program.

Use VMS excellent DCL parsing with the CLI$ routines (see HELP CLI).
Examples to use it in a Fortran program are e.g. in my
and several programs in http://www.huber-joseph.de/util/main/

Finally there are the (forthcoming F2003) standard Fortran library calls to get command-lines.

A preliminary implementation can be found in the F2KCLI package at
The F2003 standard calls are
COMMAND_ARGUMENT_COUNT : Returns the number of command arguments
GET_COMMAND_ARGUMENT : Returns a command argument.
GET_COMMAND : Returns the entire command

Using f2kcli makes the program portable to any standard Fortran environment.
Neal Kirby

Re: parameter/ variable/ argument passing in Fortran 77

Thanks to all contributions. I had used the Symbol passing as suggested and was wondering why it was not working the way it should have been. My compiler was acting up. My interpretation was correct - thanks jpe / Karl for your confirmation. Joseph's solution - I will test at a later date. NK.
John Gillings
Honored Contributor

Re: parameter/ variable/ argument passing in Fortran 77


If it's an existence yes/no type switch, it might be easier to use a logical name.

Fortran code:


! Logical name was defined
! Logical name not defined

LIB$GET_LOGICAL will return TRUE if the logical name was defined or FALSE if not.

In your command procedure:

A crucible of informative mistakes