New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
#2615 (bug in cpl_define + AGRIF) – NEMO

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#2615 closed Bug (fixed)

bug in cpl_define + AGRIF

Reported by: smasson Owned by: smasson
Priority: low Milestone:
Component: SBC Version: trunk
Severity: minor Keywords:
Cc:

Description

Context

The bugfix done in cpl_define in cpl_oasis3.F90 [12132] is not working...

#if defined key_agrif
      IF( agrif_fixed() == Agrif_Nb_Fine_Grids() ) THEN
#endif

Analysis

Agrif_Nb_Fine_Grids() is initialized in nemo_gcm when calling

      CALL Agrif_Regrid()

but nemo_init -> sbc_init -> cpl_define is called before!
In consequence, for Agrif_Root, Agrif_Nb_Fine_Grids() is not yet defined and is equal to 0, agrif_fixed() == Agrif_Nb_Fine_Grids() is .true. and we call oasis_enddef before chid grids are defined for oasis...

Fix

One solution would be to exclude Agrif_Root() from the test:

#if defined key_agrif
      IF( agrif_fixed() == Agrif_Nb_Fine_Grids() .and. .not. Agrif_Root() ) THEN
#endif

but this won't work if there is no zoom...

We should find a better solution...

Commit History (3)

ChangesetAuthorTimeChangeLog
14611smasson2021-03-15T17:00:43+01:00

AGRIF: delete dev old branch, #2598 and #2615

14434smasson2021-02-11T09:20:52+01:00

trunk: fix agrif + coupled model, #2615

14429smasson2021-02-11T08:43:31+01:00

agrif: add Agrif_Root_Only function, see #2615

Change History (6)

comment:1 Changed 4 years ago by smasson

Solution proposed by Laurent Debreu to be able to know if the mother grid has children or not: read the first line of AGRIF_FixedGrids.in.
The following function could be added in ext/AGRIF/AGRIF_FILES/modcurgridfunctions.F90:

LOGICAL FUNCTION Agrif_Root_Only()
   INTEGER ::nb_rootschildgrids
   INTEGER :: nunit
   LOGICAL :: Bexist
   
   nunit = Agrif_Get_Unit()
   OPEN(nunit, file='AGRIF_FixedGrids.in', form='formatted', status="old",ERR=98)
   READ(nunit,*) nb_rootschildgrids
   CLOSE(nuint)
   Agrif_Root_Only = (nb_rootschildgrids <= 0)
   
98 INQUIRE(FILE='AGRIF_FixedGrids.in',EXIST=BEXIST)
   IF (.NOT. BEXIST) THEN
      PRINT*,'ERROR : File AGRIF_FixedGrids.in not found.'
      STOP
   ELSE
      PRINT*,'Error opening file AGRIF_FixedGrids.in'
      STOP
   ENDIF
   
END FUNCTION Agrif_Root_Only

comment:2 Changed 4 years ago by smasson

Ok, it works perfectly... once we fixe the small bugfix in the above code ;-)

Shall we modify ext/AGRIF/AGRIF_FILES/modcurgridfunctions.F90 as suggested?
Or do we prefer to keep AGRIF unchanged and leave a possible error when a user will try to couple the code compiled with AGRIF but used without any zoom?
Changing AGRIF could be done in dev_r14312_MPI_Interface which already uses a modified version of AGRIF...

The bug is also existing in r4.0-HEAD. In this case, I propose to simply add a test on ".not. Agrif_Root()" as proposed in the Fix of the bug, assuming that the user won't try to couple the code compiled with AGRIF without any zoom...

comment:3 Changed 4 years ago by smasson

In 14429:

Error: Failed to load processor CommitTicketReference
No macro or processor named 'CommitTicketReference' found

comment:4 Changed 4 years ago by smasson

In 14434:

Error: Failed to load processor CommitTicketReference
No macro or processor named 'CommitTicketReference' found

comment:5 Changed 4 years ago by smasson

  • Resolution set to fixed
  • Status changed from new to closed

comment:6 Changed 4 years ago by smasson

In 14611:

Error: Failed to load processor CommitTicketReference
No macro or processor named 'CommitTicketReference' found
Note: See TracTickets for help on using tickets.