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 branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/TOP_SRC – NEMO

source: branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/TOP_SRC/trcstp.F90 @ 6101

Last change on this file since 6101 was 6101, checked in by cbricaud, 8 years ago

correction of bugs from last update and improvments for CRS

  • Property svn:keywords set to Id
File size: 7.8 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
7   !!----------------------------------------------------------------------
[1457]8#if defined key_top
9   !!----------------------------------------------------------------------
10   !!   trc_stp      : passive tracer system time-stepping
11   !!----------------------------------------------------------------------
12   USE oce_trc          ! ocean dynamics and active tracers variables
[2528]13   USE trc
[1457]14   USE trctrp           ! passive tracers transport
15   USE trcsms           ! passive tracers sources and sinks
16   USE prtctl_trc       ! Print control for debbuging
17   USE trcdia
[5105]18   USE trcwri , ONLY : trc_wri
[1457]19   USE trcrst
[4990]20   USE trdtrc_oce
21   USE trdmxl_trc
[5105]22   USE iom, ONLY : lk_iomput , iom_close
[1457]23   USE in_out_manager
[3294]24   USE trcsub
[6101]25   USE dom_oce, ONLY : nday, nmonth, nyear, nsec1jan000, nsec_year
26   !USE sbc_oce
[1457]27
28   IMPLICIT NONE
29   PRIVATE
30
[2528]31   PUBLIC   trc_stp    ! called by step
[3294]32
[5602]33   REAL(wp), DIMENSION(:,:,:), SAVE, ALLOCATABLE ::   qsr_arr ! save qsr during TOP time-step
34   REAL(wp) :: rdt_sampl
35   INTEGER  :: nb_rec_per_days
36   INTEGER  :: isecfst, iseclast
37   LOGICAL  :: llnew
38
[3294]39   !! * Substitutions
40#  include "domzgr_substitute.h90"
[1457]41   !!----------------------------------------------------------------------
[2528]42   !! NEMO/TOP 3.3 , NEMO Consortium (2010)
43   !! $Id$
44   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
[1457]45   !!----------------------------------------------------------------------
46CONTAINS
47
48   SUBROUTINE trc_stp( kt )
49      !!-------------------------------------------------------------------
50      !!                     ***  ROUTINE trc_stp  ***
51      !!                     
52      !! ** Purpose : Time loop of opa for passive tracer
53      !!
54      !! ** Method  :
55      !!              Compute the passive tracers trends
56      !!              Update the passive tracers
57      !!-------------------------------------------------------------------
[3294]58      INTEGER, INTENT( in ) ::  kt      ! ocean time-step index
59      INTEGER               ::  jk, jn  ! dummy loop indices
60      REAL(wp)              ::  ztrai
[4306]61      CHARACTER (len=25)    ::  charout 
62
[2528]63      !!-------------------------------------------------------------------
[3294]64      !
65      IF( nn_timing == 1 )   CALL timing_start('trc_stp')
66      !
[4990]67      IF( kt == nittrc000 .AND. lk_trdmxl_trc )  CALL trd_mxl_trc_init    ! trends: Mixed-layer
[3294]68      !
[3319]69      IF( lk_vvl ) THEN                                                   ! update ocean volume due to ssh temporal evolution
[3294]70         DO jk = 1, jpk
71            cvol(:,:,jk) = e1e2t(:,:) * fse3t(:,:,jk) * tmask(:,:,jk)
72         END DO
[5601]73         !cbr IF( lk_degrad )  cvol(:,:,:) = cvol(:,:,:) * facvol(:,:,:)       ! degrad option: reduction by facvol
[3294]74         areatot         = glob_sum( cvol(:,:,:) )
75      ENDIF
[5602]76      !
77      IF( l_trcdm2dc )   CALL trc_mean_qsr( kt )
[3294]78      !   
[4306]79      IF( nn_dttrc /= 1 )   CALL trc_sub_stp( kt )  ! averaging physical variables for sub-stepping
80      !   
81      IF( MOD( kt , nn_dttrc ) == 0 ) THEN      ! only every nn_dttrc time step
[2528]82         !
83         IF(ln_ctl) THEN
84            WRITE(charout,FMT="('kt =', I4,'  d/m/y =',I2,I2,I4)") kt, nday, nmonth, nyear
85            CALL prt_ctl_trc_info(charout)
86         ENDIF
87         !
88         tra(:,:,:,:) = 0.e0
89         !
[3294]90                                   CALL trc_rst_opn  ( kt )       ! Open tracer restart file
[3680]91         IF( lrst_trc )            CALL trc_rst_cal  ( kt, 'WRITE' )   ! calendar
[3294]92         IF( lk_iomput ) THEN  ;   CALL trc_wri      ( kt )       ! output of passive tracers with iom I/O manager
93         ELSE                  ;   CALL trc_dia      ( kt )       ! output of passive tracers with old I/O manager
[2528]94         ENDIF
[3294]95                                   CALL trc_sms      ( kt )       ! tracers: sinks and sources
96                                   CALL trc_trp      ( kt )       ! transport of passive tracers
[4147]97         IF( kt == nittrc000 ) THEN
98            CALL iom_close( numrtr )       ! close input tracer restart file
[4624]99            IF(lwm) CALL FLUSH( numont )   ! flush namelist output
[4147]100         ENDIF
[3294]101         IF( lrst_trc )            CALL trc_rst_wri  ( kt )       ! write tracer restart file
[4990]102         IF( lk_trdmxl_trc  )      CALL trd_mxl_trc  ( kt )       ! trends: Mixed-layer
[2528]103         !
[3294]104         IF( nn_dttrc /= 1   )     CALL trc_sub_reset( kt )       ! resetting physical variables when sub-stepping
105         !
[1457]106      ENDIF
[3294]107      !
108      ztrai = 0._wp                                                   !  content of all tracers
109      DO jn = 1, jptra
110         ztrai = ztrai + glob_sum( trn(:,:,:,jn) * cvol(:,:,:)   )
111      END DO
112      IF( lwp ) WRITE(numstr,9300) kt,  ztrai / areatot
1139300  FORMAT(i10,e18.10)
114      !
115      IF( nn_timing == 1 )   CALL timing_stop('trc_stp')
116      !
[1457]117   END SUBROUTINE trc_stp
118
[5602]119   SUBROUTINE trc_mean_qsr( kt )
120      !!----------------------------------------------------------------------
121      !!             ***  ROUTINE trc_mean_qsr  ***
122      !!
123      !! ** Purpose :  Compute daily mean qsr for biogeochemical model in case
124      !!               of diurnal cycle
125      !!
126      !! ** Method  : store in TOP the qsr every hour ( or every time-step the latter
127      !!              is greater than 1 hour ) and then, compute the  mean with
128      !!              a moving average over 24 hours.
129      !!              In coupled mode, the sampling is done at every coupling frequency
130      !!----------------------------------------------------------------------
131      INTEGER, INTENT(in) ::   kt
132      INTEGER  :: jn
133
134      IF( kt == nittrc000 ) THEN
135         IF( ln_cpl )  THEN 
136            rdt_sampl = 86400. / ncpl_qsr_freq
137            nb_rec_per_days = ncpl_qsr_freq
138         ELSE 
139            rdt_sampl = MAX( 3600., rdt * nn_dttrc )
140            nb_rec_per_days = INT( 86400 / rdt_sampl )
141         ENDIF
142         !
143         IF( lwp ) THEN
144            WRITE(numout,*) 
145            WRITE(numout,*) ' Sampling frequency dt = ', rdt_sampl, 's','   Number of sampling per day  nrec = ', nb_rec_per_days
146            WRITE(numout,*) 
147         ENDIF
148         !
149         ALLOCATE( qsr_arr(jpi,jpj,nb_rec_per_days ) )
150         DO jn = 1, nb_rec_per_days
151            qsr_arr(:,:,jn) = qsr(:,:)
152         ENDDO
153         qsr_mean(:,:) = qsr(:,:)
154         !
155         isecfst  = nsec_year + nsec1jan000   !   number of seconds between Jan. 1st 00h of nit000 year and the middle of time step
156         iseclast = isecfst
157         !
158      ENDIF
159      !
160      iseclast = nsec_year + nsec1jan000
161      llnew   = ( iseclast - isecfst )  > INT( rdt_sampl )   !   new shortwave to store
162      IF( kt /= nittrc000 .AND. llnew ) THEN
163          IF( lwp ) WRITE(numout,*) ' New shortwave to sample for TOP at time kt = ', kt, &
164             &                      ' time = ', (iseclast+rdt*nn_dttrc/2.)/3600.,'hours '
165          isecfst = iseclast
166          DO jn = 1, nb_rec_per_days - 1
167             qsr_arr(:,:,jn) = qsr_arr(:,:,jn+1)
168          ENDDO
169          qsr_arr (:,:,nb_rec_per_days) = qsr(:,:)
170          qsr_mean(:,:                ) = SUM( qsr_arr(:,:,:), 3 ) / nb_rec_per_days
171      ENDIF
172      !
173   END SUBROUTINE trc_mean_qsr
174
[1457]175#else
176   !!----------------------------------------------------------------------
177   !!   Default key                                     NO passive tracers
178   !!----------------------------------------------------------------------
179CONTAINS
180   SUBROUTINE trc_stp( kt )        ! Empty routine
181      WRITE(*,*) 'trc_stp: You should not have seen this print! error?', kt
182   END SUBROUTINE trc_stp
183#endif
184
185   !!======================================================================
186END MODULE trcstp
Note: See TracBrowser for help on using the repository browser.