1) Download the MinGW installer from this location: http://sourceforge.net/projects/mingwbu ... =directory
This is a minimal Web installer that will bring up an install Wizard to guide you through the installation process.
2) Run the installer downloaded from the above step:
Code: Select all
c:\temp\mingw-builds-install.exe
Code: Select all
C:\Program Files\mingw-builds\x32-4.8.1-posix-dwarf-rev3\mingw32\
IMPORTANT: Take extreme care when editing this PATH environment variable. Only add to it. Never delete from it.
More details about the PATH can be found here: viewtopic.php?f=5&t=6176
To test the PATH setting changes, start a Windows Command Line Prompt and type in this command line:
Code: Select all
gfortran.exe --version
Code: Select all
GNU FORTRAN (rev3, Built by MinGW-builds project) 4.8.1
Copyright (C) 2013 Free Software Foundation, Inc.
GNU FORTRAN comes with NO WARRANTY, to the extent permitted by law.
You may redistribute copies of GNU FORTRAN
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING
The information below shows how to run the Fortran compiler from inside the Zeus IDE.
Use the Zeus Options, Document Types menu and edit the FORTRAN Document Type and in the Compiler section define the following details:
Code: Select all
Command Line: gfortran.exe "$fn" -o "$fdd$fb.exe"
Errors Regexp: (^Error:)|(\:[0-9]+\.[0-9]+\:$)|(\:[0-9]+[\.0-9]*\:$)
(^Error:)|(\:[0-9]+\.[0-9]+\:$)|(\:[0-9]+[\.0-9]*\:$)
Warnings Regexp: (^Warning:)|(\:[0-9]+\.[0-9]+\:$)|(\:[0-9]+[\.0-9]*\:$)
If you only want to syntax check the current file change the command line to be this:
Code: Select all
gfortran.exe -c "$fn"
Code: Select all
gfortran.exe --help
Using Modules
FORTRAN allows you to better structure your code by using the USE construct and putting your code into different modules:
Code: Select all
USE random
USE interpolate
...
You can do this using the -Idir as described here, which states:
-Idir
These affect interpretation of the INCLUDE directive (as well as of the #include directive of the cpp preprocessor).
Also note that the general behavior of -I and INCLUDE is pretty much the same as of -I with #include in the cpp preprocessor, with regard to looking for header.gcc files and other such things.
This path is also used to search for .mod files when previously compiled modules are required by a USE statement.
Now if we assume the modules live in a Modules folder relative to the source code, this means the command lines mention earlier become:
Code: Select all
gfortran.exe "$fn" -I.\Modules -o "$fdd$fb.exe"
gfortran.exe -c -I.\Modules "$fn"
FORTRAN comes in many dialects and you need to make sure the dialect in use matches the style of code you write.
In the configuration of the command line described earlier, use the -std command line option to set the required FORTRAN dialect.
Below is more information about the different dialects, taken from gfortran page.
Specify the standard to which the program is expected to conform, which may be one of 'f95', 'f2003', 'gnu', or 'legacy'.
The default value for std is 'gnu', which specifies a super-set of the FORTRAN 95 standard that includes all of the extensions supported by GNU FORTRAN, although warnings will be given for obsolete extensions not recommended for use in new code.
The 'legacy' value is equivalent but without the warnings for obsolete extensions, and may be useful for old non-standard programs.
The 'f95' and 'f2003' values specify strict conformance to the FORTRAN 95 and FORTRAN 2003 standards, respectively; errors are given for all extensions beyond the relevant language standard, and warnings are given for the FORTRAN 77 features that are permitted but obsolescent in later standards.
So for example, the following command line will sets the dialect to f95 and turns on the free format code layout:
Code: Select all
gfortran.exe -ffree-form -std=f95 "$fn" -o "$fdd$fb.exe"
Code: Select all
! Simple FORTRAN Program
program HelloWorld
write(*,*) "Hello World!"
end program HelloWorld
With the c:\temp\test.f95 as the active file use the Compiler, Compile menu to compile the file.
This will produce a c:\temp\test.exe and again use the DOS Command Line menu to run the executable and you should see this output:
Code: Select all
Hello World!
For example, to run the executable via a macro edit the Macros section of the FORTRAN Document Type and add the the following macro:
Code: Select all
Menu Text: Execute '$fb.exe'
Macro Name: $zud\zscript\cs_exec.py
Arguments: $fdd$fb.exe
[x] Add to popup menu
NOTE: If the executable runs but does not produce any output refer to the Mysteries of MinGW post for details on how to fix this.
Cheers Jussi