# Agrif setup with eOrca 1 configuration

**URL:** <https://nemo-ocean.discourse.group/t/agrif-setup-with-eorca-1-configuration/996>\
**Category:** Global\
**Tags:** orca, AGRIF\
**Created:** [4 March 2026 16:28 UTC](https://nemo-ocean.discourse.group/t/agrif-setup-with-eorca-1-configuration/996 "2026-03-04T16:28:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![francesco.tuccia](https://yyz2.discourse-cdn.com/free1/user_avatar/nemo-ocean.discourse.group/francesco.tuccia/32/68_2.png) [@francesco.tuccia](https://nemo-ocean.discourse.group/u/francesco.tuccia)\
**Post date:** [4 March 2026 16:28 UTC](https://nemo-ocean.discourse.group/t/agrif-setup-with-eorca-1-configuration/996/1 "2026-03-04T16:28:36Z")

</div>

Good afternoon everyone,  
I am trying to set up an AGRIF zoom in the eORCA1 configuration that I usually run, but I am facing several problems. I am following the [_Nemo AGRIF User-guide_](https://sites.nemo-ocean.io/user-guide/zooms.html). In case you want to try to reproduce my steps with the input files that I am using, here is the archive: [Filesender link (expiration date 1 April 2026)](https://filesender.renater.fr/?s=download&token=d60510df-bcff-49d2-8e5f-9107314fdc7e). Full configuration description [here](https://agupubs.onlinelibrary.wiley.com/doi/10.1029/2024MS004824).  
I am running NEMO 5.0.1 and assuming this structure

```shell
.
└── $root_dir/
    ├── $nemo_dir
    └── input-eOrca1 (from extraction of 'input-eOrca1.tar.gz')

```

The way I setup the configuration is the following:

```shell
export Cfg_name=eOrca1_AGRIF;
cd $nemo_dir;
./makenemo -m $arch_file -r ORCA2_ICE_PISCES -n $Cfg_name --del_key "key_top" --add_key "key_isf key_agrif" -j 0;
./makenemo -m $arch_file -r ORCA2_ICE_PISCES -n $Cfg_name -j 8;
cd $nemo_dir/cfgs/$Cfg_name/EXP00;
cp $root_dir/input-eOrca1/make_links.sh .

```

where `make_links.sh` links all the input files in the `EXP00` directory (a test without `key_agrif` should run out of the box from the dataset).

### DOMAINcfg

I compile `DOMAINcfg` with the `key_agrif` key added in `/tools/DOMAINcfg/cpp_DOMAINcfg.fcm`

```shell
cd $nemo_dir/tools;
./maketools -m $arch_file -n DOMAINcfg;
cd $nemo_dir/tools/DOMAINcfg/cfgs/AGRIF_DEMO;
ln -sf $root_dir/input-eOrca1/input_fields/domain_cfg.nc .

```

I have removed all `*_namelist_ref` and `*_namelist_cfg` superior to 1 (as I am working with only one zoom for now), then modified the `AGRIF_FixedGrids.in` file to read

```shell
1
108 208 65 165 1 1 1
0

```

and then I have modified the `namelist_cfg` file as follows

```fortran
!-----------------------------------------------------------------------
&namdom ! space and time domain (bathymetry, mesh, timestep)
!-----------------------------------------------------------------------
   ln_read_cfg = .true.
   nn_bathy = 3 ! = 0 compute analyticaly
                           ! = 1 read the bathymetry file
                           ! = 2 compute from external bathymetry
                           ! = 3 compute from parent (if "key_agrif")
   nn_interp = 1 ! type of interpolation (nn_bathy =2)
   cn_domcfg = 'domain_cfg.nc'                
   cn_topo = 'GEBCO_2020.nc' ! external topo file (nn_bathy =2)
   cn_bath = 'elevation' ! topo name in file (nn_bathy =2)
   cn_lon = 'lon' ! lon name in file (nn_bathy =2)
   cn_lat = 'lat' ! lat name in file (nn_bathy =2)
   rn_scale = 1
   rn_bathy = 0. ! value of the bathymetry. if (=0) bottom flat at jpkm1
   jphgr_msh = 0 ! type of horizontal mesh
   ppglam0 = 999999.0 ! longitude of first raw and column T-point (jphgr_msh = 1)
   ppgphi0 = 999999.0 ! latitude of first raw and column T-point (jphgr_msh = 1)
   ppe1_deg = 999999.0 ! zonal grid-spacing (degrees)
   ppe2_deg = 999999.0 ! meridional grid-spacing (degrees)
   ppe1_m = 999999.0 ! zonal grid-spacing (degrees)
   ppe2_m = 999999.0 ! meridional grid-spacing (degrees)
   ppsur = -4762.96143546300 ! ORCA r4, r2 and r05 coefficients
   ppa0 = 255.58049070440 ! (default coefficients)
   ppa1 = 245.58132232490 !
   ppkth = 21.43336197938 !
   ppacr = 3.0 !
   ppdzmin = 999999. ! Minimum vertical spacing
   pphmax = 999999. ! Maximum depth
   ldbletanh = .FALSE. ! Use/do not use double tanf function for vertical coordinates
   ppa2 = 999999. ! Double tanh function parameters
   ppkth2 = 999999. !
   ppacr2 = 999999. !
/
!-----------------------------------------------------------------------
&namcfg ! parameters of the configuration
!-----------------------------------------------------------------------
   !
   ln_e3_dep = .true. ! =T : e3=dk[depth] in discret sens.
   ! ! ===>>> will become the only possibility in v4.0
   ! ! =F : e3 analytical derivative of depth function
   ! ! only there for backward compatibility test with v3.6
      ! ! if ln_e3_dep = T
      ln_dept_mid = .true. ! =T : set T points in the middle of cells
   ! !
   cp_cfg = "eORCA1" ! name of the configuration
   jp_cfg = 1 ! resolution of the configuration
   jpidta = 360 ! 1st lateral dimension ( >= jpi )
   jpjdta = 331 ! 2nd " " ( >= jpj )
   jpkdta = 75 ! number of levels ( >= jpk )
   Ni0glo = 360 ! 1st dimension of global domain --> i =jpidta
   Nj0glo = 331 ! 2nd - - --> j =jpjdta
   jpkglo = 75
   jperio = 6 ! lateral cond. type (between 0 and 6)
   ln_domclo = .false. ! computation of closed sea masks (see namclo)
/ ! only there for backward compatibility test with v3.6

```

where the `namcfg` namelist has been adapted following the characteristics of `domain_cfg.nc`. Running `./make_namelist.py` produces

```shell
Found 1 grids :
360 331
108 208 65 165
4 4 4 4
Grid 1 : Ni0glo = 108 , Nj0glo = 108

```

and the file `1_namelist_cfg` should be coherent. For now I am trying to work out the workflow, so a 1:1 zoom is the easiest scenario. Running `make_domain_cfg.exe` runs with no problems.

### WEIGHTS

I compile the tool WEIGHTS as follows

```shell
cd $nemo_dir/tools;
./maketools -m $arch_file -n WEIGHTS;
cd $nemo_dir/tools/WEIGHTS/cfgs/AGRIF_DEMO;
ln -sf $root_dir/input-eOrca1/input_fields/domain_cfg.nc .

```

and then I modify the python script `create_weights.py` such that it reads

```python
# Directory with domccfg target file
DOMCFG_DIR=os.environ["nemo_dir"]+"/tools/DOMAINcfg/cfgs/AGRIF_DEMO/"
# Suffix of domcfg files
RAD='domain_cfg.nc'
# Directory with original forcing on native grid
FORCING_DIR=os.environ["root_dir"]+'/input-eOrca1/'
# Forcing file names, interpolation method (default bilin), and weigth file name (optional), lon(optional), lat(optional)
FILES=[
['forcing_ORCA1/u_10.15JUNE2009_fill.nc' , 'bicub', 'weights_coreII_2_eORCA1.4.2_bicubic.nc' , '', ''],
['forcing_ORCA1/ncar_rad.15JUNE2009_fill.nc' , 'bilin', 'weights_coreII_2_eORCA1.4.2_bilinear.nc' , '', ''],
['input_fields/eddy_viscosity_3D.nc' , 'bilin', 'weights_eddy_visc_bilinear.nc' ,'',''],
['input_fields/geothermal_heat_flux.nc' , 'bilin', 'weights_ghflux_bilinear.nc' ,'',''],
['input_fields/merged_ESACCI_BIOMER4V1R1_CHL_REG05.nc', 'bilin', 'weights_reg05_bilinear.nc' ,'',''],
['input_fields/runoff-icb_DaiTrenberth_Depoorter.nc' , 'bilin', 'weights_runoff-icb_bilinear.nc' ,'',''],
['input_fields/sss_climatology_for_restoring.nc' , 'bilin', 'weights_sss_clima_bilinear.nc' ,'',''],
['input_fields/zdfiwm_forcing_TRA.nc' , 'bilin', 'weights_zdfiwm_bilinear.nc' ,'',''],
['initial_conditions/woce_salt_monthly_init_4p2.nc' , 'bilin', 'weights_woce_salt_bilinear.nc' ,'',''],
['initial_conditions/woce_temp_monthly_init_4p2.nc' , 'bilin', 'weights_woce_temp_bilinear.nc' ,'','']
]

```

this produces all the necessary weights that I need in the namelists.

## Restart files

At the end of this procedure, The model only complains about the missing restart files. As the AGRIF zoom is actually a 1:1 zoom, I guess I can just do something like an `ncks` to crop the restart to the size of the zoom. The first try was exactly this approach: I copied the files and cropped them

```shell
cd $nemo_dir/cfgs/$Cfg_name/EXP00;
ncks -d x,103,210 -d y,61,168 TRA_10001231_restart.nc -O 1_TRA_10001231_restart.nc
ncks -d x,103,210 -d y,61,168 TRA_10001231_restart_trc.nc -O 1_TRA_10001231_restart_trc.nc
ncks -d x,103,210 -d y,61,168 TRA_10001231_restart_icemod.nc -O 1_TRA_10001231_restart_icemod.nc

```

this approach actually works, as the code starts without complainign, but it actually stops running with weird values after just one step

```auto

   stp_ctl: |ssh| > 20 m or |U| > 10 m/s or S <= 0 or S >= 100 or NaN encounter in the tests
 
 kt 11680001 |ssh| max 2.812 at i j 9 88 MPI rank 0
 kt 11680001 |U| max 45.71 at i j k 91 11 62 MPI rank 0
 kt 11680001 |V| max 22.08 at i j k 92 11 64 MPI rank 0
 kt 11680001 Sal min 2.4482E-03 at i j k 39 23 68 MPI rank 0
 kt 11680001 Sal max 84.96 at i j k 63 13 62 MPI rank 0
 
        ===> output of last computed fields in 1_output.abort* files

```

I did not imposed any boundary condition though, should I zero-out everything on the boundary?

Moreover, in view of switching to an actual refinement, I tried to create this restart files with `NESTING`, but I cannot make it work.

- Should I use `NESTING` or `NESTING_AGRIF`?
- How can I set the parameters for the namelist of `NESTING`?
- Apparently there’s a _hot start_ option to let NEMO read parent grid restart files and interpolate them onto the child grids. I do not find any explaination on hot to use this option though. Any hint please?
- If everything goes south, would a simple interpolation of the fields onto the new grid work or should I put some extra care somewhere to amke it work?

# Questions

- Are the values from `rn_bathy ` to `ppacr2` coherent? The file `README_configs_namcfg_namdom` gives me different values for the ORCA\_R1 75 vertical levels configuration and I don’t know exactly how to choose them. More in detail, I did not create the parent configuration myself so I don’t know exactly how the vertical coordinates were built, and I don’t know how to make the child grid vertical coordinate coherent ith the parent, starting from those values. For now, I don’t need to refine the vertical resolution for now, but guidelines on how to do this would be appreciated.
- I am plannig to increase the resolution to 1/12 degree (so do two nested zooms, 1/4 and successive 1/3), so I guess a bunch of namelist parameters should be changed, starting with eddy\_viscosity. Could you perhaps provide me with some guidelines to choose the values in the refined grids?

Thank you all for your help (this conversation will also be used to improve the [AGRIF DEMO](https://github.com/ftucciarone/AGRIF_DEMO))

**Edit1** : added how I created the restarts.

---

<div class="post-metadata">

**Author:** ![francesco.tuccia](https://yyz2.discourse-cdn.com/free1/user_avatar/nemo-ocean.discourse.group/francesco.tuccia/32/68_2.png) [@francesco.tuccia](https://nemo-ocean.discourse.group/u/francesco.tuccia)\
**Post date:** [6 March 2026 14:23 UTC](https://nemo-ocean.discourse.group/t/agrif-setup-with-eorca-1-configuration/996/3 "2026-03-06T14:23:49Z")

</div>

**Update:** I have tried applying zero-boundary conditions to the restart files. This has changed nothing. Here’s the code I’ve used.

> **Python code to crop restarts**
>
> ```python
> #!/usr/bin/env python3
> import os
> import numpy as np
> import matplotlib.pyplot as plt
> import netCDF4 as netcdf
> 
> def zero_boundary(array_in):
> array_out = array_in
> #
> array_out[..., 0, :] = 0
> array_out[...,-1, :] = 0
> array_out[..., :, 0] = 0
> array_out[..., :,-1] = 0
> return array_out
> 
> # Set the folders
> root_dir = os.environ["root_dir"]
> nemo_dir = os.environ["nemo_dir"]
> cfg_name = os.environ["Cfg_name"]
> work_dir = root_dir + "/input-eOrca1" 
> path_to_restart = nemo_dir + "/cfgs/" + cfg_name + "/EXP00/"
> restart_list = ["TRA_10001231_restart.nc", "TRA_10001231_restart_trc.nc", "TRA_10001231_restart_icemod.nc"]
> 
> #
> # Open domain_cfg.nc eOrca1 (original grid)
> eOrca100_gridfile = work_dir + "/input_fields/domain_cfg.nc"
> eOrca100_restartfile = work_dir + "/restart/TRA_10001231_restart.nc"
> eOrca100_grid = netcdf.Dataset(eOrca100_gridfile, "r", format="NETCDF4")
> eOrca100_restart = netcdf.Dataset(eOrca100_restartfile, "r", format="NETCDF4")
> #
> # Open 1_domain_cfg.nc eOrca025 (target)
> pacific_gridfile = nemo_dir + "/tools/DOMAINcfg/cfgs/AGRIF_DEMO/1_domain_cfg.nc"
> pacific_grid = netcdf.Dataset(pacific_gridfile, "r", format="NETCDF4")
> 
> #
> # Open AGRIF_FixedGrids.in file (this is copied from make_namelist.py)
> AGRIF_FixedGrids = nemo_dir + "/tools/DOMAINcfg/cfgs/AGRIF_DEMO/AGRIF_FixedGrids.in"
> grid=[]
> nbghostcells = 4 
> with open(AGRIF_FixedGrids) as fp:
> line = fp.readline()
> cnt = 1
> while line:
> # print("Line {}: {}".format(cnt, line.strip()))
> # print (line.strip(' '))
> if len(line.split()) >=4 :
> #print(line.split())
> grid.append(line.split()[0:6])
> #for word in line.split() :
> #print(word)
> line = fp.readline()
> cnt += 1
> 
> # Here I should modify to work with multiple gridsin the future
> imin = int(grid[0][0]) - nbghostcells - 1
> jmin = int(grid[0][2]) - nbghostcells
> imax = int(grid[0][1]) + nbghostcells - 1
> jmax = int(grid[0][3]) + nbghostcells
> iref = int(grid[0][4])
> jref = int(grid[0][5])
> 
> # Read bathymetry for a visual check
> eOrca100_bathy = eOrca100_grid.variables["bathy_metry"][0]
> pacific_bathy = pacific_grid.variables["bathy_metry"][0]
> cropped = zero_boundary(eOrca100_bathy[jmin:jmax,imin:imax])
> # Visual check
> plt.rcParams['figure.dpi'] = 250  
> fig, axes = plt.subplots(1, 3)
> axes[0].imshow(cropped, cmap="seismic", interpolation=None)
> axes[1].imshow(pacific_bathy[:,:], cmap="seismic", interpolation=None)
> axes[2].imshow(np.abs(pacific_bathy[:,:]-cropped), cmap="seismic", interpolation=None)
> plt.tight_layout()
> plt.show()
> 
> for restart in restart_list:
> 
> print("Processing file: ", path_to_restart+restart)
> src_file = path_to_restart + restart
> dst_file = path_to_restart + "1_" + restart
> if os.path.exists(dst_file):
> os.remove(dst_file)
> src = netcdf.Dataset(src_file)
> dst = netcdf.Dataset(dst_file, "w")
> # copy attributes
> for name in src.ncattrs():
> dst.setncattr(name, src.getncattr(name))
> # copy dimensions
> for name, dimension in src.dimensions.items():
> if name == "x": 
> dim = int(imax-imin)
> elif name == "y": 
> dim = int(jmax-jmin)
> else:
> dim = len(dimension)
> dst.createDimension(name, (dim if not dimension.isunlimited() else None))
> # Duplicate and crop the variables
> for name, variable in src.variables.items():
> x = dst.createVariable(name, variable.datatype, variable.dimensions)
> if len(variable.shape) == 0:
> dst.variables[name][:] = src.variables[name][:]
> if len(variable.shape) == 1:
> dst.variables[name][:] = src.variables[name][:]
> if len(variable.shape) == 2:
> dst.variables[name][:,:] = zero_boundary(src.variables[name][jmin:jmax,imin:imax])
> if len(variable.shape) == 3:
> dst.variables[name][:,:,:] = zero_boundary(src.variables[name][:,jmin:jmax,imin:imax])
> if len(variable.shape) == 4:
> dst.variables[name][:,:,:,:] = zero_boundary(src.variables[name][:,:,jmin:jmax,imin:imax])
> dst.close()
> 
> ```

**Edit:** I have discovered the existence of `ln_init_chfrpar = .true` to set the child grids from parents. Also, I have found that if I activate the vertical remapping (`ln_vert_remap=.true.`) the extreme values are much more reasonable:

```shell
  ===>>> : E R R O R

          ===========

   stp_ctl: |ssh| > 20 m or |U| > 10 m/s or S <= 0 or S >= 100 or NaN encounter in the tests
 
 kt 11680001 |ssh| max 2.418 at i j 104 12 MPI rank 0
 kt 11680001 |U| max 0.6557 at i j k 25 5 67 MPI rank 0
 kt 11680001 |V| max 0.4728 at i j k 104 18 66 MPI rank 0
 kt 11680001 Sal min 0.000 at i j k 2 68 21 MPI rank 0
 kt 11680001 Sal max 36.96 at i j k 60 91 1 MPI rank 0
 
        ===> output of last computed fields in 1_output.abort* files

```

I still have a breakdown but at least currents are not 45m/s. The Agrif namelist reads

```fortran
!-----------------------------------------------------------------------
&namagrif ! AGRIF zoom ("key_agrif")
!-----------------------------------------------------------------------
ln_agrif_2way = .true. ! activate two way nesting
ln_init_chfrpar = .true. ! initialize child grids from parent
ln_vert_remap = .true. ! use vertical remapping
ln_spc_dyn = .false. ! use 0 as special value for dynamics
ln_chk_bathy = .false. ! =T check the parent bathymetry
rn_sponge_tra = 0.002 ! coefficient for tracer sponge layer []
rn_sponge_dyn = 0.002 ! coefficient for dynamics sponge layer []
rn_trelax_tra = 0.01 ! inverse of relaxation time (in steps) for tracers []
rn_trelax_dyn = 0.01 ! inverse of relaxation time (in steps) for dynamics []
/

```
