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

Compilation and Installation

Procedure

  1. Use SVN to check out and obtain the ROMS source code.

    Create a folder and check out the ROMS source code to the folder. To obtain the source code, you need to register an account.

    cd /path/to/ROMS
    mkdir ROMS_4.0
    svn checkout --username Account name --password Password https://www.myroms.org/svn/src/trunk ROMS_4.0

    Example:

    Check out the source code using HPC/Huawei12#$:

    svn checkout --username HPC --password Huawei12#$ https://www.myroms.org/svn/src/trunk ROMS_4.0

    The source code file structure is as follows:

  2. Customize the build script.
    1. To keep the source code unchanged, run the following commands to create a ROMSProjects folder for compiling and running ROMS. upwelling is the default test case included in the source package.
      cd /path/to/ROMS
      mkdir ROMSProjects
      cd ROMSProjects
      mkdir upwelling
      cd upwelling
    2. Copy the following files to the upwelling directory.
      cp /path/to/ROMS/ROMS_4.0/ROMS/Bin/build_roms.sh .
      cp /path/to/ROMS/ROMS_4.0/ROMS/External/roms_upwelling.in .
      cp /path/to/ROMS/ROMS_4.0/ROMS/External/varinfo.dat .
      cp /path/to/ROMS/ROMS_4.0/ROMS/Include/upwelling.h .
    3. Edit the build_roms.sh file.
      1. Open the build_roms.sh file.
        vi build_roms.sh
      2. Press i to enter the edit mode.
        • Set the ROMS root directory and upwelling path and modify the following content:
          export ROMS_APPLICATION=UPWELLING
          export MY_ROOT_DIR=/path/to/ROMS
          export MY_PROJECT_DIR=${MY_ROOT_DIR}/ROMSProjects/upwelling
          export MY_ROMS_SRC=/path/to/ROMS/ROMS_4.0

        • Set compilation options and modify the following content:
          export USE_MPI=on
          export USE_MPIF90=on
          export which_MPI=openmpi
          export FORT=flang
          export USE_NETCDF4=on

          Comment out export USE_MY_LIBS=no and use export USE_MY_LIBS=yes.

      3. Press Esc, type :wq!, and press Enter to save the file and exit.
  3. Edit the my_build_path.sh file.
    1. Open the my_build_path.sh file.
      cd /path/to/ROMS/ROMS_4.0/Compilers
      vi my_build_path.sh
    2. Press i to enter the edit mode and modify the file as follows:

      Change gfortran in line 83 to flang.

      Change MPI_ROOT in line 87 to MPI_ROOT=/path/to/hypermpi/hmpi.

      Change gfortran in lines 295 and 296 to flang.

      Change MPI_ROOT in line 311 to MPI_ROOT=/path/to/hypermpi/hmpi.

      Change NETCDF= in line 330 to NETCDF=/path/to/NETCDF.

      After performing 3.a, press Esc, type :set nu, and press Enter to display the line number.

    3. Press Esc, type :wq!, and press Enter to save the file and exit.
  4. Place the Linux-flang.mk file in /path/to/ROMS/ROMS_4.0/Compilers/.
    cd /path/to/ROMS/ROMS_4.0/Compilers/

    Compile Linux-flang.mk as follows:

    cp Linux-gfortran.mk ../
    mv Linux-gfortran.mk Linux-flang.mk
    vi Linux-flang.mk

    Modify it as follows:

    Press Esc and type :wq! to save the file and exit.

  5. Modify the roms_upwelling.in file.
    1. Open the roms_upwelling.in file.
      cd /path/to/ROMS/ROMSProjects/upwelling/
      vi roms_upwelling.in
    2. Press i to enter the edit mode and change the path of varinfo.dat in VARNAME.
      VARNAME = /path/to/ROMS/ROMSProjects/upwelling/varinfo.dat

      Set NtileI and NtileJ. The product of NtileI and NtileJ must be equal to the value of np (number of cores).

      NtileI=2

      NtileJ=4

    3. Press Esc, type :wq!, and press Enter to save the file and exit.
  6. Perform the installation.
    chmod 777 build_roms.sh
    chmod 777 /path/to/ROMS/ROMS_4.0/ROMS/Bin/cpp_clean
    chmod 777 /path/to/ROMS/ROMS_4.0/ROMS/Bin/sfmakedepend
    ./build_roms.sh -j

    If the executable file romsM is generated in the directory and no error is reported during the installation, the installation is successful.