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_r5836_NOC3_vvl_by_default/NEMOGCM/NEMO/TOP_SRC – NEMO

source: branches/2015/dev_r5836_NOC3_vvl_by_default/NEMOGCM/NEMO/TOP_SRC/trcstp.F90 @ 5845

Last change on this file since 5845 was 5845, checked in by gm, 8 years ago

#1613: vvl by default: suppression of domzgr_substitute.h90

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