简体   繁体   English

执行程序时的Fortran77参数

[英]Fortran77 parameter when executing program

I am currently doing a Fortran77 assignment, so please don't tell me the exact coding, but please give me a hint of what I want to do: 我目前正在执行Fortran77作业,因此请不要告诉我确切的编码,但是请给我一些提示:

Using UNIX terminal, I would like to get the parameter passed on by executing 使用UNIX终端,我想通过执行来传递参数

./program.exe parameter

In standard Fortran77 you can't. 在标准Fortran77中,您不能这样做。 End of story. 故事结局。 Accessing command line arguments with fortran programs wasn't standardized until Fortran 2003. 直到Fortran 2003才开始使用fortran程序访问命令行参数。

If you're using the GNU fortran compiler, you can use the iargc() and getarg(i, arg) functions, which return the number of arguments and the value of a specific argument, resepectively. 如果使用的是GNU fortran编译器,则可以使用iargc()getarg(i, arg)函数,它们分别返回参数的数量和特定参数的值。

It is possible to access command line arguments in FORTRAN77. 可以在FORTRAN77中访问命令行参数。

Given below is the code fragment I use : 下面给出的是我使用的代码片段:

  CHARACTER ARGV*10
  N=IARGC()
  CALL GETARG(1,ARGV)

Just do ./a.out 1 2 3 刚做./a.out 1 2 3

ARGV will store the value of the first argument, ie, 1 ARGV将存储第一个参数的值,即1

To convert this argument to float, use 将此参数转换为float,请使用

  READ (ARGV,*) RARG

RARG will convert ARGV into a floating-point integer. RARG会将ARGV转换为浮点整数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM