Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Once the grid is at least close to what you want proceed to steps below.


1) Save the Refinement Map - under the Actions menu. This writes a netcdf file of the map of refinement values (0 for no refinement, 1 for maximum refinement).  Save the files as something like: REFMAP_Nanjing_ne30x8.nc.

Save frequently as the VRM Editor on the Mac tends to crash.  You can then restart the Editor, Read the refinement later Refinement Map and start adjusting the grid from that point.  

Also, make note of any Longitude Shift and Rotate-X, -Y values as those are not saved in the Refinement map Map file.

2) Write EXODUS File: If you are happy with your grid, under Actions: Write Exodus File - give it a name like Nanjing_ne30x8_EXODUS.nc. 

If you want to make further manual edits to your grid, as described below, do not save the EXODUS file.

 

3) Write Refinement Grid - for manual editing of refinement region and halos

...

Once you have a rough version of your grid, save a the Refinement Grid - in the Actions menu, select 'Write Refinement Grid'.

...

(be sure this is all on one line)

For this example:

> /glade/derecho/scratch/emmons/nanjing_musica_tutorial> /glade/work/emmons/tutorial_Nanjing/VRM_tools/VRM_Editor/src/Create_VRMgrid --refine_type "LOWCONN" --grid_type "CubeSquared" --resolution 30 --refine_level 3 --smooth_type "SPRING" --smooth_dist 3 --smooth_iter 3 --x_rotate 25  --y_rotate 0  --lon_shift 30  --refine_file REFMAP_Nanjing_ne30x8.nc  --refine_cube RefGrid_Nanjing_ne30x8.dat --output Nanjing_ne30x8_EXODUS.nc 

...

Create SCRIP and LATLON grid files from EXODUS file

On casper: build Gen_ControlVolumes.exe; be sure to use the gnu (gcc) compiler. 

> cd $REPO/grids$(VRM_tools)/VRM_ControlVolumes/src
> module load gcc
> make
> module load intel


> cd $REPO/grids
> cp /glade/work/emmons/tutorial_Nanjing/${VRM_tools}/VRM_ControlVolumes/src/input.nl input-Nanjing.nl

Edit input-Nanjing_ne30x8.nl to have your path to $REPO/grids and the grid name. 

Then run Gen_ControlVolumes:

> /glade/work/emmons/tutorial_Nanjing/${VRM_tools}/VRM_ControlVolumes/src/Gen_ControlVolumes.exe input-Nanjing.nl > LOG_Nanjing

This produces the SCRIP file: Nanjing_ne30x8_np4_SCRIP.nc which is used for further regridding steps, as well as for plotting your final model output on the native grid.

 A "LATLON" file is also produced: Nanjing_ne30x8_np4 and Nanjing_ne30x8_np4_LATLON.nc

If you do not see these files, check LOG_Nanjing for errors.

Examine the LATLON file to get the number of columns in your new grid:

...

In the directory with your SCRIP file ($REPO/grids), run (be sure all on one line):

> /glade/u/apps/casper/23.10/spack/opt/spack/esmf/8.5.0/mpi-serial/2.3.0/oneapi/2023.2.1/dfkx/bin/ESMF_Scrip2Unstruct Nanjing_ne30x8_np4_SCRIP.nc Nanjing_ne30x8_np4_MESH.nc 0

Note the 0 at the end.

This creates the ESMF mesh file: Nanjing_ne30x8_np4_MESH.nc

...

The resulting file is assigned to ncdata in user_nl_cam_nl_cam.

This script uses the interpic program provided in CESM source code, but must first be compiled.  If you do not already have CESM code, see "Set up CESM3" below.

On casper, in CESM source code, ./components/cam/tools/interpic_new:

Edit Makefile:
l.15 from: LIB_NETCDF := /usr/local/lib
     to: LIB_NETCDF := $(NETCDF)/lib
l.18 from: INC_NETCDF := /usr/local/include
     to: INC_NETCDF := $(NETCDF)/include
l.99 from: LDFLAGS = -L$(LIB_NETCDF) -lnetcdf
     to: LDFLAGS = -L$(LIB_NETCDF) -lnetcdff -lnetcdf  

Currently Loaded Modules:
  1) ncarenv/23.10 (S)   2) intel/2023.2.1   3) ncarcompilers/1.0.0   4) hdf5/1.12.2   5) netcdf/4.9.2

> gmake

This should have created the executable ‘interpic’.  Alternatively, the instructions below use an existing executable available on casper.

> cd $REPO/inic
> cp /glade/work/emmons/tutorial_Nanjing/VRM_tools/gen_CAMncdata/TEMPLATES/interpic_script_TEMPLATE.sh interpic_script_Nanjing.sh
> vi interpic_script_Nanjing.sh


Edit the script to point to your grid files.  This template includes the path to an existing executable of interpic, which is available in the CESM source code. 

# USER CHANGES
VRdate="YYMMDD"
VRgridName="ne0np4.NAME.ne30xR"
VRgridLabel="NAME_RESOL"
VRrepoPath="your_repo_path"
# end of USER CHANGES

...

Check there are no errors in the log file. This should have created an ic file with the dimensions of your new grid: cami-mam4_0000-01-01_ne0np4.Nanjing.ne30x8_L32_c240809.ncwith the dimensions of your new grid: cami-mam4_0000-01-01_ne0np4.Nanjing.ne30x8_L32_c240809.nc

On your own computer, you can find ${VRM_tools}/gen_CAMncdata/TEMPLATES/interpic_script_TEMPLATE.sh, and use the interpic executable that you created.  You can start with any *.cam.i.* file that you have available.

Regrid 'atmsrf' file

The resulting file is assigned to drydep_srf_file in user_nl_cam.

Copy On casper: copy the template script to your working directory and edit for your grid. Be sure directory $REPO/maps exists.

...

Check there are no errors in the log file. This writes atmsrf_ne0np4.Nanjing.ne30x8_240809.nc. 

On your own computer: find ${VRM_tools}/gen_atmsrf/TEMPLATES/gen_atmsrf_TEMPLATE.ncl

Create Topography file

The resulting file is assigned to bnd_topo in user_nl_cam.

...

Can add option --output_data_directory to specify location of final topography file (be sure it the directory already exists).

This can take several hours.  

...

Run the make namelist script (modify the bold text for your resolution, MESH file and your ncol for model-mesh-nx)

(npl) > /glade/work/emmons/cesm_src_derecho/ctsm5.2.007/tools/mksurfdata_esmf/gen_mksurfdata_namelist --res Nanjing_ne30x8 --start-year 1979 --end-year 2026 --ssp-rcp SSP3-7.0 --model-mesh /glade/work/emmons/tutorial_Nanjing/ne0np4.Nanjing.ne30x8/grids/Nanjing_ne30x8_np4_MESH.nc --model-mesh-nx 60482 --model-mesh-ny 1

...

This creates the netcdf files that will be used in your simulation, specified in user_nl_clm: fsurdat = '/repo_path/land/surfdata_ ... .nc' and flanduse_timeseries = '/repo_path/land/landuse.timeseries_ ... .nc'.  In your $REPO, create a directory 'land' (mkdir $REPO/land) and copy these 2 nc files to it.

> conda deactivate

Anchor
Add grid to CESM
Add grid to CESM
Set up CESM3 with new grid

...