Re: [问题] 从unix的shell script呼叫fortran跑循环

楼主: aeolus0829 (阿洽)   2021-08-12 17:40:47
※ 引述《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 再执行
作者: rickieyang (Rickie Yang)   2021-08-12 18:20:00
管他编译或直译, 一样都吃参数就好.另外, PGM="/path/to/program/abc.php $i" ; php $PGM改 PGM="/path/to/program/abc.php"; php "$PGM" "$i"好像好一些.

Links booklink

Contact Us: admin [ a t ] ucptt.com