我要评分
获取效率
正确性
完整性
易理解

Compilation and Installation

Procedure

  1. Use PuTTY to log in to the server as the root user.
  2. Run the following command to create a main program installation directory:
    mkdir -p /path/to/FVCOM
  3. Run the following command to copy the installation package to the main program installation directory:
    cp fvcom-4.1.tar.gz /path/to/FVCOM
  4. Run the following command to go to the main program installation directory:
    cd /path/to/FVCOM
  5. Run the following command to decompress the installation package:
    tar -xvf fvcom-4.1.tar.gz
  6. Perform the following operations to configure the files:
    1. Copy the make.inc_example file as make.inc.
      cp Examples/Estuary/make.inc_example FVCOM_source/make.inc
    2. Create a soft link to the make.inc file.
      ln -sf FVCOM_source/make.inc ./
    3. Edit the make.inc file.
      1. Open make.inc.
        vi make.inc
      2. 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     =
      3. Press Esc, type :wq!, and press Enter to save the file and exit.
  7. Run the following command to create a compilation environment variable file:
    1. Create an environment variable file.
      1. Create an environment variable file.
        vi env-fvcom.sh
      2. 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
      3. Press Esc, type :wq!, and press Enter to save the file and exit.
    2. Load the environment variables.
      source env-fvcom.sh
  8. Run the following command to compile the METIS library:
    1. Go to the METIS installation directory.
      cd ./METIS_source
    2. Decompress the METIS installation package.
      tar -zxvf metis.tgz
    3. Copy the metis-4.0.patch file to the current directory:
      cp /path/to/METIS/metis-4.0.patch ./
    4. Go to the metis directory and execute the patch file.
      cd metis
      patch -p2 < ../metis-4.0.patch
    5. 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
    6. Compile and install the METIS library.
      make -j
      make install
  9. Run the following commands to compile the julian library:
    1. Go to the julian installation directory.
      cd ../../FVCOM_source/libs
    2. Decompress the julian.tgz installation package.
      tar -zxvf julian.tgz
    3. Go to the directory generated after the decompression.
      cd julian
    4. Perform the compilation and installation.
      make -j
      make install
  10. Run the following command to compile and install the FVCOM main program:
    1. Go to the FVCOM installation directory.
      cd  /path/to/FVCOM/FVCOM4.1/FVCOM_source
    2. Edit the mod_newinp.F file.
      1. Open mod_newinp.F.
        vi mod_newinp.F
      2. 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_Fmt

        Line 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)
      3. Press Esc, type :wq!, and press Enter to save the file and exit.
    3. 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
    4. 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.