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.
trcstp.F90 in NEMO/branches/2019/dev_r10721_KERNEL-02_Storkey_Coward_IMMERSE_first_steps/src/TOP – NEMO

source: NEMO/branches/2019/dev_r10721_KERNEL-02_Storkey_Coward_IMMERSE_first_steps/src/TOP/trcstp.F90 @ 11504

Last change on this file since 11504 was 11504, checked in by davestorkey, 5 years ago

2019/dev_r10721_KERNEL-02_Storkey_Coward_IMMERSE_first_steps : Strip out all references to nn_dttrc
and the trcsub.F90 module. Notes:

  1. This version of the code currently breaks the GYRE_PISCES test in SETTE.
  2. With the removal of this option, TOP should use the OCE time index variables, eg. Nbb_trc -> Nbb, nittrc000 -> nit0000 etc.
  • Property svn:keywords set to Id
File size: 11.6 KB
RevLine 
[1457]1MODULE trcstp
2   !!======================================================================
3   !!                       ***  MODULE trcstp  ***
4   !! Time-stepping    : time loop of opa for passive tracer
5   !!======================================================================
[2528]6   !! History :  1.0  !  2004-03  (C. Ethe)  Original
[11483]7   !!            4.1  !  2019-08  (A. Coward, D. Storkey) rewrite in preparation for new timestepping scheme
[2528]8   !!----------------------------------------------------------------------
[1457]9#if defined key_top
10   !!----------------------------------------------------------------------
[9019]11   !!   trc_stp       : passive tracer system time-stepping
[1457]12   !!----------------------------------------------------------------------
[9019]13   USE oce_trc        ! ocean dynamics and active tracers variables
[4306]14   USE sbc_oce
[2528]15   USE trc
[9019]16   USE trctrp         ! passive tracers transport
17   USE trcsms         ! passive tracers sources and sinks
[1457]18   USE trcwri
19   USE trcrst
[4990]20   USE trdtrc_oce
21   USE trdmxl_trc
[10425]22   USE sms_pisces,  ONLY : ln_check_mass
[9019]23   !
24   USE prtctl_trc     ! Print control for debbuging
25   USE iom            !
26   USE in_out_manager !
[1457]27
28   IMPLICIT NONE
29   PRIVATE
30
[2528]31   PUBLIC   trc_stp    ! called by step
[3294]32
[9019]33   LOGICAL  ::   llnew                   ! ???
34   REAL(wp) ::   rdt_sampl               ! ???
35   INTEGER  ::   nb_rec_per_day, ktdcy   ! ???
36   REAL(wp) ::   rsecfst, rseclast       ! ???
37   REAL(wp), DIMENSION(:,:,:), SAVE, ALLOCATABLE ::   qsr_arr   ! save qsr during TOP time-step
[5385]38
[1457]39   !!----------------------------------------------------------------------
[11480]40   !! time level indices
41   !!----------------------------------------------------------------------
42   INTEGER, PUBLIC :: Nbb_trc, Nnn_trc, Naa_trc, Nrhs_trc      !! used by trc_init
43
44   !!----------------------------------------------------------------------
[10067]45   !! NEMO/TOP 4.0 , NEMO Consortium (2018)
[7753]46   !! $Id$
[10068]47   !! Software governed by the CeCILL license (see ./LICENSE)
[1457]48   !!----------------------------------------------------------------------
49CONTAINS
50
[11480]51   SUBROUTINE trc_stp( kt, Kbb_oce, Kmm_oce, Krhs_oce, Kaa_oce )
[1457]52      !!-------------------------------------------------------------------
53      !!                     ***  ROUTINE trc_stp  ***
54      !!                     
[9019]55      !! ** Purpose :   Time loop of opa for passive tracer
[1457]56      !!
[9019]57      !! ** Method  :   Compute the passive tracers trends
58      !!                Update the passive tracers
[1457]59      !!-------------------------------------------------------------------
[10905]60      INTEGER, INTENT( in ) :: kt                  ! ocean time-step index
[11480]61      INTEGER, INTENT( in ) :: Kbb_oce, Kmm_oce, Krhs_oce, Kaa_oce ! time level indices
[9019]62      !
63      INTEGER ::   jk, jn   ! dummy loop indices
64      REAL(wp)::   ztrai    ! local scalar
[10570]65      LOGICAL ::   ll_trcstat ! local logical
[9019]66      CHARACTER (len=25) ::   charout   !
[2528]67      !!-------------------------------------------------------------------
[3294]68      !
[9124]69      IF( ln_timing )   CALL timing_start('trc_stp')
[3294]70      !
[7646]71      IF( ( neuler == 0 .AND. kt == nittrc000 ) .OR. ln_top_euler ) THEN     ! at nittrc000
72         r2dttrc =  rdttrc           ! = rdttrc (use or restarting with Euler time stepping)
73      ENDIF
74      !
[10570]75      ll_trcstat  = ( ln_ctl .OR. sn_cfctl%l_trcstat ) .AND. &
76     &              ( ( MOD( kt, sn_cfctl%ptimincr ) == 0 ) .OR. ( kt == nitend ) )
[4990]77      IF( kt == nittrc000 .AND. lk_trdmxl_trc )  CALL trd_mxl_trc_init    ! trends: Mixed-layer
[3294]78      !
[6140]79      IF( .NOT.ln_linssh ) THEN                                           ! update ocean volume due to ssh temporal evolution
[3294]80         DO jk = 1, jpk
[11480]81            cvol(:,:,jk) = e1e2t(:,:) * e3t(:,:,jk,Kmm_oce) * tmask(:,:,jk)
[3294]82         END DO
[10425]83         IF ( ln_ctl .OR. kt == nitrst .OR. ( ln_check_mass .AND. kt == nitend )              &
84            & .OR. iom_use( "pno3tot" ) .OR. iom_use( "ppo4tot" ) .OR. iom_use( "psiltot" )   &
85            & .OR. iom_use( "palktot" ) .OR. iom_use( "pfertot" ) )                           &
86            &     areatot = glob_sum( 'trcstp', cvol(:,:,:) )
[3294]87      ENDIF
[5385]88      !
89      IF( l_trcdm2dc )   CALL trc_mean_qsr( kt )
[3294]90      !   
[11504]91      IF( Kmm_oce /= Nnn_trc .OR. Kaa_oce /= Naa_trc .OR. Krhs_oce /= Nrhs_trc ) THEN
92         ! The OCE and TRC time indices should be the same always.
93         ! If this is not the case then something has gone wrong.
94         CALL ctl_stop( 'trc_stp : OCE and TRC time indices are different! Something has gone wrong.' )
[11480]95      ENDIF
[4306]96      !   
[11504]97      !
98      IF(ln_ctl) THEN
99         WRITE(charout,FMT="('kt =', I4,'  d/m/y =',I2,I2,I4)") kt, nday, nmonth, nyear
100         CALL prt_ctl_trc_info(charout)
[1457]101      ENDIF
[3294]102      !
[11504]103      tr(:,:,:,:,Nrhs_trc) = 0.e0
104      !
105      CALL trc_rst_opn  ( kt )       ! Open tracer restart file
106      IF( lrst_trc )            CALL trc_rst_cal  ( kt, 'WRITE' )   ! calendar
107      CALL trc_wri      ( kt,          Nnn_trc                    )  ! output of passive tracers with iom I/O manager
108      CALL trc_sms      ( kt, Nbb_trc, Nnn_trc, Nrhs_trc          )  ! tracers: sinks and sources
109      CALL trc_trp      ( kt, Nbb_trc, Nnn_trc, Nrhs_trc, Naa_trc )  ! transport of passive tracers
110      IF( kt == nittrc000 ) THEN
111         CALL iom_close( numrtr )       ! close input tracer restart file
112         IF(lwm) CALL FLUSH( numont )   ! flush namelist output
113      ENDIF
114      IF( lrst_trc )            CALL trc_rst_wri  ( kt, Nbb_trc, Nnn_trc, Nrhs_trc )       ! write tracer restart file
115      IF( lk_trdmxl_trc  )      CALL trd_mxl_trc  ( kt,          Nnn_trc           )       ! trends: Mixed-layer
116      !
[10570]117      IF (ll_trcstat) THEN
[10425]118         ztrai = 0._wp                                                   !  content of all tracers
119         DO jn = 1, jptra
[11480]120            ztrai = ztrai + glob_sum( 'trcstp', tr(:,:,:,jn,Nnn_trc) * cvol(:,:,:)   )
[10425]121         END DO
122         IF( lwm ) WRITE(numstr,9300) kt,  ztrai / areatot
123      ENDIF
[6942]1249300  FORMAT(i10,D23.16)
[3294]125      !
[9124]126      IF( ln_timing )   CALL timing_stop('trc_stp')
[3294]127      !
[1457]128   END SUBROUTINE trc_stp
129
[5385]130   SUBROUTINE trc_mean_qsr( kt )
131      !!----------------------------------------------------------------------
132      !!             ***  ROUTINE trc_mean_qsr  ***
133      !!
134      !! ** Purpose :  Compute daily mean qsr for biogeochemical model in case
135      !!               of diurnal cycle
136      !!
[6942]137      !! ** Method  : store in TOP the qsr every hour ( or every time-step if the latter
[5385]138      !!              is greater than 1 hour ) and then, compute the  mean with
139      !!              a moving average over 24 hours.
140      !!              In coupled mode, the sampling is done at every coupling frequency
141      !!----------------------------------------------------------------------
[9019]142      INTEGER, INTENT( in ) ::   kt   ! ocean time-step index
143      !
144      INTEGER  ::   jn   ! dummy loop indices
145      REAL(wp) ::   zkt, zrec     ! local scalars
146      CHARACTER(len=1) ::   cl1   ! 1 character
147      CHARACTER(len=2) ::   cl2   ! 2 characters
148      !!----------------------------------------------------------------------
149      !
[9124]150      IF( ln_timing )   CALL timing_start('trc_mean_qsr')
151      !
[5385]152      IF( kt == nittrc000 ) THEN
[5407]153         IF( ln_cpl )  THEN 
[6968]154            rdt_sampl = rday / ncpl_qsr_freq
[6942]155            nb_rec_per_day = ncpl_qsr_freq
[5385]156         ELSE 
[6981]157            rdt_sampl = MAX( 3600., rdttrc )
[6968]158            nb_rec_per_day = INT( rday / rdt_sampl )
[5385]159         ENDIF
160         !
[9019]161         IF(lwp) THEN
[5385]162            WRITE(numout,*) 
[6942]163            WRITE(numout,*) ' Sampling frequency dt = ', rdt_sampl, 's','   Number of sampling per day  nrec = ', nb_rec_per_day
[5385]164            WRITE(numout,*) 
165         ENDIF
166         !
[6942]167         ALLOCATE( qsr_arr(jpi,jpj,nb_rec_per_day ) )
[5385]168         !
[6942]169         !                                            !* Restart: read in restart file
[7787]170         IF( ln_rsttr .AND. nn_rsttr /= 0 .AND. iom_varid( numrtr, 'qsr_mean' , ldstop = .FALSE. ) > 0  &
171           &                              .AND. iom_varid( numrtr, 'qsr_arr_1', ldstop = .FALSE. ) > 0  &
172           &                              .AND. iom_varid( numrtr, 'ktdcy'    , ldstop = .FALSE. ) > 0  &
173           &                              .AND. iom_varid( numrtr, 'nrdcy'    , ldstop = .FALSE. ) > 0  ) THEN
174
175            CALL iom_get( numrtr, 'ktdcy', zkt ) 
[7812]176            rsecfst = INT( zkt ) * rdttrc
[6968]177            IF(lwp) WRITE(numout,*) 'trc_qsr_mean:   qsr_mean read in the restart file at time-step rsecfst =', rsecfst, ' s '
[6942]178            CALL iom_get( numrtr, jpdom_autoglo, 'qsr_mean', qsr_mean )   !  A mean of qsr
[7787]179            CALL iom_get( numrtr, 'nrdcy', zrec )   !  Number of record per days
180            IF( INT( zrec ) == nb_rec_per_day ) THEN
181               DO jn = 1, nb_rec_per_day 
182                  IF( jn <= 9 )  THEN
183                    WRITE(cl1,'(i1)') jn
184                    CALL iom_get( numrtr, jpdom_autoglo, 'qsr_arr_'//cl1, qsr_arr(:,:,jn) )   !  A mean of qsr
185                  ELSE
186                    WRITE(cl2,'(i2.2)') jn
187                    CALL iom_get( numrtr, jpdom_autoglo, 'qsr_arr_'//cl2, qsr_arr(:,:,jn) )   !  A mean of qsr
188                  ENDIF
[9019]189              END DO
[7787]190            ELSE
191               DO jn = 1, nb_rec_per_day
192                  qsr_arr(:,:,jn) = qsr_mean(:,:)
193               ENDDO
194            ENDIF
[6942]195         ELSE                                         !* no restart: set from nit000 values
196            IF(lwp) WRITE(numout,*) 'trc_qsr_mean:   qsr_mean set to nit000 values'
[6981]197            rsecfst  = kt * rdttrc
[6942]198            !
199            qsr_mean(:,:) = qsr(:,:)
200            DO jn = 1, nb_rec_per_day
201               qsr_arr(:,:,jn) = qsr_mean(:,:)
[9019]202            END DO
[6942]203         ENDIF
[5385]204         !
205      ENDIF
206      !
[6981]207      rseclast = kt * rdttrc
[6942]208      !
[6968]209      llnew   = ( rseclast - rsecfst ) .ge.  rdt_sampl    !   new shortwave to store
[6942]210      IF( llnew ) THEN
[7787]211          ktdcy = kt
212          IF( lwp .AND. kt < nittrc000 + 100 ) WRITE(numout,*) ' New shortwave to sample for TOP at time kt = ', ktdcy, &
[6968]213             &                      ' time = ', rseclast/3600.,'hours '
214          rsecfst = rseclast
[6942]215          DO jn = 1, nb_rec_per_day - 1
[5385]216             qsr_arr(:,:,jn) = qsr_arr(:,:,jn+1)
[6942]217          ENDDO
218          qsr_arr (:,:,nb_rec_per_day) = qsr(:,:)
219          qsr_mean(:,:                ) = SUM( qsr_arr(:,:,:), 3 ) / nb_rec_per_day
[5385]220      ENDIF
221      !
[6942]222      IF( lrst_trc ) THEN    !* Write the mean of qsr in restart file
223         IF(lwp) WRITE(numout,*)
224         IF(lwp) WRITE(numout,*) 'trc_mean_qsr : write qsr_mean in restart file  kt =', kt
225         IF(lwp) WRITE(numout,*) '~~~~~~~'
[7787]226         zkt  = REAL( ktdcy, wp )
227         zrec = REAL( nb_rec_per_day, wp )
228         CALL iom_rstput( kt, nitrst, numrtw, 'ktdcy', zkt  )
229         CALL iom_rstput( kt, nitrst, numrtw, 'nrdcy', zrec )
[6942]230          DO jn = 1, nb_rec_per_day 
231             IF( jn <= 9 )  THEN
232               WRITE(cl1,'(i1)') jn
233               CALL iom_rstput( kt, nitrst, numrtw, 'qsr_arr_'//cl1, qsr_arr(:,:,jn) )
234             ELSE
235               WRITE(cl2,'(i2.2)') jn
236               CALL iom_rstput( kt, nitrst, numrtw, 'qsr_arr_'//cl2, qsr_arr(:,:,jn) )
237             ENDIF
[9019]238         END DO
[6942]239         CALL iom_rstput( kt, nitrst, numrtw, 'qsr_mean', qsr_mean(:,:) )
240      ENDIF
241      !
[9124]242      IF( ln_timing )   CALL timing_stop('trc_mean_qsr')
243      !
[5385]244   END SUBROUTINE trc_mean_qsr
245
[1457]246#else
247   !!----------------------------------------------------------------------
248   !!   Default key                                     NO passive tracers
249   !!----------------------------------------------------------------------
250CONTAINS
251   SUBROUTINE trc_stp( kt )        ! Empty routine
252      WRITE(*,*) 'trc_stp: You should not have seen this print! error?', kt
253   END SUBROUTINE trc_stp
254#endif
255
256   !!======================================================================
257END MODULE trcstp
Note: See TracBrowser for help on using the repository browser.