Compilation and Installation
Procedure
- 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:

- Customize the build script.
- 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
- 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 .
- Edit the build_roms.sh file.
- Open the build_roms.sh file.
vi build_roms.sh
- 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.

- Set the ROMS root directory and upwelling path and modify the following content:
- Press Esc, type :wq!, and press Enter to save the file and exit.
- Open the build_roms.sh file.
- 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.
- Edit the my_build_path.sh file.
- Open the my_build_path.sh file.
cd /path/to/ROMS/ROMS_4.0/Compilers vi my_build_path.sh
- 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.

- Press Esc, type :wq!, and press Enter to save the file and exit.
- Open the my_build_path.sh file.
- 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.
- Modify the roms_upwelling.in file.
- Open the roms_upwelling.in file.
cd /path/to/ROMS/ROMSProjects/upwelling/ vi roms_upwelling.in
- 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
- Press Esc, type :wq!, and press Enter to save the file and exit.
- Open the roms_upwelling.in file.
- 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.

