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 14072 for NEMO/trunk/src/OCE/ASM/asminc.F90 – NEMO

Ignore:
Timestamp:
2020-12-04T08:48:38+01:00 (3 years ago)
Author:
laurent
Message:

Merging branch "2020/dev_r13648_ASINTER-04_laurent_bulk_ice", ticket #2369

File:
1 edited

Legend:

Unmodified
Added
Removed
  • NEMO/trunk/src/OCE/ASM/asminc.F90

    r13982 r14072  
    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 
     
    3232   USE zpshde          ! Partial step : Horizontal Derivative 
    3333   USE asmpar          ! Parameters for the assmilation interface 
    34    USE asmbkg          !  
     34   USE asmbkg          ! 
    3535   USE c1d             ! 1D initialization 
    3636   USE sbc_oce         ! Surface boundary condition variables. 
     
    4646   IMPLICIT NONE 
    4747   PRIVATE 
    48     
     48 
    4949   PUBLIC   asm_inc_init   !: Initialize the increment arrays and IAU weights 
    5050   PUBLIC   tra_asm_inc    !: Apply the tracer (T and S) increments 
     
    7373   REAL(wp), PUBLIC, DIMENSION(:,:,:), ALLOCATABLE ::   u_bkg   , v_bkg      !: Background u- & v- velocity components 
    7474   REAL(wp), PUBLIC, DIMENSION(:,:,:), ALLOCATABLE ::   t_bkginc, s_bkginc   !: Increment to the background T & S 
    75    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 
    7676   REAL(wp), PUBLIC, DIMENSION(:)    , ALLOCATABLE ::   wgtiau               !: IAU weights for each time step 
    7777#if defined key_asminc 
     
    8181   INTEGER , PUBLIC ::   nitbkg      !: Time step of the background state used in the Jb term 
    8282   INTEGER , PUBLIC ::   nitdin      !: Time step of the background state for direct initialization 
    83    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 
    8484   INTEGER , PUBLIC ::   nitiaufin   !: Time step of the end of the IAU interval 
    85    !  
     85   ! 
    8686   INTEGER , PUBLIC ::   niaufn      !: Type of IAU weighing function: = 0   Constant weighting 
    87    !                                 !: = 1   Linear hat-like, centred in middle of IAU interval  
     87   !                                 !: = 1   Linear hat-like, centred in middle of IAU interval 
    8888   REAL(wp), PUBLIC ::   salfixmin   !: Ensure that the salinity is larger than this  value if (ln_salfix) 
    8989 
     
    107107      !!---------------------------------------------------------------------- 
    108108      !!                    ***  ROUTINE asm_inc_init  *** 
    109       !!           
     109      !! 
    110110      !! ** Purpose : Initialize the assimilation increment and IAU weights. 
    111111      !! 
    112112      !! ** Method  : Initialize the assimilation increment and IAU weights. 
    113113      !! 
    114       !! ** Action  :  
     114      !! ** Action  : 
    115115      !!---------------------------------------------------------------------- 
    116116      INTEGER, INTENT(in) ::  Kbb, Kmm, Krhs  ! time level indices 
     
    264264         ! 
    265265         !                                !--------------------------------------------------------- 
    266          IF( niaufn == 0 ) THEN           ! Constant IAU forcing  
     266         IF( niaufn == 0 ) THEN           ! Constant IAU forcing 
    267267            !                             !--------------------------------------------------------- 
    268268            DO jt = 1, iiauper 
     
    270270            END DO 
    271271            !                             !--------------------------------------------------------- 
    272          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 
    273273            !                             !--------------------------------------------------------- 
    274274            ! Compute the normalization factor 
    275275            znorm = 0._wp 
    276276            IF( MOD( iiauper, 2 ) == 0 ) THEN   ! Even number of time steps in IAU interval 
    277                imid = iiauper / 2  
     277               imid = iiauper / 2 
    278278               DO jt = 1, imid 
    279279                  znorm = znorm + REAL( jt ) 
     
    281281               znorm = 2.0 * znorm 
    282282            ELSE                                ! Odd number of time steps in IAU interval 
    283                imid = ( iiauper + 1 ) / 2         
     283               imid = ( iiauper + 1 ) / 2 
    284284               DO jt = 1, imid - 1 
    285285                  znorm = znorm + REAL( jt ) 
     
    308308             DO jt = 1, icycper 
    309309                ztotwgt = ztotwgt + wgtiau(jt) 
    310                 WRITE(numout,*) '         ', jt, '       ', wgtiau(jt)  
    311              END DO    
     310                WRITE(numout,*) '         ', jt, '       ', wgtiau(jt) 
     311             END DO 
    312312             WRITE(numout,*) '         ===================================' 
    313313             WRITE(numout,*) '         Time-integrated weight = ', ztotwgt 
    314314             WRITE(numout,*) '         ===================================' 
    315315          ENDIF 
    316           
     316 
    317317      ENDIF 
    318318 
     
    339339         CALL iom_open( c_asminc, inum ) 
    340340         ! 
    341          CALL iom_get( inum, 'time'       , zdate_inc   )  
     341         CALL iom_get( inum, 'time'       , zdate_inc   ) 
    342342         CALL iom_get( inum, 'z_inc_dateb', z_inc_dateb ) 
    343343         CALL iom_get( inum, 'z_inc_datef', z_inc_datef ) 
     
    346346         ! 
    347347         IF(lwp) THEN 
    348             WRITE(numout,*)  
     348            WRITE(numout,*) 
    349349            WRITE(numout,*) 'asm_inc_init : Assimilation increments valid between dates ', z_inc_dateb,' and ', z_inc_datef 
    350350            WRITE(numout,*) '~~~~~~~~~~~~' 
     
    360360            &                ' not agree with Direct Initialization time' ) 
    361361 
    362          IF ( ln_trainc ) THEN    
     362         IF ( ln_trainc ) THEN 
    363363            CALL iom_get( inum, jpdom_auto, 'bckint', t_bkginc, 1 ) 
    364364            CALL iom_get( inum, jpdom_auto, 'bckins', s_bkginc, 1 ) 
     
    372372         ENDIF 
    373373 
    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 )               
     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 ) 
    377377            ! Apply the masks 
    378378            u_bkginc(:,:,:) = u_bkginc(:,:,:) * umask(:,:,:) 
     
    383383            WHERE( ABS( v_bkginc(:,:,:) ) > 1.0e+10 ) v_bkginc(:,:,:) = 0.0 
    384384         ENDIF 
    385          
     385 
    386386         IF ( ln_sshinc ) THEN 
    387387            CALL iom_get( inum, jpdom_auto, 'bckineta', ssh_bkginc, 1 ) 
     
    409409      IF ( ln_dyninc .AND. nn_divdmp > 0 ) THEN    ! Apply divergence damping filter 
    410410         !                                         !-------------------------------------- 
    411          ALLOCATE( zhdiv(jpi,jpj) )  
     411         ALLOCATE( zhdiv(jpi,jpj) ) 
    412412         ! 
    413413         DO jt = 1, nn_divdmp 
     
    428428                     &               + 0.2_wp * ( zhdiv(ji+1,jj) - zhdiv(ji  ,jj) ) * r1_e1u(ji,jj) * umask(ji,jj,jk) 
    429429                  v_bkginc(ji,jj,jk) = v_bkginc(ji,jj,jk)                         & 
    430                      &               + 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) 
    431431               END_2D 
    432432            END DO 
     
    434434         END DO 
    435435         ! 
    436          DEALLOCATE( zhdiv )  
     436         DEALLOCATE( zhdiv ) 
    437437         ! 
    438438      ENDIF 
     
    455455         CALL iom_open( c_asmdin, inum ) 
    456456         ! 
    457          CALL iom_get( inum, 'rdastp', zdate_bkg )  
     457         CALL iom_get( inum, 'rdastp', zdate_bkg ) 
    458458         ! 
    459459         IF(lwp) THEN 
    460             WRITE(numout,*)  
     460            WRITE(numout,*) 
    461461            WRITE(numout,*) '   ==>>>  Assimilation background state valid at : ', zdate_bkg 
    462462            WRITE(numout,*) 
     
    467467            &                ' not agree with Direct Initialization time' ) 
    468468         ! 
    469          IF ( ln_trainc ) THEN    
     469         IF ( ln_trainc ) THEN 
    470470            CALL iom_get( inum, jpdom_auto, 'tn', t_bkg ) 
    471471            CALL iom_get( inum, jpdom_auto, 'sn', s_bkg ) 
     
    474474         ENDIF 
    475475         ! 
    476          IF ( ln_dyninc ) THEN    
     476         IF ( ln_dyninc ) THEN 
    477477            CALL iom_get( inum, jpdom_auto, 'un', u_bkg, cd_type = 'U', psgn = 1._wp ) 
    478478            CALL iom_get( inum, jpdom_auto, 'vn', v_bkg, cd_type = 'V', psgn = 1._wp ) 
     
    502502      ! 
    503503   END SUBROUTINE asm_inc_init 
    504     
    505     
     504 
     505 
    506506   SUBROUTINE tra_asm_inc( kt, Kbb, Kmm, pts, Krhs ) 
    507507      !!---------------------------------------------------------------------- 
    508508      !!                    ***  ROUTINE tra_asm_inc  *** 
    509       !!           
     509      !! 
    510510      !! ** Purpose : Apply the tracer (T and S) assimilation increments 
    511511      !! 
    512512      !! ** Method  : Direct initialization or Incremental Analysis Updating 
    513513      !! 
    514       !! ** Action  :  
     514      !! ** Action  : 
    515515      !!---------------------------------------------------------------------- 
    516516      INTEGER                                  , INTENT(in   ) :: kt             ! Current time step 
     
    524524      !!---------------------------------------------------------------------- 
    525525      ! 
    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  
     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 
    528528      IF( ln_temnofreeze ) THEN 
    529529         DO jk = 1, jpkm1 
     
    587587      ELSEIF ( ln_asmdin ) THEN        ! Direct Initialization 
    588588         !                             !-------------------------------------- 
    589          !             
     589         ! 
    590590         IF ( kt == nitdin_r ) THEN 
    591591            ! 
     
    647647         ! 
    648648         ENDIF 
    649          !   
     649         ! 
    650650      ENDIF 
    651651      ! Perhaps the following call should be in step 
     
    658658      !!---------------------------------------------------------------------- 
    659659      !!                    ***  ROUTINE dyn_asm_inc  *** 
    660       !!           
     660      !! 
    661661      !! ** Purpose : Apply the dynamics (u and v) assimilation increments. 
    662662      !! 
    663663      !! ** Method  : Direct initialization or Incremental Analysis Updating. 
    664664      !! 
    665       !! ** Action  :  
     665      !! ** Action  : 
    666666      !!---------------------------------------------------------------------- 
    667667      INTEGER                             , INTENT( in )  ::  kt             ! ocean time-step index 
     
    684684            ! 
    685685            IF(lwp) THEN 
    686                WRITE(numout,*)  
     686               WRITE(numout,*) 
    687687               WRITE(numout,*) 'dyn_asm_inc : Dynamics IAU at time step = ', kt,' with IAU weight = ', wgtiau(it) 
    688688               WRITE(numout,*) '~~~~~~~~~~~~' 
     
    704704      ELSEIF ( ln_asmdin ) THEN     ! Direct Initialization 
    705705         !                          !----------------------------------------- 
    706          !          
     706         ! 
    707707         IF ( kt == nitdin_r ) THEN 
    708708            ! 
     
    711711            ! Initialize the now fields with the background + increment 
    712712            puu(:,:,:,Kmm) = u_bkg(:,:,:) + u_bkginc(:,:,:) 
    713             pvv(:,:,:,Kmm) = v_bkg(:,:,:) + v_bkginc(:,:,:)   
     713            pvv(:,:,:,Kmm) = v_bkg(:,:,:) + v_bkginc(:,:,:) 
    714714            ! 
    715715            puu(:,:,:,Kbb) = puu(:,:,:,Kmm)         ! Update before fields 
     
    730730      !!---------------------------------------------------------------------- 
    731731      !!                    ***  ROUTINE ssh_asm_inc  *** 
    732       !!           
     732      !! 
    733733      !! ** Purpose : Apply the sea surface height assimilation increment. 
    734734      !! 
    735735      !! ** Method  : Direct initialization or Incremental Analysis Updating. 
    736736      !! 
    737       !! ** Action  :  
     737      !! ** Action  : 
    738738      !!---------------------------------------------------------------------- 
    739739      INTEGER, INTENT(IN) :: kt         ! Current time step 
     
    755755            ! 
    756756            IF(lwp) THEN 
    757                WRITE(numout,*)  
     757               WRITE(numout,*) 
    758758               WRITE(numout,*) 'ssh_asm_inc : SSH IAU at time step = ', & 
    759759                  &  kt,' with IAU weight = ', wgtiau(it) 
     
    807807      !!                  ***  ROUTINE ssh_asm_div  *** 
    808808      !! 
    809       !! ** 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 
    810810      !!                across all the water column 
    811811      !! 
     
    823823      REAL(wp), DIMENSION(:,:)  , POINTER       ::   ztim     ! local array 
    824824      !!---------------------------------------------------------------------- 
    825       !  
     825      ! 
    826826#if defined key_asminc 
    827827      CALL ssh_asm_inc( kt, Kbb, Kmm ) !==   (calculate increments) 
    828828      ! 
    829       IF( ln_linssh ) THEN  
     829      IF( ln_linssh ) THEN 
    830830         phdivn(:,:,1) = phdivn(:,:,1) - ssh_iau(:,:) / e3t(:,:,1,Kmm) * tmask(:,:,1) 
    831       ELSE  
     831      ELSE 
    832832         ALLOCATE( ztim(jpi,jpj) ) 
    833833         ztim(:,:) = ssh_iau(:,:) / ( ht(:,:) + 1.0 - ssmask(:,:) ) 
    834          DO jk = 1, jpkm1                                  
    835             phdivn(:,:,jk) = phdivn(:,:,jk) - ztim(:,:) * tmask(:,:,jk)  
     834         DO jk = 1, jpkm1 
     835            phdivn(:,:,jk) = phdivn(:,:,jk) - ztim(:,:) * tmask(:,:,jk) 
    836836         END DO 
    837837         ! 
     
    846846      !!---------------------------------------------------------------------- 
    847847      !!                    ***  ROUTINE seaice_asm_inc  *** 
    848       !!           
     848      !! 
    849849      !! ** Purpose : Apply the sea ice assimilation increment. 
    850850      !! 
    851851      !! ** Method  : Direct initialization or Incremental Analysis Updating. 
    852852      !! 
    853       !! ** Action  :  
     853      !! ** Action  : 
    854854      !! 
    855855      !!---------------------------------------------------------------------- 
     
    873873            ! 
    874874            it = kt - nit000 + 1 
    875             zincwgt = wgtiau(it)      ! IAU weight for the current time step  
     875            zincwgt = wgtiau(it)      ! IAU weight for the current time step 
    876876            ! note this is not a tendency so should not be divided by rn_Dt (as with the tracer and other increments) 
    877877            ! 
     
    997997!#if defined defined key_si3 || defined key_cice 
    998998! 
    999 !            IF (ln_seaicebal ) THEN        
     999!            IF (ln_seaicebal ) THEN 
    10001000!             !! balancing salinity increments 
    10011001!             !! simple case from limflx.F90 (doesn't include a mass flux) 
     
    10091009! 
    10101010!             DO jj = 1, jpj 
    1011 !               DO ji = 1, jpi  
     1011!               DO ji = 1, jpi 
    10121012!           ! calculate change in ice and snow mass per unit area 
    10131013!           ! positive values imply adding salt to the ocean (results from ice formation) 
     
    10201020! 
    10211021!           ! prevent small mld 
    1022 !           ! less than 10m can cause salinity instability  
     1022!           ! less than 10m can cause salinity instability 
    10231023!                 IF (mld < 10) mld=10 
    10241024! 
    1025 !           ! set to bottom of a level  
     1025!           ! set to bottom of a level 
    10261026!                 DO jk = jpk-1, 2, -1 
    10271027!                   IF ((mld > gdepw(ji,jj,jk,Kmm)) .and. (mld < gdepw(ji,jj,jk+1,Kmm))) THEN 
     
    10321032! 
    10331033!            ! avoid applying salinity balancing in shallow water or on land 
    1034 !            !  
     1034!            ! 
    10351035! 
    10361036!            ! dsal_ocn (psu kg m^-2) / (kg m^-3 * m) 
     
    10431043! 
    10441044!           ! put increments in for levels in the mixed layer 
    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  
     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 
    10501050!                           sb(ji,jj,jk) = sb(ji,jj,jk) + dsal_ocn 
    10511051!                           sn(ji,jj,jk) = sn(ji,jj,jk) + dsal_ocn 
     
    10581058!      ! 
    10591059!      !! Adjust fsalt. A +ve fsalt means adding salt to ocean 
    1060 !      !!           fsalt(ji,jj) =  fsalt(ji,jj) + zpmess     ! adjust fsalt   
    1061 !      !!                
    1062 !      !!           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) 
    10631063!      !!                                                     ! E-P (kg m-2 s-2) 
    10641064!      !            emp(ji,jj) = emp(ji,jj) + zpmess          ! E-P (kg m-2 s-2) 
     
    10731073      ! 
    10741074   END SUBROUTINE seaice_asm_inc 
    1075     
     1075 
    10761076   !!====================================================================== 
    10771077END MODULE asminc 
Note: See TracChangeset for help on using the changeset viewer.