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.
Changeset 8690 for branches/2017 – NEMO

Changeset 8690 for branches/2017


Ignore:
Timestamp:
2017-11-10T12:39:45+01:00 (6 years ago)
Author:
timgraham
Message:

Bug fixes to get full bathy overflow test working

Location:
branches/2017/dev_r8126_UKMO_AGRIF_vert_interp/NEMOGCM/NEMO/NST_SRC
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/2017/dev_r8126_UKMO_AGRIF_vert_interp/NEMOGCM/NEMO/NST_SRC/agrif_opa_interp.F90

    r8596 r8690  
    601601      INTEGER                                     , INTENT(in   ) ::   nb , ndir 
    602602      ! 
    603       INTEGER  ::   ji, jj, jk, jn   ! dummy loop indices 
     603      INTEGER  ::   ji, jj, jk, jn, iref, jref   ! dummy loop indices 
    604604      INTEGER  ::   imin, imax, jmin, jmax 
    605605      REAL(wp) ::   zrhox , zalpha1, zalpha2, zalpha3 
     
    618618      zrhoxy = Agrif_rhox()*Agrif_rhoy() 
    619619 
     620 
     621 
    620622      IF (before) THEN          
    621623            IF(Agrif_UseSpecialValue) THEN  
    622                Agrif_SpecialValue = -999._wp 
     624!               Agrif_SpecialValue = -999._wp 
     625               Agrif_SpecialValue = 0._wp 
    623626            ELSE 
    624627               Agrif_SpecialValue = 0._wp 
     
    628631                  DO jj=j1,j2 
    629632                     DO ji=i1,i2 
    630                         ptab(ji,jj,jk,jn) = tsn(ji,jj,jk,jn) * e1e2t(ji,jj) * e3t_n(ji,jj,jk) * tmask(ji,jj,jk) - & 
    631                                           & (tmask(ji,jj,jk)-1) * Agrif_SpecialValue 
     633                        ptab(ji,jj,jk,jn) = tsn(ji,jj,jk,jn) * e1e2t(ji,jj) * e3t_n(ji,jj,jk)! * tmask(ji,jj,jk) - & 
     634!                                          & (tmask(ji,jj,jk)-1) * Agrif_SpecialValue 
    632635                     END DO 
    633636                  END DO 
     
    642645            END DO 
    643646      ELSE  
     647         western_side  = (nb == 1).AND.(ndir == 1) 
     648         eastern_side  = (nb == 1).AND.(ndir == 2) 
     649         southern_side = (nb == 2).AND.(ndir == 1) 
     650         northern_side = (nb == 2).AND.(ndir == 2) 
    644651         Agrif_SpecialValue = 0._wp !reset now interpolation is done 
    645652! VERTICAL REFINEMENT BEGIN 
     
    648655         do jj=j1,j2 
    649656         do ji=i1,i2 
     657           iref = ji 
     658           jref = jj 
     659           if(western_side) iref=2 
     660           if(eastern_side) iref=nlci-1 
     661           if(southern_side) jref=2 
     662           if(northern_side) jref=nlcj-1 
    650663           N_in = 0 
    651664           DO jk=k1,k2 !k2 = jpk of parent grid 
     
    653666             N_in = N_in + 1 
    654667             tabin(jk,:) = ptab(ji,jj,jk,n1:n2-1)/ptab(ji,jj,jk,n2) 
    655              h_in(N_in) = ptab(ji,jj,jk,n2)/(e1e2t(ji,jj)*zrhoxy) 
     668             h_in(N_in) = ptab(ji,jj,jk,n2)/(e1e2t(ji,jj)) 
    656669           END DO 
    657670           N_out = 0 
    658671           DO jk=1,jpk ! jpk of child grid 
    659              IF (tmask(ji,jj,jk) == 0) EXIT ! TODO: Will not work with ISF. !This doesn't seem to work at the moment in GYRE but is OK in overflow model 
     672             IF (tmask(iref,jref,jk) == 0) EXIT ! TODO: Will not work with ISF. !This doesn't seem to work at the moment in GYRE but is OK in overflow model 
    660673             N_out = N_out + 1 
    661              h_out(jk) = e3t_n(ji,jj,jk) !Child grid scale factors. Could multiply by e1e2t here instead of division above 
     674             h_out(jk) = e3t_n(iref,jref,jk) !Child grid scale factors. Could multiply by e1e2t here instead of division above 
    662675           ENDDO 
    663676           IF (N_in > 0) THEN 
     
    891904         !when interpolating the scale factors 
    892905         IF(Agrif_UseSpecialValue) THEN  
    893              Agrif_SpecialValue = -999._wp 
     906!             Agrif_SpecialValue = -999._wp 
     907             Agrif_SpecialValue = 0._wp 
    894908         ELSE 
    895909             Agrif_SpecialValue = 0._wp 
     
    925939                  N_in = N_in + 1 
    926940                  tabin(jk) = ptab(ji,jj,jk,1)/ptab(ji,jj,jk,2) 
    927                   h_in(N_in) = ptab(ji,jj,jk,2)/(e2u(ji,jj) * zrhoy)  
     941                  h_in(N_in) = ptab(ji,jj,jk,2)/(e2u(ji,jj))  
    928942              ENDDO 
    929943          
     
    945959              ENDIF 
    946960          
    947 !              IF (N_in * N_out > 0) THEN 
    948 !                 h_diff = sum(h_out(1:N_out))-sum(h_in(1:N_in)) 
     961              IF (N_in * N_out > 0) THEN 
     962                 h_diff = sum(h_out(1:N_out))-sum(h_in(1:N_in)) 
    949963! Should be able to remove the next IF/ELSEIF statement once scale factors are dealt with properly 
    950 !                 if (h_diff < 0.) then 
    951 !                    print *,'CHECK YOUR BATHY ...', h_diff, sum(h_out(1:N_out)), sum(h_in(1:N_in)) 
     964                 if (h_diff < -1.e4) then 
     965                    print *,'CHECK YOUR BATHY ...', h_diff, sum(h_out(1:N_out)), sum(h_in(1:N_in)) 
    952966!                    stop 
    953 !                 endif 
    954 !              ENDIF 
     967                 endif 
     968              ENDIF 
    955969              call reconstructandremap(tabin(1:N_in),h_in(1:N_in),ptab_child(ji,jj,1:N_out),h_out(1:N_out),N_in,N_out) 
    956970          
     
    958972         ENDDO 
    959973 
    960 ! in the following 
    961 ! remove division of ua by fs e3u (already done) and also zrhoy and e2u 
    962974! VERTICAL REFINEMENT END 
    963975         DO jk = 1, jpkm1 
     
    10061018      IF (before) THEN           
    10071019         IF(Agrif_UseSpecialValue) THEN  
    1008              Agrif_SpecialValue = -999._wp 
     1020!             Agrif_SpecialValue = -999._wp 
     1021             Agrif_SpecialValue = 0._wp 
    10091022         ELSE 
    10101023             Agrif_SpecialValue = 0._wp 
     
    10371050                  N_in = N_in + 1 
    10381051                  tabin(jk) = ptab(ji,jj,jk,1)/ptab(ji,jj,jk,2) 
    1039                   h_in(N_in) = ptab(ji,jj,jk,2)/(e1v(ji,jj)*zrhox) 
     1052                  h_in(N_in) = ptab(ji,jj,jk,2)/(e1v(ji,jj)) 
    10401053               enddo 
    10411054               IF (N_in == 0) THEN 
  • branches/2017/dev_r8126_UKMO_AGRIF_vert_interp/NEMOGCM/NEMO/NST_SRC/agrif_opa_update.F90

    r8596 r8690  
    200200      IF (before) THEN 
    201201# if defined key_vertical 
     202            AGRIF_SpecialValue = -999._wp 
    202203            zrho_xy = Agrif_rhox() * Agrif_rhoy()  
    203204            DO jn = n1,n2-1 
     
    205206                  DO jj=j1,j2 
    206207                     DO ji=i1,i2 
    207                         tabres(ji,jj,jk,jn) = zrho_xy * tsn(ji,jj,jk,jn) * e1e2t(ji,jj) * e3t_n(ji,jj,jk) 
     208                        tabres(ji,jj,jk,jn) = (zrho_xy * tsn(ji,jj,jk,jn) * e1e2t(ji,jj) * e3t_n(ji,jj,jk) ) & 
     209                                              * tmask(ji,jj,jk) + (tmask(ji,jj,jk)-1)*999._wp 
    208210                     END DO 
    209211                  END DO 
     
    213215               DO jj=j1,j2 
    214216                  DO ji=i1,i2 
    215                      tabres(ji,jj,jk,n2) = tmask(ji,jj,jk) * zrho_xy * e1e2t(ji,jj) * e3t_n(ji,jj,jk)  
     217                     tabres(ji,jj,jk,n2) = tmask(ji,jj,jk) * e1e2t(ji,jj) * e3t_n(ji,jj,jk)  & 
     218                                              + (tmask(ji,jj,jk)-1)*999._wp 
    216219                  END DO 
    217220               END DO 
     
    232235         tabres_child(:,:,:,:) = 0. 
    233236# if defined key_vertical 
     237         AGRIF_SpecialValue = 0._wp 
    234238         DO jj=j1,j2 
    235239         DO ji=i1,i2 
    236240           N_in = 0 
    237241           DO jk=k1,k2 !k2 = jpk of child grid 
    238              IF (tabres(ji,jj,jk,n2) == 0) EXIT 
     242             IF (tabres(ji,jj,jk,n2) > -900) EXIT 
    239243             N_in = N_in + 1 
    240244             tabin(jk,:) = tabres(ji,jj,jk,n1:n2-1)/tabres(ji,jj,jk,n2) 
     
    247251             h_out(N_out) = e3t_n(ji,jj,jk) !Parent grid scale factors. Could multiply by e1e2t here instead of division above 
    248252           ENDDO 
     253!           IF(ji.EQ.i1 .AND. jj.EQ.j1) print *,'1st parent point',sum(h_in(1:N_in)), sum(h_out(1:N_out)) 
    249254           IF (N_in > 0) THEN 
    250255             h_diff = sum(h_out(1:N_out))-sum(h_in(1:N_in)) 
     
    255260!               tabin(N_in,:) = tabin(N_in-1,:) 
    256261             IF (h_diff < -1.e-4) THEN 
    257              print *,'CHECK YOUR bathy T points ...',ji,jj,h_diff,sum(h_in(1:N_in)),sum(h_out(1:N_out)) 
    258              print *, tabres(ji,j1:j2,1,n2) 
     262             print *,'CHECK YOUR bathy T points ...',ji,jj,h_diff,e1e2t(ji,jj),sum(h_in(1:N_in)),sum(h_out(1:N_out)), N_in, N_out 
     263             print *,h_in(1:N_in) 
     264             print *,h_out(1:N_out) 
    259265             STOP 
    260266!               N_out = N_out + 1 
     
    329335      !  
    330336      IF( before ) THEN 
     337         print *, i1,i2,j1,j2,k1,k2 
    331338         zrhoy = Agrif_Rhoy() 
    332339# if defined key_vertical 
     340         AGRIF_SpecialValue = -999._wp 
    333341         DO jk=k1,k2 
    334342            DO jj=j1,j2 
    335343               DO ji=i1,i2 
    336                   tabres(ji,jj,jk,1) = zrhoy * e2u(ji,jj) * e3u_n(ji,jj,jk) * umask(ji,jj,jk) * un(ji,jj,jk) 
    337                   tabres(ji,jj,jk,2) = umask(ji,jj,jk) * zrhoy * e2u(ji,jj) * e3u_n(ji,jj,jk)  
     344                  tabres(ji,jj,jk,1) = zrhoy * e2u(ji,jj) * e3u_n(ji,jj,jk) * umask(ji,jj,jk) * un(ji,jj,jk)  & 
     345                                       - (umask(ji,jj,jk)-1)*999._wp 
     346                  tabres(ji,jj,jk,2) = umask(ji,jj,jk) * e2u(ji,jj) * e3u_n(ji,jj,jk)  & 
     347                                       - (umask(ji,jj,jk)-1)*999._wp 
    338348               END DO 
    339349            END DO 
     
    347357         tabres_child(:,:,:) = 0. 
    348358# if defined key_vertical 
    349 ! VERTICAL REFINEMENT BEGIN 
     359         AGRIF_SpecialValue = -999._wp 
    350360         DO jj=j1,j2 
    351361         DO ji=i1,i2 
    352362           N_in = 0 
    353363           DO jk=k1,k2 !k2=jpk of child grid 
    354              IF (tabres(ji,jj,jk,2) == 0) EXIT 
     364             IF (tabres(ji,jj,jk,2) > -900) EXIT 
    355365             N_in = N_in + 1 
    356366             tabin(jk) = tabres(ji,jj,jk,1)/tabres(ji,jj,jk,2) 
     
    367377! Should be able to remove the next IF/ELSEIF statement once scale factors are dealt with properly 
    368378             if (h_diff < -1.e-4) then 
    369              print *,'CHECK YOUR BATHY ...' 
     379             print *,'CHECK YOUR bathy U points ...',ji,jj,h_diff,e2u(ji,jj),sum(h_in(1:N_in)),sum(h_out(1:N_out)), N_in, N_out 
    370380             stop 
    371381!             else ! Extends with 0 
Note: See TracChangeset for help on using the changeset viewer.