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
將編譯命令更改爲僅使用相對路徑訪問源。
感謝Hristo,但我的程序是用Cmake編譯的,我沒有明確告訴gfortran我的源文件的位置。相反,我將源文件夾和bin文件夾輸入到Cmake GUI中。源文件是輸入到Cmakelist.txt文件中的信息的一部分。我不知道在CMake GUI中是否有一個選項可以設置爲使其通過相對路徑而不是完整路徑。 謝謝 Abdinasir –
對不起,我從來沒有使用Cmake GUI(甚至不知道它存在到現在)。 –