Repository navigation
7. Generate Tidal Boundaries
This Wiki page details how to generate the tidal boundaries for the SANH model using PyNEMO. It is assumed the miniconda package has already been installed (see here).
To install PyNEMO, in a new terminal window:
cd /work/n01/n01/$USER
git clone https://github.com/NOC-MSM/PyNEMO.git
Check for any updates in the master branch:
cd PyNEMO
git checkout master
View the pynemo_39.yml file and change numpy to numpy=1.12.
Create the conda environment:
conda env create -f pynemo_39.yml
conda activate pynemo
Build and install pynemo:
python setup.py build
export PYTHONPATH=/work/n01/n01/$USER/miniconda3/envs/pynemo/lib/python3.9/site-packages:$PYTHONPATH
python setup.py install
Verify it works: pynemo -h
First, we need a mask variable which takes values as: -1 mask, 1 wet/active domain, 0 land. PyNEMO looks for the interface between -1 and 1 to generate boundary forcings. We need to only mask a single point around the edge since the rimwidth is considered to be part of the active domain.
In your $OBC directory, link the necessary domain/bathymetry files:
cd $OBC
ln -s $DOMAIN/domain_cfg.nc ./
ln -s $DOMAIN/bathy_meter.nc ./
Copy over the mask scripts in the $GITCLONE/OBC directory and run the scripts:
cp $GITCLONE/OBC/create_* ./
. ./create_bdy_mask.sh
This should output a bdy_mask.nc file for the domain.
The namelist*.bdy drives PyNEMO and has input files which point to the data sources sn_src_hgr, sn_src_zgr, sn_src_msk. These source files are the parent files for the (non-harmonic) time varying boundaries. Even if only tides are being generated, these need to be specified and real because their presence is checked before running the tide bit of code.
Copy the required files into the $OBC directory.
cp $GITCLONE/OBC/CMEMS*
cp $GITCLONE/OBC/namelist*.bdy ./
These include ready-made CMEMS_subdomain_coordinates.nc and CMEMS_subdomain_mask.nc files, bespoke to data downloaded here. While these files are not needed to generate the tidal boundary conditions, they must still be present for PyNEMO to run. CMEMS subdomain mask and coordinates files can be generated for any domain using generate_CMEMS_coordinates.sh located in $GITCLONE/OBC/.
Modify namelist_FES2014.bdy so that it points to the correct files:
sn_src_hgr = './CMEMS_subdomain_coordinates.nc' ! parent /grid/
sn_src_zgr = './inputs_src_zgr.ncml' ! parent
sn_dst_hgr = './domain_cfg.nc' ! child
sn_dst_zgr = './inputs_dst.ncml' ! rename output variables
sn_src_msk = './CMEMS_subdomain_mask.nc' ! NOT NEEDED FOR TIDES ! parent
sn_bathy = './bathy_meter.nc' ! ! child
!------------------------------------------------------------------------------
! I/O
!------------------------------------------------------------------------------
sn_src_dir = './CMEMS.ncml' ! src_files/'
The ncml files remap some variable names in the source and destination files (open and check the paths are correct). The CMEMS_1993.ncml points to data located in $CMEMS; access to the folder is needed even if for a tide-only run, as those files are not used and the date and time specified in the namelist are dummy values.
To generate tidal boundaries, select ln_tide = .true.:
!------------------------------------------------------------------------------
! unstructured open boundaries
!------------------------------------------------------------------------------
ln_coords_file = .true. ! =T : produce bdy coordinates files
cn_coords_file = 'coordinates.bdy.nc' ! name of bdy coordinates files
! (if ln_coords_file=.TRUE.)
ln_mask_file = .true. ! =T : read mask from file
cn_mask_file = '../DOMAIN/bdy_mask.nc' ! name of mask file
! (if ln_mask_file=.TRUE.)
ln_dyn2d = .false. ! boundary conditions for
! barotropic fields
ln_dyn3d = .false. ! boundary conditions for
! baroclinic velocities
ln_tra = .false. ! boundary conditions for T and S
ln_ice = .false. ! ice boundary condition
nn_rimwidth = 9 ! width of the relaxation zone
!------------------------------------------------------------------------------
!------------------------------------------------------------------------------
! unstructured open boundaries tidal parameters
!------------------------------------------------------------------------------
ln_tide = .true. ! =T : produce bdy tidal conditions
sn_tide_model = 'FES2014' ! Name of tidal model (FES2014|TPXO7p2)
clname(1) = 'M2' ! constituent name
clname(2) = 'S2'
clname(3) = 'N2'
clname(4) = 'O1'
clname(5) = 'K1'
clname(6) = 'K2'
clname(7) = 'L2'
clname(8) = 'NU2'
clname(9) = 'M4'
clname(10) = 'MS4'
clname(11) = 'Q1'
clname(12) = 'P1'
clname(13) = 'S1'
clname(14) = '2N2'
clname(15) = 'MU2'
ln_trans = .true. ! interpolate transport rather than velocities
For NOC users FES2014 data are stored in /work/n01/n01/shared/jelt/FES2014/ or are obtainable from AVISO.
!------------------------------------------------------------------------------
! Time information
!------------------------------------------------------------------------------
nn_year_000 = 1993 ! year start
nn_year_end = 1993 ! year end
nn_month_000 = 1 ! month start (default = 1 is years>1)
nn_month_end = 12 ! month end (default = 12 is years>1)
sn_dst_calendar = 'gregorian' ! output calendar format
nn_base_year = 1900 ! base year for time counter
! TPXO file locations
sn_tide_grid = ''
sn_tide_h = ''
sn_tide_u = ''
! location of FES data
sn_tide_fes = '/work/n01/n01/shared/jelt/FES2014/' ! SYMBOLIC LINK
To run PyNEMO:
conda activate pynemo
mkdir OUTPUT
pynemo -s namelist_FES14.bdy
This creates files in OUTPUT.
The generated files aren't outputted with the right name format, so rename the files (NEMO expects them as *grid_[UVT].nc) and move all files to the designated $TIDES folder.
for var in M2 S2 O1 K1 K2 N2 L2 NU2 M4 MS4 Q1 P1 S1 2N2 MU2 #edit the the constituents
do
echo $var
mv 'OUTPUT/SANH_FES14_bdytide_FES2014_'$var'_grd_U.nc' 'OUTPUT/SANH_bdytide_'$var'_grid_U.nc'
mv 'OUTPUT/SANH_FES14_bdytide_FES2014_'$var'_grd_V.nc' 'OUTPUT/SANH_bdytide_'$var'_grid_V.nc'
mv 'OUTPUT/SANH_FES14_bdytide_FES2014_'$var'_grd_Z.nc' 'OUTPUT/SANH_bdytide_'$var'_grid_T.nc'
done
cd $TIDES
cp $OBC/OUTPUT/SANH_bdy* ./
cp $OBC/OUTPUT/coordinates.bdy.nc ./