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

F$ENVIRONMENT("PROCEDURE") within Fortran

SOLVED
Go to solution
HDS
Frequent Advisor

F$ENVIRONMENT("PROCEDURE") within Fortran

Hello.

I am looking for the system service (or the like) that would return the name of the executing command file.

I know that, in DCL, I could use the F$ENVIRONMENT("PROCEDURE") lexical.

Is there anything that would do the same in Fortran[-77] ??

Many thanks.
-Howard-
5 REPLIES
Karl Rohwedder
Honored Contributor

Re: F$ENVIRONMENT("PROCEDURE") within Fortran

Out of memory I know no easy what, but you could easily setup a DCL symbol before running your program and read it inside the program using LIB$GET_SYMBOL.

regards Kalle
Hoff
Honored Contributor

Re: F$ENVIRONMENT("PROCEDURE") within Fortran

Getting specific DCL-level details from within an application isn't necessarily directly available (short of some supervisor-mode hackery). No, there's no documented API back into DCL to get this or other similar details.

If you want to look for supervisor-mode code related to the cited hackery, you'll want to search for the (undocumented) sys$cli call, and at various of the tools that look at or dump DCL symbols and such. There have been various examples posted around the 'net over the years.

It's certainly also possible to provide a way for the DCL to tell the Fortran its name; to have the DCL pass in data that the Fortran code can use. That's little effort, and there are various documented means to pass along that information. If you combine this work with some DCL batch restart-related DCL symbols for instance, you can create a quite robust process management environment.

There are cases when there is no DCL present in the process, and I've certainly written and maintained Fortran code that runs as a fully detached process. A CLI-related callback in this run-time environment would return the classic NOCLI error.

There are ways to directly acquire information related to a batch job, if that is of interest. That involves calls into the sys$getqui system service. There are examples of that (mildly hairy) system service (and its associated DCL f$getqui lexical) posted at various spots around the 'net.

Stephen Hoffman
HoffmanLabs



Steven Schweda
Honored Contributor

Re: F$ENVIRONMENT("PROCEDURE") within Fortran

I'd also vote for having something in the DCL
pass what it knows to the Fortran program.

Now, if you wanted the program to identify
its own _executable_, you should be able to
get that from SYS$GETJPI() with item code
JPI$_IMAGNAME (which I know I can do in C,
and I could probably puzzle out in Fortran,
eventually).
David B Sneddon
Honored Contributor
Solution

Re: F$ENVIRONMENT("PROCEDURE") within Fortran

Howard,

Not in Fortran but I have some macro that will
do what you want... it is on the latest (I think)
freeware CD.
Package is DBS-SYSRTL.
Routine is DCL_ENVI_PROCEDURE.

Dave
HDS
Frequent Advisor

Re: F$ENVIRONMENT("PROCEDURE") within Fortran

Thank you for your responses.

-H-