# Creating nested domains with DOMAINcfg

**URL:** https://nemo-ocean.discourse.group/t/creating-nested-domains-with-domaincfg/375
**Category:** Configurations
**Tags:** tools, DOM, AGRIF
**Created:** [18 October 2022 14:55 UTC](https://nemo-ocean.discourse.group/t/creating-nested-domains-with-domaincfg/375 "2022-10-18T14:55:11Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![qtqw](https://avatars.discourse-cdn.com/v4/letter/q/77aa72/32.png) [@qtqw](https://nemo-ocean.discourse.group/u/qtqw)
#### Post date: [18 October 2022 14:55 UTC](https://nemo-ocean.discourse.group/t/creating-nested-domains-with-domaincfg/375/1 "2022-10-18T14:55:11Z")

</div>

I use DOMAINcfg to create initial conditions for nested domains, e.g. _domain\_cfg.nc_ and _1\_domain\_cfg.nc_ files.  
I found that _1\_domain\_cfg.nc_ is bigger than _1\_coordinates.nc_ and _1\_bathy\_meter.nc_ by 4 points.  
For example,  
_1\_bathy\_meter.nc_ and _1\_coordinates.nc_ are 631 x 313 points but _1\_domain\_cfg.nc_ is 635 x 317 points.  
Also, it seems that area in _1\_domain\_cfg.nc_ is shifted to the south-west by 5 points so that  
(6,6)-point in _1\_domain\_cfg.nc_ coincides with (1,1)-point in _1\_coordinates.nc_.

I use the following options _1\_namelist\_cfg_

```fortran
!-----------------------------------------------------------------------
&namagrif ! AGRIF zoom ("key_agrif")
!-----------------------------------------------------------------------
   ln_vert_remap = .false. ! volume conserving update
   ln_remove_closedseas = .true. ! Fill lakes inside zoom
   npt_connect = 4
   npt_copy = 2
/

```

My questions are:

1. What does parameters `npt_connect` and `npt_copy` mean ?
2. Is it possible to create _1\_domain\_cfg.nc_ with the same size as _1\_coordinates.nc_ ?

---

<div class="post-metadata">

### Author: ![jchanut](https://yyz2.discourse-cdn.com/free1/user_avatar/nemo-ocean.discourse.group/jchanut/32/9_2.png) [@jchanut](https://nemo-ocean.discourse.group/u/jchanut)
#### Post date: [18 October 2022 20:31 UTC](https://nemo-ocean.discourse.group/t/creating-nested-domains-with-domaincfg/375/2 "2022-10-18T20:31:59Z")

</div>

> [@qtqw](#):
>
> What does parameters `npt_connect` and `npt_copy` mean ?

`npt_copy` and `npt_connect` are numbers of coarse grid points.

- `npt_copy` refers to the width of a zone right inside the child grid where the child bathymetry is exactly set to the parent one (so basically it is constant by blocks of `nrafx X nrafy` child grid points).
- `npt_connect` refers to the width of a “connecting zone” right after the “copy zone” where the child bathymetry is linearly blended with the parent bathymetry.

These do not change neither the child grid size nor the grid positioning. You should not change these (the `npt_copy` parameter in particular that matches the “sponge zone” used in NEMO.)

> [@qtqw](#):
>
> Is it possible to create _1\_domain\_cfg.nc_ with the same size as _1\_coordinates.nc_ ?

The _1\_domain\_cfg.nc_ has the required number of points following what you have defined in your _AGRIF\_FixedGrids.in_ file. You apparently provide _1\_bathy\_meter.nc_ and _1\_coordinates.nc_ files that do not comply with the expected size. The code should not allow this, even if it does.

My questions:

1. How did you get your _1\_bathy\_meter.nc_ and _1\_coordinates.nc_ files ? From the previous _NESTING\_TOOLS_ ? If so, grid positioning over the parent grid has changed: It would be normal to have a shift.

2. What is your refinement factor ?

If you extract your _1\_bathy\_meter.nc_ and _1\_coordinates.nc_ files from a global grid, the right way to go is extract the zone that exactly matches the lon/lat coordinates you have in your _1\_domain\_cfg.nc_ file. You can find information about how that here:  
[https://sites.nemo-ocean.io/user-guide/zooms.html#how-do-i-retrieve-the-exact-zoom-positioning-over-the-parent-grid](https://sites.nemo-ocean.io/user-guide/zooms.html#how-do-i-retrieve-the-exact-zoom-positioning-over-the-parent-grid)

---

<div class="post-metadata">

### Author: ![qtqw](https://avatars.discourse-cdn.com/v4/letter/q/77aa72/32.png) [@qtqw](https://nemo-ocean.discourse.group/u/qtqw)
#### Post date: [27 October 2022 08:55 UTC](https://nemo-ocean.discourse.group/t/creating-nested-domains-with-domaincfg/375/3 "2022-10-27T08:55:21Z")

</div>

Thank you for the explanation.

I use NEMO for coupled modelling with WRF.  
I prepare _1\_ bathy\_meter.nc_ and _1\_coordinates.nc_ myself so that the nested domain in NEMO matches the nested domain in WRF.  
My refinement factor is 3.  
_1\_bathy\_meter.nc_ and _1\_coordinates.nc_ are both `631 x 313`  
I use _AGRIF\_FixedGrids.in_

```auto
1
157 366 123 226 3 3 3
0

```

The resulted _1\_domain\_cfg.nc_ is `635 x 317`

When I try to use another values in _AGRIF\_FixedGrids.in_ (for example, `158 366 124 226`), DOMAINcfg fails with a message

```auto
 AGRIF boundaries and ghost cells:
 lk_west T
 lk_east T
 lk_south T
 lk_north T
 nbghostcells_y_s 4
 nbghostcells_y_n 4
 nbghostcells_x_w 4
 nbghostcells_x_e 4
 nbcellsx = 624
 nbcellsy = 306
 Ni0glo = 631
 Ni0glo should be: 632
  ===>>> : E R R O R
          ===========
 STOP
mpp_init: Agrif children requires Ni0glo == nbcellsx + nbghostcells_x_w + nbghostcells_x_e

```

It seems to me that the size of a nested domain in NEMO must be 3 nx + 8, 3 ny + 8  
So it is impossible to create a nested domain, which is `631 x 313`.  
Am I correct?

---

<div class="post-metadata">

### Author: ![jchanut](https://yyz2.discourse-cdn.com/free1/user_avatar/nemo-ocean.discourse.group/jchanut/32/9_2.png) [@jchanut](https://nemo-ocean.discourse.group/u/jchanut)
#### Post date: [4 November 2022 09:33 UTC](https://nemo-ocean.discourse.group/t/creating-nested-domains-with-domaincfg/375/4 "2022-11-04T09:33:39Z")

</div>

> [@qtqw](#):
>
> It seems to me that the size of a nested domain in NEMO must be 3 nx + 8, 3ny+8  
> So it is impossible to create a nested domain, which is `631 x 313`.  
> Am I correct?

You’re right. BTW, if changing values in `AGRIF_FixedGrids.in`, be careful: you must provide compliant child grid sizes in your `1_namelist_cfg`. You may use the `make_namelist.py` python script that’s does that for you.
