24小时热门版块排行榜    

查看: 905  |  回复: 5
当前主题已经存档。

maomao1210

金虫 (正式写手)

[交流] 【求助】getarg 的用法

求高手指点Fortran 中Getarg的用法。
看程序的时候已经见到Getarg(),但始终没弄明白,求高手指点。。。。

[ Last edited by sunxiao on 2009-4-30 at 11:30 ]
回复此楼

» 收录本帖的淘帖专辑推荐

fortran相关

» 猜你喜欢

已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

snoopyzhao

至尊木虫 (职业作家)

★ ★
sunxiao(金币+2,VIP+0):谢谢参与,欢迎常来交流 3-23 23:09
g77 的说明文档中如是说:

8.11.9.118 GetArg Intrinsic
CALL GetArg(Pos, Value)
Pos: INTEGER not wider than the default kind; scalar; INTENT(IN).
Value: CHARACTER; scalar; INTENT(OUT).
Intrinsic groups: unix.
Description:
Sets Value to the Pos-th command-line argument (or to all blanks if there are fewer
than Value command-line arguments); CALL GETARG(0, value) sets value to the name of
the program (on systems that support this feature).
See Section 8.11.9.133 [IArgC Intrinsic], page 145, for information on how to get the
number of arguments.

相关的 IArgC() 如下:

8.11.9.133 IArgC Intrinsic
IArgC()
IArgC: INTEGER(KIND=1) function.
Intrinsic groups: unix.
Description:
Returns the number of command-line arguments.
This count does not include the specification of the program name itself.
2楼2009-03-23 14:11:55
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

maomao1210

金虫 (正式写手)

呵呵,感谢,不过看不明白,呵呵,
3楼2009-03-23 15:49:32
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

maomao1210

金虫 (正式写手)

这么多用fortran的,连这个用法都不会嘛????
4楼2009-03-25 09:27:39
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

老虎大王

木虫 (著名写手)

★ ★ ★ ★ ★
maomao1210(金币+5,VIP+0):Thanks a lot,.. 3-28 17:58
这个是用来返回你输入的命令行参数的。
call getarg(n,buffer)

其中n是命令序号, buffer是相应的命令行参数。运行程序本身的命令是0号,跟在它后面的参数是1,2。。。号。

比如,你写这样一个小程序:

character*80 buff
call getarg(0,buff)
write(*,*) buff
call getarg(1, buff)
write(*,*) buff
call getarg(2, buff )
write (*,*) buff
end

然后编译它,比如把这个可执行程序命名为mypro,然后键入命令如下
Linux系统,键入
./mypro   ar1 ar2
可以看到结果是
./mypro
ar1
ar2

Windows下,则键入
mypro ar1 ar2
可看到结果是
mypro
ar1
ar2

可见,用命令行方式,程序执行命令本身是第0个参数,后面跟的第1,2。。个参量则可以用相应的getarg来获得。利用这个getarg,你可以在外部输入命令时控制程序中的一些东西。
5楼2009-03-27 19:29:53
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

windhair

铜虫 (小有名气)

引用回帖:
Originally posted by maomao1210 at 2009-3-25 09:27:
这么多用fortran的,连这个用法都不会嘛????

学程序这个东西,很多不能一句句教你怎么用,你也不能等别人一句一句给你说,得结合别人给的例子的相关帮助文档来理解学习。
6楼2009-04-02 23:33:37
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 maomao1210 的主题更新
普通表情 高级回复 (可上传附件)
信息提示
请填处理意见