简体   繁体   English

在命令提示符下编译fortran程序

[英]Compiling a fortran program on command prompt

I'm using Windows 7. This is my code 我正在使用Windows7。这是我的代码

program Myfirstfortran
 implicit none
 character*20 :: name
 print *, "What's your name "
 read *, name
 print *, "Hello ", name

end program Myfirstfortran

How to Compile this fortran program on cmd ? 如何在cmd上编译此fortran程序?

As Vladimir F stated, you should add some details about the FORTRAN compiler which you're using on your Windows 7 machine. 如Vladimir F所述,您应该添加有关Windows 7计算机上使用的FORTRAN编译器的一些详细信息。

If you're using the INTEL Fortran compiler then you can use the following on your command line: 如果使用的是INTEL Fortran编译器,则可以在命令行上使用以下命令:

ifort Myfirstfortran.f90 /exe:Myfirstfortran.exe

More information regarding ifort invoking . 有关ifort调用的更多信息。

If you're using the GNU Fortran compiler then type this: 如果您使用的是GNU Fortran编译器,请输入以下命令:

gfortran Myfirstfortran.f90 -o Myfirstfortran.exe

More information regarding gfortran invoking . 有关gfortran调用的更多信息。

Please make sure that the compilers binary directory has been added to your PATH environment variable. 请确保已将编译器的二进制目录添加到您的PATH环境变量中。 Otherwise you have to call the compiler with the absolute path, eg 否则,您必须使用绝对路径调用编译器,例如

C:\<Program dir>\<Compiler dir>\<compiler_linker_exe> ...

Hope it helps? 希望能帮助到你?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM