Repository navigation
04. Make tidal boundary conditions
In this page we describe how to run a tide-only NEMO run. We make the open ocean boundary conditions using the PyNEMO tool. Tidal boundary files contains tidal harmonics, that are used by NEMO to generate tidal elevation on-the-fly. In this workflow we use the FES2014 tidal products.
Even for a test simulation with frozen boundaries, you need a coordinates.bdy.nc file (generated here) to tell NEMO where the frozen boundaries are.
Workflow:
instructions here
The mask variable takes values (-1 mask, 1 wet/active domain, 0 land). Need to only mask a single point around the edge since the rimwidth is considered to be part of the active domain.
PyNEMO looks for the interface between -1 and 1 to generate boundary forcings. Get a template from domain_cfg.nc and then modify as desired around the boundary.
Maked the entire boundary "land=0", except for the wet bits along the southern boundary which are "mask=-1"::
cd /work/n01/n01/$USER/SEVERN-SWOT/BUILD_CFG/DOMAIN/
module load nco
rm -f bdy_mask.nc tmp[12].nc
ncks -v top_level domain_cfg_$REPO.nc tmp1.nc
ncrename -h -v top_level,mask tmp1.nc tmp2.nc
ncwa -a t tmp2.nc bdy_mask.nc
rm -f tmp[12].nc
Then in python edit the westward boundary value only
conda activate pynemo
python
Then
import netCDF4
import numpy as np
dset = netCDF4.Dataset('bdy_mask.nc','a')
[ny,nx] = np.shape(dset.variables['mask'][:])
for i in range(ny):
if dset.variables['mask'][i,1] == 1:
dset.variables['mask'][i,0] = -1
else:
dset.variables['mask'][i,0] = 0
#dset.variables['mask'][248::,0:20] = 0 # Mask out rogue 'lake'.
dset.close()
exit()
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.
In this case study, we use the Atlantic - European North West Shelf - Ocean Physics Analysis and Forecast data at 1.5 km resolution for the open boundaries. Variables needed and downloadable from CMEMS AMM15 are currents, salinity, temperature and sea surface height. How to build the required coordinates and mask file is described here.
For NOC users, in /work/n01/n01/micdom/CMEMS_AMM15 there are CMEMS_subdomain_coordinates.nc and CMEMS_subdomain_mask.nc, copy or link them:
cd /work/n01/n01/$USER/SEVERN-SWOT/BUILD_CFG/OPEN_BOUNDARIES
ln -s /work/n01/n01/micdom/CMEMS_AMM15/CMEMS_subdomain_coordinates.nc CMEMS_subdomain_coordinates.nc
ln -s /work/n01/n01/micdom/CMEMS_AMM15/CMEMS_subdomain_mask.nc CMEMS_subdomain_mask.nc
ln -s ../DOMAIN/domain_cfg_SEVERN-SWOT.nc domain_cfg.nc
ln -s ../DOMAIN/bathy_meter.nc bathy_meter.nc
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 (edit/check the paths are correct).
For NOC Users, the CMEMS.ncml points to data located in /work/n01/n01/micdom/CMEMS_AMM15, access to the folder is needed even if for a tide-only run 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. and uncomment the constituents to be used:
!------------------------------------------------------------------------------
! 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 = 2019 ! year start
nn_year_end = 2019 ! year end
nn_month_000 = 08 ! month start (default = 1 is years>1)
nn_month_end = 08 ! month end (default = 12 is years>1)
sn_dst_calendar = 'gregorian' ! output calendar format
nn_base_year = 1970 ! 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
conda activate pynemo
mkdir OUTPUT
pynemo -s namelist_FES14.bdy
This creates files in OUTPUT.
If the number of constituents to be created is more than two, is advisable to run PyNEMO as a job, using a slurm script like this submitpynemo.slurm
:
#!/bin/bash
#SBATCH --job-name=pynemo
#SBATCH --time=00:10:00
#SBATCH --nodes=1
#SBATCH --ntasks=3
#SBATCH --account=n01-ACCORD
#SBATCH --partition=serial
#SBATCH --qos=serial
source ~/.bashrc
conda activate pynemo
cd /work/n01/n01/$USER/SEVERN-SWOT/BUILD_CFG/OPEN_BOUNDARIES/
pynemo -s namelist_FES14.bdy
~
to run it:
sbatch submitpynemo.slurm
Rename and move files (names are not quite what will be expected *grid_[UVT].nc)
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/SEVERN_FES14_bdytide_FES2014_'$var'_grd_U.nc' 'OUTPUT/SEVERN_FES14_bdytide_'$var'_grid_U.nc'
mv 'OUTPUT/SEVERN_FES14_bdytide_FES2014_'$var'_grd_V.nc' 'OUTPUT/SEVERN_FES14_bdytide_'$var'_grid_V.nc'
mv 'OUTPUT/SEVERN_FES14_bdytide_FES2014_'$var'_grd_Z.nc' 'OUTPUT/SEVERN_FES14_bdytide_'$var'_grid_T.nc'
done
mkdir /work/n01/n01/$USER/SEVERN-SWOT/INPUTS/TIDES/
cp OUTPUT/SEVERN_FES14_bdy* /work/n01/n01/$USER/SEVERN-SWOT/INPUTS/TIDES/.
cp OUTPUT/coordinates.bdy.nc /work/n01/n01/$USER/SEVERN-SWOT/INPUTS/OBC/.