Anton Golovenko
Anton Golovenko

Reputation: 644

How to get command line arguments in OpenVMS Fortran?

I need to realize c-code in fortran 90 standard and stopped on next problem. How get and use command line arguments. I found

GET_COMMAND_ARGUMENT

getarg

But it doesn't work in the openvms system with fortran 90 compiler. There is another way to get command line arguments in Fortran?

Example in C

   int main(int argc, char **argv)
{
  if (argc > 1)
....
}

Example (which doesn't work "

ILINK-W-NUDFSYMS, 2 undefined symbols:
%ILINK-I-UDFSYM, GETARG
%ILINK-I-UDFSYM, IARGC
%ILINK-W-USEUNDEF, undefined symbol IARGC referenced )

PROGRAM bulk1
    INTEGER :: i
    CHARACTER(len=32) :: arg

    DO i = 1, iargc()
    CALL getarg(i, arg)
    WRITE (*,*) arg
    END DO
END PROGRAM

Upvotes: 1

Views: 349

Answers (2)

Hein
Hein

Reputation: 1463

If you have licenses for both compilers, you may want to look at creating a C main program, calling the Fortran service function.

A relatively easy way to get the commandline, albeit without further parsing into 'words', would be to call the OpenVMS specific function LIB$GET_FOREIGN

Check out: http://computer-programming-forum.com/49-fortran/e047637fc421ace6.htm

Good luck. Hein.

Upvotes: 1

Anton Golovenko
Anton Golovenko

Reputation: 644

"How do I access the program command line?" is likely to feature high on any Fortran related FAQ. Unfortunately, the equally frequent answer is "It depends". Up to and including Fortran 95, there has been no standard method of command-line access. While the F2003 standard finally addresses this requirement, it is reasonable to assume that F2003 compilers will not be in general usage for some time. In the meantime, this leaves the Fortran community with its existing hotchpotch of inconsistent solutions for several years to come.

You can use this library http://www.winteracter.com/f2kcli/index.htm

Upvotes: 2

Related Questions