作者aeolus0829 (阿洽)
看板Linux
标题Re: [问题] 从unix的shell script呼叫fortran跑回圈
时间Thu Aug 12 17:40:47 2021
※ 引述《bearching (Exploring inspirations)》之铭言:
: ※ [本文转录自 Fortran 看板 #1X58vrGJ ]
: 作者: bearching (Exploring inspirations) 看板: Fortran
: 标题: [问题] unix的shell script呼叫fortran跑回圈
: 时间: Thu Aug 12 10:58:59 2021
: 我是fortran的超超超超新手
: 所以想要请问一下,
: 我平常是需要远端连到unix上,用shell script跑程式,
: 然後这个程式会呼叫fortran的程式进来跑资料
: 我的问题可能满笼统的,因为其实也不知该从何问起XD
: 就是我想在shell script写个回圈,
: 假设i 是我的变数好了
: for i in {1..10}这样
: 那我呼叫的fortran
: PGM="abc.f"
在 shell 呼叫外部程式,以 php 为例
PGM="/path/to/program/abc.php"
php $PGM
或者直接写成
php /path/to/program/abc.php
: 请问一下在这个abc.f里面直接把loop的变数$i写进去
一样以 php 为例
PGM="/path/to/program/abc.php $i"
php $PGM
: 那我在执行shell script的时候,
: 呼叫abc.f的时候,能够顺利执行吗?
: 不好意思因为真的很不熟悉fortran跟unix,问的问题可能很笨
: 再麻烦各位了,谢谢
你可能要先建个 lab ,跑看看再来问会比较具体一点
fortran 应该可以在 linux 跑吧
刚爬文看 fortran 是编译程式,而 php 是直译程式
因此 fortran 的作法就不会是
php $PGM 这种
会比较偏 make 这种
程式写完要先 compile 成 binary 再执行
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 59.126.254.234 (台湾)
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Linux/M.1628761249.A.E57.html
1F:推 rickieyang: 管他编译或直译, 一样都吃参数就好. 08/12 18:20
2F:→ rickieyang: 另外, PGM="/path/to/program/abc.php $i" ; php $PGM 08/12 18:21
3F:→ rickieyang: 改 PGM="/path/to/program/abc.php"; php "$PGM" "$i" 08/12 18:23
4F:→ rickieyang: 好像好一些. 08/12 18:23