NOC-MSM / Regional-NEMO-Medusa

Developing NEMO-MEDUSA in regional (anything non-global) applications
GNU General Public License v3.0
0 stars 0 forks source link

Boundary conditions : code #3

Open jasontempestholt opened 3 years ago

vleguenn commented 2 years ago

I. Make tidal boundary conditions (local livljobs)

Summary : It explains how to generate the FES2014 tidal boundary data.

Workflow:

I.a) 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_MASTEREA/):

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

I.b) 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 and real because their presence is checked before running the tide bit of code.

Modify namelist_FES2014.bdy so that it points to the appropriate files.

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

I.c) Run PyNEMO

Create directory that will contain the tide outputs:

mkdir OUTPUT

Run in 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

py

This creates files in OUTPUT:

output

I.d) 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 valegu@livgen2.nerc-liv.ac.uk:/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).