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 6225 for branches/2014/dev_r4704_NOC5_MPP_BDY_UPDATE/NEMOGCM/NEMO/OPA_SRC/ASM/asminc.F90 – NEMO

Ignore:
Timestamp:
2016-01-08T10:35:19+01:00 (8 years ago)
Author:
jamesharle
Message:

Update MPP_BDY_UPDATE branch to be consistent with head of trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2014/dev_r4704_NOC5_MPP_BDY_UPDATE/NEMOGCM/NEMO/OPA_SRC/ASM/asminc.F90

    r4624 r6225  
    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 
     
    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) 
     
    109106      !! ** Action  :  
    110107      !!---------------------------------------------------------------------- 
    111       INTEGER :: ji, jj, jk 
    112       INTEGER :: jt 
    113       INTEGER :: imid 
    114       INTEGER :: inum 
     108      INTEGER :: ji, jj, jk, jt  ! dummy loop indices 
     109      INTEGER :: imid, inum      ! local integers 
     110      INTEGER :: ios             ! Local integer output status for namelist read 
    115111      INTEGER :: iiauper         ! Number of time steps in the IAU period 
    116112      INTEGER :: icycper         ! Number of time steps in the cycle 
    117       INTEGER :: iitend_date     ! Date YYYYMMDD of final time step 
    118       INTEGER :: iitbkg_date     ! Date YYYYMMDD of background time step for Jb term 
    119       INTEGER :: iitdin_date     ! Date YYYYMMDD of background time step for DI 
    120       INTEGER :: iitiaustr_date  ! Date YYYYMMDD of IAU interval start time step 
    121       INTEGER :: iitiaufin_date  ! Date YYYYMMDD of IAU interval final time step 
    122       INTEGER :: ios             ! Local integer output status for namelist read 
     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 
    123118 
    124119      REAL(wp) :: znorm        ! Normalization factor for IAU weights 
    125       REAL(wp) :: ztotwgt      ! Value of time-integrated IAU weights  
    126                                ! (should be equal to one) 
     120      REAL(wp) :: ztotwgt      ! Value of time-integrated IAU weights (should be equal to one) 
    127121      REAL(wp) :: z_inc_dateb  ! Start date of interval on which increment is valid 
    128122      REAL(wp) :: z_inc_datef  ! End date of interval on which increment is valid 
    129123      REAL(wp) :: zdate_bkg    ! Date in background state file for DI 
    130124      REAL(wp) :: zdate_inc    ! Time axis in increments file 
    131  
    132       REAL(wp), POINTER, DIMENSION(:,:) :: hdiv 
     125      ! 
     126      REAL(wp), POINTER, DIMENSION(:,:) ::   hdiv   ! 2D workspace 
    133127      !! 
    134128      NAMELIST/nam_asminc/ ln_bkgwri,                                      & 
     
    136130         &                 ln_asmdin, ln_asmiau,                           & 
    137131         &                 nitbkg, nitdin, nitiaustr, nitiaufin, niaufn,   & 
    138          &                 ln_salfix, salfixmin,                & 
    139          &                 nn_divdmp 
     132         &                 ln_salfix, salfixmin, nn_divdmp 
    140133      !!---------------------------------------------------------------------- 
    141134 
     
    143136      ! Read Namelist nam_asminc : assimilation increment interface 
    144137      !----------------------------------------------------------------------- 
    145  
    146       ln_seaiceinc = .FALSE. 
     138      ln_seaiceinc   = .FALSE. 
    147139      ln_temnofreeze = .FALSE. 
    148140 
     
    187179 
    188180      ! Date of final time step 
    189       CALL calc_date( nit000, nitend, ndate0, iitend_date ) 
     181      CALL calc_date( nitend, ditend_date ) 
    190182 
    191183      ! Background time for Jb referenced to ndate0 
    192       CALL calc_date( nit000, nitbkg_r, ndate0, iitbkg_date ) 
     184      CALL calc_date( nitbkg_r, ditbkg_date ) 
    193185 
    194186      ! Background time for DI referenced to ndate0 
    195       CALL calc_date( nit000, nitdin_r, ndate0, iitdin_date ) 
     187      CALL calc_date( nitdin_r, ditdin_date ) 
    196188 
    197189      ! IAU start time referenced to ndate0 
    198       CALL calc_date( nit000, nitiaustr_r, ndate0, iitiaustr_date ) 
     190      CALL calc_date( nitiaustr_r, ditiaustr_date ) 
    199191 
    200192      ! IAU end time referenced to ndate0 
    201       CALL calc_date( nit000, nitiaufin_r, ndate0, iitiaufin_date ) 
     193      CALL calc_date( nitiaufin_r, ditiaufin_date ) 
    202194 
    203195      IF(lwp) THEN 
     
    215207         WRITE(numout,*) '       ndastp         = ', ndastp 
    216208         WRITE(numout,*) '       ndate0         = ', ndate0 
    217          WRITE(numout,*) '       iitend_date    = ', iitend_date 
    218          WRITE(numout,*) '       iitbkg_date    = ', iitbkg_date 
    219          WRITE(numout,*) '       iitdin_date    = ', iitdin_date 
    220          WRITE(numout,*) '       iitiaustr_date = ', iitiaustr_date 
    221          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 
    222215      ENDIF 
    223216 
    224       IF ( nacc /= 0 ) & 
    225          & CALL ctl_stop( ' nacc /= 0 and key_asminc :',  & 
    226          &                ' Assimilation increments have only been implemented', & 
    227          &                ' for synchronous time stepping' ) 
    228217 
    229218      IF ( ( ln_asmdin ).AND.( ln_asmiau ) )   & 
     
    236225         &                ' but ln_asmdin and ln_asmiau are both set to .false. :', & 
    237226         &                ' Inconsistent options') 
    238  
    239       IF ( ( ln_bkgwri ).AND.( ( ln_asmdin ).OR.( ln_asmiau ) ) )  & 
    240          & CALL ctl_stop( ' ln_bkgwri and either ln_asmdin or ln_asmiau are set to .true.:', & 
    241          &                ' The background state must be written before applying the increments') 
    242227 
    243228      IF ( ( niaufn /= 0 ).AND.( niaufn /= 1 ) ) & 
     
    381366            WRITE(numout,*)  
    382367            WRITE(numout,*) 'asm_inc_init : Assimilation increments valid ', & 
    383                &            ' between dates ', NINT( z_inc_dateb ),' and ',  & 
    384                &            NINT( z_inc_datef ) 
     368               &            ' between dates ', z_inc_dateb,' and ',  & 
     369               &            z_inc_datef 
    385370            WRITE(numout,*) '~~~~~~~~~~~~' 
    386371         ENDIF 
    387372 
    388          IF (     ( NINT( z_inc_dateb ) < ndastp      ) & 
    389             & .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 ) ) & 
    390375            & CALL ctl_warn( ' Validity time of assimilation increments is ', & 
    391376            &                ' outside the assimilation interval' ) 
    392377 
    393          IF ( ( ln_asmdin ).AND.( NINT( zdate_inc ) /= iitdin_date ) ) & 
     378         IF ( ( ln_asmdin ).AND.( zdate_inc /= ditdin_date ) ) & 
    394379            & CALL ctl_warn( ' Validity time of assimilation increments does ', & 
    395380            &                ' not agree with Direct Initialization time' ) 
     
    446431 
    447432      IF ( ln_dyninc .AND. nn_divdmp > 0 ) THEN 
    448  
    449          CALL wrk_alloc(jpi,jpj,hdiv)  
    450  
    451          DO  jt = 1, nn_divdmp 
    452  
    453             DO jk = 1, jpkm1 
    454  
     433         ! 
     434         CALL wrk_alloc( jpi,jpj,   hdiv )  
     435         ! 
     436         DO jt = 1, nn_divdmp 
     437            ! 
     438            DO jk = 1, jpkm1           ! hdiv = e1e1 * div 
    455439               hdiv(:,:) = 0._wp 
    456  
    457440               DO jj = 2, jpjm1 
    458441                  DO ji = fs_2, fs_jpim1   ! vector opt. 
    459                      hdiv(ji,jj) =   & 
    460                         (  e2u(ji  ,jj  ) * fse3u(ji  ,jj  ,jk) * u_bkginc(ji  ,jj  ,jk)     & 
    461                          - e2u(ji-1,jj  ) * fse3u(ji-1,jj  ,jk) * u_bkginc(ji-1,jj  ,jk)     & 
    462                          + e1v(ji  ,jj  ) * fse3v(ji  ,jj  ,jk) * v_bkginc(ji  ,jj  ,jk)     & 
    463                          - e1v(ji  ,jj-1) * fse3v(ji  ,jj-1,jk) * v_bkginc(ji  ,jj-1,jk)  )  & 
    464                          / ( 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) 
    465446                  END DO 
    466447               END DO 
    467  
    468448               CALL lbc_lnk( hdiv, 'T', 1. )   ! lateral boundary cond. (no sign change) 
    469  
     449               ! 
    470450               DO jj = 2, jpjm1 
    471451                  DO ji = fs_2, fs_jpim1   ! vector opt. 
    472                      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)   & 
    473                                                                         - e1t(ji  ,jj)*e2t(ji  ,jj) * hdiv(ji  ,jj) ) & 
    474                                                                       / e1u(ji,jj) * umask(ji,jj,jk)  
    475                      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)   & 
    476                                                                         - e1t(ji,jj  )*e2t(ji,jj  ) * hdiv(ji,jj  ) ) & 
    477                                                                       / 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)  
    478456                  END DO 
    479457               END DO 
    480  
    481458            END DO 
    482  
     459            ! 
    483460         END DO 
    484  
    485          CALL wrk_dealloc(jpi,jpj,hdiv)  
    486  
     461         ! 
     462         CALL wrk_dealloc( jpi,jpj,   hdiv )  
     463         ! 
    487464      ENDIF 
    488  
    489  
    490465 
    491466      !----------------------------------------------------------------------- 
     
    494469 
    495470      IF ( ln_asmdin ) THEN 
    496  
     471         ! 
    497472         ALLOCATE( t_bkg(jpi,jpj,jpk) ) 
    498473         ALLOCATE( s_bkg(jpi,jpj,jpk) ) 
     
    500475         ALLOCATE( v_bkg(jpi,jpj,jpk) ) 
    501476         ALLOCATE( ssh_bkg(jpi,jpj)   ) 
    502  
    503          t_bkg(:,:,:) = 0.0 
    504          s_bkg(:,:,:) = 0.0 
    505          u_bkg(:,:,:) = 0.0 
    506          v_bkg(:,:,:) = 0.0 
    507          ssh_bkg(:,:) = 0.0 
    508  
     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         ! 
    509484         !-------------------------------------------------------------------- 
    510485         ! Read from file the background state at analysis time 
    511486         !-------------------------------------------------------------------- 
    512  
     487         ! 
    513488         CALL iom_open( c_asmdin, inum ) 
    514  
     489         ! 
    515490         CALL iom_get( inum, 'rdastp', zdate_bkg )  
    516          
     491         ! 
    517492         IF(lwp) THEN 
    518493            WRITE(numout,*)  
    519494            WRITE(numout,*) 'asm_inc_init : Assimilation background state valid at : ', & 
    520                &  NINT( zdate_bkg ) 
     495               &  zdate_bkg 
    521496            WRITE(numout,*) '~~~~~~~~~~~~' 
    522497         ENDIF 
    523  
    524          IF ( NINT( zdate_bkg ) /= iitdin_date ) & 
     498         ! 
     499         IF ( zdate_bkg /= ditdin_date ) & 
    525500            & CALL ctl_warn( ' Validity time of assimilation background state does', & 
    526501            &                ' not agree with Direct Initialization time' ) 
    527  
     502         ! 
    528503         IF ( ln_trainc ) THEN    
    529504            CALL iom_get( inum, jpdom_autoglo, 'tn', t_bkg ) 
     
    532507            s_bkg(:,:,:) = s_bkg(:,:,:) * tmask(:,:,:) 
    533508         ENDIF 
    534  
     509         ! 
    535510         IF ( ln_dyninc ) THEN    
    536511            CALL iom_get( inum, jpdom_autoglo, 'un', u_bkg ) 
     
    539514            v_bkg(:,:,:) = v_bkg(:,:,:) * vmask(:,:,:) 
    540515         ENDIF 
    541          
     516         ! 
    542517         IF ( ln_sshinc ) THEN 
    543518            CALL iom_get( inum, jpdom_autoglo, 'sshn', ssh_bkg ) 
    544519            ssh_bkg(:,:) = ssh_bkg(:,:) * tmask(:,:,1) 
    545520         ENDIF 
    546  
     521         ! 
    547522         CALL iom_close( inum ) 
    548  
     523         ! 
    549524      ENDIF 
    550525      ! 
    551526   END SUBROUTINE asm_inc_init 
    552  
    553  
    554    SUBROUTINE calc_date( kit000, kt, kdate0, kdate ) 
    555       !!---------------------------------------------------------------------- 
    556       !!                    ***  ROUTINE calc_date  *** 
    557       !!           
    558       !! ** Purpose : Compute the calendar date YYYYMMDD at a given time step. 
    559       !! 
    560       !! ** Method  : Compute the calendar date YYYYMMDD at a given time step. 
    561       !! 
    562       !! ** Action  :  
    563       !!---------------------------------------------------------------------- 
    564       INTEGER, INTENT(IN) :: kit000  ! Initial time step 
    565       INTEGER, INTENT(IN) :: kt      ! Current time step referenced to kit000 
    566       INTEGER, INTENT(IN) :: kdate0  ! Initial date 
    567       INTEGER, INTENT(OUT) :: kdate  ! Current date reference to kdate0 
    568       ! 
    569       INTEGER :: iyea0    ! Initial year 
    570       INTEGER :: imon0    ! Initial month 
    571       INTEGER :: iday0    ! Initial day 
    572       INTEGER :: iyea     ! Current year 
    573       INTEGER :: imon     ! Current month 
    574       INTEGER :: iday     ! Current day 
    575       INTEGER :: idaystp  ! Number of days between initial and current date 
    576       INTEGER :: idaycnt  ! Day counter 
    577  
    578       INTEGER, DIMENSION(12) ::   imonth_len    !: length in days of the months of the current year 
    579  
    580       !----------------------------------------------------------------------- 
    581       ! Compute the calendar date YYYYMMDD 
    582       !----------------------------------------------------------------------- 
    583  
    584       ! Initial date 
    585       iyea0 =   kdate0 / 10000 
    586       imon0 = ( kdate0 - ( iyea0 * 10000 ) ) / 100 
    587       iday0 =   kdate0 - ( iyea0 * 10000 ) - ( imon0 * 100 )  
    588  
    589       ! Check that kt >= kit000 - 1 
    590       IF ( kt < kit000 - 1 ) CALL ctl_stop( ' kt must be >= kit000 - 1') 
    591  
    592       ! If kt = kit000 - 1 then set the date to the restart date 
    593       IF ( kt == kit000 - 1 ) THEN 
    594  
    595          kdate = ndastp 
    596          RETURN 
    597  
    598       ENDIF 
    599  
    600       ! Compute the number of days from the initial date 
    601       idaystp = INT( REAL( kt - kit000 ) * rdt / 86400. ) 
    602     
    603       iday    = iday0 
    604       imon    = imon0 
    605       iyea    = iyea0 
    606       idaycnt = 0 
    607  
    608       CALL calc_month_len( iyea, imonth_len ) 
    609  
    610       DO WHILE ( idaycnt < idaystp ) 
    611          iday = iday + 1 
    612          IF ( iday > imonth_len(imon) )  THEN 
    613             iday = 1 
    614             imon = imon + 1 
    615          ENDIF 
    616          IF ( imon > 12 ) THEN 
    617             imon = 1 
    618             iyea = iyea + 1 
    619             CALL calc_month_len( iyea, imonth_len )  ! update month lengths 
    620          ENDIF                  
    621          idaycnt = idaycnt + 1 
    622       END DO 
    623       ! 
    624       kdate = iyea * 10000 + imon * 100 + iday 
    625       ! 
    626    END SUBROUTINE 
    627  
    628  
    629    SUBROUTINE calc_month_len( iyear, imonth_len ) 
    630       !!---------------------------------------------------------------------- 
    631       !!                    ***  ROUTINE calc_month_len  *** 
    632       !!           
    633       !! ** Purpose : Compute the number of days in a months given a year. 
    634       !! 
    635       !! ** Method  :  
    636       !!---------------------------------------------------------------------- 
    637       INTEGER, DIMENSION(12) ::   imonth_len    !: length in days of the months of the current year 
    638       INTEGER :: iyear         !: year 
    639       !!---------------------------------------------------------------------- 
    640       ! 
    641       ! length of the month of the current year (from nleapy, read in namelist) 
    642       IF ( nleapy < 2 ) THEN  
    643          imonth_len(:) = (/ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 /) 
    644          IF ( nleapy == 1 ) THEN   ! we are using calendar with leap years 
    645             IF ( MOD(iyear, 4) == 0 .AND. ( MOD(iyear, 400) == 0 .OR. MOD(iyear, 100) /= 0 ) ) THEN 
    646                imonth_len(2) = 29 
    647             ENDIF 
    648          ENDIF 
    649       ELSE 
    650          imonth_len(:) = nleapy   ! all months with nleapy days per year 
    651       ENDIF 
    652       ! 
    653    END SUBROUTINE 
    654  
    655  
    656527   SUBROUTINE tra_asm_inc( kt ) 
    657528      !!---------------------------------------------------------------------- 
     
    664535      !! ** Action  :  
    665536      !!---------------------------------------------------------------------- 
    666       INTEGER, INTENT(IN) :: kt               ! Current time step 
    667       ! 
    668       INTEGER :: ji,jj,jk 
    669       INTEGER :: it 
     537      INTEGER, INTENT(IN) ::   kt   ! Current time step 
     538      ! 
     539      INTEGER  :: ji, jj, jk 
     540      INTEGER  :: it 
    670541      REAL(wp) :: zincwgt  ! IAU weight for current time step 
    671542      REAL (wp), DIMENSION(jpi,jpj,jpk) :: fzptnz ! 3d freezing point values 
    672543      !!---------------------------------------------------------------------- 
    673  
     544      ! 
    674545      ! freezing point calculation taken from oc_fz_pt (but calculated for all depths)  
    675546      ! used to prevent the applied increments taking the temperature below the local freezing point  
    676  
    677       DO jk=1, jpkm1 
    678          fzptnz (:,:,jk) = tfreez( tsn(:,:,jk,jp_sal), fsdept(:,:,jk) ) 
    679       ENDDO 
    680  
    681       IF ( ln_asmiau ) THEN 
    682  
    683          !-------------------------------------------------------------------- 
    684          ! Incremental Analysis Updating 
    685          !-------------------------------------------------------------------- 
    686  
     547      DO jk = 1, jpkm1 
     548        CALL eos_fzp( tsn(:,:,jk,jp_sal), fzptnz(:,:,jk), gdept_n(:,:,jk) ) 
     549      END DO 
     550         ! 
     551         !                             !-------------------------------------- 
     552      IF ( ln_asmiau ) THEN            ! Incremental Analysis Updating 
     553         !                             !-------------------------------------- 
     554         ! 
    687555         IF ( ( kt >= nitiaustr_r ).AND.( kt <= nitiaufin_r ) ) THEN 
    688  
     556            ! 
    689557            it = kt - nit000 + 1 
    690558            zincwgt = wgtiau(it) / rdt   ! IAU weight for the current time step 
    691  
     559            ! 
    692560            IF(lwp) THEN 
    693561               WRITE(numout,*)  
    694                WRITE(numout,*) 'tra_asm_inc : Tracer IAU at time step = ', & 
    695                   &  kt,' with IAU weight = ', wgtiau(it) 
     562               WRITE(numout,*) 'tra_asm_inc : Tracer IAU at time step = ', kt,' with IAU weight = ', wgtiau(it) 
    696563               WRITE(numout,*) '~~~~~~~~~~~~' 
    697564            ENDIF 
    698  
     565            ! 
    699566            ! Update the tracer tendencies 
    700567            DO jk = 1, jpkm1 
     
    719586               ENDIF 
    720587            END DO 
    721  
    722          ENDIF 
    723  
     588            ! 
     589         ENDIF 
     590         ! 
    724591         IF ( kt == nitiaufin_r + 1  ) THEN   ! For bias crcn to work 
    725592            DEALLOCATE( t_bkginc ) 
    726593            DEALLOCATE( s_bkginc ) 
    727594         ENDIF 
    728  
    729  
    730       ELSEIF ( ln_asmdin ) THEN 
    731  
    732          !-------------------------------------------------------------------- 
    733          ! Direct Initialization 
    734          !-------------------------------------------------------------------- 
    735              
     595         !                             !-------------------------------------- 
     596      ELSEIF ( ln_asmdin ) THEN        ! Direct Initialization 
     597         !                             !-------------------------------------- 
     598         !             
    736599         IF ( kt == nitdin_r ) THEN 
    737  
     600            ! 
    738601            neuler = 0  ! Force Euler forward step 
    739  
     602            ! 
    740603            ! Initialize the now fields with the background + increment 
    741604            IF (ln_temnofreeze) THEN 
    742605               ! Do not apply negative increments if the temperature will fall below freezing 
    743                WHERE(t_bkginc(:,:,:) > 0.0_wp .OR. & 
    744                   &   tsn(:,:,:,jp_tem) + t_bkginc(:,:,:) > fzptnz(:,:,:) )  
     606               WHERE( t_bkginc(:,:,:) > 0.0_wp .OR. tsn(:,:,:,jp_tem) + t_bkginc(:,:,:) > fzptnz(:,:,:) )  
    745607                  tsn(:,:,:,jp_tem) = t_bkg(:,:,:) + t_bkginc(:,:,:)    
    746608               END WHERE 
     
    751613               ! Do not apply negative increments if the salinity will fall below a specified 
    752614               ! minimum value salfixmin 
    753                WHERE(s_bkginc(:,:,:) > 0.0_wp .OR. & 
    754                   &   tsn(:,:,:,jp_sal) + s_bkginc(:,:,:) > salfixmin )  
     615               WHERE( s_bkginc(:,:,:) > 0.0_wp .OR. tsn(:,:,:,jp_sal) + s_bkginc(:,:,:) > salfixmin )  
    755616                  tsn(:,:,:,jp_sal) = s_bkg(:,:,:) + s_bkginc(:,:,:)    
    756617               END WHERE 
     
    759620            ENDIF 
    760621 
    761             tsb(:,:,:,:) = tsn(:,:,:,:)               ! Update before fields 
    762  
    763             CALL eos( tsb, rhd, rhop, gdept_0(:,:,:) )                ! Before potential and in situ densities 
    764           
    765             IF( ln_zps .AND. .NOT. lk_c1d ) & 
    766                &  CALL zps_hde( nit000, jpts, tsb, &  ! Partial steps: before horizontal derivative 
    767                &                gtsu, gtsv, rhd,   &  ! of T, S, rd at the bottom ocean level 
    768                &                gru , grv ) 
    769  
    770 #if defined key_zdfkpp 
    771             CALL eos( tsn, rhd, fsdept_n(:,:,:) )                      ! Compute rhd 
    772 #endif 
     622            tsb(:,:,:,:) = tsn(:,:,:,:)                 ! Update before fields 
     623 
     624            CALL eos( tsb, rhd, rhop, gdept_0(:,:,:) )  ! Before potential and in situ densities 
     625!!gm  fabien 
     626!            CALL eos( tsb, rhd, rhop )                ! Before potential and in situ densities 
     627!!gm 
     628 
     629            IF( ln_zps .AND. .NOT. lk_c1d .AND. .NOT. ln_isfcav)      & 
     630               &  CALL zps_hde    ( kt, jpts, tsb, gtsu, gtsv,        &  ! Partial steps: before horizontal gradient 
     631               &                              rhd, gru , grv          )  ! of t, s, rd at the last ocean level 
     632            IF( ln_zps .AND. .NOT. lk_c1d .AND.       ln_isfcav)      & 
     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 
    773635 
    774636            DEALLOCATE( t_bkginc ) 
     
    780642      ENDIF 
    781643      ! Perhaps the following call should be in step 
    782       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 
    783645      ! 
    784646   END SUBROUTINE tra_asm_inc 
     
    801663      REAL(wp) :: zincwgt  ! IAU weight for current time step 
    802664      !!---------------------------------------------------------------------- 
    803  
    804       IF ( ln_asmiau ) THEN 
    805  
    806          !-------------------------------------------------------------------- 
    807          ! Incremental Analysis Updating 
    808          !-------------------------------------------------------------------- 
    809  
     665      ! 
     666      !                          !-------------------------------------------- 
     667      IF ( ln_asmiau ) THEN      ! Incremental Analysis Updating 
     668         !                       !-------------------------------------------- 
     669         ! 
    810670         IF ( ( kt >= nitiaustr_r ).AND.( kt <= nitiaufin_r ) ) THEN 
    811  
     671            ! 
    812672            it = kt - nit000 + 1 
    813673            zincwgt = wgtiau(it) / rdt   ! IAU weight for the current time step 
    814  
     674            ! 
    815675            IF(lwp) THEN 
    816676               WRITE(numout,*)  
    817                WRITE(numout,*) 'dyn_asm_inc : Dynamics IAU at time step = ', & 
    818                   &  kt,' with IAU weight = ', wgtiau(it) 
     677               WRITE(numout,*) 'dyn_asm_inc : Dynamics IAU at time step = ', kt,' with IAU weight = ', wgtiau(it) 
    819678               WRITE(numout,*) '~~~~~~~~~~~~' 
    820679            ENDIF 
    821  
     680            ! 
    822681            ! Update the dynamic tendencies 
    823682            DO jk = 1, jpkm1 
     
    825684               va(:,:,jk) = va(:,:,jk) + v_bkginc(:,:,jk) * zincwgt 
    826685            END DO 
    827             
     686            ! 
    828687            IF ( kt == nitiaufin_r ) THEN 
    829688               DEALLOCATE( u_bkginc ) 
    830689               DEALLOCATE( v_bkginc ) 
    831690            ENDIF 
    832  
    833          ENDIF 
    834  
    835       ELSEIF ( ln_asmdin ) THEN  
    836  
    837          !-------------------------------------------------------------------- 
    838          ! Direct Initialization 
    839          !-------------------------------------------------------------------- 
    840           
     691            ! 
     692         ENDIF 
     693         !                          !----------------------------------------- 
     694      ELSEIF ( ln_asmdin ) THEN     ! Direct Initialization 
     695         !                          !----------------------------------------- 
     696         !          
    841697         IF ( kt == nitdin_r ) THEN 
    842  
     698            ! 
    843699            neuler = 0                    ! Force Euler forward step 
    844  
     700            ! 
    845701            ! Initialize the now fields with the background + increment 
    846702            un(:,:,:) = u_bkg(:,:,:) + u_bkginc(:,:,:) 
    847703            vn(:,:,:) = v_bkg(:,:,:) + v_bkginc(:,:,:)   
    848  
     704            ! 
    849705            ub(:,:,:) = un(:,:,:)         ! Update before fields 
    850706            vb(:,:,:) = vn(:,:,:) 
    851   
     707            ! 
    852708            DEALLOCATE( u_bkg    ) 
    853709            DEALLOCATE( v_bkg    ) 
     
    877733      REAL(wp) :: zincwgt  ! IAU weight for current time step 
    878734      !!---------------------------------------------------------------------- 
    879  
    880       IF ( ln_asmiau ) THEN 
    881  
    882          !-------------------------------------------------------------------- 
    883          ! Incremental Analysis Updating 
    884          !-------------------------------------------------------------------- 
    885  
     735      ! 
     736      !                             !----------------------------------------- 
     737      IF ( ln_asmiau ) THEN         ! Incremental Analysis Updating 
     738         !                          !----------------------------------------- 
     739         ! 
    886740         IF ( ( kt >= nitiaustr_r ).AND.( kt <= nitiaufin_r ) ) THEN 
    887  
     741            ! 
    888742            it = kt - nit000 + 1 
    889743            zincwgt = wgtiau(it) / rdt   ! IAU weight for the current time step 
    890  
     744            ! 
    891745            IF(lwp) THEN 
    892746               WRITE(numout,*)  
     
    895749               WRITE(numout,*) '~~~~~~~~~~~~' 
    896750            ENDIF 
    897  
     751            ! 
    898752            ! Save the tendency associated with the IAU weighted SSH increment 
    899753            ! (applied in dynspg.*) 
     
    904758               DEALLOCATE( ssh_bkginc ) 
    905759            ENDIF 
    906  
    907          ENDIF 
    908  
    909       ELSEIF ( ln_asmdin ) THEN 
    910  
    911          !-------------------------------------------------------------------- 
    912          ! Direct Initialization 
    913          !-------------------------------------------------------------------- 
    914  
     760            ! 
     761         ENDIF 
     762         !                          !----------------------------------------- 
     763      ELSEIF ( ln_asmdin ) THEN     ! Direct Initialization 
     764         !                          !----------------------------------------- 
     765         ! 
    915766         IF ( kt == nitdin_r ) THEN 
    916  
    917             neuler = 0                    ! Force Euler forward step 
    918  
    919             ! Initialize the now fields the background + increment 
    920             sshn(:,:) = ssh_bkg(:,:) + ssh_bkginc(:,:)   
    921  
    922             ! Update before fields 
    923             sshb(:,:) = sshn(:,:)          
    924  
    925             IF( lk_vvl ) THEN 
    926                DO jk = 1, jpk 
    927                   fse3t_b(:,:,jk) = fse3t_n(:,:,jk) 
    928                END DO 
    929             ENDIF 
    930  
     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            ! 
    931776            DEALLOCATE( ssh_bkg    ) 
    932777            DEALLOCATE( ssh_bkginc ) 
    933  
     778            ! 
    934779         ENDIF 
    935780         ! 
     
    950795      !! 
    951796      !!---------------------------------------------------------------------- 
    952       IMPLICIT NONE 
    953       ! 
    954       INTEGER, INTENT(in)           ::   kt   ! Current time step 
     797      INTEGER, INTENT(in)           ::   kt       ! Current time step 
    955798      INTEGER, INTENT(in), OPTIONAL ::   kindic   ! flag for disabling the deallocation 
    956799      ! 
     
    962805#endif 
    963806      !!---------------------------------------------------------------------- 
    964  
    965       IF ( ln_asmiau ) THEN 
    966  
    967          !-------------------------------------------------------------------- 
    968          ! Incremental Analysis Updating 
    969          !-------------------------------------------------------------------- 
    970  
     807      ! 
     808      !                             !----------------------------------------- 
     809      IF ( ln_asmiau ) THEN         ! Incremental Analysis Updating 
     810         !                          !----------------------------------------- 
     811         ! 
    971812         IF ( ( kt >= nitiaustr_r ).AND.( kt <= nitiaufin_r ) ) THEN 
    972  
     813            ! 
    973814            it = kt - nit000 + 1 
    974815            zincwgt = wgtiau(it)      ! IAU weight for the current time step  
    975816            ! note this is not a tendency so should not be divided by rdt (as with the tracer and other increments) 
    976  
     817            ! 
    977818            IF(lwp) THEN 
    978819               WRITE(numout,*)  
    979                WRITE(numout,*) 'seaice_asm_inc : sea ice conc IAU at time step = ', & 
    980                   &  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) 
    981821               WRITE(numout,*) '~~~~~~~~~~~~' 
    982822            ENDIF 
    983  
     823            ! 
    984824            ! Sea-ice : LIM-3 case (to add) 
    985  
     825            ! 
    986826#if defined key_lim2 
    987827            ! Sea-ice : LIM-2 case 
     
    1021861 
    1022862#if defined key_cice && defined key_asminc 
    1023             ! Sea-ice : CICE case. Zero ice increment tendency into CICE 
    1024             ndaice_da(:,:) = 0.0_wp 
    1025 #endif 
    1026  
    1027          ENDIF 
    1028  
    1029       ELSEIF ( ln_asmdin ) THEN 
    1030  
    1031          !-------------------------------------------------------------------- 
    1032          ! Direct Initialization 
    1033          !-------------------------------------------------------------------- 
    1034  
     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         ! 
    1035871         IF ( kt == nitdin_r ) THEN 
    1036  
     872            ! 
    1037873            neuler = 0                    ! Force Euler forward step 
    1038  
     874            ! 
    1039875            ! Sea-ice : LIM-3 case (to add) 
    1040  
     876            ! 
    1041877#if defined key_lim2 
    1042878            ! Sea-ice : LIM-2 case. 
     
    1054890               zhicifinc(:,:) = (zhicifmin - hicif(:,:)) * zincwgt     
    1055891            ELSEWHERE 
    1056                zhicifinc(:,:) = 0.0_wp 
     892               zhicifinc(:,:) = 0._wp 
    1057893            END WHERE 
    1058894            ! 
     
    1063899            ! seaice salinity balancing (to add) 
    1064900#endif 
    1065   
     901            ! 
    1066902#if defined key_cice && defined key_asminc 
    1067903            ! Sea-ice : CICE case. Pass ice increment tendency into CICE 
    1068904           ndaice_da(:,:) = seaice_bkginc(:,:) / rdt 
    1069905#endif 
    1070            IF ( .NOT. PRESENT(kindic) ) THEN 
    1071               DEALLOCATE( seaice_bkginc ) 
    1072            END IF 
    1073  
     906            IF ( .NOT. PRESENT(kindic) ) THEN 
     907               DEALLOCATE( seaice_bkginc ) 
     908            END IF 
     909            ! 
    1074910         ELSE 
    1075  
     911            ! 
    1076912#if defined key_cice && defined key_asminc 
    1077             ! Sea-ice : CICE case. Zero ice increment tendency into CICE  
    1078             ndaice_da(:,:) = 0.0_wp 
    1079 #endif 
    1080           
     913            ndaice_da(:,:) = 0._wp     ! Sea-ice : CICE case. Zero ice increment tendency into CICE 
     914 
     915#endif 
     916            ! 
    1081917         ENDIF 
    1082918 
     
    1155991! 
    1156992!#endif 
    1157  
     993         ! 
    1158994      ENDIF 
    1159  
     995      ! 
    1160996   END SUBROUTINE seaice_asm_inc 
    1161997    
Note: See TracChangeset for help on using the changeset viewer.