3. Make open boundary conditions : TIDES - NOC-MSM/Regional-NEMO-Medusa GitHub Wiki
We made the open ocean boundary conditions using the PyNEMO tool. This includes time varying fields (SSH and barotropic currents) and tidal harmonics (which NEMO reconstructs on-the-fly). An overview of PyNEMO usage.
For tidiness, this section focus only on the generation of the tidal harmonics. To generate the 3D boundaries for the physical and biological tracers, see the following section 4.
Even for a simulation with frozen boundaries, you need a coordinates.bdy.nc
file to tell NEMO where the frozen boundaries are..
Workflow done to create the tides boundary conditions:
- Build and install PyNEMO (master branch)
- Tides datasets
- Prepare PyNEMO files
- Run PyNEMO
- Make sure any output is where it is supposed to end up
1) Build and install PyNEMO
I installed PyNEMO MASTER
branch on a local machine (here livljobs7
).
The file name used for that is Install_pynemo_MASTER
(located here: projectsa/NEMO/valegu/TIDES_MASTER_EA/):
vi Install_pynemo_MASTER
# Install Pynemo, testing the MASTER branch
cd /work/$USER
#--> Set up the directory for Pynemo
mkdir TIDES_MASTER_EA
cd TIDES_MASTER_EA
#--> Obtain the code from the git repository
git clone https://github.com/NOC-MSM/PyNEMO.git
#--> Load the correct branch
cd /work/$USER/TIDES_MASTER_EA/PyNEMO/
git checkout master
git status
module load anaconda/3-2018_12
conda env create -f pynemo_39.yml
source activate pynemo
# Set the necessary Java path
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.322.b06-1.el7_9.x86_64/
# Set python path to where the conda env is installed. Check root locaction with ``conda env list``
export PYTHONPATH=/work/valegu/valegu-conda/pynemo/lib/python3.9/site-packages:$PYTHONPATH
# Build and install pynemo
python setup.py build
python setup.py install --prefix /work/valegu/valegu-conda/pynemo
For subsequent uses of PyNEMO, rebuilding is not necessary but path setting and environment activation are: E.g.
module load anaconda/3-2018_12
source activate pynemo
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.322.b06-1.el7_9.x86_64/
export PYTHONPATH=/work/valegu/valegu-conda/pynemo/lib/python3.9/site-packages:$PYTHONPATH
pynemo -h
2) Tides datasets
Jeff and James have been working on the Master Pynemo branch
to add the functionality to extract FES2014 tides. See the details here : https://github.com/NOC-MSM/PyNEMO/pull/84
I am using the FES2014 data for the tides. They are taken from here : /projectsa/NEMO/Forcing/FES2014
3) Prepare PyNEMO files
The namelist_FES2014.bdy
drives PyNEMO and has input files which point to the data sources sn_src_hgr
, sn_src_zgr
, sn_src_msk
. Even if only tides are being generated these need to be specified because their presence is checked before running the tide bit of code.
Modify namelist_FES2014.bdy
so that it points to the appropriate files. The key elements to outputs the tidal harmonics inside the namelist_FES2014.bdy
are that you need to turn on ln_tide = .true.
and choose the tides dataset of interest, here its sn_tide_model = 'FES2014'
vi namelist_FES2014.bdy
!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
!! NEMO/OPA : namelist for BDY generation tool
!!
!! User inputs for generating open boundary conditions
!! employed by the BDY module in NEMO. Boundary data
!! can be set up for v3.2 NEMO and above.
!!
!! More info here.....
!!
!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
!-----------------------------------------------------------------------
! vertical coordinate
!-----------------------------------------------------------------------
ln_zco = .false. ! z-coordinate - full steps (T/F)
ln_zps = .true. ! z-coordinate - partial steps (T/F)
ln_sco = .false. ! s- or hybrid z-s-coordinate (T/F)
rn_hmin = -10 ! min depth of the ocean (>0) or
! min number of ocean level (<0)
!-----------------------------------------------------------------------
! s-coordinate or hybrid z-s-coordinate
!-----------------------------------------------------------------------
rn_sbot_min = 0.52 ! minimum depth of s-bottom surface (>0) (m)
rn_sbot_max = 5902. ! maximum depth of s-bottom surface
! (= ocean depth) (>0) (m)
ln_s_sigma = .false. ! hybrid s-sigma coordinates
rn_hc = 39.0 ! critical depth with s-sigma
!-----------------------------------------------------------------------
! grid information
!-----------------------------------------------------------------------
sn_src_hgr = '/projectsa/NEMO/valegu/gws/nopw/j04/nemo_vol1/ORCA0083-N006/mesh_hgr.nc'
sn_src_zgr = '/projectsa/NEMO/valegu/BDY_VALEGU_TMP/mesh_zgr_renamed.nc'
sn_dst_hgr = '/projectsa/NEMO/valegu/BDY_VALEGU_TMP/domain_cfg.nc'
sn_dst_zgr = '/projectsa/NEMO/valegu/BDY_VALEGU_TMP/inputs_dst.ncml'
sn_src_msk = '/projectsa/NEMO/valegu/gws/nopw/j04/nemo_vol1/ORCA0083-N006/mask.nc'
sn_bathy = '/projectsa/NEMO/valegu/BDY_VALEGU_TMP/bathy_meter.nc'
!-----------------------------------------------------------------------
! I/O
!-----------------------------------------------------------------------
sn_src_dir = 'NCML/ORCA_2013.ncml' ! src_files/'
sn_dst_dir = 'OUTPUT/'
sn_fn = 'EA_MASTER' ! prefix for output files
nn_fv = -1e20 ! set fill value for output files
nn_src_time_adj = 0 ! src time adjustment
sn_dst_metainfo = 'metadata info: valegu'
!-----------------------------------------------------------------------
! 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 = .false. ! =T : read mask from file
cn_mask_file = '/projectsa/NEMO/valegu/Test_Pynemo/bdy_mask.nc' ! name of mask file (if ln_mask_file=.TRUE.)
ln_dyn2d = .true. ! boundary conditions for barotropic fields
ln_dyn3d = .true. ! boundary conditions for baroclinic velocities
ln_tra = .true. ! 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) = 'K2'
clname(4) = 'O1'
clname(5) = 'P1'
clname(6) = 'Q1'
clname(7) = 'M4'
ln_trans = .true. ! interpolate transport rather than
! velocities
!-----------------------------------------------------------------------
! Time information
!-----------------------------------------------------------------------
nn_year_000 = 2013 ! year start ! val: updated
nn_year_end = 2013 ! year end ! val: updated
nn_month_000 = 12 ! 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 = 2013 !1900 ! base year for time counter in output data
! location of TPXO7.2 data
sn_tide_grid = './inputs/tpxo7.2/grid_tpxo7.2.nc'
sn_tide_h = './inputs/tpxo7.2/h_tpxo7.2.nc'
sn_tide_u = './inputs/tpxo7.2/u_tpxo7.2.nc'
! location of FES2014 data
sn_tide_fes = './PyNEMO/inputs/FES2014/'
sn_tide_grid = '/work/jelt/tpxo7.2/grid_tpxo7.2.nc'
nn_src_time_adj = 0 != -3168000 - 86400 ! N01: fix to align model time stamp
!-----------------------------------------------------------------------
! Additional parameters
!-----------------------------------------------------------------------
nn_wei = 1 ! smoothing filter weights
rn_r0 = 0.041666666 ! decorrelation distance use in gauss
! smoothing onto dst points. Need to
! make this a funct. of dlon
sn_history = 'bdy files produced by jelt from ORCA0083-N01'
! history for netcdf file
ln_nemo3p4 = .true. ! else presume v3.2 or v3.3
nn_alpha = 0 ! Euler rotation angle
nn_beta = 0 ! Euler rotation angle
nn_gamma = 0 ! Euler rotation angle
rn_mask_max_depth = 300.0 ! Maximum depth to be ignored for the mask
rn_mask_shelfbreak_dist = 60 ! Distance from the shelf break
4) Run PyNEMO
Create directory that will contain the tide outputs:
mkdir OUTPUT
Run on livljobs7
:
module load anaconda/3-2018_12
source activate pynemo
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.322.b06-1.el7_9.x86_64/
export PYTHONPATH=/work/valegu/valegu-conda/pynemo/lib/python3.9/site-packages:$PYTHONPATH
pynemo -s namelist_FES14.bdy
This creates files in OUTPUT
:
5) Make sure any output is where it is supposed to end up
I copied all the tides boundaries data into /work/valegu/TRANSITION/, then from there, I transferred them into ARCHER2 :
Go inside ARCHER2 on the directory you want your data, then type :
cd /work/n01/n01/valegu/EA_R12_BIO/nemo_vr4.06/cfgs/ORCA2_MEDUSA/EXP_FINAL/TIDES_MASTER/
rsync -zav [email protected]:/work/valegu/TRANSITION/* ./
Generated file names from PyNEMO are not quite what will be expected by NEMO (*grid_[UVT].nc). So fix after the transfer:
mv EA_MASTER_bdytide_FES2014_K2_grd_U.nc EA_MASTER_bdytide_FES2014_K2_grid_U.nc
mv EA_MASTER_bdytide_FES2014_K2_grd_V.nc EA_MASTER_bdytide_FES2014_K2_grid_V.nc
mv EA_MASTER_bdytide_FES2014_K2_grd_Z.nc EA_MASTER_bdytide_FES2014_K2_grid_T.nc
Then do the same for all other constituents (M2, M4, O1, P1, Q1 and S2).