Use FtranProjectBuilder to Develop Fortran Codes with the Free PGI Fortran Compiler

Some exciting news is that the Portland Group has released a free developer version of their C99 and Fortran 2003 compilers for the Mac.

The Portland Group has detailed and extensive documentation on how to install and use the pgfortran compiler. It’s quite easy to set up, but there are a couple of preliminaries not to miss. First, you must have Xcode installed on your machine. Xcode is free, and you get it from the App Store. You need this for pretty much any compiler that you want to use, so if you have been using FTranProjectBuilder that’s already taken care of. The next thing, however, if you are running Mavericks, is that you must install the command line tools so that they can be found in the terminal. You do this by typing

sudo xcode-select —install 

in the terminal. Again, the online documentation on how to install is really good.

The Free PGI “app" is an interesting beast: It is an AppleScript.The package contains the compiler within it. When you double click on the icon, it launches the terminal so that you can program the old fashioned way. Not as old fashioned as punched cards, mind you, but old fashioned enough. It does not, therefore, integrate with Xcode. That’s where FtranProjectBuilder comes in.

Instead of the terminal, you can use FTranProjectBuilder for your development environment. To use it, you must first set up a number of enviroment variables. These variables are set automatically when you double click on the Free PGI icon, where you see something like

export PGI_PGI_PATH="/Applications/Free PGI.app/Contents/Resources/pgi";export PATH="/Applications/Free PGI.app/Contents/Resources/pgi/osx86-64/14.3/bin:$PATH";export PGI_OEM_INFO="64-bit target on Apple OS/X developer $INFOTPVAL";export PGI_GCCVERSION="40201";export PGI_GCCINC="/Applications/Xcode.app/Contents/Developer/usr/lib/llvm-gcc/4.2.1/include";export PGI_GCCDIR64="/Applications/Xcode.app/Contents/Developer/usr/lib/llvm-gcc/4.2.1";export PGI_MINOSX="10.9.2";export PGI_MINOSX="10.9.2";export PGI_MINOSXNUM="109";export PGI_HASGCC_EH="0";export PGI_ISCLANG31="501";export PGI_LOCALDEFS="__PGI_5XC__"

printed in the terminal window. The environment variable names are in upper case; The values follow the equals signs. 

Setting up FTranProjectBuilder to use the compiler is simply a matter of adding these to the Environment Variables table in the General Preferences panel. Click the Add (‘+’) button for each environment variable you add. Cut and paste the name and the value from the terminal to avoid mistyping anything. You will notice above that there are two PATH variables defined. You can combine them in a single PATH variable by separating them with a colon.

screenshot164


Once you have set the environment variables you are good to go. Simply chose the PGI compiler from the compiler pulldown list in the Compiler Options tab of the project window and click build. That’s it.

One of the Portland Group’s emphases is in parallel programming. For example, if you are using openmp (and compiling with the -mp compiler option) or mpi, then you can choose the number of processors to use in the Execute Options tab of the project window. Simply type the number of processors that you want to use in the box and run.

screenshot165


Thanks to the Portland Group for making their compiler available to us!  

UPDATE May 24, 2015:

Just a couple of tips. FTranProjectBuilder updates its list of compilers at launch time. So after you add the path, quit the application and restart. You should then see the PGI compiler in the pulldown list on the compiler options pane. 

Also, from user DG, “...when you first run the Free PGI app, it opens terminal and sets the environment variables, and then it executes a “clear” command, so the definitions disappear.  You need to either scroll back up to see the command that it executes, or more easily just type “env” to list them all, and then set the “PATH” and all the ones that begin with “PGI” within FTPB by copy and paste." 

© Nocturnal Aviation Software 2011-2014. Mac and Mac OS are trademarks of Apple Inc., registered in the U.S. and other countries. iMac drawing by dinodigital. All other trademarks are the property of their respective owners. Privacy Policy.