# Updated parent grids in AGRIF configurations

**URL:** <https://nemo-ocean.discourse.group/t/updated-parent-grids-in-agrif-configurations/897>\
**Category:** Uncategorized\
**Tags:** DOM, AGRIF\
**Created:** [14 May 2025 09:40 UTC](https://nemo-ocean.discourse.group/t/updated-parent-grids-in-agrif-configurations/897 "2025-05-14T09:40:50Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Franziska](https://avatars.discourse-cdn.com/v4/letter/f/8797f3/32.png) [@Franziska](https://nemo-ocean.discourse.group/u/Franziska)\
**Post date:** [14 May 2025 09:40 UTC](https://nemo-ocean.discourse.group/t/updated-parent-grids-in-agrif-configurations/897/1 "2025-05-14T09:40:50Z")

</div>

Hi all,

how exactly are updated parent grid(s) in AGRIF configurations defined and used in NEMO 5 and is it the same for NEMO 4.2.2?

For different puposes (e.g. runoff distribution, restart masking) I used masks from mesh\_mask files for the parent grid(s) in AGRIF configurations. First of all, these masks differ depending on whether created using the DOMAINcfg tool or produced by NEMO during integration (`ln_meshmask = .true.`). Which are the “correct” masks?

From older NEMO versions (e.g. 3.6) updated masks on the parent grid(s) were treated to (at least along coasts) ensure wet grid cells on the parent grid(s), whereever a wet grid cell is located on the respective nest grid. This seems to not be the case any longer. Is there some documentation on how exactly the parent grid(s) are treated?

Thank you!  
Franziska

---

<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:** [20 May 2025 10:30 UTC](https://nemo-ocean.discourse.group/t/updated-parent-grids-in-agrif-configurations/897/2 "2025-05-20T10:30:46Z")

</div>

Hi Franziska,

There is no documentation, but you can have a look at the following file: [agrif\_dom\_update.F90](https://forge.nemo-ocean.eu/nemo/nemo/-/blob/main/tools/DOMAINcfg/src/agrif_dom_update.F90). You’ll see a parameter in the module header, [`rminfrac`](https://forge.nemo-ocean.eu/nemo/nemo/-/blob/main/tools/DOMAINcfg/src/agrif_dom_update.F90?ref_type=heads#L12) that defines the minimum coarse grid area fraction that should be wet in order to unmask a parent grid cell. It’s 98% by default. You can play with that, and eventually set it to 0 so that you would retrieve what you were used to.

---

<div class="post-metadata">

**Author:** ![Franziska](https://avatars.discourse-cdn.com/v4/letter/f/8797f3/32.png) [@Franziska](https://nemo-ocean.discourse.group/u/Franziska)\
**Post date:** [21 May 2025 07:30 UTC](https://nemo-ocean.discourse.group/t/updated-parent-grids-in-agrif-configurations/897/3 "2025-05-21T07:30:50Z")

</div>

Thank you Jérôme!

I will have a look into it and its effect (but will need some time).

I’m still a bit worried about the different masks produced through DOMAINcfg and NEMO itself. Can you say something about that?

---

<div class="post-metadata">

**Author:** ![dbruciaf](https://avatars.discourse-cdn.com/v4/letter/d/a88e57/32.png) [@dbruciaf](https://nemo-ocean.discourse.group/u/dbruciaf)\
**Post date:** [22 May 2025 08:45 UTC](https://nemo-ocean.discourse.group/t/updated-parent-grids-in-agrif-configurations/897/4 "2025-05-22T08:45:51Z")

</div>

Hi Franziska,

In the past I also found that when using the DOMAINcfg, the land-sea masking applied in the mesh\_mask.nc differs from the one used in the domain\_cfg.nc, and I think this is consistent with what you are reporting, since the mesh\_mask.nc created during a NEMO run will be generated using the fields from the input domain\_cfg.nc file. I should have addressed this problem here (see small bug 1): [mbathy might be not correct when using AGRIF with ln\_vert\_remap and ln\_read\_cfg activated (#431) · Issues · NEMO Workspace / Nemo · GitLab](https://forge.nemo-ocean.eu/nemo/nemo/-/issues/431) - which version of DOMAINcfg are you using?

---

<div class="post-metadata">

**Author:** ![Franziska](https://avatars.discourse-cdn.com/v4/letter/f/8797f3/32.png) [@Franziska](https://nemo-ocean.discourse.group/u/Franziska)\
**Post date:** [22 May 2025 09:14 UTC](https://nemo-ocean.discourse.group/t/updated-parent-grids-in-agrif-configurations/897/5 "2025-05-22T09:14:17Z")

</div>

Hi Diego,

thanks for the hint!  
I was using DOMAINcfg from tagged versions 4.2.2 and 5.0.

---

<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:** [22 May 2025 13:51 UTC](https://nemo-ocean.discourse.group/t/updated-parent-grids-in-agrif-configurations/897/6 "2025-05-22T13:51:12Z")

</div>

Again, as stated elsewhere, I’m a bit unsure of anything produced with DOMAINcfg tool and `ln_read_cfg=T`. My advice is to start over from coordinates and topography.

---

<div class="post-metadata">

**Author:** ![Franziska](https://avatars.discourse-cdn.com/v4/letter/f/8797f3/32.png) [@Franziska](https://nemo-ocean.discourse.group/u/Franziska)\
**Post date:** [22 May 2025 14:07 UTC](https://nemo-ocean.discourse.group/t/updated-parent-grids-in-agrif-configurations/897/7 "2025-05-22T14:07:35Z")

</div>

What I do is using `ln_read_cfg=F` and providing coordinates and bathymetry for the outermost parent grid and an external bathymetry (GEBCO) for the nest(s) to be interpolated by DOMAINcfg (compiled with key\_agrif).  
Is this what you’d advice Jérôme?

---

<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:** [22 May 2025 14:19 UTC](https://nemo-ocean.discourse.group/t/updated-parent-grids-in-agrif-configurations/897/8 "2025-05-22T14:19:57Z")

</div>

yes, this is my advice

---

<div class="post-metadata">

**Author:** ![dbruciaf](https://avatars.discourse-cdn.com/v4/letter/d/a88e57/32.png) [@dbruciaf](https://nemo-ocean.discourse.group/u/dbruciaf)\
**Post date:** [22 May 2025 15:44 UTC](https://nemo-ocean.discourse.group/t/updated-parent-grids-in-agrif-configurations/897/9 "2025-05-22T15:44:28Z")

</div>

Hi Jérôme,

I think the small bug 1 I am refering in the ticket was affecting the DOMAINcfg tool everytime AGRIF was used, indipendentently from the `ln_read_cfg=T` flag. This was because when using AGRIF, `dom_wri` was called before `Agrif_Step_Child(agrif_boundary_connections)`, `Agrif_Step_Child(agrif_recompute_scalefactors)` and `Agrif_Step_Child_adj(agrif_update_all)`, preventing the `mesh_mask.nc` of the parent model from having the modications needed to make the bathymetry of the parent and the zooms consistent (contrarily to the `domain_cfg.nc`). You can see some tests I did for this ticket here [Resolve "mbathy might be not correct when using AGRIF with ln\_vert\_remap and ln\_read\_cfg activated" (!529) · Merge requests · NEMO Workspace / Nemo · GitLab](https://forge.nemo-ocean.eu/nemo/nemo/-/merge_requests/529#note_14317).

---

<div class="post-metadata">

**Author:** ![dbruciaf](https://avatars.discourse-cdn.com/v4/letter/d/a88e57/32.png) [@dbruciaf](https://nemo-ocean.discourse.group/u/dbruciaf)\
**Post date:** [23 May 2025 08:21 UTC](https://nemo-ocean.discourse.group/t/updated-parent-grids-in-agrif-configurations/897/10 "2025-05-23T08:21:36Z")

</div>

Hi Franziska,

I just checked and the fixes of the ticket I mentioned above are not included in v4.2.2 while they are in v5.0.

This should mean that

1. the DOMAINcfg@v4.2.2 with AGRIF generates `domain_cfg.nc` and `mesh_mask.nc` files for the parent model with fields (e.g., bathymetry, e3\*, masks) that are not consistent between each other (`domain_cfg.nc` being the correct one) - for the reason, see comment above.

2. the DOMAINcfg@v5.0 with AGRIF generates `domain_cfg.nc` and `mesh_mask.nc` files for the parent model with fields (e.g., bathymetry, e3\*, masks) that are consistent between each other.

In theory, this should imply that if you use the DOMAINcfg@v5.0 you should not have the mismatch between the `mesh_mask.nc` generated with the DOMAINcfg tool and the one from a NEMO run - is this consistent with your experiments?

---

<div class="post-metadata">

**Author:** ![Franziska](https://avatars.discourse-cdn.com/v4/letter/f/8797f3/32.png) [@Franziska](https://nemo-ocean.discourse.group/u/Franziska)\
**Post date:** [23 May 2025 09:17 UTC](https://nemo-ocean.discourse.group/t/updated-parent-grids-in-agrif-configurations/897/11 "2025-05-23T09:17:48Z")

</div>

Hi Diego,

thank you for checking the fixes.

Unfortunately this is not consistent with my experiments.  
I re-checked for tmasks:  
On the innermost nest grid (which is not updated during production), these are identical produced by DOMAINcfg and a NEMO run  
On all other grids which represent a parent of any nest (and should be subject to updates), these differ depending on their origin.

[I will get back to this issue in mid June - any in between clarification is very much appreciated.]

---

<div class="post-metadata">

**Author:** ![dbruciaf](https://avatars.discourse-cdn.com/v4/letter/d/a88e57/32.png) [@dbruciaf](https://nemo-ocean.discourse.group/u/dbruciaf)\
**Post date:** [23 May 2025 09:59 UTC](https://nemo-ocean.discourse.group/t/updated-parent-grids-in-agrif-configurations/897/12 "2025-05-23T09:59:57Z")

</div>

Thanks Franziska! Would it be possible to see a plot of the differences that you are finding?

---

<div class="post-metadata">

**Author:** ![Franziska](https://avatars.discourse-cdn.com/v4/letter/f/8797f3/32.png) [@Franziska](https://nemo-ocean.discourse.group/u/Franziska)\
**Post date:** [19 June 2025 05:57 UTC](https://nemo-ocean.discourse.group/t/updated-parent-grids-in-agrif-configurations/897/13 "2025-06-19T05:57:37Z")

</div>

Hi Diego,  
back to this topic…  
Here’s a figure showing parts of the global parent grid from a configuration with a child grid covering the South Atlantic and parts of the Indian Ocean. Depicted is the difference between tmask built by NEMO minus tmask built using DOMAINcfg for two different depths.

 ![tmask_difference](https://global.discourse-cdn.com/free1/uploads/nemo_ocean/original/1X/1ffcb47b39d1bc9abf1def15fa18a1b6bf68ffa9.png)

---

<div class="post-metadata">

**Author:** ![Franziska](https://avatars.discourse-cdn.com/v4/letter/f/8797f3/32.png) [@Franziska](https://nemo-ocean.discourse.group/u/Franziska)\
**Post date:** [19 June 2025 06:04 UTC](https://nemo-ocean.discourse.group/t/updated-parent-grids-in-agrif-configurations/897/14 "2025-06-19T06:04:00Z")

</div>

Hi Jérôme,  
I am still wondering about the change from “opening” parent cells everywhere to “almost nowhere” between the different code versions. What is the rational behind this choice? Would changing anything here impact on volume conservation, divergence conservation between the grids (proper vertical velocities on the parent grid) or anything else?  
Thanks a lot for more insights into this.

---

<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:** [19 June 2025 09:03 UTC](https://nemo-ocean.discourse.group/t/updated-parent-grids-in-agrif-configurations/897/15 "2025-06-19T09:03:25Z")

</div>

Hi Franziska,

The rationale is quite simple: Let’s take for example a 3:1 refinement. Imagine that one parent cell is covered by just 1 child grid cell with a 9 m depth. Conserving volume between cells (without changing areas) leads to 1m depth coarse grid. You can get into trouble during the integration of the barotropic mode, which I recall, is done everywhere over the coarse grid.  
On the other hand, not systematically unmasking a coarse grid that has at least 1 wet child grid point prevents from divergence conservation when doing the child to coarse feedback. So there’s a kind of imbalance at each startup of the 2d mode over the parent grid due to spurious divergences near the coastline. That’s the reason why I implemented this “double barotropic open boundary” option `PARENT_EXT_BDY` which simply assumes persistence over the coarse grid overlapping region during barotropic mode integration. But it seems that the parameters associated to this option have to be better explored (so it has been disabled in NEMO 5.x).

---

<div class="post-metadata">

**Author:** ![dbruciaf](https://avatars.discourse-cdn.com/v4/letter/d/a88e57/32.png) [@dbruciaf](https://nemo-ocean.discourse.group/u/dbruciaf)\
**Post date:** [19 June 2025 10:58 UTC](https://nemo-ocean.discourse.group/t/updated-parent-grids-in-agrif-configurations/897/16 "2025-06-19T10:58:52Z")

</div>

Hi Franziska,

Thanks a lot for the plots - could you please check if there are any differences in the grids (lat and lon)?

---

<div class="post-metadata">

**Author:** ![Franziska](https://avatars.discourse-cdn.com/v4/letter/f/8797f3/32.png) [@Franziska](https://nemo-ocean.discourse.group/u/Franziska)\
**Post date:** [19 June 2025 12:10 UTC](https://nemo-ocean.discourse.group/t/updated-parent-grids-in-agrif-configurations/897/17 "2025-06-19T12:10:25Z")

</div>

Hi Diego,  
I checked glam[tuv] and gphgi[tuv]. glam is identical in both, gphi differs at certain cells along the “northenmost” row (only for t and u). There are no differences in the region of the nest.

---

<div class="post-metadata">

**Author:** ![dbruciaf](https://avatars.discourse-cdn.com/v4/letter/d/a88e57/32.png) [@dbruciaf](https://nemo-ocean.discourse.group/u/dbruciaf)\
**Post date:** [19 June 2025 13:14 UTC](https://nemo-ocean.discourse.group/t/updated-parent-grids-in-agrif-configurations/897/18 "2025-06-19T13:14:17Z")

</div>

Thanks Franziska! One more thing - what if you compare the domain\_cfg,nc for the DOMAINcfg tool with the one from a NEMO run? do they have variables that differ?

---

<div class="post-metadata">

**Author:** ![Franziska](https://avatars.discourse-cdn.com/v4/letter/f/8797f3/32.png) [@Franziska](https://nemo-ocean.discourse.group/u/Franziska)\
**Post date:** [20 June 2025 05:30 UTC](https://nemo-ocean.discourse.group/t/updated-parent-grids-in-agrif-configurations/897/19 "2025-06-20T05:30:08Z")

</div>

Hi Diego,  
I’m using coordinates and bathymetry files as input for DOMAINcfg to build domain\_cfg.nc which I then use for NEMO. Comparing variables in coordinates.nc and domain\_cfg.nc shows differences in the nest region - the update to the grid apparently works. However, this is not reflected in the mesh\_mask.nc as produced by DOMAINcfg. Comparing to a mesh\_mask.nc build by DOMAINcfg but without introducing a nest shows identical masks (which should not be the case).  
From what I see, the mesh\_mask.nc file appears to be written before the update is applied.

---

<div class="post-metadata">

**Author:** ![dbruciaf](https://avatars.discourse-cdn.com/v4/letter/d/a88e57/32.png) [@dbruciaf](https://nemo-ocean.discourse.group/u/dbruciaf)\
**Post date:** [20 June 2025 14:25 UTC](https://nemo-ocean.discourse.group/t/updated-parent-grids-in-agrif-configurations/897/20 "2025-06-20T14:25:14Z")

</div>

Hi Franziska,  
Sorry but I am a bit confused now. At the beginning of this discussion you were reporting that “masks differ depending on whether created using the DOMAINcfg tool or produced by NEMO during integration” (se your original post).

Now you are reporting that “a mesh\_mask.nc build by DOMAINcfg but without introducing a nest shows identical masks” to the ones of a mesh\_mask.nc build with the same tool but with nests. I agree this shouldn’t happen, but this is different from your original post, could you please clarify?

Regarding the problem you report in this last post: can I ask you again which version of DOMAINcfg are you using please? Since you mentioned that “the mesh\_mask.nc file appears to be written before the update is applied”, then my guess is that you are using v4.2.2, and I should have fixed this in the ticket I mentioned above and it should be available in v5.0.

[Next page](https://nemo-ocean.discourse.group/t/updated-parent-grids-in-agrif-configurations/897.md?page=2)
