Opened 8 weeks ago

Closed 4 days ago

#2378 closed Defect (fixed)

numnul with Agrif

Reported by: rblod Owned by: systeam
Priority: normal Milestone: Unscheduled
Component: AGRIF Version: 4.0-HEAD
Severity: major Keywords: agrif gfortran
Cc: smasson

Description

Context

Trying to run Vortex test case or Agrif Demo fails (compiled with gfortran). It was also reported in the forum https://forge.ipsl.jussieu.fr/nemo/discussion/topic/79

Analysis

All grids are trying to open /dev/null so it fails since it's already open by the first grid. It's in NEMO V4.0. I think the pb is still there in 4.0.1. It's minor by itself but pretty annoying though for anybody using Agrif with gfortran (at least)

Recommendation

In nemogcm, replace

         CALL ctl_opn( numnul, '/dev/null', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE. )

by


     IF( Agrif_Root() ) THEN
         CALL ctl_opn( numnul, '/dev/null', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE. )
#ifdef key_agrif
      ELSE
         numnul = Agrif_Parent(numnul)   
#endif
      ENDIF

Commit History (1)

ChangesetAuthorTimeChangeLog
12640smasson2020-04-01T14:27:05+02:00

r4.0-HEAD: numnul with Agrif, see #2378

Change History (10)

comment:1 Changed 8 weeks ago by jchanut

Yes, indeed, this was in the stack of bugs for (most of) mac users in particular. BTW, if you're in that case, you have to avoid symbolic links for namelists files.

comment:2 Changed 9 days ago by smasson

I am testing this with gcc8.3 with the trunk@12618

As proposed, I added this in nemogcm.F90:

      IF( Agrif_Root() ) THEN
                  CALL ctl_opn(     numnul,           '/dev/null', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, -1, .FALSE. )
#ifdef key_agrif
      ELSE
                  numnul = Agrif_Parent(numnul)   
#endif
      ENDIF      !

but there is what I got in after the precompilation in nemogcm.f90:

      IF( Agrif_Root() ) THEN
                  CALL ctl_opn(     numnul,           '/dev/null', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, -1, .FALSE. )
      ELSE
                  numnul = numnul   
      ENDIF      !

So, of course, the tick is not working…

Note that, for example, in icestp.F90, we also use Agrif_Parent

#if defined key_agrif
!                              ! nbstep_ice ranges from 1 to the nb of child ocean steps inside one parent ice step
IF( .NOT. Agrif_Root() )       nbstep_ice = MOD( nbstep_ice, Agrif_irhot() * Agrif_Parent(nn_fsbc) / nn_fsbc ) + 1

And it seems to work, when we look at icestp.f90

!                              ! nbstep_ice ranges from 1 to the nb of child ocean steps inside one parent ice step
IF( .NOT. Agrif_Root() )       nbstep_ice = MOD( nbstep_ice, Agrif_irhot() *  Agrif_tabvars_i(231) % parent_var% iarray0 / nn_fsbc ) + 1

I must say I am a little bit lost…
Any idea?

comment:3 Changed 9 days ago by rblod

I was working with another version of AGRIF, and it works. With the trunk, I have the same issue as you, and I don't have any idea why. But putting numnul as !$AGRIF_DO_NOT_TREAT in inout_manager, with an opening only done by Agrif_Root could be a workaround

comment:4 Changed 8 days ago by clevy

  • Version changed from release-4.0 to 4.0-HEAD

comment:5 Changed 6 days ago by smasson

I done tests on irene with gcc8.3.0 or gcc4.8.5, with the trunk and with r4.0-HEAD, with AGRIF before and after Andrew's modifications
https://forge.ipsl.jussieu.fr/nemo/log/vendors/AGRIF/dev

None of them is able to correctly "translate"

numnul = Agrif_Parent(numnul)

I always get (except fot the trunk with the old AGRIF which does not compile)

numnul = numnul

comment:6 Changed 6 days ago by smasson

  • Cc smasson added

comment:7 Changed 6 days ago by acc

Solved; but it is a scary one.

nemogcm.F90 doesn't explicitly USE in_out_manager which seems to be enough to confuse conv.
Not quite sure why it has been compiling (probably because it is included inside other modules such as step_oce?). Anyway stick a:

USE in_out_manager


at the top of nemogcm.F90 (e.g. just before USE xios ) and conv behaves itself:

IF( Agrif_Root() ) THEN
      CALL ctl_opn(     numnul,           '/dev/null', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, -1, .FALSE. )
ELSE
      numnul =  Agrif_tabvars_i(174) % parent_var% iarray0
ENDIF


comment:8 Changed 6 days ago by smasson

Note that we also have the same conv error with ifort!

numnul = numnul

The only difference is that, apparently, ifort does not complain when using a negative logical unit (numnul = -1 by default in in_out_manager)

comment:9 Changed 4 days ago by smasson

In 12640:

r4.0-HEAD: numnul with Agrif, see #2378

comment:10 Changed 4 days ago by smasson

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

fixed in [12640]

Note: See TracTickets for help on using tickets.