Fortran 简明教程
Fortran - Environment Setup
Setting up Fortran in Windows
G95 是用于在 Windows 中设置 Fortran 的 GNU Fortran 多架构编译器。Windows 版本使用 MinGW 模拟 Windows 上的 Unix 环境。安装程序处理此问题并自动将 g95 添加到 Windows PATH 变量。
G95 is the GNU Fortran multi-architechtural compiler, used for setting up Fortran in Windows. The windows version emulates a unix environment using MingW under windows. The installer takes care of this and automatically adds g95 to the windows PATH variable.
您可以从 here 获取 G95 的稳定版本
You can get the stable version of G95 from here


How to use G95
在安装过程中,如果你选择“推荐”选项, g95 将自动添加到你的 PATH 变量。这意味着你可以直接打开一个新的命令提示符窗口并输入“g95”来启动编译器。以下是一些基本命令,助你入门。
During installation, g95 is automatically added to your PATH variable if you select the option “RECOMMENDED”. This means that you can simply open a new Command Prompt window and type “g95” to bring up the compiler. Find some basic commands below to get you started.
Sr.No |
Command & Description |
1 |
g95 –c hello.f90 Compiles hello.f90 to an object file named hello.o |
2 |
g95 hello.f90 Compiles hello.f90 and links it to produce an executable a.out |
3 |
g95 -c h1.f90 h2.f90 h3.f90 Compiles multiple source files. If all goes well, object files h1.o, h2.o and h3.o are created |
4 |
g95 -o hello h1.f90 h2.f90 h3.f90 Compiles multiple source files and links them together to an executable file named 'hello' |
Command line options for G95
-c Compile only, do not run the linker.
-o Specify the name of the output file, either an object file or the executable.
可以一次指定多个源文件和对象文件。Fortran 文件由以 “.f”, “.F”, “.for”, “.FOR”, “.f90”, “.F90”, “.f95”, “.F95”, “.f03” 和 “.F03”结尾的名称指示。可指定多个源文件。也可指定对象文件,并将其链接起来形成可执行文件。
Multiple source and object files can be specified at once. Fortran files are indicated by names ending in ".f", ".F", ".for", ".FOR", ".f90", ".F90", ".f95", ".F95", ".f03" and ".F03". Multiple source files can be specified. Object files can be specified as well and will be linked to form an executable file.