Operating System - OpenVMS
1752579 Members
4144 Online
108788 Solutions
New Discussion юеВ

Re: parameter/ variable/ argument passing in Fortran 77

 
SOLVED
Go to solution
Neal Kirby
Advisor

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.

Thanks

Neal
5 REPLIES 5
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
Solution

Re: parameter/ variable/ argument passing in Fortran 77

Neal,

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)

hth

Proost.

Have one on me.

jpe

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
(see HELp RTL LIB$ 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
http://www.huber-joseph.de/util/init_cli_for.for
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
http://www.winteracter.com/f2kcli
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.
http://www.mpp.mpg.de/~huber
Neal Kirby
Advisor

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

Neal,

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

Fortran code:

LOGICAL LIB$GET_LOGICAL
...

IF(LIB$GET_LOGICAL('NEALS_SWITCH'))THEN
! Logical name was defined
ELSE
! Logical name not defined
ENDIF

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

In your command procedure:

$ DEFINE NEALS_SWITCH YES
$ RUN ENALS_PROGRAM
A crucible of informative mistakes