0

私は gfortran を使用して、多数のモジュールを含む大きなプログラムをコンパイルしています。コードにエラーがあると、プログラムはエラーが発生した行番号とその行が属するモジュールのフル パスを含むエラー メッセージを生成します。例えば:

At line 1775 of file C:\temp\test.f90 (Unit = 200, file=' ')
Fortran Run time error: File '*' does not exist

私の質問は、プログラムが問題のあるモジュールの完全なパスをリストするのをどのように停止し、エラーが発生したモジュール名のみを報告するようにするかです。

4

1 に答える 1

1

gfortranコンパイル段階でソース ファイルへのアクセスに使用されたパスを埋め込みます。たとえば、ファイルへのフル パスを指定してコンパイルすると、デバッグ出力にフル パスが表示されます。相対パスでコンパイルすると、出力に相対パスが表示されます。

~/tests[520]$ gfortran -o test.x test.f90
~/tests[521]$ test.x
At line 3 of file test.f90 (unit = 200, file = '')
Fortran runtime error: File '' does not exist

~/tests[522]$ gfortran -o test.x ./test.f90
~/tests[523]$ test.x
At line 3 of file ./test.f90 (unit = 200, file = '')
Fortran runtime error: File '' does not exist

~/tests[524]$ gfortran -o test.x ~/tests/test.f90
~/tests[525]$ test.x
At line 3 of file /home/username/tests/test.f90 (unit = 200, file = '')
Fortran runtime error: File '' does not exist

相対パスを使用してのみソースにアクセスするようにコンパイル コマンドを変更します。

于 2012-06-12T09:25:27.193 に答える