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 6140 for trunk/NEMOGCM/NEMO/OPA_SRC/ASM/asminc.F90 – NEMO

Ignore:
Timestamp:
2015-12-21T12:35:23+01:00 (8 years ago)
Author:
timgraham
Message:

Merge of branches/2015/dev_merge_2015 back into trunk. Merge excludes NEMOGCM/TOOLS/OBSTOOLS/ for now due to issues with the change of file type. Will sort these manually with further commits.

Branch merged as follows:
In the working copy of branch ran:
svn merge svn+ssh://forge.ipsl.jussieu.fr/ipsl/forge/projets/nemo/svn/trunk@HEAD
Small conflicts due to bug fixes applied to trunk since the dev_merge_2015 was copied. Bug fixes were applied to the branch as well so these were easy to resolve.
Branch committed at this stage

In working copy run:
svn switch svn+ssh://forge.ipsl.jussieu.fr/ipsl/forge/projets/nemo/svn/trunk
to switch working copy

Run:
svn merge --reintegrate svn+ssh://forge.ipsl.jussieu.fr/ipsl/forge/projets/nemo/svn/branches/2015/dev_merge_2015
to merge the branch into the trunk and then commit - no conflicts at this stage.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/NEMOGCM/NEMO/OPA_SRC/ASM/asminc.F90

    r5836 r6140  
    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 
    1517   !!---------------------------------------------------------------------- 
    1618   !!   asm_inc_init   : Initialize the increment arrays and IAU weights 
    17    !!   calc_date      : Compute the calendar date YYYYMMDD on a given step 
    1819   !!   tra_asm_inc    : Apply the tracer (T and S) increments 
    1920   !!   dyn_asm_inc    : Apply the dynamic (u and v) increments 
     
    3839#endif 
    3940   USE sbc_oce          ! Surface boundary condition variables. 
     41   USE diaobs, ONLY: calc_date     ! Compute the calendar date on a given step 
    4042 
    4143   IMPLICIT NONE 
     
    4345    
    4446   PUBLIC   asm_inc_init   !: Initialize the increment arrays and IAU weights 
    45    PUBLIC   calc_date      !: Compute the calendar date YYYYMMDD on a given step 
    4647   PUBLIC   tra_asm_inc    !: Apply the tracer (T and S) increments 
    4748   PUBLIC   dyn_asm_inc    !: Apply the dynamic (u and v) increments 
     
    8788 
    8889   !! * Substitutions 
    89 #  include "domzgr_substitute.h90" 
    9090#  include "vectopt_loop_substitute.h90" 
    9191   !!---------------------------------------------------------------------- 
    92    !! NEMO/OPA 3.3 , NEMO Consortium (2010) 
     92   !! NEMO/OPA 3.7 , NEMO Consortium (2015) 
    9393   !! $Id$ 
    9494   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt) 
     
    111111      INTEGER :: iiauper         ! Number of time steps in the IAU period 
    112112      INTEGER :: icycper         ! Number of time steps in the cycle 
    113       INTEGER :: iitend_date     ! Date YYYYMMDD of final time step 
    114       INTEGER :: iitbkg_date     ! Date YYYYMMDD of background time step for Jb term 
    115       INTEGER :: iitdin_date     ! Date YYYYMMDD of background time step for DI 
    116       INTEGER :: iitiaustr_date  ! Date YYYYMMDD of IAU interval start time step 
    117       INTEGER :: iitiaufin_date  ! Date YYYYMMDD of IAU interval final time step 
    118       ! 
     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 
    119119      REAL(wp) :: znorm        ! Normalization factor for IAU weights 
    120120      REAL(wp) :: ztotwgt      ! Value of time-integrated IAU weights (should be equal to one) 
     
    178178      icycper = nitend      - nit000      + 1  ! Cycle interval length 
    179179 
    180       CALL calc_date( nit000, nitend     , ndate0, iitend_date    )     ! Date of final time step 
    181       CALL calc_date( nit000, nitbkg_r   , ndate0, iitbkg_date    )     ! Background time for Jb referenced to ndate0 
    182       CALL calc_date( nit000, nitdin_r   , ndate0, iitdin_date    )     ! Background time for DI referenced to ndate0 
    183       CALL calc_date( nit000, nitiaustr_r, ndate0, iitiaustr_date )     ! IAU start time referenced to ndate0 
    184       CALL calc_date( nit000, nitiaufin_r, ndate0, iitiaufin_date )     ! IAU end time referenced to ndate0 
    185       ! 
     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 
    186195      IF(lwp) THEN 
    187196         WRITE(numout,*) 
     
    198207         WRITE(numout,*) '       ndastp         = ', ndastp 
    199208         WRITE(numout,*) '       ndate0         = ', ndate0 
    200          WRITE(numout,*) '       iitend_date    = ', iitend_date 
    201          WRITE(numout,*) '       iitbkg_date    = ', iitbkg_date 
    202          WRITE(numout,*) '       iitdin_date    = ', iitdin_date 
    203          WRITE(numout,*) '       iitiaustr_date = ', iitiaustr_date 
    204          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 
    205215      ENDIF 
    206216 
    207       IF ( nacc /= 0 ) & 
    208          & CALL ctl_stop( ' nacc /= 0 and key_asminc :',  & 
    209          &                ' Assimilation increments have only been implemented', & 
    210          &                ' for synchronous time stepping' ) 
    211217 
    212218      IF ( ( ln_asmdin ).AND.( ln_asmiau ) )   & 
     
    360366            WRITE(numout,*)  
    361367            WRITE(numout,*) 'asm_inc_init : Assimilation increments valid ', & 
    362                &            ' between dates ', NINT( z_inc_dateb ),' and ',  & 
    363                &            NINT( z_inc_datef ) 
     368               &            ' between dates ', z_inc_dateb,' and ',  & 
     369               &            z_inc_datef 
    364370            WRITE(numout,*) '~~~~~~~~~~~~' 
    365371         ENDIF 
    366372 
    367          IF (     ( NINT( z_inc_dateb ) < ndastp      ) & 
    368             & .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 ) ) & 
    369375            & CALL ctl_warn( ' Validity time of assimilation increments is ', & 
    370376            &                ' outside the assimilation interval' ) 
    371377 
    372          IF ( ( ln_asmdin ).AND.( NINT( zdate_inc ) /= iitdin_date ) ) & 
     378         IF ( ( ln_asmdin ).AND.( zdate_inc /= ditdin_date ) ) & 
    373379            & CALL ctl_warn( ' Validity time of assimilation increments does ', & 
    374380            &                ' not agree with Direct Initialization time' ) 
     
    430436         DO jt = 1, nn_divdmp 
    431437            ! 
    432             DO jk = 1, jpkm1 
     438            DO jk = 1, jpkm1           ! hdiv = e1e1 * div 
    433439               hdiv(:,:) = 0._wp 
    434440               DO jj = 2, jpjm1 
    435441                  DO ji = fs_2, fs_jpim1   ! vector opt. 
    436                      hdiv(ji,jj) =   & 
    437                         (  e2u(ji  ,jj  ) * fse3u(ji  ,jj  ,jk) * u_bkginc(ji  ,jj  ,jk)     & 
    438                          - e2u(ji-1,jj  ) * fse3u(ji-1,jj  ,jk) * u_bkginc(ji-1,jj  ,jk)     & 
    439                          + e1v(ji  ,jj  ) * fse3v(ji  ,jj  ,jk) * v_bkginc(ji  ,jj  ,jk)     & 
    440                          - e1v(ji  ,jj-1) * fse3v(ji  ,jj-1,jk) * v_bkginc(ji  ,jj-1,jk)  )  & 
    441                          / ( e1e2t(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) 
    442446                  END DO 
    443447               END DO 
     
    446450               DO jj = 2, jpjm1 
    447451                  DO ji = fs_2, fs_jpim1   ! vector opt. 
    448                      u_bkginc(ji,jj,jk) = u_bkginc(ji,jj,jk) + 0.2_wp * ( e1e2t(ji+1,jj) * hdiv(ji+1,jj)   & 
    449                         &                                               - e1e2t(ji  ,jj) * hdiv(ji  ,jj) ) & 
    450                         &                                             * r1_e1u(ji,jj) * umask(ji,jj,jk)  
    451                      v_bkginc(ji,jj,jk) = v_bkginc(ji,jj,jk) + 0.2_wp * ( e1e2t(ji,jj+1) * hdiv(ji,jj+1)   & 
    452                         &                                               - e1e2t(ji,jj  ) * hdiv(ji,jj  ) ) & 
    453                         &                                             * r1_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)  
    454456                  END DO 
    455457               END DO 
     
    490492         IF(lwp) THEN 
    491493            WRITE(numout,*)  
    492             WRITE(numout,*) 'asm_inc_init : Assimilation background state valid at : ', NINT( zdate_bkg ) 
     494            WRITE(numout,*) 'asm_inc_init : Assimilation background state valid at : ', & 
     495               &  zdate_bkg 
    493496            WRITE(numout,*) '~~~~~~~~~~~~' 
    494497         ENDIF 
    495498         ! 
    496          IF ( NINT( zdate_bkg ) /= iitdin_date ) & 
     499         IF ( zdate_bkg /= ditdin_date ) & 
    497500            & CALL ctl_warn( ' Validity time of assimilation background state does', & 
    498501            &                ' not agree with Direct Initialization time' ) 
     
    522525      ! 
    523526   END SUBROUTINE asm_inc_init 
    524  
    525  
    526    SUBROUTINE calc_date( kit000, kt, kdate0, kdate ) 
    527       !!---------------------------------------------------------------------- 
    528       !!                    ***  ROUTINE calc_date  *** 
    529       !!           
    530       !! ** Purpose : Compute the calendar date YYYYMMDD at a given time step. 
    531       !! 
    532       !! ** Method  : Compute the calendar date YYYYMMDD at a given time step. 
    533       !! 
    534       !! ** Action  :  
    535       !!---------------------------------------------------------------------- 
    536       INTEGER, INTENT(IN) :: kit000  ! Initial time step 
    537       INTEGER, INTENT(IN) :: kt      ! Current time step referenced to kit000 
    538       INTEGER, INTENT(IN) :: kdate0  ! Initial date 
    539       INTEGER, INTENT(OUT) :: kdate  ! Current date reference to kdate0 
    540       ! 
    541       INTEGER :: iyea0    ! Initial year 
    542       INTEGER :: imon0    ! Initial month 
    543       INTEGER :: iday0    ! Initial day 
    544       INTEGER :: iyea     ! Current year 
    545       INTEGER :: imon     ! Current month 
    546       INTEGER :: iday     ! Current day 
    547       INTEGER :: idaystp  ! Number of days between initial and current date 
    548       INTEGER :: idaycnt  ! Day counter 
    549  
    550       INTEGER, DIMENSION(12) ::   imonth_len    !: length in days of the months of the current year 
    551  
    552       !----------------------------------------------------------------------- 
    553       ! Compute the calendar date YYYYMMDD 
    554       !----------------------------------------------------------------------- 
    555  
    556       ! Initial date 
    557       iyea0 =   kdate0 / 10000 
    558       imon0 = ( kdate0 - ( iyea0 * 10000 ) ) / 100 
    559       iday0 =   kdate0 - ( iyea0 * 10000 ) - ( imon0 * 100 )  
    560  
    561       ! Check that kt >= kit000 - 1 
    562       IF ( kt < kit000 - 1 ) CALL ctl_stop( ' kt must be >= kit000 - 1') 
    563  
    564       ! If kt = kit000 - 1 then set the date to the restart date 
    565       IF ( kt == kit000 - 1 ) THEN 
    566          kdate = ndastp 
    567          RETURN 
    568       ENDIF 
    569  
    570       ! Compute the number of days from the initial date 
    571       idaystp = INT( REAL( kt - kit000 ) * rdt / 86400. ) 
    572     
    573       iday    = iday0 
    574       imon    = imon0 
    575       iyea    = iyea0 
    576       idaycnt = 0 
    577  
    578       CALL calc_month_len( iyea, imonth_len ) 
    579  
    580       DO WHILE ( idaycnt < idaystp ) 
    581          iday = iday + 1 
    582          IF ( iday > imonth_len(imon) )  THEN 
    583             iday = 1 
    584             imon = imon + 1 
    585          ENDIF 
    586          IF ( imon > 12 ) THEN 
    587             imon = 1 
    588             iyea = iyea + 1 
    589             CALL calc_month_len( iyea, imonth_len )  ! update month lengths 
    590          ENDIF                  
    591          idaycnt = idaycnt + 1 
    592       END DO 
    593       ! 
    594       kdate = iyea * 10000 + imon * 100 + iday 
    595       ! 
    596    END SUBROUTINE 
    597  
    598  
    599    SUBROUTINE calc_month_len( iyear, imonth_len ) 
    600       !!---------------------------------------------------------------------- 
    601       !!                    ***  ROUTINE calc_month_len  *** 
    602       !!           
    603       !! ** Purpose : Compute the number of days in a months given a year. 
    604       !! 
    605       !! ** Method  :  
    606       !!---------------------------------------------------------------------- 
    607       INTEGER, DIMENSION(12) ::   imonth_len    !: length in days of the months of the current year 
    608       INTEGER :: iyear         !: year 
    609       !!---------------------------------------------------------------------- 
    610       ! 
    611       ! length of the month of the current year (from nleapy, read in namelist) 
    612       IF ( nleapy < 2 ) THEN  
    613          imonth_len(:) = (/ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 /) 
    614          IF ( nleapy == 1 ) THEN   ! we are using calendar with leap years 
    615             IF ( MOD(iyear, 4) == 0 .AND. ( MOD(iyear, 400) == 0 .OR. MOD(iyear, 100) /= 0 ) ) THEN 
    616                imonth_len(2) = 29 
    617             ENDIF 
    618          ENDIF 
    619       ELSE 
    620          imonth_len(:) = nleapy   ! all months with nleapy days per year 
    621       ENDIF 
    622       ! 
    623    END SUBROUTINE 
    624  
    625  
    626527   SUBROUTINE tra_asm_inc( kt ) 
    627528      !!---------------------------------------------------------------------- 
     
    645546      ! used to prevent the applied increments taking the temperature below the local freezing point  
    646547      DO jk = 1, jpkm1 
    647         CALL eos_fzp( tsn(:,:,jk,jp_sal), fzptnz(:,:,jk), fsdept(:,:,jk) ) 
     548        CALL eos_fzp( tsn(:,:,jk,jp_sal), fzptnz(:,:,jk), gdept_n(:,:,jk) ) 
    648549      END DO 
    649550         ! 
     
    726627!!gm 
    727628 
    728             IF( ln_zps .AND. .NOT. lk_c1d ) THEN      ! Partial steps: before horizontal gradient 
    729                IF(ln_isfcav) THEN                        ! ocean cavities: top and bottom cells (ISF) 
    730                   CALL zps_hde_isf( nit000, jpts, tsb, gtsu, gtsv, gtui, gtvi,     & 
    731                      &                            rhd, gru , grv , aru , arv , gzu , gzv , ge3ru , ge3rv ,   & 
    732                      &                     grui, grvi, arui, arvi, gzui, gzvi, ge3rui, ge3rvi    ) 
    733                ELSE                                      ! no ocean cavities: bottom cells 
    734                   CALL zps_hde    ( kt, jpts, tsb, gtsu, gtsv,        &  !  
    735                      &                        rhd, gru , grv          )  ! of t, s, rd at the last ocean level 
    736                ENDIF 
    737             ENDIF 
    738             ! 
     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 
     635 
    739636            DEALLOCATE( t_bkginc ) 
    740637            DEALLOCATE( s_bkginc ) 
     
    874771            ! 
    875772            sshb(:,:) = sshn(:,:)                        ! Update before fields 
    876             ! 
    877             IF( lk_vvl ) THEN 
    878                DO jk = 1, jpk 
    879                   fse3t_b(:,:,jk) = fse3t_n(:,:,jk) 
    880                END DO 
    881             ENDIF 
     773            e3t_b(:,:,:) = e3t_n(:,:,:) 
     774!!gm why not e3u_b, e3v_b, gdept_b ???? 
    882775            ! 
    883776            DEALLOCATE( ssh_bkg    ) 
Note: See TracChangeset for help on using the changeset viewer.