Opened 3 months ago

Last modified 5 weeks ago

#2474 new Bug

Bug(s) in the hpg_prj code?

Reported by: jamesharle Owned by: jamesharle
Priority: low Milestone: Unscheduled
Component: DYN Version: 4.0-HEAD
Severity: minor Keywords: dyn, hpg, hpg_prj
Cc: smasson

Description (last modified by jamesharle)

Context

With constant T/S in an unforced simulation the hpg_prj scheme produces max velocities of ~3cm/s in the AMM7 configuration.

One of the main issues arises in this part of the code

      ! Preparing vertical density profile "zrhh(:,:,:)" for hybrid-sco coordinate
      DO jj = 1, jpj
        DO ji = 1, jpi
          jk = mbkt(ji,jj)+1
          IF(     jk <=  0   ) THEN   ;   zrhh(ji,jj,    :   ) = 0._wp
          ELSEIF( jk ==  1   ) THEN   ;   zrhh(ji,jj,jk+1:jpk) = rhd(ji,jj,jk)
          ELSEIF( jk < jpkm1 ) THEN
             DO jkk = jk+1, jpk
                zrhh(ji,jj,jkk) = interp1(gde3w_n(ji,jj,jkk  ), gde3w_n(ji,jj,jkk-1),   &
                   &                      gde3w_n(ji,jj,jkk-2), rhd    (ji,jj,jkk-1), rhd(ji,jj,jkk-2))
             END DO
          ENDIF
        END DO
      END DO

Analysis

  • If mbkt(ji,jj) is equal to jpkm2, jk=jpkm1 and we don't enter into the last ELSEIF statement and so no extrapolation is performed for those cells.
  • I believe the first IF statement is now redundant as mbkt is always > 0 (unlike when mbathy was used)
  • The second statement is also incorrect now as jk can only ever be ≥2 in the above code snippet - land points are masked later in the code so no IF statement needed here.

NB v3.6 employs jk=mbathy(ji,jj)

Fix

Set jk = mbkt(ji,jj) and remove other IF statements as they are redundant (subsequent masking takes care of land points)

      ! Preparing vertical density profile "zrhh(:,:,:)" for hybrid-sco coordinate
      DO jj = 1, jpj
        DO ji = 1, jpi
          jk = mbkt(ji,jj)
          IF( jk < jpkm1 ) THEN
             DO jkk = jk+1, jpk
                zrhh(ji,jj,jkk) = interp1(gde3w_n(ji,jj,jkk  ), gde3w_n(ji,jj,jkk-1),   &
                   &                      gde3w_n(ji,jj,jkk-2), rhd    (ji,jj,jkk-1), rhd(ji,jj,jkk-2))
             END DO
          ENDIF
        END DO
      END DO

This is one of possibly a few issues Diego Bruciaferri, Enda O'Dea and I are looking at with the hpg_prj routine. James

Another possible source of error is the fact rhd is used in the interactive extrapolation loop - as rhd is never updated. The variable zrhh should be used instead:

      ! Preparing vertical density profile "zrhh(:,:,:)" for hybrid-sco coordinate
      DO jj = 1, jpj
        DO ji = 1, jpi
          jk = mbkt(ji,jj)
          IF( jk < jpkm1 ) THEN
             DO jkk = jk+1, jpk
                zrhh(ji,jj,jkk) = interp1(gde3w_n(ji,jj,jkk  ), gde3w_n(ji,jj,jkk-1),   &
                   &                      gde3w_n(ji,jj,jkk-2), zrhh(ji,jj,jkk-1), zrhh(ji,jj,jkk-2))
             END DO
          ENDIF
        END DO
      END DO

Commit History (2)

ChangesetAuthorTimeChangeLog
13288smasson2020-07-09T18:23:18+02:00

trunk: bugfix following #2474

13095jamesharle2020-06-11T14:08:55+02:00

Update indexing in hpg_prj (see ticket #2474)

Change History (4)

comment:1 Changed 2 months ago by jamesharle

  • Description modified (diff)

comment:2 Changed 2 months ago by jamesharle

In 13095:

Update indexing in hpg_prj (see ticket #2474)

comment:3 Changed 2 months ago by smasson

  • Cc smasson added

[13095] passes all sette tests and changes AMM12 results. see below

Is this error also existing in the trunk?

Current code is : NEMO/releases/r4.0/r4.0-HEAD @ r13095  ( last change @ r13095 )

SETTE validation report generated for :

       NEMO/releases/r4.0/r4.0-HEAD @ r13095 (last changed revision)

       on X64_IRENE arch file


!!---------------1st pass------------------!!

   !----restart----!
WGYRE_PISCES_ST              run.stat    restartability  passed :  13095
WGYRE_PISCES_ST              tracer.stat restartability  passed :  13095
WORCA2_ICE_PISCES_ST         run.stat    restartability  passed :  13095
WORCA2_ICE_PISCES_ST         tracer.stat restartability  passed :  13095
WORCA2_OFF_PISCES_ST         tracer.stat restartability  passed :  13095
WAMM12_ST                    run.stat    restartability  passed :  13095
WORCA2_SAS_ICE_ST            run.stat    restartability  passed :  13095
WAGRIF_DEMO_ST               run.stat    restartability  passed :  13095
WSPITZ12_ST                  run.stat    restartability  passed :  13095
WISOMIP_ST                   run.stat    restartability  passed :  13095
WOVERFLOW_ST                 run.stat    restartability  passed :  13095
WLOCK_EXCHANGE_ST            run.stat    restartability  passed :  13095
WVORTEX_ST                   run.stat    restartability  passed :  13095
WICE_AGRIF_ST                run.stat    restartability  passed :  13095

   !----repro----!
WGYRE_PISCES_ST              run.stat    reproducibility passed :  13095
WGYRE_PISCES_ST              tracer.stat reproducibility passed :  13095
WORCA2_ICE_PISCES_ST         run.stat    reproducibility passed :  13095
WORCA2_ICE_PISCES_ST         tracer.stat reproducibility passed :  13095
WORCA2_OFF_PISCES_ST         tracer.stat reproducibility passed :  13095
WAMM12_ST                    run.stat    reproducibility passed :  13095
WORCA2_SAS_ICE_ST            run.stat    reproducibility passed :  13095
WORCA2_ICE_OBS_ST            run.stat    reproducibility passed :  13095
WAGRIF_DEMO_ST               run.stat    reproducibility passed :  13095
WSPITZ12_ST                  run.stat    reproducibility passed :  13095
WISOMIP_ST                   run.stat    reproducibility passed :  13095
WVORTEX_ST                   run.stat    reproducibility passed :  13095
WICE_AGRIF_ST                run.stat    reproducibility passed :  13095

   !----agrif check----!
ORCA2 AGRIF vs ORCA2 NOAGRIF run.stat    unchanged  -    passed :  13095 13095

   !----result comparison check----!

check result differences between :
VALID directory : /ccc/work/cont005/ra0542/massons/NEMO_ALL_VALIDATIONS/r4.0-HEAD/NEMO_VALIDATION at rev 13095
and
REFERENCE directory : /ccc/work/cont005/ra0542/massons/NEMO_ALL_VALIDATIONS/r4.0-HEAD/NEMO_VALIDATION at rev 12926

WGYRE_PISCES_ST       run.stat    files are identical
WGYRE_PISCES_ST       tracer.stat files are identical
WORCA2_ICE_PISCES_ST  run.stat    files are identical
WORCA2_ICE_PISCES_ST  tracer.stat files are identical
WORCA2_OFF_PISCES_ST  tracer.stat files are identical
WAMM12_ST             run.stat    files are DIFFERENT
WISOMIP_ST            run.stat    files are identical
WORCA2_SAS_ICE_ST     run.stat    files are identical
WAGRIF_DEMO_ST        run.stat    files are identical
WSPITZ12_ST           run.stat    files are identical
WISOMIP_ST            run.stat    files are identical
WVORTEX_ST            run.stat    files are identical
WICE_AGRIF_ST         run.stat    files are identical

comment:4 Changed 5 weeks ago by smasson

In 13288:

trunk: bugfix following #2474

Note: See TracTickets for help on using tickets.