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

source: branches/NERC/dev_r5518_NOC_MEDUSA_Stable/NEMOGCM/NEMO/TOP_SRC/trcstp.F90 @ 5726

Last change on this file since 5726 was 5726, checked in by jpalmier, 9 years ago

JPALM -- 10-09-2015 -- add MEDUSA in the branch ; adapted TOP_SRC to MEDUSA ; remove some svn keywords in the branch

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