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 6808 for branches/NERC/dev_r5549_BDY_ZEROGRAD/NEMOGCM/NEMO/OPA_SRC/ASM/asminc.F90 – NEMO

Ignore:
Timestamp:
2016-07-19T10:38:35+02:00 (8 years ago)
Author:
jamesharle
Message:

merge with trunk@6232 for consistency with SSB code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/NERC/dev_r5549_BDY_ZEROGRAD/NEMOGCM/NEMO/OPA_SRC/ASM/asminc.F90

    r5541 r6808  
    1111   !!             -   ! 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 
     13   !!                 ! 2014-09  (D. Lea)  Local calc_date removed use routine from OBS 
     14   !!                 ! 2015-11  (D. Lea)  Handle non-zero initial time of day 
    1315   !!---------------------------------------------------------------------- 
    1416 
    15    !!---------------------------------------------------------------------- 
    16    !!   'key_asminc'   : Switch on the assimilation increment interface 
    1717   !!---------------------------------------------------------------------- 
    1818   !!   asm_inc_init   : Initialize the increment arrays and IAU weights 
    19    !!   calc_date      : Compute the calendar date YYYYMMDD on a given step 
    2019   !!   tra_asm_inc    : Apply the tracer (T and S) increments 
    2120   !!   dyn_asm_inc    : Apply the dynamic (u and v) increments 
     
    2827   USE domvvl           ! domain: variable volume level 
    2928   USE oce              ! Dynamics and active tracers defined in memory 
    30    USE ldfdyn_oce       ! ocean dynamics: lateral physics 
     29   USE ldfdyn           ! lateral diffusion: eddy viscosity coefficients 
    3130   USE eosbn2           ! Equation of state - in situ and potential density 
    3231   USE zpshde           ! Partial step : Horizontal Derivative 
     
    4039#endif 
    4140   USE sbc_oce          ! Surface boundary condition variables. 
     41   USE diaobs, ONLY: calc_date     ! Compute the calendar date on a given step 
    4242 
    4343   IMPLICIT NONE 
     
    4545    
    4646   PUBLIC   asm_inc_init   !: Initialize the increment arrays and IAU weights 
    47    PUBLIC   calc_date      !: Compute the calendar date YYYYMMDD on a given step 
    4847   PUBLIC   tra_asm_inc    !: Apply the tracer (T and S) increments 
    4948   PUBLIC   dyn_asm_inc    !: Apply the dynamic (u and v) increments 
     
    5655    LOGICAL, PUBLIC, PARAMETER :: lk_asminc = .FALSE.  !: No assimilation increments 
    5756#endif 
    58    LOGICAL, PUBLIC :: ln_bkgwri = .FALSE.      !: No output of the background state fields 
    59    LOGICAL, PUBLIC :: ln_asmiau = .FALSE.      !: No applying forcing with an assimilation increment 
    60    LOGICAL, PUBLIC :: ln_asmdin = .FALSE.      !: No direct initialization 
    61    LOGICAL, PUBLIC :: ln_trainc = .FALSE.      !: No tracer (T and S) assimilation increments 
    62    LOGICAL, PUBLIC :: ln_dyninc = .FALSE.      !: No dynamics (u and v) assimilation increments 
    63    LOGICAL, PUBLIC :: ln_sshinc = .FALSE.      !: No sea surface height assimilation increment 
    64    LOGICAL, PUBLIC :: ln_seaiceinc             !: No sea ice concentration increment 
    65    LOGICAL, PUBLIC :: ln_salfix = .FALSE.      !: Apply minimum salinity check 
     57   LOGICAL, PUBLIC :: ln_bkgwri     !: No output of the background state fields 
     58   LOGICAL, PUBLIC :: ln_asmiau     !: No applying forcing with an assimilation increment 
     59   LOGICAL, PUBLIC :: ln_asmdin     !: No direct initialization 
     60   LOGICAL, PUBLIC :: ln_trainc     !: No tracer (T and S) assimilation increments 
     61   LOGICAL, PUBLIC :: ln_dyninc     !: No dynamics (u and v) assimilation increments 
     62   LOGICAL, PUBLIC :: ln_sshinc     !: No sea surface height assimilation increment 
     63   LOGICAL, PUBLIC :: ln_seaiceinc  !: No sea ice concentration increment 
     64   LOGICAL, PUBLIC :: ln_salfix     !: Apply minimum salinity check 
    6665   LOGICAL, PUBLIC :: ln_temnofreeze = .FALSE. !: Don't allow the temperature to drop below freezing 
    67    INTEGER, PUBLIC :: nn_divdmp                !: Apply divergence damping filter nn_divdmp times 
     66   INTEGER, PUBLIC :: nn_divdmp     !: Apply divergence damping filter nn_divdmp times 
    6867 
    6968   REAL(wp), PUBLIC, DIMENSION(:,:,:), ALLOCATABLE ::   t_bkg   , s_bkg      !: Background temperature and salinity 
     
    8988 
    9089   !! * Substitutions 
    91 #  include "domzgr_substitute.h90" 
    92 #  include "ldfdyn_substitute.h90" 
    9390#  include "vectopt_loop_substitute.h90" 
    9491   !!---------------------------------------------------------------------- 
    95    !! NEMO/OPA 3.3 , NEMO Consortium (2010) 
     92   !! NEMO/OPA 3.7 , NEMO Consortium (2015) 
    9693   !! $Id$ 
    9794   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt) 
     
    114111      INTEGER :: iiauper         ! Number of time steps in the IAU period 
    115112      INTEGER :: icycper         ! Number of time steps in the cycle 
    116       INTEGER :: iitend_date     ! Date YYYYMMDD of final time step 
    117       INTEGER :: iitbkg_date     ! Date YYYYMMDD of background time step for Jb term 
    118       INTEGER :: iitdin_date     ! Date YYYYMMDD of background time step for DI 
    119       INTEGER :: iitiaustr_date  ! Date YYYYMMDD of IAU interval start time step 
    120       INTEGER :: iitiaufin_date  ! Date YYYYMMDD of IAU interval final time step 
    121       ! 
     113      REAL(KIND=dp) :: ditend_date     ! Date YYYYMMDD.HHMMSS of final time step 
     114      REAL(KIND=dp) :: ditbkg_date     ! Date YYYYMMDD.HHMMSS of background time step for Jb term 
     115      REAL(KIND=dp) :: ditdin_date     ! Date YYYYMMDD.HHMMSS of background time step for DI 
     116      REAL(KIND=dp) :: ditiaustr_date  ! Date YYYYMMDD.HHMMSS of IAU interval start time step 
     117      REAL(KIND=dp) :: ditiaufin_date  ! Date YYYYMMDD.HHMMSS of IAU interval final time step 
     118 
    122119      REAL(wp) :: znorm        ! Normalization factor for IAU weights 
    123120      REAL(wp) :: ztotwgt      ! Value of time-integrated IAU weights (should be equal to one) 
     
    139136      ! Read Namelist nam_asminc : assimilation increment interface 
    140137      !----------------------------------------------------------------------- 
    141       ln_seaiceinc = .FALSE. 
     138      ln_seaiceinc   = .FALSE. 
    142139      ln_temnofreeze = .FALSE. 
    143140 
     
    181178      icycper = nitend      - nit000      + 1  ! Cycle interval length 
    182179 
    183       CALL calc_date( nit000, nitend     , ndate0, iitend_date    )     ! Date of final time step 
    184       CALL calc_date( nit000, nitbkg_r   , ndate0, iitbkg_date    )     ! Background time for Jb referenced to ndate0 
    185       CALL calc_date( nit000, nitdin_r   , ndate0, iitdin_date    )     ! Background time for DI referenced to ndate0 
    186       CALL calc_date( nit000, nitiaustr_r, ndate0, iitiaustr_date )     ! IAU start time referenced to ndate0 
    187       CALL calc_date( nit000, nitiaufin_r, ndate0, iitiaufin_date )     ! IAU end time referenced to ndate0 
    188       ! 
     180      ! Date of final time step 
     181      CALL calc_date( nitend, ditend_date ) 
     182 
     183      ! Background time for Jb referenced to ndate0 
     184      CALL calc_date( nitbkg_r, ditbkg_date ) 
     185 
     186      ! Background time for DI referenced to ndate0 
     187      CALL calc_date( nitdin_r, ditdin_date ) 
     188 
     189      ! IAU start time referenced to ndate0 
     190      CALL calc_date( nitiaustr_r, ditiaustr_date ) 
     191 
     192      ! IAU end time referenced to ndate0 
     193      CALL calc_date( nitiaufin_r, ditiaufin_date ) 
     194 
    189195      IF(lwp) THEN 
    190196         WRITE(numout,*) 
     
    201207         WRITE(numout,*) '       ndastp         = ', ndastp 
    202208         WRITE(numout,*) '       ndate0         = ', ndate0 
    203          WRITE(numout,*) '       iitend_date    = ', iitend_date 
    204          WRITE(numout,*) '       iitbkg_date    = ', iitbkg_date 
    205          WRITE(numout,*) '       iitdin_date    = ', iitdin_date 
    206          WRITE(numout,*) '       iitiaustr_date = ', iitiaustr_date 
    207          WRITE(numout,*) '       iitiaufin_date = ', iitiaufin_date 
     209         WRITE(numout,*) '       nn_time0       = ', nn_time0 
     210         WRITE(numout,*) '       ditend_date    = ', ditend_date 
     211         WRITE(numout,*) '       ditbkg_date    = ', ditbkg_date 
     212         WRITE(numout,*) '       ditdin_date    = ', ditdin_date 
     213         WRITE(numout,*) '       ditiaustr_date = ', ditiaustr_date 
     214         WRITE(numout,*) '       ditiaufin_date = ', ditiaufin_date 
    208215      ENDIF 
    209216 
    210       IF ( nacc /= 0 ) & 
    211          & CALL ctl_stop( ' nacc /= 0 and key_asminc :',  & 
    212          &                ' Assimilation increments have only been implemented', & 
    213          &                ' for synchronous time stepping' ) 
    214217 
    215218      IF ( ( ln_asmdin ).AND.( ln_asmiau ) )   & 
     
    363366            WRITE(numout,*)  
    364367            WRITE(numout,*) 'asm_inc_init : Assimilation increments valid ', & 
    365                &            ' between dates ', NINT( z_inc_dateb ),' and ',  & 
    366                &            NINT( z_inc_datef ) 
     368               &            ' between dates ', z_inc_dateb,' and ',  & 
     369               &            z_inc_datef 
    367370            WRITE(numout,*) '~~~~~~~~~~~~' 
    368371         ENDIF 
    369372 
    370          IF (     ( NINT( z_inc_dateb ) < ndastp      ) & 
    371             & .OR.( NINT( z_inc_datef ) > iitend_date ) ) & 
     373         IF (     ( z_inc_dateb < ndastp + nn_time0*0.0001_wp ) & 
     374            & .OR.( z_inc_datef > ditend_date ) ) & 
    372375            & CALL ctl_warn( ' Validity time of assimilation increments is ', & 
    373376            &                ' outside the assimilation interval' ) 
    374377 
    375          IF ( ( ln_asmdin ).AND.( NINT( zdate_inc ) /= iitdin_date ) ) & 
     378         IF ( ( ln_asmdin ).AND.( zdate_inc /= ditdin_date ) ) & 
    376379            & CALL ctl_warn( ' Validity time of assimilation increments does ', & 
    377380            &                ' not agree with Direct Initialization time' ) 
     
    428431 
    429432      IF ( ln_dyninc .AND. nn_divdmp > 0 ) THEN 
    430  
    431          CALL wrk_alloc(jpi,jpj,hdiv)  
    432  
    433          DO  jt = 1, nn_divdmp 
    434  
    435             DO jk = 1, jpkm1 
    436  
     433         ! 
     434         CALL wrk_alloc( jpi,jpj,   hdiv )  
     435         ! 
     436         DO jt = 1, nn_divdmp 
     437            ! 
     438            DO jk = 1, jpkm1           ! hdiv = e1e1 * div 
    437439               hdiv(:,:) = 0._wp 
    438  
    439440               DO jj = 2, jpjm1 
    440441                  DO ji = fs_2, fs_jpim1   ! vector opt. 
    441                      hdiv(ji,jj) =   & 
    442                         (  e2u(ji  ,jj  ) * fse3u(ji  ,jj  ,jk) * u_bkginc(ji  ,jj  ,jk)     & 
    443                          - e2u(ji-1,jj  ) * fse3u(ji-1,jj  ,jk) * u_bkginc(ji-1,jj  ,jk)     & 
    444                          + e1v(ji  ,jj  ) * fse3v(ji  ,jj  ,jk) * v_bkginc(ji  ,jj  ,jk)     & 
    445                          - e1v(ji  ,jj-1) * fse3v(ji  ,jj-1,jk) * v_bkginc(ji  ,jj-1,jk)  )  & 
    446                          / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) ) 
     442                     hdiv(ji,jj) = (  e2u(ji  ,jj) * e3u_n(ji  ,jj,jk) * u_bkginc(ji  ,jj,jk)    & 
     443                        &           - e2u(ji-1,jj) * e3u_n(ji-1,jj,jk) * u_bkginc(ji-1,jj,jk)    & 
     444                        &           + e1v(ji,jj  ) * e3v_n(ji,jj  ,jk) * v_bkginc(ji,jj  ,jk)    & 
     445                        &           - e1v(ji,jj-1) * e3v_n(ji,jj-1,jk) * v_bkginc(ji,jj-1,jk)  ) / e3t_n(ji,jj,jk) 
    447446                  END DO 
    448447               END DO 
    449  
    450448               CALL lbc_lnk( hdiv, 'T', 1. )   ! lateral boundary cond. (no sign change) 
    451  
     449               ! 
    452450               DO jj = 2, jpjm1 
    453451                  DO ji = fs_2, fs_jpim1   ! vector opt. 
    454                      u_bkginc(ji,jj,jk) = u_bkginc(ji,jj,jk) + 0.2_wp * ( e1t(ji+1,jj)*e2t(ji+1,jj) * hdiv(ji+1,jj)   & 
    455                                                                         - e1t(ji  ,jj)*e2t(ji  ,jj) * hdiv(ji  ,jj) ) & 
    456                                                                       / e1u(ji,jj) * umask(ji,jj,jk)  
    457                      v_bkginc(ji,jj,jk) = v_bkginc(ji,jj,jk) + 0.2_wp * ( e1t(ji,jj+1)*e2t(ji,jj+1) * hdiv(ji,jj+1)   & 
    458                                                                         - e1t(ji,jj  )*e2t(ji,jj  ) * hdiv(ji,jj  ) ) & 
    459                                                                       / e2v(ji,jj) * vmask(ji,jj,jk)  
     452                     u_bkginc(ji,jj,jk) = u_bkginc(ji,jj,jk)                         & 
     453                        &               + 0.2_wp * ( hdiv(ji+1,jj) - hdiv(ji  ,jj) ) * r1_e1u(ji,jj) * umask(ji,jj,jk) 
     454                     v_bkginc(ji,jj,jk) = v_bkginc(ji,jj,jk)                         & 
     455                        &               + 0.2_wp * ( hdiv(ji,jj+1) - hdiv(ji,jj  ) ) * r1_e2v(ji,jj) * vmask(ji,jj,jk)  
    460456                  END DO 
    461457               END DO 
    462  
    463458            END DO 
    464  
     459            ! 
    465460         END DO 
    466  
    467          CALL wrk_dealloc(jpi,jpj,hdiv)  
    468  
     461         ! 
     462         CALL wrk_dealloc( jpi,jpj,   hdiv )  
     463         ! 
    469464      ENDIF 
    470  
    471  
    472465 
    473466      !----------------------------------------------------------------------- 
     
    476469 
    477470      IF ( ln_asmdin ) THEN 
    478  
     471         ! 
    479472         ALLOCATE( t_bkg(jpi,jpj,jpk) ) 
    480473         ALLOCATE( s_bkg(jpi,jpj,jpk) ) 
     
    482475         ALLOCATE( v_bkg(jpi,jpj,jpk) ) 
    483476         ALLOCATE( ssh_bkg(jpi,jpj)   ) 
    484  
    485          t_bkg(:,:,:) = 0.0 
    486          s_bkg(:,:,:) = 0.0 
    487          u_bkg(:,:,:) = 0.0 
    488          v_bkg(:,:,:) = 0.0 
    489          ssh_bkg(:,:) = 0.0 
    490  
     477         ! 
     478         t_bkg(:,:,:) = 0._wp 
     479         s_bkg(:,:,:) = 0._wp 
     480         u_bkg(:,:,:) = 0._wp 
     481         v_bkg(:,:,:) = 0._wp 
     482         ssh_bkg(:,:) = 0._wp 
     483         ! 
    491484         !-------------------------------------------------------------------- 
    492485         ! Read from file the background state at analysis time 
    493486         !-------------------------------------------------------------------- 
    494  
     487         ! 
    495488         CALL iom_open( c_asmdin, inum ) 
    496  
     489         ! 
    497490         CALL iom_get( inum, 'rdastp', zdate_bkg )  
    498          
     491         ! 
    499492         IF(lwp) THEN 
    500493            WRITE(numout,*)  
    501494            WRITE(numout,*) 'asm_inc_init : Assimilation background state valid at : ', & 
    502                &  NINT( zdate_bkg ) 
     495               &  zdate_bkg 
    503496            WRITE(numout,*) '~~~~~~~~~~~~' 
    504497         ENDIF 
    505  
    506          IF ( NINT( zdate_bkg ) /= iitdin_date ) & 
     498         ! 
     499         IF ( zdate_bkg /= ditdin_date ) & 
    507500            & CALL ctl_warn( ' Validity time of assimilation background state does', & 
    508501            &                ' not agree with Direct Initialization time' ) 
    509  
     502         ! 
    510503         IF ( ln_trainc ) THEN    
    511504            CALL iom_get( inum, jpdom_autoglo, 'tn', t_bkg ) 
     
    514507            s_bkg(:,:,:) = s_bkg(:,:,:) * tmask(:,:,:) 
    515508         ENDIF 
    516  
     509         ! 
    517510         IF ( ln_dyninc ) THEN    
    518511            CALL iom_get( inum, jpdom_autoglo, 'un', u_bkg ) 
     
    521514            v_bkg(:,:,:) = v_bkg(:,:,:) * vmask(:,:,:) 
    522515         ENDIF 
    523          
     516         ! 
    524517         IF ( ln_sshinc ) THEN 
    525518            CALL iom_get( inum, jpdom_autoglo, 'sshn', ssh_bkg ) 
    526519            ssh_bkg(:,:) = ssh_bkg(:,:) * tmask(:,:,1) 
    527520         ENDIF 
    528  
     521         ! 
    529522         CALL iom_close( inum ) 
    530  
     523         ! 
    531524      ENDIF 
    532525      ! 
    533526   END SUBROUTINE asm_inc_init 
    534  
    535  
    536    SUBROUTINE calc_date( kit000, kt, kdate0, kdate ) 
    537       !!---------------------------------------------------------------------- 
    538       !!                    ***  ROUTINE calc_date  *** 
    539       !!           
    540       !! ** Purpose : Compute the calendar date YYYYMMDD at a given time step. 
    541       !! 
    542       !! ** Method  : Compute the calendar date YYYYMMDD at a given time step. 
    543       !! 
    544       !! ** Action  :  
    545       !!---------------------------------------------------------------------- 
    546       INTEGER, INTENT(IN) :: kit000  ! Initial time step 
    547       INTEGER, INTENT(IN) :: kt      ! Current time step referenced to kit000 
    548       INTEGER, INTENT(IN) :: kdate0  ! Initial date 
    549       INTEGER, INTENT(OUT) :: kdate  ! Current date reference to kdate0 
    550       ! 
    551       INTEGER :: iyea0    ! Initial year 
    552       INTEGER :: imon0    ! Initial month 
    553       INTEGER :: iday0    ! Initial day 
    554       INTEGER :: iyea     ! Current year 
    555       INTEGER :: imon     ! Current month 
    556       INTEGER :: iday     ! Current day 
    557       INTEGER :: idaystp  ! Number of days between initial and current date 
    558       INTEGER :: idaycnt  ! Day counter 
    559  
    560       INTEGER, DIMENSION(12) ::   imonth_len    !: length in days of the months of the current year 
    561  
    562       !----------------------------------------------------------------------- 
    563       ! Compute the calendar date YYYYMMDD 
    564       !----------------------------------------------------------------------- 
    565  
    566       ! Initial date 
    567       iyea0 =   kdate0 / 10000 
    568       imon0 = ( kdate0 - ( iyea0 * 10000 ) ) / 100 
    569       iday0 =   kdate0 - ( iyea0 * 10000 ) - ( imon0 * 100 )  
    570  
    571       ! Check that kt >= kit000 - 1 
    572       IF ( kt < kit000 - 1 ) CALL ctl_stop( ' kt must be >= kit000 - 1') 
    573  
    574       ! If kt = kit000 - 1 then set the date to the restart date 
    575       IF ( kt == kit000 - 1 ) THEN 
    576  
    577          kdate = ndastp 
    578          RETURN 
    579  
    580       ENDIF 
    581  
    582       ! Compute the number of days from the initial date 
    583       idaystp = INT( REAL( kt - kit000 ) * rdt / 86400. ) 
    584     
    585       iday    = iday0 
    586       imon    = imon0 
    587       iyea    = iyea0 
    588       idaycnt = 0 
    589  
    590       CALL calc_month_len( iyea, imonth_len ) 
    591  
    592       DO WHILE ( idaycnt < idaystp ) 
    593          iday = iday + 1 
    594          IF ( iday > imonth_len(imon) )  THEN 
    595             iday = 1 
    596             imon = imon + 1 
    597          ENDIF 
    598          IF ( imon > 12 ) THEN 
    599             imon = 1 
    600             iyea = iyea + 1 
    601             CALL calc_month_len( iyea, imonth_len )  ! update month lengths 
    602          ENDIF                  
    603          idaycnt = idaycnt + 1 
    604       END DO 
    605       ! 
    606       kdate = iyea * 10000 + imon * 100 + iday 
    607       ! 
    608    END SUBROUTINE 
    609  
    610  
    611    SUBROUTINE calc_month_len( iyear, imonth_len ) 
    612       !!---------------------------------------------------------------------- 
    613       !!                    ***  ROUTINE calc_month_len  *** 
    614       !!           
    615       !! ** Purpose : Compute the number of days in a months given a year. 
    616       !! 
    617       !! ** Method  :  
    618       !!---------------------------------------------------------------------- 
    619       INTEGER, DIMENSION(12) ::   imonth_len    !: length in days of the months of the current year 
    620       INTEGER :: iyear         !: year 
    621       !!---------------------------------------------------------------------- 
    622       ! 
    623       ! length of the month of the current year (from nleapy, read in namelist) 
    624       IF ( nleapy < 2 ) THEN  
    625          imonth_len(:) = (/ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 /) 
    626          IF ( nleapy == 1 ) THEN   ! we are using calendar with leap years 
    627             IF ( MOD(iyear, 4) == 0 .AND. ( MOD(iyear, 400) == 0 .OR. MOD(iyear, 100) /= 0 ) ) THEN 
    628                imonth_len(2) = 29 
    629             ENDIF 
    630          ENDIF 
    631       ELSE 
    632          imonth_len(:) = nleapy   ! all months with nleapy days per year 
    633       ENDIF 
    634       ! 
    635    END SUBROUTINE 
    636  
    637  
    638527   SUBROUTINE tra_asm_inc( kt ) 
    639528      !!---------------------------------------------------------------------- 
     
    646535      !! ** Action  :  
    647536      !!---------------------------------------------------------------------- 
    648       INTEGER, INTENT(IN) :: kt               ! Current time step 
    649       ! 
    650       INTEGER :: ji,jj,jk 
    651       INTEGER :: it 
     537      INTEGER, INTENT(IN) ::   kt   ! Current time step 
     538      ! 
     539      INTEGER  :: ji, jj, jk 
     540      INTEGER  :: it 
    652541      REAL(wp) :: zincwgt  ! IAU weight for current time step 
    653542      REAL (wp), DIMENSION(jpi,jpj,jpk) :: fzptnz ! 3d freezing point values 
    654543      !!---------------------------------------------------------------------- 
    655  
     544      ! 
    656545      ! freezing point calculation taken from oc_fz_pt (but calculated for all depths)  
    657546      ! used to prevent the applied increments taking the temperature below the local freezing point  
    658  
    659547      DO jk = 1, jpkm1 
    660         CALL eos_fzp( tsn(:,:,jk,jp_sal), fzptnz(:,:,jk), fsdept(:,:,jk) ) 
     548        CALL eos_fzp( tsn(:,:,jk,jp_sal), fzptnz(:,:,jk), gdept_n(:,:,jk) ) 
    661549      END DO 
    662  
    663       IF ( ln_asmiau ) THEN 
    664  
    665          !-------------------------------------------------------------------- 
    666          ! Incremental Analysis Updating 
    667          !-------------------------------------------------------------------- 
    668  
     550         ! 
     551         !                             !-------------------------------------- 
     552      IF ( ln_asmiau ) THEN            ! Incremental Analysis Updating 
     553         !                             !-------------------------------------- 
     554         ! 
    669555         IF ( ( kt >= nitiaustr_r ).AND.( kt <= nitiaufin_r ) ) THEN 
    670  
     556            ! 
    671557            it = kt - nit000 + 1 
    672558            zincwgt = wgtiau(it) / rdt   ! IAU weight for the current time step 
    673  
     559            ! 
    674560            IF(lwp) THEN 
    675561               WRITE(numout,*)  
     
    677563               WRITE(numout,*) '~~~~~~~~~~~~' 
    678564            ENDIF 
    679  
     565            ! 
    680566            ! Update the tracer tendencies 
    681567            DO jk = 1, jpkm1 
     
    700586               ENDIF 
    701587            END DO 
    702  
    703          ENDIF 
    704  
     588            ! 
     589         ENDIF 
     590         ! 
    705591         IF ( kt == nitiaufin_r + 1  ) THEN   ! For bias crcn to work 
    706592            DEALLOCATE( t_bkginc ) 
    707593            DEALLOCATE( s_bkginc ) 
    708594         ENDIF 
    709  
    710  
    711       ELSEIF ( ln_asmdin ) THEN 
    712  
    713          !-------------------------------------------------------------------- 
    714          ! Direct Initialization 
    715          !-------------------------------------------------------------------- 
    716              
     595         !                             !-------------------------------------- 
     596      ELSEIF ( ln_asmdin ) THEN        ! Direct Initialization 
     597         !                             !-------------------------------------- 
     598         !             
    717599         IF ( kt == nitdin_r ) THEN 
    718  
     600            ! 
    719601            neuler = 0  ! Force Euler forward step 
    720  
     602            ! 
    721603            ! Initialize the now fields with the background + increment 
    722604            IF (ln_temnofreeze) THEN 
     
    745627!!gm 
    746628 
    747  
    748629            IF( ln_zps .AND. .NOT. lk_c1d .AND. .NOT. ln_isfcav)      & 
    749630               &  CALL zps_hde    ( kt, jpts, tsb, gtsu, gtsv,        &  ! Partial steps: before horizontal gradient 
    750631               &                              rhd, gru , grv          )  ! of t, s, rd at the last ocean level 
    751632            IF( ln_zps .AND. .NOT. lk_c1d .AND.       ln_isfcav)      & 
    752                &  CALL zps_hde_isf( nit000, jpts, tsb, gtsu, gtsv,    &    ! Partial steps for top cell (ISF) 
    753                &                                  rhd, gru , grv , aru , arv , gzu , gzv , ge3ru , ge3rv ,   & 
    754                &                           gtui, gtvi, grui, grvi, arui, arvi, gzui, gzvi, ge3rui, ge3rvi    ) ! of t, s, rd at the last ocean level 
    755  
    756 #if defined key_zdfkpp 
    757             CALL eos( tsn, rhd, fsdept_n(:,:,:) )                      ! Compute rhd 
    758 !!gm fabien            CALL eos( tsn, rhd )                      ! Compute rhd 
    759 #endif 
     633               &  CALL zps_hde_isf( nit000, jpts, tsb, gtsu, gtsv, gtui, gtvi,    &    ! Partial steps for top cell (ISF) 
     634               &                                  rhd, gru , grv , grui, grvi     )    ! of t, s, rd at the last ocean level 
    760635 
    761636            DEALLOCATE( t_bkginc ) 
     
    767642      ENDIF 
    768643      ! Perhaps the following call should be in step 
    769       IF   ( ln_seaiceinc  )   CALL seaice_asm_inc ( kt )   ! apply sea ice concentration increment 
     644      IF ( ln_seaiceinc  )   CALL seaice_asm_inc ( kt )   ! apply sea ice concentration increment 
    770645      ! 
    771646   END SUBROUTINE tra_asm_inc 
     
    788663      REAL(wp) :: zincwgt  ! IAU weight for current time step 
    789664      !!---------------------------------------------------------------------- 
    790  
    791       IF ( ln_asmiau ) THEN 
    792  
    793          !-------------------------------------------------------------------- 
    794          ! Incremental Analysis Updating 
    795          !-------------------------------------------------------------------- 
    796  
     665      ! 
     666      !                          !-------------------------------------------- 
     667      IF ( ln_asmiau ) THEN      ! Incremental Analysis Updating 
     668         !                       !-------------------------------------------- 
     669         ! 
    797670         IF ( ( kt >= nitiaustr_r ).AND.( kt <= nitiaufin_r ) ) THEN 
    798  
     671            ! 
    799672            it = kt - nit000 + 1 
    800673            zincwgt = wgtiau(it) / rdt   ! IAU weight for the current time step 
    801  
     674            ! 
    802675            IF(lwp) THEN 
    803676               WRITE(numout,*)  
    804                WRITE(numout,*) 'dyn_asm_inc : Dynamics IAU at time step = ', & 
    805                   &  kt,' with IAU weight = ', wgtiau(it) 
     677               WRITE(numout,*) 'dyn_asm_inc : Dynamics IAU at time step = ', kt,' with IAU weight = ', wgtiau(it) 
    806678               WRITE(numout,*) '~~~~~~~~~~~~' 
    807679            ENDIF 
    808  
     680            ! 
    809681            ! Update the dynamic tendencies 
    810682            DO jk = 1, jpkm1 
     
    812684               va(:,:,jk) = va(:,:,jk) + v_bkginc(:,:,jk) * zincwgt 
    813685            END DO 
    814             
     686            ! 
    815687            IF ( kt == nitiaufin_r ) THEN 
    816688               DEALLOCATE( u_bkginc ) 
    817689               DEALLOCATE( v_bkginc ) 
    818690            ENDIF 
    819  
    820          ENDIF 
    821  
    822       ELSEIF ( ln_asmdin ) THEN  
    823  
    824          !-------------------------------------------------------------------- 
    825          ! Direct Initialization 
    826          !-------------------------------------------------------------------- 
    827           
     691            ! 
     692         ENDIF 
     693         !                          !----------------------------------------- 
     694      ELSEIF ( ln_asmdin ) THEN     ! Direct Initialization 
     695         !                          !----------------------------------------- 
     696         !          
    828697         IF ( kt == nitdin_r ) THEN 
    829  
     698            ! 
    830699            neuler = 0                    ! Force Euler forward step 
    831  
     700            ! 
    832701            ! Initialize the now fields with the background + increment 
    833702            un(:,:,:) = u_bkg(:,:,:) + u_bkginc(:,:,:) 
    834703            vn(:,:,:) = v_bkg(:,:,:) + v_bkginc(:,:,:)   
    835  
     704            ! 
    836705            ub(:,:,:) = un(:,:,:)         ! Update before fields 
    837706            vb(:,:,:) = vn(:,:,:) 
    838   
     707            ! 
    839708            DEALLOCATE( u_bkg    ) 
    840709            DEALLOCATE( v_bkg    ) 
     
    864733      REAL(wp) :: zincwgt  ! IAU weight for current time step 
    865734      !!---------------------------------------------------------------------- 
    866  
    867       IF ( ln_asmiau ) THEN 
    868  
    869          !-------------------------------------------------------------------- 
    870          ! Incremental Analysis Updating 
    871          !-------------------------------------------------------------------- 
    872  
     735      ! 
     736      !                             !----------------------------------------- 
     737      IF ( ln_asmiau ) THEN         ! Incremental Analysis Updating 
     738         !                          !----------------------------------------- 
     739         ! 
    873740         IF ( ( kt >= nitiaustr_r ).AND.( kt <= nitiaufin_r ) ) THEN 
    874  
     741            ! 
    875742            it = kt - nit000 + 1 
    876743            zincwgt = wgtiau(it) / rdt   ! IAU weight for the current time step 
    877  
     744            ! 
    878745            IF(lwp) THEN 
    879746               WRITE(numout,*)  
     
    882749               WRITE(numout,*) '~~~~~~~~~~~~' 
    883750            ENDIF 
    884  
     751            ! 
    885752            ! Save the tendency associated with the IAU weighted SSH increment 
    886753            ! (applied in dynspg.*) 
     
    891758               DEALLOCATE( ssh_bkginc ) 
    892759            ENDIF 
    893  
    894          ENDIF 
    895  
    896       ELSEIF ( ln_asmdin ) THEN 
    897  
    898          !-------------------------------------------------------------------- 
    899          ! Direct Initialization 
    900          !-------------------------------------------------------------------- 
    901  
     760            ! 
     761         ENDIF 
     762         !                          !----------------------------------------- 
     763      ELSEIF ( ln_asmdin ) THEN     ! Direct Initialization 
     764         !                          !----------------------------------------- 
     765         ! 
    902766         IF ( kt == nitdin_r ) THEN 
    903  
    904             neuler = 0                    ! Force Euler forward step 
    905  
    906             ! Initialize the now fields the background + increment 
    907             sshn(:,:) = ssh_bkg(:,:) + ssh_bkginc(:,:)   
    908  
    909             ! Update before fields 
    910             sshb(:,:) = sshn(:,:)          
    911  
    912             IF( lk_vvl ) THEN 
    913                DO jk = 1, jpk 
    914                   fse3t_b(:,:,jk) = fse3t_n(:,:,jk) 
    915                END DO 
    916             ENDIF 
    917  
     767            ! 
     768            neuler = 0                                   ! Force Euler forward step 
     769            ! 
     770            sshn(:,:) = ssh_bkg(:,:) + ssh_bkginc(:,:)   ! Initialize the now fields the background + increment 
     771            ! 
     772            sshb(:,:) = sshn(:,:)                        ! Update before fields 
     773            e3t_b(:,:,:) = e3t_n(:,:,:) 
     774!!gm why not e3u_b, e3v_b, gdept_b ???? 
     775            ! 
    918776            DEALLOCATE( ssh_bkg    ) 
    919777            DEALLOCATE( ssh_bkginc ) 
    920  
     778            ! 
    921779         ENDIF 
    922780         ! 
     
    937795      !! 
    938796      !!---------------------------------------------------------------------- 
    939       IMPLICIT NONE 
    940       ! 
    941       INTEGER, INTENT(in)           ::   kt   ! Current time step 
     797      INTEGER, INTENT(in)           ::   kt       ! Current time step 
    942798      INTEGER, INTENT(in), OPTIONAL ::   kindic   ! flag for disabling the deallocation 
    943799      ! 
     
    949805#endif 
    950806      !!---------------------------------------------------------------------- 
    951  
    952       IF ( ln_asmiau ) THEN 
    953  
    954          !-------------------------------------------------------------------- 
    955          ! Incremental Analysis Updating 
    956          !-------------------------------------------------------------------- 
    957  
     807      ! 
     808      !                             !----------------------------------------- 
     809      IF ( ln_asmiau ) THEN         ! Incremental Analysis Updating 
     810         !                          !----------------------------------------- 
     811         ! 
    958812         IF ( ( kt >= nitiaustr_r ).AND.( kt <= nitiaufin_r ) ) THEN 
    959  
     813            ! 
    960814            it = kt - nit000 + 1 
    961815            zincwgt = wgtiau(it)      ! IAU weight for the current time step  
    962816            ! note this is not a tendency so should not be divided by rdt (as with the tracer and other increments) 
    963  
     817            ! 
    964818            IF(lwp) THEN 
    965819               WRITE(numout,*)  
    966                WRITE(numout,*) 'seaice_asm_inc : sea ice conc IAU at time step = ', & 
    967                   &  kt,' with IAU weight = ', wgtiau(it) 
     820               WRITE(numout,*) 'seaice_asm_inc : sea ice conc IAU at time step = ', kt,' with IAU weight = ', wgtiau(it) 
    968821               WRITE(numout,*) '~~~~~~~~~~~~' 
    969822            ENDIF 
    970  
     823            ! 
    971824            ! Sea-ice : LIM-3 case (to add) 
    972  
     825            ! 
    973826#if defined key_lim2 
    974827            ! Sea-ice : LIM-2 case 
     
    1008861 
    1009862#if defined key_cice && defined key_asminc 
    1010             ! Sea-ice : CICE case. Zero ice increment tendency into CICE 
    1011             ndaice_da(:,:) = 0.0_wp 
    1012 #endif 
    1013  
    1014          ENDIF 
    1015  
    1016       ELSEIF ( ln_asmdin ) THEN 
    1017  
    1018          !-------------------------------------------------------------------- 
    1019          ! Direct Initialization 
    1020          !-------------------------------------------------------------------- 
    1021  
     863            ndaice_da(:,:) = 0._wp        ! Sea-ice : CICE case. Zero ice increment tendency into CICE 
     864#endif 
     865 
     866         ENDIF 
     867         !                          !----------------------------------------- 
     868      ELSEIF ( ln_asmdin ) THEN     ! Direct Initialization 
     869         !                          !----------------------------------------- 
     870         ! 
    1022871         IF ( kt == nitdin_r ) THEN 
    1023  
     872            ! 
    1024873            neuler = 0                    ! Force Euler forward step 
    1025  
     874            ! 
    1026875            ! Sea-ice : LIM-3 case (to add) 
    1027  
     876            ! 
    1028877#if defined key_lim2 
    1029878            ! Sea-ice : LIM-2 case. 
     
    1041890               zhicifinc(:,:) = (zhicifmin - hicif(:,:)) * zincwgt     
    1042891            ELSEWHERE 
    1043                zhicifinc(:,:) = 0.0_wp 
     892               zhicifinc(:,:) = 0._wp 
    1044893            END WHERE 
    1045894            ! 
     
    1050899            ! seaice salinity balancing (to add) 
    1051900#endif 
    1052   
     901            ! 
    1053902#if defined key_cice && defined key_asminc 
    1054903            ! Sea-ice : CICE case. Pass ice increment tendency into CICE 
    1055904           ndaice_da(:,:) = seaice_bkginc(:,:) / rdt 
    1056905#endif 
    1057            IF ( .NOT. PRESENT(kindic) ) THEN 
    1058               DEALLOCATE( seaice_bkginc ) 
    1059            END IF 
    1060  
     906            IF ( .NOT. PRESENT(kindic) ) THEN 
     907               DEALLOCATE( seaice_bkginc ) 
     908            END IF 
     909            ! 
    1061910         ELSE 
    1062  
     911            ! 
    1063912#if defined key_cice && defined key_asminc 
    1064             ! Sea-ice : CICE case. Zero ice increment tendency into CICE  
    1065             ndaice_da(:,:) = 0.0_wp 
    1066 #endif 
    1067           
     913            ndaice_da(:,:) = 0._wp     ! Sea-ice : CICE case. Zero ice increment tendency into CICE 
     914 
     915#endif 
     916            ! 
    1068917         ENDIF 
    1069918 
     
    1142991! 
    1143992!#endif 
    1144  
     993         ! 
    1145994      ENDIF 
    1146  
     995      ! 
    1147996   END SUBROUTINE seaice_asm_inc 
    1148997    
Note: See TracChangeset for help on using the changeset viewer.