How to get command line arguments in OpenVMS Fortran?

送分小仙女□ 提交于 2021-02-10 18:23:12

问题


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

回答1:


"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




回答2:


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.



来源:https://stackoverflow.com/questions/63932163/how-to-get-command-line-arguments-in-openvms-fortran

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!