ifortからgfortranへの移行〜Can't Open included file編~
手短に
上記のようなフォルダ構成のプロジェクトのコンパイル
root> ifort -o hoge test00/*.f90 test01/src/*.f90
だとコンパイルが通るが、
root> gfortran -o hoge test00/*.f90 test01/src/*.f90
これだと通らない。
きったないMakefile
を書いて解決
環境
OS:ubuntu 18.04LTS
コンパイラ:gcc 7.4.0
解決方法
件のMakefile
はこちら。(Makeはずぶの素人なのでユルシテ…)
hoge: test00.o test01.o
gfortran -o hoge test00.o test01.o -g
test00.o: test00/test00.f90 head00
gfortran -c test00/test00.f90 -o test00.o -g
test01.o: test01/src/test01.f90 head00 test01/head01
gfortran -c test01/src/test01.f90 -I./test01/ -I./ -o test01.o -g
原因
ifort
だと依存関係は明らかにしなくても羅列するだけでよしなにやってくれているらしい
一方で、gfortran
だと依存関係を1つ1つ書かないといけないらしい
ちなみに
twitterでわからんって言ってたら、つよつよFortranエンジニアの方から反応をいただきました。
近々Fotran+CMakeで幸せになる記事を書かれるそうです。(ありがてぇ(五体投地))
Fortran90+Makefileは、各ソースの依存関係までは自分で定義しないといけないので、結局自力でやる部分が多いうえにgnuでないと使えない(Windowsに持ち出しにくい)けれど
— ねこぜせんぱい (@ijknabla) 2019年6月9日
cmakeであれば、ソースファイルをリストで書くだけで依存関係の解決までやってくれるしコンパイラ/OSに依存しないし最高。
Author And Source
この問題について(ifortからgfortranへの移行〜Can't Open included file編~), 我々は、より多くの情報をここで見つけました https://qiita.com/cuz/items/e7be3787385d88729321著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .