GENIE Compiling

From SourceWiki
Revision as of 15:54, 24 March 2010 by Genie-user (talk | contribs) (removed old Apple OSX and g95 section)
Jump to navigation Jump to search

Mac OSX - March 2010

by Greg Colbourn, with thanks to Simon Mueller

  • Intel Core 2 Duo, 2.26GHz MacBook Pro
  • OSX Snow Leopard 10.6.2, Xcode 3.2.1

1. Download netcdf from http://www.unidata.ucar.edu/downloads/netcdf/ftp/netcdf-4.0.1.tar.gz

2. Go to unzipped netcdf directory and type following commands:

   export FFLAGS="-m32"; export FCFLAGS="-m32"; export CFLAGS="-m32"; export CXXFLAGS="-m32"
   ./configure --prefix=[your path]/netcdf-4.0.1 FC=/usr/local/bin/gfortran F90=/usr/local/bin/gfortran CC=gcc CXX=g++ CPPFLAGS="-DpgiFortran"
   make check
   make install

3. In user.mak have:

  F77=gfortran
  CC=gcc
  CXX=g++-4.0
  NETCDF_NAME=netcdf

Compilation error with NetCDF version 4

If you are using identical compilers for genie and netcdf, but still get a compilation error message associated with netcdf (e.g. This module file was generated for a different platform or by an incompatible compiler or compiler release. It cannot be read), there may be a compatibility issue with your netcdf version. Switching from NetCDF version 4 (RHES4) to v3.6.1 has bypassed this problem (using Red Hat/ifort/icc), although the reason for this is not known.

k.i.c.oliver@open.ac.uk, 21st November 2006

Intel Fortran v7.1, INT() and PARAMETER()

ifcv7.1 will not compile statements of the form:

* PARAMETER (N=INT(..))

Hence they have been removed from genie-land/src/fotran/qsat.f

Gethin Williams Fri Dec 15 16:58:47 GMT 2006

New line characters in text files (UNIX/Windows)

Description of problem

UNIX uses a linefeed character (as should CVS internally), but Windows uses both carriage-return and linefeed (CR/LF). Some compilers/other tools may have trouble reading or displaying files that have the wrong new line characters for the platform. A symptom of this can be a large number of "odd-looking" compiler errors, and the problem may not be easy to spot because most code editors correctly display both UNIX and Windows new lines. Note that CVS should append the appropriate new line characters for the platform onto which a source file is checked out, but this may not be reliable.

Suggested solutions

If your text editor has an option allowing you to change the new line character, edit the option and save the file. UNIX commands are also available to do the job, for example:

  • dos2unix -ascii my_source_file.f90 my_source_file.f90
  • unix2dos -ascii my_source_file.f90 my_source_file.f90

Ian Henderson Fri Jan 12 15:49:57 GMT 2007

Standard Fortran compliance

Description of problem

Most compilers allow extensions to the Fortran language, but using these extensions may cause errors when a different (often older) compiler is used. For instance, the only format descriptor that can be used without an explicit width is the character descriptor "A", however many compilers will allow other format descriptors to be used without a width, e.g. "G", to which a default width (and number of characters right of the decimal place) is applied by the compiler.

Suggested solutions

The GENIE overnight tests are carried out on several different platforms (Linux, Windows, Solaris) with different compilers. However, it isn't practicable to test every combination of platform and compiler, so when adding significant amounts of new code to GENIE it may be worth testing on more than one compiler/platform if available.

A good check for non-standard Fortran is to compile GENIE with an appropriate compiler option that checks for standards compliance (the compiler option can be added in makefile.arc). In general, it's best to avoid non-standard Fortran unless there's a strong argument for using it.

Compiler flags for popular Fortran compilers:

  • -std -- Intel (ifort)
  • -Mstandard -- Portland (pgf90)
  • -ansi -- Sun (f95)

The ISO Fortran standard homepage is here: http://www.nag.co.uk/sc22wg5/

Ian Henderson Fri Jan 12 15:49:57 GMT 2007