Repository navigation
02. Build domain configuration file
To create a new configuration a domain configuration file must be created that defines the grid. This only needs to be done once for a new configuration. This includes bathymetry, depth and horizontal grid discretisation.
Edit make_paths.sh as necessary (if not done previously), then execute
cd SCRIPTS
. ./make_paths.sh
. ./make_directories.sh
. ./make_tools.sh
Start with a coordinates file from a parent NEMO simulation. In this example we use the AMM15 coordinate file (attached within the Zenodo Version history).
This parent coordinates file needs to be saved in the DOWNLOADS folder and named coordinates_AMM15.nc. This file stores the horizontal grid information.
For NOC users only:
The file is available locally (E.g. /projectsa/NEMO/nibrun/ARCHER_DATA/INPUTS/AMM15/coordinates.nc).
For example from livljobs* to get the file on ARCHER2 (edit according to your ARCHER2 aliasing syntax):
scp /projectsa/NEMO/nibrun/ARCHER_DATA/INPUTS/AMM15/coordinates.nc $USER@login.archer2.ac.uk:/work/n01/n01/$USER/SEVERN-SWOT/DOWNLOADS/coordinates_AMM15.nc
The AGRIF NESTING tools are used to generate child grid horizontal coordinates from the parent grid. To control this one needs to figure out the indices of the child domain start and end, and also the resolution scale factor. This information is edited in the BUILD_CFG/DOMAIN/namelist.input file. For the Severn domain (BUILD_CFG/DOMAIN/namelist.input_SEVERN) to get a horizontal resolution of 500m from a parent with resolution of 1.5km increase resolution by factor of 3. To achieve this the namelist file is as follows:
&nesting
imin = 694
imax = 807
jmin = 400
jmax = 490
rho = 3
rhot = 3
Then run in SCRIPTS:
. ./make_coordinates_from_parent_Severn.sh
The output is a coordinates.nc file in BUILD_CFG/DOMAIN.
This is mostly covered in the generic ./make_bathymetry_from_gebco.sh but this step also requires some pre-processing of a bathymetry file, downloaded from GEBCO, which doesn't really automate. The region downloaded should
be copied to 'DOWNLOADS' for pre processing. E.g.
scp gebco_2020_n51.8_s50.1_w-6.9_e-2.0.nc $USER@login.archer2.ac.uk:/work/n01/n01/$USER/SEVERN-SWOT/DOWNLOADS/.
Then using convenient relabeling
export BATHYFILE=gebco_2020_n51.8_s50.1_w-6.9_e-2.0.nc
Process the bathymetry in DOWNLOADS. Modify the 'elevation' variable such that water depths are positive; land points are zero
module load nco/5.0.5
module load libfabric/1.11.0.4.71
## Flatten the land
ncap2 -s 'where(elevation > 0) elevation=0' $BATHYFILE tmp.nc
## Make negative depths positive
ncflint --fix_rec_crd -w -1.0,0.0 tmp.nc tmp.nc gebco_in.nc
rm tmp.nc
Then block out areas of water that you don't want to simulate in python. 1st Make a copy for editing:
cp gebco_in.nc fixed_bathy.nc
2nd load python modules:
module load cray-python
module load netcdf4/1.5.7
3rd execute in python:
python
import netCDF4
import numpy as np
dset = netCDF4.Dataset('gebco_in.nc','r')
dout = netCDF4.Dataset('fixed_bathy.nc','a')
dout.variables['elevation'][0:99,:] = 0
dout.variables['elevation'][0:200,650::] = 0
dset.close()
dout.close()
exit()
If happy relabel and copy to BUILD_CFG/DOMAIN location (as required in script: make_bathymetry_from_gebco.sh):
cp fixed_bathy.nc $WDIR/BUILD_CFG/DOMAIN/gebco_in.nc
Then in SCRIPTS run:
. ./make_bathymetry_from_gebco.sh
The output is a bathy_meter.nc file in BUILD_CFG/DOMAIN. Some post-processing might be needed, typically one might want a minimum depth of 10m:
# load nco modules (if not done already)
module load nco/5.0.5
# Remove weirdness with negative bathymetry and make minimum bathymetry
#equal to 10 m (resolve any possible wet-drying problems)
ncap2 -s 'where(Bathymetry < 0) Bathymetry=0' bathy_meter.nc tmp1.nc
ncap2 -s 'where(Bathymetry < 10 && Bathymetry > 0) Bathymetry=10' tmp1.nc -O bathy_meter.nc
rm tmp1.nc
# Copy it if you want for safe keeping
cp bathy_meter.nc bathy_meter_10m.nc
Or fix bathymetry to deal with instabilities (e.g. opening some straights that have only 2 grid points), using an nco command like:
ncap2 -s 'Bathymetry(0,0)=0' bathy_meter.nc bathy_meter.nc -O
ncap2 -s 'Bathymetry(105:116,108:117)=0' bathy_meter.nc bathy_meter.nc -O
NOTE: There is a creek/estuary at i=113, j=114 (river Taw) that looks too narrow to let the water easily flow in and out. This leads to a hydrological jump at time step =261, (dt=20s) starting at 1st Jan 2013. Water in the estuary has a sea level of -5m. At the mouth it is -2m. So there is an unphysical steep SSH gradient at the mouth. This seems to result in a blow up. The previous line of code closes the estuary. This might need to be revisited and follow a different approach (smoothing bathymetry)
_NOTE: problem with IC.
ncap2 -s 'Bathymetry(225:255,321:341)=0' bathy_meter.nc bathy_meter.nc -O
ncap2 -s 'Bathymetry(249:263,0:20)=0' bathy_meter.nc bathy_meter.nc -O
ncap2 -s 'Bathymetry(105:115,105:115)=0' bathy_meter.nc bathy_meter.nc -O
Finally generate the domain_cfg.nc file using the coordinates.nc, bathy_meter.nc. This is done in the tools directory using make_domain_cfg.sh script in the SCRIPTS directory. The tools used are the DOMAINcfg and REBUILD_NEMO tools. The DOMAINcfg tool is submitted as a slurm job.
If making changes to the configuration, these are controlled by the namelist_cfg file. In this configuration, it is $DOMAIN/"$REPO"_s-sig_DOMAINcfg_namelist_cfg, as per $WDIR/SCRIPTS/make_domain_cfg.sh. Ensure this has the appropriate parameters and number of lat,lon,depth levels etc set.
For example the lateral size of the domain can be extracted from bathy_meter.nc using ncdump -h bathy_meter.nc, then namelist can be edited accordingly e.g.: for the SEVERN-SWOT domain
vi namelist_cfg
...
jpidta = 342 ! 1st lateral dimension ( >= jpi )
jpjdta = 273 ! 2nd " " ( >= jpj )
jpkdta = 31 ! number of levels ( >= jpk )
...
When ready, run:
cd SCRIPTS
. ./make_domain_cfg.sh
creating $DOMAIN/domain_cfg.nc