Compilation and Installation
Procedure
- Use PuTTY to log in to the server as the root user.
- Run the following command to create a main program installation directory:
mkdir -p /path/to/FVCOM
- Run the following command to copy the installation package to the main program installation directory:
cp fvcom-4.1.tar.gz /path/to/FVCOM
- Run the following command to go to the main program installation directory:
cd /path/to/FVCOM
- Run the following command to decompress the installation package:
tar -xvf fvcom-4.1.tar.gz
- Perform the following operations to configure the files:
- Copy the make.inc_example file as make.inc.
cp Examples/Estuary/make.inc_example FVCOM_source/make.inc
- Create a soft link to the make.inc file.
ln -sf FVCOM_source/make.inc ./
- Edit the make.inc file.
- Open make.inc.
vi make.inc
- Press i to enter the insert mode and modify the file as follows:Line 51:
TOPDIR = /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
Line 97:IOLIBS = -L/path/to/NETCDF/lib -L/path/to/HDF5/lib -lnetcdff -lnetcdf -lhdf5_hl -lhdf5 -lz -lcurl -lm
Line 98:IOINCS = -I/path/to/NETCDF/include -I/path/to/HDF5/include
Comment out and add the following content as follows:# Intel/MPI Compiler Definitions (SMAST) #-------------------------------------------------------------------------- # CPP = /usr/bin/cpp # COMPILER = -DIFORT # CC = mpicc # CXX = mpicxx # CFLAGS = -O3 # FC = mpif90 # DEBFLGS = -check all traceback # Use 'OPT = -O0 -g' for fast compile to test the make # Use 'OPT = -xP' for fast run on em64t (Hydra and Guppy) # Use 'OPT = -xN' for fast run on ia32 (Salmon and Minke) # OPT = -O0 –g # OPT = -axN –xN # OPT = -O3 # gfortran defs #-------------------------------------------------------------------------- CPP = /usr/bin/cpp COMPILER = -DGFORTRAN CC = mpicc CXX = mpicxx FC = mpif90 DEBFLGS = OPT = -O3 -ffixed-line-length-none -ffree-form -ffree-line-length-none CLIB = - Press Esc, type :wq!, and press Enter to save the file and exit.
- Open make.inc.
- Copy the make.inc_example file as make.inc.
- Run the following command to create a compilation environment variable file:
- Create an environment variable file.
- Create an environment variable file.
vi env-fvcom.sh
- Press i to enter the insert mode and add the following content:
export GCC_HOME=/path/to/GNU export PATH=$GCC_HOME/bin:$PATH export LD_LIBRARY_PATH=$GCC_HOME/lib:$GCC_HOME/lib64:$LD_LIBRARY_PATH export MPI_HOME=/path/to/OPENMPI 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
- Create an environment variable file.
- Run the following command to compile the METIS library:
- Go to the METIS installation directory.
cd ./METIS_source
- Decompress the METIS installation package.
tar -zxvf metis.tgz
- Copy the metis-4.0.patch file to the current directory:
cp /path/to/METIS/metis-4.0.patch ./
- Go to the metis directory and execute the patch file.
cd metis patch -p2 < ../metis-4.0.patch
- Create the corresponding 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 -j make install
- Go to the METIS installation directory.
- Run the following commands to compile the julian library:
- 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
- Perform the compilation and installation.
make -j make install
- Go to the julian installation directory.
- Run the following command to compile and install the FVCOM main program:
- Go to the FVCOM installation directory.
cd /path/to/FVCOM/FVCOM4.1/FVCOM_source
- Edit the mod_newinp.F file.
- Open mod_newinp.F.
vi mod_newinp.F
- Press i to enter the insert mode and modify the file as follows:Add the following content to 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_FmtLine 352:
Before the modification:write(*,'(A20,<size>F10.4)')trim(argname)//': ',fval(1:SIZE)
After the modification:write(*,N_Fmt('(A20,<size>F10.4)',SIZE))trim(argname)//': ',fval(1:SIZE)Line 421:
Before the modification:write(*,'(A20,<size>I10)')trim(argname)//': ',ival(1:SIZE)
After the modification:write(*,N_Fmt('(A20,<size>I10)',SIZE))trim(argname)//': ',ival(1:SIZE)Line 494:
Before the modification:write(*,'(A20,<size>L10)')trim(argname)//': ',cval(1:SIZE)
After the modification:write(*,N_Fmt('(A20,<size>L10)',SIZE))trim(argname)//': ',cval(1:SIZE)Line 567:
Before the modification:write(*,'(A20,<size>A10)')trim(argname)//': ',sval(1:SIZE)
After the modification: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 mod_newinp.F.
- Modify the mod_scal.F, internal_step.F, adv_t.F, and adv_s.F files. Modify the statements starting with IF(BACKWARD_ADVECTION in the files. 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
- Compile and install the 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.
- Go to the FVCOM installation directory.
Parent topic: FVCOM 4.1 Porting Guide (CentOS 7.6)