LoginSignup
3
5

More than 5 years have passed since last update.

fortran90でコマンドライン引数を取得

Posted at
getarg(k,arg)
integer :: k !入力: 引数の索引 (0 = 最初の引数 = コマンド名) 
character :: arg*n !出力: k番目の引数
iargc()
integer :: iargc !返り値: コマンドラインの引数の個数
実行ファイル名のすぐ後の引数をoptionalに取得
integer :: i
character :: arg*10

if(iargc()>0)then !実行ファイル名以外の引数がある時
   call getarg( 1, arg ) !文字列として取得
   read(arg,*) i !整数に変換
else
   i=7 !無ければ適当な値
end if

fortran2000とかなら別のやり方があるらしい

3
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
5