作者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/m.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