Regridding BISICLES output with ESMF and NCO

From CliC Wiki
Revision as of 00:18, 20 October 2015 by Jguerber (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Will Roberts (University of Bristol) has had success regridding BISICLES output using ESMF to generate weights and NCO to calculate the regridded data values. This page is adapted from notes provided by Will.

Note: For simplicity, the most of the directories shown below are the original ones from Will's notes, and refer to U. Bristol's installations. Remember to adapt them for your own situation!


Take a BISICLES hdf5 file and regrid it to the SeaRISE grid in NetCDF (.nc) format.

Making sure that the data are in a SCRIP format seems to make things run smoothly.


  1. Convert B.hdf5 into
  2. Create SCRIP type grid description file
  3. Create ESMF weights for
  4. Regrid into using the esmf weights make

hdf5 → nc

Use amr2CF in BISICLES/code/filetools/amrtocf.cpp

cd /data/ggslc/opt/BISICLES/BISICLES/code/filetools
amrtocf2d.Linux.64.g++.gfortran.DEBUG.ex config.amrtocf infile=plot.GrIS.1km.l1l2.4lev.017584.2d.hdf5 outfile=~/ismip6/

Create SCRIP grid description file

At present amr2CF won't produce SCRIP-type grid files. Thus you need to mangle the output a little to get SCRIP compatible files. Use scrip_from_plot.m to do this.

Principally this requires the grid corner matrix to go in a circle (ie enclose the grid box) and the grid bits need to be renamed:

  • grid_corner_lat
  • grid_corner_lon
  • grid_center_lon
  • grid_center_lat
  • grid_dims
  • grid_imask

and you need to have the dimensions grid_corners – how many corners there are to your grid and grid_rank which in our case is just 1 and used by grid_dims, which tells us how many grid boxes we have (this is the same as grid_size in our case).

Information about SCRIP is here. For more information on SCRIP-format grid description files, see the User's Guide for SCRIP here.

Build ESMF

ESMF's home page is at

On Macintoshes, ESMF can be easily installed via the MacPorts package manager. MacPorts will also automatically install any other libraries ESMF requires.

For other systems, after downloading and unpacking the source distribution,

Note: Directories shown below are those used at U. Bristol. Adapt to your own installation.
export ESMF_DIR="/home/paleo/ggwhgr/esmf"
export ESMF_NETCDF_LIBPATH="/data/ggslc/opt/lib"
export ESMF_NETCDF="split"
export ESMF_NETCDF_INCLUDE="/data/ggslc/opt/include"
export ESMF_NETCDF_LIBS="-lnetcdf -lnetcdff"
export ESMF_LAPACK_LIBPATH="/data/ggslc/opt/lib"
export ESMF_LAPACK_INCLUDE="/data/ggslc/opt/include/"
export ESMF_LAPACK_LIBS="-llapack -lblas"

Note: At Goddard, we also needed to specify export ESMF_F90COMPILEPATHS="-I/usr/include" to tell gfortran where to find the netcdf.mod file.

Use ESMF to create the weights file

Change directories to where ESMF installed its executable files; this may be somewhere beneath esmf/DEFAULTINSTALLDIR/, but the subdirectory will depend on which architechture and compiler you used. Then,

./ESMF_RegridWeightGen -s ~/ismip6/ -d ~/ismip6/ -m conserve -i --src_regional --dst_regional --check  -w ~/ismip6/


where is the source grid. This is the file created by scrip_from_plot.m in the step above.
where is the destination grid. is a SCRIP grid description file for the standard Greenland 5 km polar-stereographic grid.
-m conserve 
does a conservative regridding
ignores unmapped destination points
--src_regional --dst_regional
indicates the source and destination grids are not global (seems to work with global too)
runs a check after calculating weights – ensures they actually work
where do you want the weight file


Grid File Formats (ESMF Reference Manual)
ESMF_RegridWeightGen (ESMF Reference Manual)

Use NCO to apply weights to input file, giving regridded output file

The NCO home page is at For information on regridding with NCO, see

Requires nco ≥ 4.5.0 (released June 2015)

ncks --rgr col_nm=grid_size

regrid input file to output file, using (created with ESMF_RegridWeightGen in the step above) as the weight (map) file.
--rgr col_nm=grid_size
name of the dimension to be used for the unstructured output grid 
input data file, on source grid 
output file, data regridded to target grid