Version 2 (modified by nicolasmartin, 3 years ago) (diff)

NOC BDY Tools

This is just a note to illustrate where I had got to with a few scripts to set up open boundaries for NEMO simulations using the BDY code. This set of tools was born out of a requirement to have a generic method by which to provide boundary data for use in regional NEMO configurations. The original code for these tools was written in Mathworks Matlab. It is was being translated into Python for wider distribution and to facilitate development, but this process stalled at the beginning of 2013. The Python port is 70% complete and the desire is to finish an alpha version within the next six months. At present the tools have only been tested by transferring data from global NEMO simulations to refined regional domains, although in principle could use non-NEMO input to generate BDY data.

The BDY tools use grid information from the source data (e.g. a global NEMO 025 run) and destination simulation (i.e. the proposed regional simulation - at present you have to run the proposed regional simulation with nn_msh=3 to get the required mesh/mask files for the setup tools) to determine which source points are required for data extraction. This is done using a kdtree approximate nearest neighbour algorithm. The idea behind this targeted method is that if a NEMO style grid file is produced (tool to be written) for non-NEMO source data (e.g. we could use NCML [XML] to wrap non-NEMO netcdf files so they appear to have the common variables and dimensions e.g. votemper etc) in principle the BDY tools become more generic. At present the tools do not contain many options, but those that exist are accessed through a NEMO style namelist that is read in when the main python call is made.

Summary:

  • Works using a NEMO style namelist to initiate BDY configuration.
  • Automatic identification of BDY points from a user chosen or predefined mask
  • KDTree nearest neighbour matchup between the identified BDY points and the associated locations on source grid
  • Data are first interpolated (horizontally) from source grid to destination BDY points using:
    • Bi-linear
    • Gauss-like – distance weighted function using nearest 9 points with a de-correlation distance r0 proportional to dx*cos(lat(j,i))
    • Nearest – takes closest point on distance (for use with similar res src and dst grids)
  • Then in the vertical
    • Linear
    • Cubic-Spline
  • Output in NEMO v3.2/3.3 and 3.4 forms
  • Time stretching used to accommodate mismatch in source and destination calendars
  • Optional smoothing of BDY boundary (post interpolation)
  • Should be able to accept non NEMO netcdf src files, but not tested yet
  • Handles rotation of vector quantities and can accommodate rotated grids (e.g. pan arctic)
  • At present is only coded to use TPXO7.2 inverse tidal model to provide tidal boundary conditions
  • Recently add a hack to setup generic tracer boundary conditions (e.g. so one can include nutrients for coupled ecosystem simulations

Example namelist:

!-----------------------------------------------------------------------
!   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 =   10.     !  minimum depth of s-bottom surface (>0) (m)
   rn_sbot_max = 7000.     !  maximum depth of s-bottom surface 
                           !  (= ocean depth) (>0) (m)
   ln_s_sigma  = .false.   !  hybrid s-sigma coordinates
   rn_hc       =  150.0    !  critical depth with s-sigma

!-----------------------------------------------------------------------
!  grid information 
!-----------------------------------------------------------------------
   cn_src_hgr = 'some_dir/mesh_hgr_src.nc'
   cn_src_zgr = 'some_dir/mesh_zgr_src.nc'
   cn_dst_hgr = 'some_dir/mesh_hgr_dst.nc'
   cn_dst_zgr = 'some_dir/mesh_zgr_dst.nc'
   cn_src_msk = 'some_dir/mask_src.nc'

!-----------------------------------------------------------------------
!  I/O 
!-----------------------------------------------------------------------
   cn_src_dir = 'path_to_src_data/'
   cn_dst_dir = 'path_to_dst_data/'
   cn_fn      = 'my_exp'                  ! prefix for output files
   nn_fv      = -1e20                     !  set fill value for output files

!-----------------------------------------------------------------------
!  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   = ''                   !  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         = .true.               !  ice boundary condition   
    ln_tide        = .true.               !  tide boundary condition   
    nn_rimwidth    = 9                    !  width of the relaxation zone

!-----------------------------------------------------------------------
!  Time information
!-----------------------------------------------------------------------
    nn_year_000     = 1982        !  year start
    nn_year_end     = 1982        !  year end
    nn_month_000    = 1           !  month start (default = 1 is years>1)
    nn_month_end    = 12          !  month end (default = 12 is years>1)
    cn_dst_calendar = 'gregorian' !  output calendar format
    nn_base_year    = 1960        !  base year for time counter

!-----------------------------------------------------------------------
!  Additional parameters
!-----------------------------------------------------------------------
    nn_wei  = 1                   !  smoothing filter weights 
    rn_r0   = 0.0417              !  decorrelation distance use in gauss
                                  !  smoothing onto dst points. Need to 
                                  !  make this a funct. of dlon
    cn_history  = 'bdy files produced by a.nobody'
                                  !  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

Examples: