Setup FVCOM3.2.1 for serial with gfortran on Ubuntu 14.04LTS

Table of Contents


If you have not installed netcdf, netcdf-3.6.3 may be installed as follows:
Download the netcdf 3.6.3 source code from Unidata website and install it:
$ tar xvzf netcdf-3.6.3.tar.gz
$ cd netcdf-3.6.3
$ export FC=gfortran
$ ./configure --prefix=/usr/local/netcdf-3.6.3
$ make
$ sudo make install
$ make check


makedepf90 should have been installed. See this article.

Prepare source codes

Download sourcecode.tar.gz and extract it:
$ tar xvzf sourcecode.tar.gz


Move onto ./FVCOM3.1.1/Configure/ and type:
$ ./ series
The file “” will be created in ./FVCOM3.1.1/FVCOM_source/ and edit the “” as follows:

  • Set “TOPDIR” based on your system.
  • Comment out “LIBDIR” and “INCDIR” for MEDM ENVIRONMENT. Then uncomment those for LOCAL INSTALL.
  • Set “IOLIBS” and IOINCS for netCDF according to your installation of netCDF (netCDF should be compiled using the same compiler and pre-installed.)
  • Edit FLAGs dependent on your desired simulation type.

Compiler setting for gfortran in may be:
("CPP = /usr/bin/cpp" did not work on my system.)
# gfortran defs
CPP = gcc -E
CC = gcc
CXX = g++
FC = gfortran
OPT = -O3

Install libraries

Then before compiling FVCOM, you need to move onto ./FVCOM_source/libs and edit makefile as follows:

  • Delete “fproj," "metis” and “netcdf” in PACKAGES.
  • Comment out the lines including fproj, metis and netcdf.

Now part of your mekefile has been modified like below:
# $Id$
# $Name$
# $Revision$
#-----------BEGIN MAKEFILE-------------------------------------------------
SHELL = /bin/sh


PACKAGES = proj julian

for item in $(PACKAGES); do (./ $$item ) || exit 1; done
cd proj && ./configure CC=$(CC) CFLAGS=-O3 CXX=$(CC) CXXFLAGS=-O3 F77=$(FC) FFLAGS=-O3 --prefix=$(MYINSTALLDIR)
cd proj && make install
# cd fproj && ./configure CPPFLAGS='$(COMPILER)' CC=$(CC) CFLAGS=-O3 CXX=$(CXX) CXXFLAGS=-O3 FC=$(FC) FFLAGS=-O3 --with-proj4=$(MYINSTALLDIR) --prefix=$(MYINSTALLDIR)
# cd fproj && make install
# cd netcdf && ./configure CC=$(CC) CFLAGS=-O3 CXX=$(CC) CXXFLAGS=-O3 F77=$(FC) F90=$(FC) FFLAGS=-O3 --prefix=$(MYINSTALLDIR) --build=$(MACHTYPE)
# cd netcdf && make install
# cd metis && make install
cd julian && make install

for item in $(PACKAGES); do (cd $$item && make clean) || exit 1; done

for item in $(PACKAGES); do (rm -rf $$item) || exit 1; done
rm -rf $(MYINSTALLDIR)/*

include ../
Now you can make libs:
$ make
Finally, you can compile FVCOM:
$ cd ..
$ make
However, you may encounter errors. I thus modified some codes as follows:
In mod_utils.F, the lines including "sign":
Line 2998: sign(1.,a) => sign(1._sp,a); sign(1.,b) => sign(1._sp,b)
Line 3007: sign(1.,a) => sign(1._sp,a); sign(1.,b) => sign(1._sp,b)

In mod_interp.F, the lines including "SIGN":
Line 2290: SIGN(1.,DX) => SIGN(1._SP,DX)
Line 2291: SIGN(1.,DY) => SIGN(1._SP,DY)

Setup FVCOM3.2.1 for serial with gfortran on Ubuntu 14.04LTS” に対して1件のコメントがあります。