How to use Photran with G95
Authors:from: http://www.g95.org/howto.html
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. (Revised 25/01/2007 thanks Hani)
- If you use MinGW it is useful to download and install “msys” and “msysDTK” from www.mingw.org. The bin directory of msys has to be in your path.
- Download the Perl script “mkmf” from <http://www.gfdl.noaa.gov/fms/pubrel/k/am2/bin/mkmf.html> and copy it somewhere in your path (e.g. c:\msys\1.0\bin). Create a template file for your compiler. Below is an example template file for g95:
FC = g95
LD = g95
FFLAGS = -I c:/mingw/include
LDFLAGS = $(LIBS)
# add your libraries after LIBS= , e.g. -lblas
LIBS =
Give a name to this template file (e.g. mkmf.g95) and save it somewhere (e.g. c:\msys\1.0\bin)
- To use mkmf in Photran open Photran and click the menu “Run->External tools->External tools…”
Click on the tab “main” and fill out the form as described below. You should change the following example to fit your environment if necessary:Name: g95 make Makefile
Location: c:windowssystem32cmd.exe
Working directory: ${workspace_loc}Arguments: /C "cd ${container_loc} && perl c:msys1.0binmkmf -t c:msys1.0binmkmf.g95 -p ${container_name}" - Click on the “Refresh” tab:
[x] Refresh resources …
Click “Apply” - Click on menu Windows->Preferences->C/C++->Make->New Make Projects.
Choose Tab ‘Binary Parser’. Enable ‘PE Windows Parser’ and disable all others. Click on the OK button. - Setup is done.
To edit, compile and run Fortran programs do the following:
- File->New->Standard Make Fortran Project. Give a name to your project in the ‘Project Name’ field. Click ‘Finish’.
- Make sure that your project name is highlighted in the ‘Fortran Projects’ or ‘Navigator’ frame on the left. Click File->New->Source File. Fill outthe ‘Source File’ field (e.g. myprogram.f90). Click ‘Finish’.
- Type your code in the new editor tab and save it (File->Save)
- Add further source files if necessary.
- Click on one of your source files in the Navigator or Fortran projects frame.
- Click menu “Run->External tools->External tools …”
- 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 iconfor easy invocation).
- Select one of your source files in the Navigator/Fortran Projects frame again.
- Click menu Project->Build Project or Clean …
- After compilation you should see “myproject.exe” in your Navigator/Fortran Projects frame.
- Right click on “myproject.exe” and click “Run As->Run Local C/C++ Application”.
- Voilà
For information on setting up Photran with Cygwin, see: ftp://ftp.swcp.com/pub/walt/F/photran.pdf
Leave a Reply
You must be logged in to post a comment.