# \[v4.2.x\] \`namcouple variable not used\` error (NEMO-WRF-OASIS with nested domain)

**URL:** <https://nemo-ocean.discourse.group/t/v4-2-x-namcouple-variable-not-used-error-nemo-wrf-oasis-with-nested-domain/329>\
**Category:** v4.2.x\
**Tags:** OASIS, AGRIF\
**Created:** [17 July 2022 14:07 UTC](https://nemo-ocean.discourse.group/t/v4-2-x-namcouple-variable-not-used-error-nemo-wrf-oasis-with-nested-domain/329 "2022-07-17T14:07:46Z")\
**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:** [17 July 2022 14:07 UTC](https://nemo-ocean.discourse.group/t/v4-2-x-namcouple-variable-not-used-error-nemo-wrf-oasis-with-nested-domain/329/1 "2022-07-17T14:07:46Z")

</div>

I am trying to launch trunk NEMO with one nested domain in coupled mode (NEMO + WRF + OASIS).

The coupled model fails with the messages

```nohighlight
(oasis_coupler_setup) ERROR: namcouple variable not used: 1_O_SSTSST
(oasis_coupler_setup) ERROR: namcouple variable not used: 1_O_OCurx1
etc

```

I checked debug files and it seems that NEMO does not call `oasis_def_var()` for nested domain, i.e. for variables `1_O_SSTSST 1_O_OCurx1 1_O_OCury1 1_O_OTaux1 1_O_OTauy1 1_O_QsrOce 1_O_QnsOce 1_OOEvaMPr 1_O_TauMod`

I used the following command to compile NEMO

```shell
$ ./makenemo -m linux_ifort_cpl_agrif -r AGRIF_DEMO -n MY_OCE_cpl_agrif_no_xios -j 8 del_key "key_si3 key_top key_xios" add_key "key_netcdf4 key_agrif key_oasis3"

```

Also, I launched NEMO in uncoupled mode with one nested domain and it ran successfully.

What else options should I check?  
Can you please give me hints/ suggestions?

---

<div class="post-metadata">

**Author:** ![smasson](https://avatars.discourse-cdn.com/v4/letter/s/eb9ed0/32.png) [@smasson](https://nemo-ocean.discourse.group/u/smasson)\
**Post date:** [25 July 2022 10:11 UTC](https://nemo-ocean.discourse.group/t/v4-2-x-namcouple-variable-not-used-error-nemo-wrf-oasis-with-nested-domain/329/2 "2022-07-25T10:11:25Z")

</div>

the first thing to look at is your `namcouple`, _namelist\_cfg_ and _1\_namelist\_cfg_ files to make sure you properly defined all exchanges between OASIS and NEMO parent and child grids.

---

<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:** [26 July 2022 15:33 UTC](https://nemo-ocean.discourse.group/t/v4-2-x-namcouple-variable-not-used-error-nemo-wrf-oasis-with-nested-domain/329/3 "2022-07-26T15:33:06Z")

</div>

It seems there is a bug in _NEMOGCM/src/OCE/SBC/cpl\_oasis3.F90_

```fortran
#if defined key_agrif
      ! Warning: Agrif_Nb_Fine_Grids not yet defined at this stage for Agrif_Root -> must use Agrif_Root_Only()
      IF( Agrif_Root_Only() .OR. agrif_fixed() == Agrif_Nb_Fine_Grids() ) THEN
#endif
      CALL oasis_enddef(nerror)
      IF( nerror /= OASIS_Ok ) CALL oasis_abort ( ncomp_id, 'cpl_define', 'Failure in oasis_enddef')
#if defined key_agrif
      ENDIF
#endif

```

I checked that `agrif_fixed()` and `Agrif_Nb_Fine_Grids()` are both = 0 for a parent domain.  
So NEMO calls `oasis_enddef` for a parent domain, which prevents initialisation of variables for a nested domain.

I replaced `IF( Agrif_Root_Only() .OR. agrif_fixed() == Agrif_Nb_Fine_Grids() ) THEN` by `IF( .not. Agrif_Root() ) THEN`

---

<div class="post-metadata">

**Author:** ![smasson](https://avatars.discourse-cdn.com/v4/letter/s/eb9ed0/32.png) [@smasson](https://nemo-ocean.discourse.group/u/smasson)\
**Post date:** [29 August 2022 14:14 UTC](https://nemo-ocean.discourse.group/t/v4-2-x-namcouple-variable-not-used-error-nemo-wrf-oasis-with-nested-domain/329/4 "2022-08-29T14:14:52Z")

</div>

I agree with the diagnostic of the bug. It is an old staff that was not correctly fixed.  
I created a related ticket on NEMO GitLab.

> **[error in coupled model initialization (#88) · Issues · NEMO Sources / Nemo ·...](https://forge.nemo-ocean.eu/nemo/nemo/-/issues/88)**
>
> Context Branches impacted: branch\_4.2 and main

I propose a more general solution in [841e6954](https://forge.nemo-ocean.eu/nemo/nemo/-/commit/841e69540491bf9db6e6fb751dff373594ad6d61)  
Is it working for you?
