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 14789 for NEMO/branches/2021/dev_r13747_HPC-11_mcastril_HPDAonline_DiagGPU/src/OCE/ASM/asminc.F90 – NEMO

Ignore:
Timestamp:
2021-05-05T13:18:04+02:00 (3 years ago)
Author:
mcastril
Message:

[2021/HPC-11_mcastril_HPDAonline_DiagGPU] Update externals

Location:
NEMO/branches/2021/dev_r13747_HPC-11_mcastril_HPDAonline_DiagGPU
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • NEMO/branches/2021/dev_r13747_HPC-11_mcastril_HPDAonline_DiagGPU

    • Property svn:externals
      •  

        old new  
        33^/utils/build/mk@HEAD         mk 
        44^/utils/tools@HEAD            tools 
        5 ^/vendors/AGRIF/dev_r12970_AGRIF_CMEMS      ext/AGRIF 
         5^/vendors/AGRIF/dev@HEAD      ext/AGRIF 
        66^/vendors/FCM@HEAD            ext/FCM 
        77^/vendors/IOIPSL@HEAD         ext/IOIPSL 
         8^/vendors/PPR@HEAD            ext/PPR 
        89 
        910# SETTE 
        10 ^/utils/CI/sette@13559        sette 
         11^/utils/CI/sette@14244        sette 
  • NEMO/branches/2021/dev_r13747_HPC-11_mcastril_HPDAonline_DiagGPU/src/OCE/ASM/asminc.F90

    r13295 r14789  
    99   !!                 ! 2007-04  (A. Weaver)  Merge with OPAVAR/NEMOVAR 
    1010   !!   NEMO     3.3  ! 2010-05  (D. Lea)  Update to work with NEMO v3.2 
    11    !!             -   ! 2010-05  (D. Lea)  add calc_month_len routine based on day_init  
     11   !!             -   ! 2010-05  (D. Lea)  add calc_month_len routine based on day_init 
    1212   !!            3.4  ! 2012-10  (A. Weaver and K. Mogensen) Fix for direct initialization 
    1313   !!                 ! 2014-09  (D. Lea)  Local calc_date removed use routine from OBS 
     
    2626   USE par_oce         ! Ocean space and time domain variables 
    2727   USE dom_oce         ! Ocean space and time domain 
     28   USE domtile 
    2829   USE domvvl          ! domain: variable volume level 
    2930   USE ldfdyn          ! lateral diffusion: eddy viscosity coefficients 
     
    3132   USE zpshde          ! Partial step : Horizontal Derivative 
    3233   USE asmpar          ! Parameters for the assmilation interface 
    33    USE asmbkg          !  
     34   USE asmbkg          ! 
    3435   USE c1d             ! 1D initialization 
    3536   USE sbc_oce         ! Surface boundary condition variables. 
     
    4546   IMPLICIT NONE 
    4647   PRIVATE 
    47     
     48 
    4849   PUBLIC   asm_inc_init   !: Initialize the increment arrays and IAU weights 
    4950   PUBLIC   tra_asm_inc    !: Apply the tracer (T and S) increments 
     
    7273   REAL(wp), PUBLIC, DIMENSION(:,:,:), ALLOCATABLE ::   u_bkg   , v_bkg      !: Background u- & v- velocity components 
    7374   REAL(wp), PUBLIC, DIMENSION(:,:,:), ALLOCATABLE ::   t_bkginc, s_bkginc   !: Increment to the background T & S 
    74    REAL(wp), PUBLIC, DIMENSION(:,:,:), ALLOCATABLE ::   u_bkginc, v_bkginc   !: Increment to the u- & v-components  
     75   REAL(wp), PUBLIC, DIMENSION(:,:,:), ALLOCATABLE ::   u_bkginc, v_bkginc   !: Increment to the u- & v-components 
    7576   REAL(wp), PUBLIC, DIMENSION(:)    , ALLOCATABLE ::   wgtiau               !: IAU weights for each time step 
    7677#if defined key_asminc 
     
    8081   INTEGER , PUBLIC ::   nitbkg      !: Time step of the background state used in the Jb term 
    8182   INTEGER , PUBLIC ::   nitdin      !: Time step of the background state for direct initialization 
    82    INTEGER , PUBLIC ::   nitiaustr   !: Time step of the start of the IAU interval  
     83   INTEGER , PUBLIC ::   nitiaustr   !: Time step of the start of the IAU interval 
    8384   INTEGER , PUBLIC ::   nitiaufin   !: Time step of the end of the IAU interval 
    84    !  
     85   ! 
    8586   INTEGER , PUBLIC ::   niaufn      !: Type of IAU weighing function: = 0   Constant weighting 
    86    !                                 !: = 1   Linear hat-like, centred in middle of IAU interval  
     87   !                                 !: = 1   Linear hat-like, centred in middle of IAU interval 
    8788   REAL(wp), PUBLIC ::   salfixmin   !: Ensure that the salinity is larger than this  value if (ln_salfix) 
    8889 
     
    106107      !!---------------------------------------------------------------------- 
    107108      !!                    ***  ROUTINE asm_inc_init  *** 
    108       !!           
     109      !! 
    109110      !! ** Purpose : Initialize the assimilation increment and IAU weights. 
    110111      !! 
    111112      !! ** Method  : Initialize the assimilation increment and IAU weights. 
    112113      !! 
    113       !! ** Action  :  
     114      !! ** Action  : 
    114115      !!---------------------------------------------------------------------- 
    115116      INTEGER, INTENT(in) ::  Kbb, Kmm, Krhs  ! time level indices 
     
    263264         ! 
    264265         !                                !--------------------------------------------------------- 
    265          IF( niaufn == 0 ) THEN           ! Constant IAU forcing  
     266         IF( niaufn == 0 ) THEN           ! Constant IAU forcing 
    266267            !                             !--------------------------------------------------------- 
    267268            DO jt = 1, iiauper 
     
    269270            END DO 
    270271            !                             !--------------------------------------------------------- 
    271          ELSEIF ( niaufn == 1 ) THEN      ! Linear hat-like, centred in middle of IAU interval  
     272         ELSEIF ( niaufn == 1 ) THEN      ! Linear hat-like, centred in middle of IAU interval 
    272273            !                             !--------------------------------------------------------- 
    273274            ! Compute the normalization factor 
    274275            znorm = 0._wp 
    275276            IF( MOD( iiauper, 2 ) == 0 ) THEN   ! Even number of time steps in IAU interval 
    276                imid = iiauper / 2  
     277               imid = iiauper / 2 
    277278               DO jt = 1, imid 
    278279                  znorm = znorm + REAL( jt ) 
     
    280281               znorm = 2.0 * znorm 
    281282            ELSE                                ! Odd number of time steps in IAU interval 
    282                imid = ( iiauper + 1 ) / 2         
     283               imid = ( iiauper + 1 ) / 2 
    283284               DO jt = 1, imid - 1 
    284285                  znorm = znorm + REAL( jt ) 
     
    307308             DO jt = 1, icycper 
    308309                ztotwgt = ztotwgt + wgtiau(jt) 
    309                 WRITE(numout,*) '         ', jt, '       ', wgtiau(jt)  
    310              END DO    
     310                WRITE(numout,*) '         ', jt, '       ', wgtiau(jt) 
     311             END DO 
    311312             WRITE(numout,*) '         ===================================' 
    312313             WRITE(numout,*) '         Time-integrated weight = ', ztotwgt 
    313314             WRITE(numout,*) '         ===================================' 
    314315          ENDIF 
    315           
     316 
    316317      ENDIF 
    317318 
     
    338339         CALL iom_open( c_asminc, inum ) 
    339340         ! 
    340          CALL iom_get( inum, 'time'       , zdate_inc   )  
     341         CALL iom_get( inum, 'time'       , zdate_inc   ) 
    341342         CALL iom_get( inum, 'z_inc_dateb', z_inc_dateb ) 
    342343         CALL iom_get( inum, 'z_inc_datef', z_inc_datef ) 
     
    345346         ! 
    346347         IF(lwp) THEN 
    347             WRITE(numout,*)  
     348            WRITE(numout,*) 
    348349            WRITE(numout,*) 'asm_inc_init : Assimilation increments valid between dates ', z_inc_dateb,' and ', z_inc_datef 
    349350            WRITE(numout,*) '~~~~~~~~~~~~' 
     
    359360            &                ' not agree with Direct Initialization time' ) 
    360361 
    361          IF ( ln_trainc ) THEN    
     362         IF ( ln_trainc ) THEN 
    362363            CALL iom_get( inum, jpdom_auto, 'bckint', t_bkginc, 1 ) 
    363364            CALL iom_get( inum, jpdom_auto, 'bckins', s_bkginc, 1 ) 
     
    371372         ENDIF 
    372373 
    373          IF ( ln_dyninc ) THEN    
    374             CALL iom_get( inum, jpdom_auto, 'bckinu', u_bkginc, 1 )               
    375             CALL iom_get( inum, jpdom_auto, 'bckinv', v_bkginc, 1 )               
     374         IF ( ln_dyninc ) THEN 
     375            CALL iom_get( inum, jpdom_auto, 'bckinu', u_bkginc, 1 ) 
     376            CALL iom_get( inum, jpdom_auto, 'bckinv', v_bkginc, 1 ) 
    376377            ! Apply the masks 
    377378            u_bkginc(:,:,:) = u_bkginc(:,:,:) * umask(:,:,:) 
     
    382383            WHERE( ABS( v_bkginc(:,:,:) ) > 1.0e+10 ) v_bkginc(:,:,:) = 0.0 
    383384         ENDIF 
    384          
     385 
    385386         IF ( ln_sshinc ) THEN 
    386387            CALL iom_get( inum, jpdom_auto, 'bckineta', ssh_bkginc, 1 ) 
     
    408409      IF ( ln_dyninc .AND. nn_divdmp > 0 ) THEN    ! Apply divergence damping filter 
    409410         !                                         !-------------------------------------- 
    410          ALLOCATE( zhdiv(jpi,jpj) )  
     411         ALLOCATE( zhdiv(jpi,jpj) ) 
    411412         ! 
    412413         DO jt = 1, nn_divdmp 
     
    427428                     &               + 0.2_wp * ( zhdiv(ji+1,jj) - zhdiv(ji  ,jj) ) * r1_e1u(ji,jj) * umask(ji,jj,jk) 
    428429                  v_bkginc(ji,jj,jk) = v_bkginc(ji,jj,jk)                         & 
    429                      &               + 0.2_wp * ( zhdiv(ji,jj+1) - zhdiv(ji,jj  ) ) * r1_e2v(ji,jj) * vmask(ji,jj,jk)  
     430                     &               + 0.2_wp * ( zhdiv(ji,jj+1) - zhdiv(ji,jj  ) ) * r1_e2v(ji,jj) * vmask(ji,jj,jk) 
    430431               END_2D 
    431432            END DO 
     
    433434         END DO 
    434435         ! 
    435          DEALLOCATE( zhdiv )  
     436         DEALLOCATE( zhdiv ) 
    436437         ! 
    437438      ENDIF 
     
    454455         CALL iom_open( c_asmdin, inum ) 
    455456         ! 
    456          CALL iom_get( inum, 'rdastp', zdate_bkg )  
     457         CALL iom_get( inum, 'rdastp', zdate_bkg ) 
    457458         ! 
    458459         IF(lwp) THEN 
    459             WRITE(numout,*)  
     460            WRITE(numout,*) 
    460461            WRITE(numout,*) '   ==>>>  Assimilation background state valid at : ', zdate_bkg 
    461462            WRITE(numout,*) 
     
    466467            &                ' not agree with Direct Initialization time' ) 
    467468         ! 
    468          IF ( ln_trainc ) THEN    
     469         IF ( ln_trainc ) THEN 
    469470            CALL iom_get( inum, jpdom_auto, 'tn', t_bkg ) 
    470471            CALL iom_get( inum, jpdom_auto, 'sn', s_bkg ) 
     
    473474         ENDIF 
    474475         ! 
    475          IF ( ln_dyninc ) THEN    
     476         IF ( ln_dyninc ) THEN 
    476477            CALL iom_get( inum, jpdom_auto, 'un', u_bkg, cd_type = 'U', psgn = 1._wp ) 
    477478            CALL iom_get( inum, jpdom_auto, 'vn', v_bkg, cd_type = 'V', psgn = 1._wp ) 
     
    501502      ! 
    502503   END SUBROUTINE asm_inc_init 
    503     
    504     
     504 
     505 
    505506   SUBROUTINE tra_asm_inc( kt, Kbb, Kmm, pts, Krhs ) 
    506507      !!---------------------------------------------------------------------- 
    507508      !!                    ***  ROUTINE tra_asm_inc  *** 
    508       !!           
     509      !! 
    509510      !! ** Purpose : Apply the tracer (T and S) assimilation increments 
    510511      !! 
    511512      !! ** Method  : Direct initialization or Incremental Analysis Updating 
    512513      !! 
    513       !! ** Action  :  
     514      !! ** Action  : 
    514515      !!---------------------------------------------------------------------- 
    515516      INTEGER                                  , INTENT(in   ) :: kt             ! Current time step 
     
    518519      ! 
    519520      INTEGER  :: ji, jj, jk 
    520       INTEGER  :: it 
     521      INTEGER  :: it, itile 
    521522      REAL(wp) :: zincwgt  ! IAU weight for current time step 
    522       REAL (wp), DIMENSION(jpi,jpj,jpk) :: fzptnz ! 3d freezing point values 
    523       !!---------------------------------------------------------------------- 
    524       ! 
    525       ! freezing point calculation taken from oc_fz_pt (but calculated for all depths)  
    526       ! used to prevent the applied increments taking the temperature below the local freezing point  
    527       DO jk = 1, jpkm1 
    528         CALL eos_fzp( pts(:,:,jk,jp_sal,Kmm), fzptnz(:,:,jk), gdept(:,:,jk,Kmm) ) 
    529       END DO 
     523      REAL(wp), DIMENSION(A2D(nn_hls),jpk) :: fzptnz ! 3d freezing point values 
     524      !!---------------------------------------------------------------------- 
     525      ! 
     526      ! freezing point calculation taken from oc_fz_pt (but calculated for all depths) 
     527      ! used to prevent the applied increments taking the temperature below the local freezing point 
     528      IF( ln_temnofreeze ) THEN 
     529         DO jk = 1, jpkm1 
     530           CALL eos_fzp( pts(:,:,jk,jp_sal,Kmm), fzptnz(:,:,jk), gdept(:,:,jk,Kmm) ) 
     531         END DO 
     532      ENDIF 
    530533         ! 
    531534         !                             !-------------------------------------- 
     
    538541            zincwgt = wgtiau(it) / rn_Dt   ! IAU weight for the current time step 
    539542            ! 
    540             IF(lwp) THEN 
    541                WRITE(numout,*)  
    542                WRITE(numout,*) 'tra_asm_inc : Tracer IAU at time step = ', kt,' with IAU weight = ', wgtiau(it) 
    543                WRITE(numout,*) '~~~~~~~~~~~~' 
     543            IF( ntile == 0 .OR. ntile == 1 )  THEN                       ! Do only on the first tile 
     544               IF(lwp) THEN 
     545                  WRITE(numout,*) 
     546                  WRITE(numout,*) 'tra_asm_inc : Tracer IAU at time step = ', kt,' with IAU weight = ', wgtiau(it) 
     547                  WRITE(numout,*) '~~~~~~~~~~~~' 
     548               ENDIF 
    544549            ENDIF 
    545550            ! 
     
    548553               IF (ln_temnofreeze) THEN 
    549554                  ! Do not apply negative increments if the temperature will fall below freezing 
    550                   WHERE(t_bkginc(:,:,jk) > 0.0_wp .OR. & 
    551                      &   pts(:,:,jk,jp_tem,Kmm) + pts(:,:,jk,jp_tem,Krhs) + t_bkginc(:,:,jk) * wgtiau(it) > fzptnz(:,:,jk) )  
    552                      pts(:,:,jk,jp_tem,Krhs) = pts(:,:,jk,jp_tem,Krhs) + t_bkginc(:,:,jk) * zincwgt   
     555                  WHERE(t_bkginc(A2D(0),jk) > 0.0_wp .OR. & 
     556                     &   pts(A2D(0),jk,jp_tem,Kmm) + pts(A2D(0),jk,jp_tem,Krhs) + t_bkginc(A2D(0),jk) * wgtiau(it) > fzptnz(:,:,jk) ) 
     557                     pts(A2D(0),jk,jp_tem,Krhs) = pts(A2D(0),jk,jp_tem,Krhs) + t_bkginc(A2D(0),jk) * zincwgt 
    553558                  END WHERE 
    554559               ELSE 
    555                   pts(:,:,jk,jp_tem,Krhs) = pts(:,:,jk,jp_tem,Krhs) + t_bkginc(:,:,jk) * zincwgt   
     560                  DO_2D( 0, 0, 0, 0 ) 
     561                     pts(ji,jj,jk,jp_tem,Krhs) = pts(ji,jj,jk,jp_tem,Krhs) + t_bkginc(ji,jj,jk) * zincwgt 
     562                  END_2D 
    556563               ENDIF 
    557564               IF (ln_salfix) THEN 
    558565                  ! Do not apply negative increments if the salinity will fall below a specified 
    559566                  ! minimum value salfixmin 
    560                   WHERE(s_bkginc(:,:,jk) > 0.0_wp .OR. & 
    561                      &   pts(:,:,jk,jp_sal,Kmm) + pts(:,:,jk,jp_sal,Krhs) + s_bkginc(:,:,jk) * wgtiau(it) > salfixmin )  
    562                      pts(:,:,jk,jp_sal,Krhs) = pts(:,:,jk,jp_sal,Krhs) + s_bkginc(:,:,jk) * zincwgt 
     567                  WHERE(s_bkginc(A2D(0),jk) > 0.0_wp .OR. & 
     568                     &   pts(A2D(0),jk,jp_sal,Kmm) + pts(A2D(0),jk,jp_sal,Krhs) + s_bkginc(A2D(0),jk) * wgtiau(it) > salfixmin ) 
     569                     pts(A2D(0),jk,jp_sal,Krhs) = pts(A2D(0),jk,jp_sal,Krhs) + s_bkginc(A2D(0),jk) * zincwgt 
    563570                  END WHERE 
    564571               ELSE 
    565                   pts(:,:,jk,jp_sal,Krhs) = pts(:,:,jk,jp_sal,Krhs) + s_bkginc(:,:,jk) * zincwgt 
     572                  DO_2D( 0, 0, 0, 0 ) 
     573                     pts(ji,jj,jk,jp_sal,Krhs) = pts(ji,jj,jk,jp_sal,Krhs) + s_bkginc(ji,jj,jk) * zincwgt 
     574                  END_2D 
    566575               ENDIF 
    567576            END DO 
     
    569578         ENDIF 
    570579         ! 
    571          IF ( kt == nitiaufin_r + 1  ) THEN   ! For bias crcn to work 
    572             DEALLOCATE( t_bkginc ) 
    573             DEALLOCATE( s_bkginc ) 
     580         IF( ntile == 0 .OR. ntile == nijtile )  THEN                ! Do only on the last tile 
     581            IF ( kt == nitiaufin_r + 1  ) THEN   ! For bias crcn to work 
     582               DEALLOCATE( t_bkginc ) 
     583               DEALLOCATE( s_bkginc ) 
     584            ENDIF 
    574585         ENDIF 
    575586         !                             !-------------------------------------- 
    576587      ELSEIF ( ln_asmdin ) THEN        ! Direct Initialization 
    577588         !                             !-------------------------------------- 
    578          !             
     589         ! 
    579590         IF ( kt == nitdin_r ) THEN 
    580591            ! 
     
    584595            IF (ln_temnofreeze) THEN 
    585596               ! Do not apply negative increments if the temperature will fall below freezing 
    586                WHERE( t_bkginc(:,:,:) > 0.0_wp .OR. pts(:,:,:,jp_tem,Kmm) + t_bkginc(:,:,:) > fzptnz(:,:,:) )  
    587                   pts(:,:,:,jp_tem,Kmm) = t_bkg(:,:,:) + t_bkginc(:,:,:)    
     597               WHERE( t_bkginc(A2D(0),:) > 0.0_wp .OR. pts(A2D(0),:,jp_tem,Kmm) + t_bkginc(A2D(0),:) > fzptnz(:,:,:) ) 
     598                  pts(A2D(0),:,jp_tem,Kmm) = t_bkg(A2D(0),:) + t_bkginc(A2D(0),:) 
    588599               END WHERE 
    589600            ELSE 
    590                pts(:,:,:,jp_tem,Kmm) = t_bkg(:,:,:) + t_bkginc(:,:,:)    
     601               DO_3D( 0, 0, 0, 0, 1, jpk ) 
     602                  pts(ji,jj,jk,jp_tem,Kmm) = t_bkg(ji,jj,jk) + t_bkginc(ji,jj,jk) 
     603               END_3D 
    591604            ENDIF 
    592605            IF (ln_salfix) THEN 
    593606               ! Do not apply negative increments if the salinity will fall below a specified 
    594607               ! minimum value salfixmin 
    595                WHERE( s_bkginc(:,:,:) > 0.0_wp .OR. pts(:,:,:,jp_sal,Kmm) + s_bkginc(:,:,:) > salfixmin )  
    596                   pts(:,:,:,jp_sal,Kmm) = s_bkg(:,:,:) + s_bkginc(:,:,:)    
     608               WHERE( s_bkginc(A2D(0),:) > 0.0_wp .OR. pts(A2D(0),:,jp_sal,Kmm) + s_bkginc(A2D(0),:) > salfixmin ) 
     609                  pts(A2D(0),:,jp_sal,Kmm) = s_bkg(A2D(0),:) + s_bkginc(A2D(0),:) 
    597610               END WHERE 
    598611            ELSE 
    599                pts(:,:,:,jp_sal,Kmm) = s_bkg(:,:,:) + s_bkginc(:,:,:)    
    600             ENDIF 
    601  
    602             pts(:,:,:,:,Kbb) = pts(:,:,:,:,Kmm)                 ! Update before fields 
     612               DO_3D( 0, 0, 0, 0, 1, jpk ) 
     613                  pts(ji,jj,jk,jp_sal,Kmm) = s_bkg(ji,jj,jk) + s_bkginc(ji,jj,jk) 
     614               END_3D 
     615            ENDIF 
     616 
     617            DO_3D( 0, 0, 0, 0, 1, jpk ) 
     618               pts(ji,jj,jk,:,Kbb) = pts(ji,jj,jk,:,Kmm)             ! Update before fields 
     619            END_3D 
    603620 
    604621            CALL eos( pts(:,:,:,:,Kbb), rhd, rhop, gdept_0(:,:,:) )  ! Before potential and in situ densities 
     
    607624!!gm 
    608625 
    609             IF( ln_zps .AND. .NOT. lk_c1d .AND. .NOT. ln_isfcav)           & 
    610                &  CALL zps_hde    ( kt, Kmm, jpts, pts(:,:,:,:,Kbb), gtsu, gtsv,        &  ! Partial steps: before horizontal gradient 
    611                &                              rhd, gru , grv               )  ! of t, s, rd at the last ocean level 
    612             IF( ln_zps .AND. .NOT. lk_c1d .AND.       ln_isfcav)                       & 
    613                &  CALL zps_hde_isf( nit000, Kmm, jpts, pts(:,:,:,:,Kbb), gtsu, gtsv, gtui, gtvi,    &  ! Partial steps for top cell (ISF) 
    614                &                                  rhd, gru , grv , grui, grvi          )  ! of t, s, rd at the last ocean level 
    615  
    616             DEALLOCATE( t_bkginc ) 
    617             DEALLOCATE( s_bkginc ) 
    618             DEALLOCATE( t_bkg    ) 
    619             DEALLOCATE( s_bkg    ) 
    620          ENDIF 
    621          !   
     626            ! TEMP: [tiling] This change not necessary after extra haloes development (lbc_lnk removed from zps_hde*) 
     627            IF( ntile == 0 .OR. ntile == nijtile )  THEN                ! Do only for the full domain 
     628               itile = ntile 
     629               IF( ln_tile ) CALL dom_tile( ntsi, ntsj, ntei, ntej, ktile = 0 )            ! Use full domain 
     630 
     631               IF( ln_zps .AND. .NOT. lk_c1d .AND. .NOT. ln_isfcav)           & 
     632                  &  CALL zps_hde    ( kt, Kmm, jpts, pts(:,:,:,:,Kbb), gtsu, gtsv,        &  ! Partial steps: before horizontal gradient 
     633                  &                              rhd, gru , grv               )  ! of t, s, rd at the last ocean level 
     634               IF( ln_zps .AND. .NOT. lk_c1d .AND.       ln_isfcav)                       & 
     635                  &  CALL zps_hde_isf( nit000, Kmm, jpts, pts(:,:,:,:,Kbb), gtsu, gtsv, gtui, gtvi,    &  ! Partial steps for top cell (ISF) 
     636                  &                                  rhd, gru , grv , grui, grvi          )  ! of t, s, rd at the last ocean level 
     637 
     638               IF( ln_tile ) CALL dom_tile( ntsi, ntsj, ntei, ntej, ktile = itile )            ! Revert to tile domain 
     639            ENDIF 
     640 
     641            IF( ntile == 0 .OR. ntile == nijtile )  THEN                ! Do only on the last tile 
     642               DEALLOCATE( t_bkginc ) 
     643               DEALLOCATE( s_bkginc ) 
     644               DEALLOCATE( t_bkg    ) 
     645               DEALLOCATE( s_bkg    ) 
     646            ENDIF 
     647         ! 
     648         ENDIF 
     649         ! 
    622650      ENDIF 
    623651      ! Perhaps the following call should be in step 
     
    630658      !!---------------------------------------------------------------------- 
    631659      !!                    ***  ROUTINE dyn_asm_inc  *** 
    632       !!           
     660      !! 
    633661      !! ** Purpose : Apply the dynamics (u and v) assimilation increments. 
    634662      !! 
    635663      !! ** Method  : Direct initialization or Incremental Analysis Updating. 
    636664      !! 
    637       !! ** Action  :  
     665      !! ** Action  : 
    638666      !!---------------------------------------------------------------------- 
    639667      INTEGER                             , INTENT( in )  ::  kt             ! ocean time-step index 
     
    656684            ! 
    657685            IF(lwp) THEN 
    658                WRITE(numout,*)  
     686               WRITE(numout,*) 
    659687               WRITE(numout,*) 'dyn_asm_inc : Dynamics IAU at time step = ', kt,' with IAU weight = ', wgtiau(it) 
    660688               WRITE(numout,*) '~~~~~~~~~~~~' 
     
    676704      ELSEIF ( ln_asmdin ) THEN     ! Direct Initialization 
    677705         !                          !----------------------------------------- 
    678          !          
     706         ! 
    679707         IF ( kt == nitdin_r ) THEN 
    680708            ! 
     
    683711            ! Initialize the now fields with the background + increment 
    684712            puu(:,:,:,Kmm) = u_bkg(:,:,:) + u_bkginc(:,:,:) 
    685             pvv(:,:,:,Kmm) = v_bkg(:,:,:) + v_bkginc(:,:,:)   
     713            pvv(:,:,:,Kmm) = v_bkg(:,:,:) + v_bkginc(:,:,:) 
    686714            ! 
    687715            puu(:,:,:,Kbb) = puu(:,:,:,Kmm)         ! Update before fields 
     
    702730      !!---------------------------------------------------------------------- 
    703731      !!                    ***  ROUTINE ssh_asm_inc  *** 
    704       !!           
     732      !! 
    705733      !! ** Purpose : Apply the sea surface height assimilation increment. 
    706734      !! 
    707735      !! ** Method  : Direct initialization or Incremental Analysis Updating. 
    708736      !! 
    709       !! ** Action  :  
     737      !! ** Action  : 
    710738      !!---------------------------------------------------------------------- 
    711739      INTEGER, INTENT(IN) :: kt         ! Current time step 
     
    727755            ! 
    728756            IF(lwp) THEN 
    729                WRITE(numout,*)  
     757               WRITE(numout,*) 
    730758               WRITE(numout,*) 'ssh_asm_inc : SSH IAU at time step = ', & 
    731759                  &  kt,' with IAU weight = ', wgtiau(it) 
     
    779807      !!                  ***  ROUTINE ssh_asm_div  *** 
    780808      !! 
    781       !! ** Purpose :   ssh increment with z* is incorporated via a correction of the local divergence           
     809      !! ** Purpose :   ssh increment with z* is incorporated via a correction of the local divergence 
    782810      !!                across all the water column 
    783811      !! 
     
    795823      REAL(wp), DIMENSION(:,:)  , POINTER       ::   ztim     ! local array 
    796824      !!---------------------------------------------------------------------- 
    797       !  
     825      ! 
    798826#if defined key_asminc 
    799827      CALL ssh_asm_inc( kt, Kbb, Kmm ) !==   (calculate increments) 
    800828      ! 
    801       IF( ln_linssh ) THEN  
     829      IF( ln_linssh ) THEN 
    802830         phdivn(:,:,1) = phdivn(:,:,1) - ssh_iau(:,:) / e3t(:,:,1,Kmm) * tmask(:,:,1) 
    803       ELSE  
     831      ELSE 
    804832         ALLOCATE( ztim(jpi,jpj) ) 
    805833         ztim(:,:) = ssh_iau(:,:) / ( ht(:,:) + 1.0 - ssmask(:,:) ) 
    806          DO jk = 1, jpkm1                                  
    807             phdivn(:,:,jk) = phdivn(:,:,jk) - ztim(:,:) * tmask(:,:,jk)  
     834         DO jk = 1, jpkm1 
     835            phdivn(:,:,jk) = phdivn(:,:,jk) - ztim(:,:) * tmask(:,:,jk) 
    808836         END DO 
    809837         ! 
     
    818846      !!---------------------------------------------------------------------- 
    819847      !!                    ***  ROUTINE seaice_asm_inc  *** 
    820       !!           
     848      !! 
    821849      !! ** Purpose : Apply the sea ice assimilation increment. 
    822850      !! 
    823851      !! ** Method  : Direct initialization or Incremental Analysis Updating. 
    824852      !! 
    825       !! ** Action  :  
     853      !! ** Action  : 
    826854      !! 
    827855      !!---------------------------------------------------------------------- 
     
    829857      INTEGER, INTENT(in), OPTIONAL ::   kindic   ! flag for disabling the deallocation 
    830858      ! 
     859      INTEGER  ::   ji, jj 
    831860      INTEGER  ::   it 
    832861      REAL(wp) ::   zincwgt   ! IAU weight for current time step 
    833862#if defined key_si3 
    834       REAL(wp), DIMENSION(jpi,jpj) ::   zofrld, zohicif, zseaicendg, zhicifinc 
     863      REAL(wp), DIMENSION(A2D(nn_hls)) ::   zofrld, zohicif, zseaicendg, zhicifinc 
    835864      REAL(wp) ::   zhicifmin = 0.5_wp      ! ice minimum depth in metres 
    836865#endif 
     
    844873            ! 
    845874            it = kt - nit000 + 1 
    846             zincwgt = wgtiau(it)      ! IAU weight for the current time step  
     875            zincwgt = wgtiau(it)      ! IAU weight for the current time step 
    847876            ! note this is not a tendency so should not be divided by rn_Dt (as with the tracer and other increments) 
    848877            ! 
    849             IF(lwp) THEN 
    850                WRITE(numout,*)  
    851                WRITE(numout,*) 'seaice_asm_inc : sea ice conc IAU at time step = ', kt,' with IAU weight = ', wgtiau(it) 
    852                WRITE(numout,*) '~~~~~~~~~~~~' 
     878            IF( ntile == 0 .OR. ntile == 1 )  THEN                       ! Do only on the first tile 
     879               IF(lwp) THEN 
     880                  WRITE(numout,*) 
     881                  WRITE(numout,*) 'seaice_asm_inc : sea ice conc IAU at time step = ', kt,' with IAU weight = ', wgtiau(it) 
     882                  WRITE(numout,*) '~~~~~~~~~~~~' 
     883               ENDIF 
    853884            ENDIF 
    854885            ! 
     
    856887            ! 
    857888#if defined key_si3 
    858             zofrld (:,:) = 1._wp - at_i(:,:) 
    859             zohicif(:,:) = hm_i(:,:) 
    860             ! 
    861             at_i  (:,:) = 1. - MIN( MAX( 1.-at_i  (:,:) - seaice_bkginc(:,:) * zincwgt, 0.0_wp), 1.0_wp) 
    862             at_i_b(:,:) = 1. - MIN( MAX( 1.-at_i_b(:,:) - seaice_bkginc(:,:) * zincwgt, 0.0_wp), 1.0_wp) 
    863             fr_i(:,:) = at_i(:,:)        ! adjust ice fraction 
    864             ! 
    865             zseaicendg(:,:) = zofrld(:,:) - (1. - at_i(:,:))   ! find out actual sea ice nudge applied 
     889            DO_2D( 0, 0, 0, 0 ) 
     890               zofrld (ji,jj) = 1._wp - at_i(ji,jj) 
     891               zohicif(ji,jj) = hm_i(ji,jj) 
     892               ! 
     893               at_i  (ji,jj) = 1. - MIN( MAX( 1.-at_i  (ji,jj) - seaice_bkginc(ji,jj) * zincwgt, 0.0_wp), 1.0_wp) 
     894               at_i_b(ji,jj) = 1. - MIN( MAX( 1.-at_i_b(ji,jj) - seaice_bkginc(ji,jj) * zincwgt, 0.0_wp), 1.0_wp) 
     895               fr_i(ji,jj) = at_i(ji,jj)        ! adjust ice fraction 
     896               ! 
     897               zseaicendg(ji,jj) = zofrld(ji,jj) - (1. - at_i(ji,jj))   ! find out actual sea ice nudge applied 
     898            END_2D 
    866899            ! 
    867900            ! Nudge sea ice depth to bring it up to a required minimum depth 
    868             WHERE( zseaicendg(:,:) > 0.0_wp .AND. hm_i(:,:) < zhicifmin )  
    869                zhicifinc(:,:) = (zhicifmin - hm_i(:,:)) * zincwgt     
     901            WHERE( zseaicendg(:,:) > 0.0_wp .AND. hm_i(A2D(0)) < zhicifmin ) 
     902               zhicifinc(:,:) = (zhicifmin - hm_i(A2D(0))) * zincwgt 
    870903            ELSEWHERE 
    871904               zhicifinc(:,:) = 0.0_wp 
     
    873906            ! 
    874907            ! nudge ice depth 
    875             hm_i (:,:) = hm_i (:,:) + zhicifinc(:,:) 
     908            DO_2D( 0, 0, 0, 0 ) 
     909               hm_i (ji,jj) = hm_i (ji,jj) + zhicifinc(ji,jj) 
     910            END_2D 
    876911            ! 
    877912            ! seaice salinity balancing (to add) 
     
    880915#if defined key_cice && defined key_asminc 
    881916            ! Sea-ice : CICE case. Pass ice increment tendency into CICE 
    882             ndaice_da(:,:) = seaice_bkginc(:,:) * zincwgt / rn_Dt 
    883 #endif 
    884             ! 
    885             IF ( kt == nitiaufin_r ) THEN 
    886                DEALLOCATE( seaice_bkginc ) 
     917            DO_2D( 0, 0, 0, 0 ) 
     918               ndaice_da(ji,jj) = seaice_bkginc(ji,jj) * zincwgt / rn_Dt 
     919            END_2D 
     920#endif 
     921            ! 
     922            IF( ntile == 0 .OR. ntile == nijtile )  THEN                ! Do only on the last tile 
     923               IF ( kt == nitiaufin_r ) THEN 
     924                  DEALLOCATE( seaice_bkginc ) 
     925               ENDIF 
    887926            ENDIF 
    888927            ! 
     
    890929            ! 
    891930#if defined key_cice && defined key_asminc 
    892             ndaice_da(:,:) = 0._wp        ! Sea-ice : CICE case. Zero ice increment tendency into CICE 
     931            DO_2D( 0, 0, 0, 0 ) 
     932               ndaice_da(ji,jj) = 0._wp        ! Sea-ice : CICE case. Zero ice increment tendency into CICE 
     933            END_2D 
    893934#endif 
    894935            ! 
     
    905946            ! 
    906947#if defined key_si3 
    907             zofrld (:,:) = 1._wp - at_i(:,:) 
    908             zohicif(:,:) = hm_i(:,:) 
    909             !  
    910             ! Initialize the now fields the background + increment 
    911             at_i(:,:) = 1. - MIN( MAX( 1.-at_i(:,:) - seaice_bkginc(:,:), 0.0_wp), 1.0_wp) 
    912             at_i_b(:,:) = at_i(:,:)  
    913             fr_i(:,:) = at_i(:,:)        ! adjust ice fraction 
    914             ! 
    915             zseaicendg(:,:) = zofrld(:,:) - (1. - at_i(:,:))   ! find out actual sea ice nudge applied 
     948            DO_2D( 0, 0, 0, 0 ) 
     949               zofrld (ji,jj) = 1._wp - at_i(ji,jj) 
     950               zohicif(ji,jj) = hm_i(ji,jj) 
     951               ! 
     952               ! Initialize the now fields the background + increment 
     953               at_i(ji,jj) = 1. - MIN( MAX( 1.-at_i(ji,jj) - seaice_bkginc(ji,jj), 0.0_wp), 1.0_wp) 
     954               at_i_b(ji,jj) = at_i(ji,jj) 
     955               fr_i(ji,jj) = at_i(ji,jj)        ! adjust ice fraction 
     956               ! 
     957               zseaicendg(ji,jj) = zofrld(ji,jj) - (1. - at_i(ji,jj))   ! find out actual sea ice nudge applied 
     958            END_2D 
    916959            ! 
    917960            ! Nudge sea ice depth to bring it up to a required minimum depth 
    918             WHERE( zseaicendg(:,:) > 0.0_wp .AND. hm_i(:,:) < zhicifmin )  
    919                zhicifinc(:,:) = zhicifmin - hm_i(:,:) 
     961            WHERE( zseaicendg(:,:) > 0.0_wp .AND. hm_i(A2D(0)) < zhicifmin ) 
     962               zhicifinc(:,:) = zhicifmin - hm_i(A2D(0)) 
    920963            ELSEWHERE 
    921964               zhicifinc(:,:) = 0.0_wp 
     
    923966            ! 
    924967            ! nudge ice depth 
    925             hm_i (:,:) = hm_i (:,:) + zhicifinc(:,:) 
     968            DO_2D( 0, 0, 0, 0 ) 
     969               hm_i(ji,jj) = hm_i (ji,jj) + zhicifinc(ji,jj) 
     970            END_2D 
    926971            ! 
    927972            ! seaice salinity balancing (to add) 
     
    930975#if defined key_cice && defined key_asminc 
    931976            ! Sea-ice : CICE case. Pass ice increment tendency into CICE 
    932            ndaice_da(:,:) = seaice_bkginc(:,:) / rn_Dt 
    933 #endif 
    934             IF ( .NOT. PRESENT(kindic) ) THEN 
    935                DEALLOCATE( seaice_bkginc ) 
    936             END IF 
     977            DO_2D( 0, 0, 0, 0 ) 
     978               ndaice_da(ji,jj) = seaice_bkginc(ji,jj) / rn_Dt 
     979            END_2D 
     980#endif 
     981            IF( ntile == 0 .OR. ntile == nijtile )  THEN                ! Do only on the last tile 
     982               IF ( .NOT. PRESENT(kindic) ) THEN 
     983                  DEALLOCATE( seaice_bkginc ) 
     984               END IF 
     985            ENDIF 
    937986            ! 
    938987         ELSE 
    939988            ! 
    940989#if defined key_cice && defined key_asminc 
    941             ndaice_da(:,:) = 0._wp     ! Sea-ice : CICE case. Zero ice increment tendency into CICE 
     990            DO_2D( 0, 0, 0, 0 ) 
     991               ndaice_da(ji,jj) = 0._wp     ! Sea-ice : CICE case. Zero ice increment tendency into CICE 
     992            END_2D 
    942993#endif 
    943994            ! 
     
    946997!#if defined defined key_si3 || defined key_cice 
    947998! 
    948 !            IF (ln_seaicebal ) THEN        
     999!            IF (ln_seaicebal ) THEN 
    9491000!             !! balancing salinity increments 
    9501001!             !! simple case from limflx.F90 (doesn't include a mass flux) 
     
    9581009! 
    9591010!             DO jj = 1, jpj 
    960 !               DO ji = 1, jpi  
     1011!               DO ji = 1, jpi 
    9611012!           ! calculate change in ice and snow mass per unit area 
    9621013!           ! positive values imply adding salt to the ocean (results from ice formation) 
     
    9691020! 
    9701021!           ! prevent small mld 
    971 !           ! less than 10m can cause salinity instability  
     1022!           ! less than 10m can cause salinity instability 
    9721023!                 IF (mld < 10) mld=10 
    9731024! 
    974 !           ! set to bottom of a level  
     1025!           ! set to bottom of a level 
    9751026!                 DO jk = jpk-1, 2, -1 
    9761027!                   IF ((mld > gdepw(ji,jj,jk,Kmm)) .and. (mld < gdepw(ji,jj,jk+1,Kmm))) THEN 
     
    9811032! 
    9821033!            ! avoid applying salinity balancing in shallow water or on land 
    983 !            !  
     1034!            ! 
    9841035! 
    9851036!            ! dsal_ocn (psu kg m^-2) / (kg m^-3 * m) 
     
    9921043! 
    9931044!           ! put increments in for levels in the mixed layer 
    994 !           ! but prevent salinity below a threshold value  
    995 ! 
    996 !                   DO jk = 1, jkmax               
    997 ! 
    998 !                     IF (dsal_ocn > 0.0_wp .or. sb(ji,jj,jk)+dsal_ocn > sal_thresh) THEN  
     1045!           ! but prevent salinity below a threshold value 
     1046! 
     1047!                   DO jk = 1, jkmax 
     1048! 
     1049!                     IF (dsal_ocn > 0.0_wp .or. sb(ji,jj,jk)+dsal_ocn > sal_thresh) THEN 
    9991050!                           sb(ji,jj,jk) = sb(ji,jj,jk) + dsal_ocn 
    10001051!                           sn(ji,jj,jk) = sn(ji,jj,jk) + dsal_ocn 
     
    10071058!      ! 
    10081059!      !! Adjust fsalt. A +ve fsalt means adding salt to ocean 
    1009 !      !!           fsalt(ji,jj) =  fsalt(ji,jj) + zpmess     ! adjust fsalt   
    1010 !      !!                
    1011 !      !!           emps(ji,jj) = emps(ji,jj) + zpmess        ! or adjust emps (see icestp1d)  
     1060!      !!           fsalt(ji,jj) =  fsalt(ji,jj) + zpmess     ! adjust fsalt 
     1061!      !! 
     1062!      !!           emps(ji,jj) = emps(ji,jj) + zpmess        ! or adjust emps (see icestp1d) 
    10121063!      !!                                                     ! E-P (kg m-2 s-2) 
    10131064!      !            emp(ji,jj) = emp(ji,jj) + zpmess          ! E-P (kg m-2 s-2) 
     
    10221073      ! 
    10231074   END SUBROUTINE seaice_asm_inc 
    1024     
     1075 
    10251076   !!====================================================================== 
    10261077END MODULE asminc 
Note: See TracChangeset for help on using the changeset viewer.