A bug in nesting.F (2 way nesting with WET_DRY)

Bug reports, work arounds and fixes

Moderators: arango, robertson

Post Reply
Message
Author
takashi

A bug in nesting.F (2 way nesting with WET_DRY)

#1 Unread post by takashi »

Hello all,
I found a bug when I test 2 way nesting with wetting & drying function.
Once wet cell became dry, the dry cell could not return to wet cell, even if surrounding zeta values were higher than h-DCRIT.
Maybe because zeta value on dry cell sets zero (zeta = 0 is lower than h-DCRIT) in fine2coarse2d routine, the dry cell don't have a chance for changing wet cell.

For fixing the bug, I think the lines 3477-3515 in nesting.F should be modified as following:

Code: Select all

!
!  Free-surface.
!
            AreaAvg=.FALSE.
# ifdef SOLVE3D
            CALL fine2coarse2d (rg, dg, model, tile,                    &
     &                          r2dvar, 'Zt_avg1',                      &
     &                          AreaAvg, RefineScale(dg),               &
     &                          cr, Rcontact(cr)%Npoints, Rcontact,     &
     &                          LBiD, UBiD, LBjD, UBjD,                 &
     &                          LBiR, UBiR, LBjR, UBjR,                 &
     &                          GRID(dg)%om_r,                          &
     &                          GRID(dg)%on_r,                          &
     &                          GRID(rg)%pm,                            &
     &                          GRID(rg)%pn,                            &
#  ifdef MASKING
     &                          GRID(dg)%rmask,                         &  !!! rmask_full -> rmask
     &                          GRID(rg)%rmask,                         &  !!! rmask_full -> rmask
#  endif
     &                          COUPLING(dg)%Zt_avg1,                   &
     &                          COUPLING(rg)%Zt_avg1)
# else
            CALL fine2coarse2d (rg, dg, model, tile,                    &
     &                          r2dvar, Vname(1,idFsur),                &
     &                          AreaAvg, RefineScale(dg),               &
     &                          cr, Rcontact(cr)%Npoints, Rcontact,     &
     &                          LBiD, UBiD, LBjD, UBjD,                 &
     &                          LBiR, UBiR, LBjR, UBjR,                 &
     &                          GRID(dg)%om_r,                          &
     &                          GRID(dg)%on_r,                          &
     &                          GRID(rg)%pm,                            &
     &                          GRID(rg)%pn,                            &
#  ifdef MASKING
     &                          GRID(dg)%rmask,                         &  !!! rmask_full -> rmask
     &                          GRID(rg)%rmask,                         &  !!! rmask_full -> rmask
#  endif
     &                          OCEAN(dg)%zeta(:,:,Dindex2d),           &
     &                          OCEAN(rg)%zeta(:,:,Rindex2d))
# endif

In similar sense, since tracers (temp, salt, etc.) values on dry cells also set zero,
when a cell become wet from dry, tracer values on this cell will appear as zero values.
So I think the lines 3574-3596 is better to be modified as following:

Code: Select all

!
!  Tracer type-variables.
!
            AreaAvg=.FALSE.
            DO itrc=1,NT(rg)
              CALL fine2coarse3d (rg, dg, model, tile,                  &
     &                            r3dvar, Vname(1,idTvar(itrc)),        &
     &                            AreaAvg, RefineScale(dg),             &
     &                            cr, Rcontact(cr)%Npoints, Rcontact,   &
     &                            LBiD, UBiD, LBjD, UBjD, 1, N(dg),     &
     &                            LBiR, UBiR, LBjR, UBjR, 1, N(rg),     &
     &                            GRID(dg)%om_r,                        &
     &                            GRID(dg)%on_r,                        &
     &                            GRID(rg)%pm,                          &
     &                            GRID(rg)%pn,                          &
#  ifdef MASKING
     &                            GRID(dg)%rmask,                       &  !!! rmask_full -> rmask
     &                            GRID(rg)%rmask,                       &  !!! rmask_full -> rmask
#  endif
     &                            OCEAN(dg)%t(:,:,:,Dindex3d,itrc),     &
     &                            OCEAN(rg)%t(:,:,:,Rindex3d,itrc))
              IF (exit_flag.ne.NoError) RETURN
            END DO

Moreover, when all the donor grid corners became wet cell, the tracer values on the receiver grids inside the donor grid set zero,
because Lweingt values inside the donor grids set zero.
It also a problem when the cells return to wet cells.

So,the line 1293:

Code: Select all

                  Lweight=0.0_r8               ! all the donor grid
is better to be modified as, for example:

Code: Select all

                  Lweight(:)=Rcontact(cr)%LweightUnmasked(:,m)
and the line 1380:

Code: Select all

                  Qweight=0.0_r8               ! all the donor grid
is better to be modified as:

Code: Select all

                  Qweight(:)=Rcontact(cr)%QweightUnmasked(:,m)
In addition, I found a small bug in nesting.F with QUADRATIC_WEIGHTS.
The 'END IF' codes on the lines 1839-1840 are duplicated like this.

Code: Select all

                END IF                         ! corners are on land
                END IF

simion1232006
Posts: 60
Joined: Tue Sep 29, 2009 3:50 pm
Location: School of Environment System Engineering,UWA

Re: A bug in nesting.F (2 way nesting with WET_DRY)

#2 Unread post by simion1232006 »

Good catch. I saw similar problems and did similar modifications. Still better let ROMS group to update an official version based on what we report.

User avatar
kate
Posts: 4091
Joined: Wed Jul 02, 2003 5:29 pm
Location: CFOS/UAF, USA

Re: A bug in nesting.F (2 way nesting with WET_DRY)

#3 Unread post by kate »

Yes, thank you for reporting the bugs. Also for providing fixes!

Post Reply