Christopher Bull bio photo

Christopher Bull

Aspiring Oceanographer at Northumbria University. Big data python enthusiast. Outdoor adventurer.

Email Twitter Github

Building the initial state and forcing fields for WED12.

Suggested reading:

Build the bathymetry (and ice shelf draft if needed) and coordinates files for the regional domain. Go to your repo, and update the following file for your machine: vi BUILD_CONFIG_NEMO/ (in the ARCHER case this was unnecessary).

./extract_bathy_coord   ## -> should create the bathy and coordinate files,
                        ##    e.g. and
                        ##    (stored in directory defined as config_dir in the namelist)

Build the mesh mask

Prerequisite: successful compile of NEMO (see Step 3).

Create mesh_mask file.

To do this, you need to run nemo.exe to calculate the exact mesh and mask. Run nemo with nn_msh = 1 in the namelist. No need to have all the input files here, just: xios_files, namelists,, and It will crash shortly after creating Details:

mkdir -p /fs2/n02/n02/chbull/nemo/run/create_mesh_mask_wed12
cd /fs2/n02/n02/chbull/nemo/run/create_mesh_mask_wed12
ln -s /fs2/n02/n02/chbull/nemo/bld_configs/input_WED12/
ln -s /fs2/n02/n02/chbull/nemo/bld_configs/input_WED12/
ln -s /fs2/n02/n02/chbull/nemo/bld_configs/input_WED12/ 
ln -s /fs2/n02/n02/chbull/nemo/models/XIOS/bin/xios_server.exe xios_server.exe
ln -s /fs2/n02/n02/chbull/nemo/models/dev_r5518_GO6_package/NEMOGCM/CONFIG/WED12/BLD/bin/nemo.exe nemo.exe
#cp namelist_ref AND namelist_cfg into create_mesh_mask_wed12 folder
#cp namelist_ice_ref AND namelist_ice_cfg into create_mesh_mask_wed12 folder

#grab any xios2 files just so the model will start, e.g.
cp /fs2/n02/n02/chbull/nemo/models/dev_r5518_GO6_package/NEMOGCM/CONFIG/GYRE_XIOS/EXP00/iodef.xml /fs2/n02/n02/chbull/nemo/run/create_mesh_mask_wed12_two/
cp /fs2/n02/n02/chbull/nemo/models/dev_r5518_GO6_package/NEMOGCM/CONFIG/SHARED/field_def.xml /fs2/n02/n02/chbull/nemo/run/create_mesh_mask_wed12_two/
cp /fs2/n02/n02/chbull/nemo/models/dev_r5518_GO6_package/NEMOGCM/CONFIG/GYRE_XIOS/EXP00/file_def.xml /fs2/n02/n02/chbull/nemo/run/create_mesh_mask_wed12_two/
cp /fs2/n02/n02/chbull/nemo/models/dev_r5518_GO6_package/NEMOGCM/CONFIG/GYRE_XIOS/EXP00/domain_def.xml /fs2/n02/n02/chbull/nemo/run/create_mesh_mask_wed12_two/

## NB: set jpni=jpnj=jpnij=0 in the &nammpp section of NEMO's namelist.
##     and use the same &namdom parameters as in the simulation used as BDYs.
qsub    ## this will create mesh_mask_${CONFIG}.nc before crashing

In my ARCHER case the file looks like:

#PBS -N PC-eos80
#PBS -l walltime=1:00:00
#PBS -l select=1
#PBS -j oe
#PBS -A n02-bas

export PBS_O_WORKDIR=$(readlink -f $PBS_O_WORKDIR)               

aprun -n 2 ./nemo.exe
aprun -n 2 ./xios_server.exe

This should result in and out of this (check that mbathy, misf, isfdraft look sensible). We now need to stick them back together…

cd /fs2/n02/n02/chbull/nemo/run/create_mesh_mask_wed12
#From BUILD_CONFIG_NEMO, make sure NEMOdir is correct
mv $WORKDIR/input/nemo_${CONFIG}/mesh_mask_${CONFIG}.nc ## directory defined as config_dir

Create the inital state

Create the initial state (temperature and salinity)

./extract_istate            ## -> should create the initial state for temperature and salinity
                            ##    e.g. and
                            ##    (stored in directory defined as config_dir in the namelist)

Ocean forcing files

Create the lateral boundary conditions (u, v, T, S, SSH, sea-ice thic, sea-ice frac)

./build_coordinates_bdy       ## -> creates the coordinate file for lateral boundaries
                              ##    e.g.

./extract_bdy_gridT           ## -> creates T,S bdy files and store them in a BDY folder
                              ##    itself located in directory defined as config_dir

./extract_bdy_gridU           ## -> creates U   bdy files and store them in a BDY folder
./extract_bdy_gridV           ## -> creates V   bdy files and store them in a BDY folder
./extract_bdy_icemod          ## -> creates ice bdy files and store them in a BDY folder
./extract_bdy_ssh             ## -> creates SSH bdy files and store them in a BDY folder

./   ## Edit this file first.
                              ## -> concatenate the bdy files into yearly files

./extract_bdy_tides           ## if you want to put tidal signals along the BDYs

Interpolate CICE onto NEMO

If necessary, interpolate CICE onto NEMO grid before running ./extract_bdy_icemod (above). We use CDO to do a linear interpoation. Here’s an example:

#hack up a griddes file so the source file looks more like the target..
cdo griddes > new_grid.txt
cdo griddes > old_grid.txt

#xname/yname as nav_lon/nav_lat (the latter seems to be important to match the target x/y names)
sed -i -e 's/TLON/nav_lon/g' old_grid.txt
sed -i -e 's/TLAT/nav_lat/g' old_grid.txt

#remove area from new_grid.txt, the following will help find it.
#grep –n “[a-d][f-z] new_grid.txt 

#re-write with hacked grid defn
cdo setgrid,old_grid.txt -select,name=aice,hi,hs ../ ./

#Re-mapping, creating the weights first.. 
cdo gennn,new_grid.txt
cdo remap,new_grid.txt,

#copy interpolated data to a G07 file and match LIM variable names according to BUILD_CONFIG_NEMO/src/extract_bdy_icemod.f90

Other files (SSS for restoring, runoff, chlorophyll)

./extract_SSS_restoring       ## -> creates SSS files and store them in a SSS folder
./   ## Edit this file first.
                              ## -> concatenate the bdy files into yearly files

./extract_runoff_icebergs     ## -> creates iceberg runoff file
                              ##    (stored in config_dir defined in the namelist)

./extract_chloro              ## -> creates chlorophyll file
                              ##    (stored in config_dir defined in the namelist)

Atmospheric forcing files

Weights for the interpolation of atmospheric forcing

# here it is assumed that you have NEMO downloaded and installed as explained in step #1
maketools -m XC_ARCHER_INTEL -n WEIGHTS           ## Adapt for any machine different from ARCHER (try makenemo -h)
cd WEIGHTS                                ## See nice README file in this directoy.
cp -p nocsutil/namelist_example_bilin namelist_WEIGHTS_${CONFIG}_bilin ## Edit this namelist

NB: you may have to increase char_len in src/kinds_mod.f90 if you include long path for file names.

Below is an example for namelist_WEIGHTS_${CONFIG}_bilin:

    input_file = ''
    nemo_file = ''
    datagrid_file = ''
    nemogrid_file = ''
    method = 'regular'
    input_lon = 'LON'
    input_lat = 'LAT'
    nemo_lon = 'glamt'
    nemo_lat = 'gphit'
    nemo_mask = 'none'
    nemo_mask_value = 10
    input_mask = 'none'
    input_mask_value = 10

    num_maps = 1
    grid1_file = ''
    grid2_file = ''
    interp_file1 = ''
    interp_file2 = ''
    map1_name = 'data to nemo bilin Mapping'
    map2_name = 'nemo to data bilin Mapping'
    map_method = 'bilinear'
    normalize_opt = 'frac'
    output_opt = 'scrip'
    restrict_type = 'latitude'
    num_srch_bins = 90
    luse_grid1_area = .false.
    luse_grid2_area = .false.

    input_file = ""
    interp_file = ""
    input_name = "snow"
    input_start = 1,1,1,1
    input_stride = 1,1,1,1
    input_stop = 0,0,0,1
    input_vars = 'initial_time0_hours'

    output_file = ""
    output_mode = "create"
    output_dims = 'x', 'y', 'time_counter'
    output_scaling = "snow|1.0", "time_counter|86400.0"
    output_name = 'snow'
    output_lon = 'x'
    output_lat = 'y'
    output_vars = 'time_counter'
    output_attributes = 'time_counter|units|seconds since 1995-00-00 00:00:00',

Then, execute these things:

#create links to relevant input files -> /fs2/n02/n02/chbull/nemo/bld_configs/input_WED12/ -> /fs2/n02/n02/chbull/nemo/bld_configs/input_WED12_mathiot_eORCA025-GO7/ -> /fs2/n02/n02/chbull/nemo/bld_configs/input_WED12_mathiot_eORCA025-GO7/

./scripgrid.exe   ## namelist_${CONFIG}_bilin
./scrip.exe       ## namelist_${CONFIG}_bilin
./scripshape.exe  ## namelist_${CONFIG}_bilin

Then create another namelist: namelist_${CONFIG}_bicub and just change these parameters:

interp_file1 = ''
interp_file2 = ''
map1_name = 'data to nemo bicubic Mapping'
map2_name = 'nemo to data bicubic Mapping'
map_method = 'bicubic'
interp_file = ''
output_file = ''

Then execute :

./scrip.exe       ## namelist_${CONFIG}_bicub
./scripshape.exe  ## namelist_${CONFIG}_bicub

At the end of this, you should have: and

In category: nemo