Compilation and Installation
Procedure
- Use PuTTY to log in to the server as the root user.
- Go to the FVCOM installation package directory.
cd /path/to/FVCOM
- Decompress the installation package.
tar -xvf fvcom-4.1.tar.gz
- Go to the directory generated after the decompression.
cd FVCOM4.1
- Copy the make.inc_example file and rename it to make.inc.
cp Examples/Estuary/make.inc_example FVCOM_source/make.inc
- Create a soft link for the make.inc file.
ln -sf FVCOM_source/make.inc ./
- Edit the make.inc file.
- Open the make.inc file.
vi make.inc
- Press i to enter the edit mode and modify the content in lines 51, 79, 80, 97, and 99.
Line 51:
TOPDIR = /path/to/FVCOM/FVCOM4.1/FVCOM_source
Delete the space next to /path/to/FVCOM/FVCOM4.1/FVCOM_source.
Lines 79 and 80:
LIBDIR = -L$(INSTALLDIR)/lib -L../METIS_source/metis -L./libs/julian INCDIR = -I$(INSTALLDIR)/include -I../METIS_source/metis -I./libs/julian
Delete the comment tag (#).
In line 97, modify the IOLIBS content that is not commented out using #.
IOLIBS = -L/path/to/NETCDF/lib -L/path/to/HDF5/lib -lnetcdff -lnetcdf -lhdf5_hl -lhdf5 -lz -lcurl -lm
In line 98, modify the IOINCS content that is not commented out using #.
IOINCS = -I/path/to/NETCDF/include -I/path/to/HDF5/include
Comment out and add the content in the following figure:

- Press Esc, type :wq!, and press Enter to save the file and exit.
- Open the make.inc file.
- Create a compilation environment variable file.
- Create an environment variable file.
vi env-fvcom.sh
- Press i to enter the edit mode and add the following content:
export CXX=mpicxx export CC=mpicc export MPI_HOME=/path/to/HMPI export PATH=$MPI_HOME/bin:$PATH export LD_LIBRARY_PATH=$MPI_HOME/lib:$LD_LIBRARY_PATH export HDF5=/path/to/HDF5 export PATH=$HDF5/bin:$PATH export LD_LIBRARY_PATH=$HDF5/lib:$LD_LIBRARY_PATH export NETCDF=/path/to/NETCDF export PATH=$NETCDF/bin:$PATH export LD_LIBRARY_PATH=$NETCDF/lib:$LD_LIBRARY_PATH
- Press Esc, type :wq!, and press Enter to save the file and exit.
- Create an environment variable file.
- Load the environment variables.
source env-fvcom.sh
- Go to the METIS installation directory.
cd ./METIS_source
- Decompress the METIS installation package.
tar -zxvf metis.tgz cd metis sed -i 's/log2/log2_function/g' *.*
- Create the related directories.
mkdir -p /path/to/FVCOM/FVCOM4.1/FVCOM_source/libs/install/lib mkdir -p /path/to/FVCOM/FVCOM4.1/FVCOM_source/libs/install/include mkdir -p /path/to/FVCOM/FVCOM4.1/FVCOM_source/libs/install/bin
- Compile and install the METIS library.
make make install
- Go to the julian installation directory.
cd ../../FVCOM_source/libs
- Decompress the julian.tgz installation package.
tar -zxvf julian.tgz
- Go to the directory generated after the decompression.
cd julian
- Compile and install the julian library.
make make install
- Go to the FVCOM installation directory.
cd /path/to/FVCOM/FVCOM4.1/FVCOM_source
- Edit the mod_newinp.F file.
- Open the mod_newinp.F file.
vi mod_newinp.F
- Press i to enter the edit mode.
Add the following information in bold below the first contains statement.
!---------------------------------------- ! functions !---------------------------------------- contains Character( Len = 256 ) Function N_Fmt( c , n ) Character( Len = * ) , Intent( IN ) :: c Integer , Intent( IN ) :: n integer :: i , j character( len = 16 ) :: cn i = index( c , '<' ) j = index( c , '>' ) write( cn , '(g0)' ) n N_Fmt = c(:i-1) // Trim(adjustL(cn)) // c(j+1:) End Function N_Fmt
Modify the content in lines 352, 421, 494, and 567.
Line 352:
write(*,N_Fmt('(A20,<size>F10.4)',SIZE))trim(argname)//': ',fval(1:SIZE)Line 421:
write(*,N_Fmt('(A20,<size>I10)',SIZE))trim(argname)//': ',ival(1:SIZE)Line 494:
write(*,N_Fmt('(A20,<size>L10)',SIZE))trim(argname)//': ',cval(1:SIZE)Line 567:
write(*,N_Fmt('(A20,<size>A10)',SIZE))trim(argname)//': ',sval(1:SIZE) - Press Esc, type :wq!, and press Enter to save the file and exit.
- Open the mod_newinp.F file.
- Modify the mod_scal.F, internal_step.F, adv_t.F, and adv_s.F files. Modify the statement that starts with IF(BACKWARD_ADVECTION in the file. Change == to .eqv and /= to .neqv.
sed -i 's/\/=\.TRUE\./\.neqv\.\.TRUE\./g' mod_scal.F sed -i 's/==\.TRUE/\.eqv\.\.TRUE/g' internal_step.F sed -i 's/==\.FALSE\./\.eqv\.\.FALSE\./g' adv_t.F sed -i 's/==\.FALSE\./\.eqv\.\.FALSE\./g' adv_s.F
- Edit the mod_utils.F file.
- Open the mod_utils.F file.
vi mod_utils.F
- Press i to enter the edit mode and change the ISNAN function to IEEE USENAN.
- Press Esc, type :wq!, and press Enter to save the file and exit.
- Open the mod_utils.F file.
- Compile and install the FVCOM main program.
make
After the installation is successful, you can run the ll command to view the generated executable file fvcom in the current directory.
Parent topic: FVCOM 4.1 Porting Guide (openEuler 21.03)