我正在使用Windows 7。这是我的代码
program Myfirstfortran
implicit none
character*20 :: name
print *, "What's your name "
read *, name
print *, "Hello ", name
end program Myfirstfortran
如何在cmd上编译此fortran程序?
如Vladimir F所述,您应该添加一些有关Windows 7计算机上使用的FORTRAN编译器的详细信息。
如果使用的是INTEL Fortran编译器,则可以在命令行上使用以下命令:
ifort Myfirstfortran.f90 /exe:Myfirstfortran.exe
有关ifort invoking的更多信息。
如果您使用的是GNU Fortran编译器,请输入以下内容:
gfortran Myfirstfortran.f90 -o Myfirstfortran.exe
有关gfortran invoking的更多信息。
请确保已将编译器的二进制目录添加到您的PATH
环境变量中。否则,您必须使用绝对路径调用编译器,例如
C:\<Program dir>\<Compiler dir>\<compiler_linker_exe> ...
希望有帮助吗?