How to use Photran with G95

Now you can develop your Fortran programs with g95 using Photran, a full featured Fortran IDE based on Eclipse. It is available for both Windows and Linux systems. This is a summary of the steps required to setup Photran and g95 on a Windows XP system.

1. If you use MinGW it is useful to download and install "msys" and "msysDTK" from www.mingw.org. The Msys bin directory has to be in your path.

2. Generating a g95 Makefile automatically

(Skip this section if you don’t want to use mkmf for auto creation of Makefile)

Set up mkmf by carefully following all the directions provided in How to use mkmf with g95. If your paths are different from those used in the install instructions make appropriate adjustments to the paths used in the following steps.

In order to use mkmf in Photran, Perl 5 must be installed. If using Windows, Perl is included in the msysDTK package from www.mingw.org.

2.1. Open Photran and click the menu "Run -> External tools -> External tools..."

2.1.1. On the Main Tab fill out the form as follows:

Name: g95 make Makefile
Location: c:/mingw/bin/mkmf-g95.bat
Working directory: ${container_loc}
Arguments: ${project_name}

Note: The file c:\mingw\bin\mkmf-g95.bat is the batch file for running the mkmf Perl script described in Section 6 of How to use mkmf with g95

2.1.2 Refresh Tab

For refresh tab fill the form as follows:

[x] Refresh resources upon completion

(x) The folder containing the selected resources

[x] Recursively include sub-folders

2.1.3. Common Tab

(x) Local file

Display in favorite menu

[x] External Tools

[x] Launch in background

2.1.4. Click "Apply"

2.2  On the Photran toolbar click the menu "Run -> External tools -> External tools..."

2.2.1  Start a new configuration.

2.2.2  On the Main Tab fill out the form as follows:

Name: g95 build
Location: c:/msys/1.0/bin/make.exe
Working directory: ${container_loc}
Arguments: all

2.2.3  Fill out the Refresh Tab as in 2.1.2 and the Common Tab as in section 2.1.3

2.2.4  Click "Apply"

2.3  On the Photran toolbar click the menu "Run -> External tools -> External tools..."

2.3.1  Start a new configuration.

2.3.2  On the Main Tab fill out the form as follows:

Name: Run
Location: ${container_loc}/${resource_name}
Working directory: ${container_loc}
Arguments: 

2.3.3  Fill out the Refresh Tab as in 2.1.2 and the Common Tab as in section 2.1.3

2.3.4  Click "Apply"

3. Click on menu Windows->Preferences->C/C++->Make->Makefile Editor->New Make Projects.

Choose Tab 'Binary Parser'. Enable 'PE Windows Parser' and disable all others. Click on the OK button.

4. Setup is done.

To edit, compile and run Fortran programs do the following:

1. File->New->Standard Make Fortran Project. Give a name to your project in the 'Project Name' field. Click 'Finish'.

2. Make sure that your project name is highlighted in the 'Fortran Projects' or 'Navigator' frame on the left. Click File->New->Source File. Fill out the 'Source File' field (e.g. myprogram.f90). Click 'Finish'.

3. Type your code in the new editor tab and save it (File->Save)

4. Add further source files if necessary.

5. Click on one of your source files in the Navigator or Fortran projects frame.

6. Create Makefile

6.1. If you have set up mkmf (see section 2) do as follows:

6.1.1. Click menu "Run->External tools->External tools ..."

6.1.2. Choose (e.g.) "g95 make Makefile" and click the "Run" button. In the Navigator/Fortran Projects frame you should see the "Makefile" file in your project section. (After the first run of "g95 make Makefile" it will appear in the root section of the External tools submenu or toolbar icon for easy invocation.)

6.2. If you have not set up mkmf on your system you will need to code the Makefile yourself

7. Select one of your source files in the Navigator/Fortran Projects frame again.

8. Click menu "Run->External tools->External tools ..." and select "g95 build". 

9. After compilation you should see "myprogram.exe" in your Navigator/Fortran Projects frame.

10. Select "myprogram.exe" in the Navigator/Fortran Projects frame, then click on the  menu "Run->External tools->External tools ..." and select "Run". The program output will display in the Console. 

For information on setting up Photran with Cygwin, see: ftp://ftp.swcp.com/pub/walt/F/photran.pdf