2. Create the Domain - NOC-MSM/SRIL34 GitHub Wiki

Generate coordinates and Bathymetry files

To generate the domain_cfg.nc you first need to create the a coordinates file coordinates.nc and a bathymetry file bathy_meter.nc. For the SRIL34 domain, this is done using the GridBuilder matlab toolbox. To install it and use grid builder, follow the instruction in the make_grid.txt:

on livljobs8, cd into the directory you want to work from and download Gridbuilder:

#Download GridBuilder
wget https://austides.com/wp-content/uploads/GridBuilder_toolbox.mltbx

To install it, open matlab and click on the GridBuilder_toolbox.mltbx:

#Open matlab:

module load matlab
matlab

#When in matlab, click on
GridBuilder_toolbox.mltbx to install

You then need to modify one of the GridBuilder's functions to allow it to read NetCDF files. To do this, still in matlab, check the Add-Ons location in the preferences. The path should look something like this:

#Check Add-Ons location in Preferences:
~/Documents/MATLAB/Add-Ons/Toolboxes/

Then copy the getUserBathymetry.m to the GridBuilder's functions:

#Add a trick to allow Gridbuilder to read *.nc files:

cp getUserBathymetry.m ~/Documents/MATAB/Add-Ons/Toolboxes/Gridbuilder/Functions/

then modify the paths in environment.m and run it to set you path.

in matlab's command window type: GridBuilder

This will open up the Gridbuilder GUI. From there, go to File --> Import --> Bathymetry and select your bathymetry file (in this case, it'ss LME_32_34_GEBCO_bathy.nc).

Draw your grid on the map, starting from the bottom left-hand corner (more stable this way). Change the resolution of your grid in the box at the top . You can rotate the grid using the "Grid Edit" tools on the right hand side of the GUI When happy with your grid, go to Mask Settings and choose GSHHC Coastlines (this takes a while so should be your last step). Save your grid using a unique identifier e.g. SRIL34_Grid.mat (SRIL34 stands for Sri Lanka in LME number 34).

Now you have your grid, open GridBuilder_to_NEMO.m. In this script, DOMNAM is the unique identifier you used (e.g. SRIL34). Change the grid_path to reflect the location of your saved grid file, and change the domain paths to reflect your directories (NOTE: the assessment path is not called in this script).

Run the MATLAB script.

This should output your chosen grid in NEMO compatable files:

SRIL34_bathy_meter.nc
SRIL34_coordinates.nc

This files will then be used to create the domain_cfg.nc file

Generate the domain_cfg.nc

The domain generation is done on archer. Move the bathymetry and coordinate files you have just created in an archer2 directory (eg: using scp). IMPORTANT: for this work you need to already have compiled NEMO and tool

cd into the directory where you have put your bathymetry and coordinate files. Copy the namelist_cfg from your NEMO tools. Eg:

 cp /work/n01/n01/<user>/SANH/NEMO_4.0.4/tools/DOMAINcfg/namelist_cfg .

Now, find out your domain size by dumping the bathymetry file (eg: ncdump -h bathy_meter.nc) and edit namelist_cfg for domain size:

vi namelist_cfg

then change the dimensions (in this case 324,424,50)

   jpidta      =     324   !  1st lateral dimension ( >= jpi )
   jpjdta      =     424   !  2nd    "         "    ( >= jpj )
   jpkdta      =      50   !  number of levels      ( >= jpk )
   jpiglo      =     324   !  1st dimension of global domain --> i =jpidta
   jpjglo      =     424   !  2nd   

now creat symbolic links to all other files that you need contain in your NEMO tool directory. These are the *.xml* files, the namelist_ref, and the executable. Eg:

ln -s /work/n01/n01/<user>/SANH/NEMO_4.0.4/tools/DOMAINcfg/*.xml .
ln  -s /work/n01/n01/<user>/SANH/NEMO_4.0.4/tools/DOMAINcfg/namelist_ref .
ln -s /work/n01/n01/<user>/SANH/NEMO_4.0.4/tools/DOMAINcfg/make_domain_cfg.exe .

you should now have the bathymetry file, the coordinate file, the namelist_cfg, and the (symbolic) *.xml, namelist_ref and executable in the same directory.

Run the domain_cfg tools using the make_domain.slurm (for archer2):

sbatch make_domain.slurm

Note: remember to change the account name and time before running it

⚠️ **GitHub.com Fallback** ⚠️