New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
WorkingGroups/TAM/InstallationsMacInstosh/InstallMacGfortran – NEMO
wiki:WorkingGroups/TAM/InstallationsMacInstosh/InstallMacGfortran

Version 13 (modified by chauvin, 15 years ago) (diff)

--

Installing the gfortran compiler

gfortran 4.2.3 available on the site http://r.research.att.com/tools/

Generating NETCDF modules and library

The following script is executed in the directory netcdf-3.6.1. gcc-4.0 comes from the XCode (Mac OS X 10.5.8). Flags avoid conflicts between C and Fortran during the library compilation.

#!/bin/sh

export FC=gfortran
export F90=gfortran
export F77=gfortran

export FFLAGS='-O3 -ff2c'
export F90FLAGS='-O3 -ff2c'

export CC=gcc-4.0
export CPPFLAGS='-Df2cFortran'

./configure --prefix=/usr/local/netcdf-3.6.1/gfortran

Compiling NETCDF-3.6.2 using gcc-4.3

During NETCDF-3.6.2 make check process we have the following error message:

libtool: compile:  c++ -DHAVE_CONFIG_H -I. -I. -I.. -I../fortran -DDEBUG -I../libsrc -g -O2 -MT ncvalues.lo -MD -MP -MF
.deps/ncvalues.Tpo -c ncvalues.cpp -o ncvalues.o
ncvalues.cpp: In member function 'virtual char* NcValues_ncbyte::as_string(long int) const':
ncvalues.cpp:238: error: 'strncpy' was not declared in this scope

A temporary solution (awaiting for new release) may be found here: http://www.cyrius.com/journal/gcc/gcc-4.3-include.html

e.g: modify some cpp files by adding #include <cstring.h>

Compiling NEMO

Debugging option: -gdwarf-2 (and not -g). The optimizing option -O3 is ok.

NETCDF_INCLUDE=/usr/local/netcdf-3.6.1/gfortran/include
NETCDF_LIB=-L/usr/local/netcdf-3.6.1/gfortran/lib -lnetcdf
CPP=cpp
CPPFLAGS=-traditional -P
AR=ar 
ARFLAGS=cvr
FC=gfortran
FCFLAGS=  -c -gdwarf-2 -fdefault-real-8 -ffree-line-length-none -I$(NETCDF_INCLUDE) -I$(NEMOLIB)
FCFLAGSF90=  -c -gdwarf-2  -fdefault-real-8 -ffree-line-length-none -I$(NETCDF_INCLUDE) -I$(NEMOLIB)
LDFLAGS=  -gdwarf-2  -free-line-length-none -o 

Compiling NEMOVAR

Link with the lapack library is needed (conjgrad).