1 | MODULE 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_day |
---|
35 | INTEGER :: isecfst, iseclast |
---|
36 | LOGICAL :: llnew |
---|
37 | |
---|
38 | !! * Substitutions |
---|
39 | # include "domzgr_substitute.h90" |
---|
40 | !!---------------------------------------------------------------------- |
---|
41 | !! NEMO/TOP 3.3 , NEMO Consortium (2010) |
---|
42 | !! $Id$ |
---|
43 | !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt) |
---|
44 | !!---------------------------------------------------------------------- |
---|
45 | CONTAINS |
---|
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 | !!------------------------------------------------------------------- |
---|
57 | INTEGER, INTENT( in ) :: kt ! ocean time-step index |
---|
58 | INTEGER :: jk, jn ! dummy loop indices |
---|
59 | REAL(wp) :: ztrai |
---|
60 | CHARACTER (len=25) :: charout |
---|
61 | |
---|
62 | !!------------------------------------------------------------------- |
---|
63 | ! |
---|
64 | IF( nn_timing == 1 ) CALL timing_start('trc_stp') |
---|
65 | ! |
---|
66 | IF( kt == nittrc000 .AND. lk_trdmxl_trc ) CALL trd_mxl_trc_init ! trends: Mixed-layer |
---|
67 | ! |
---|
68 | IF( lk_vvl ) THEN ! update ocean volume due to ssh temporal evolution |
---|
69 | DO jk = 1, jpk |
---|
70 | cvol(:,:,jk) = e1e2t(:,:) * fse3t(:,:,jk) * tmask(:,:,jk) |
---|
71 | END DO |
---|
72 | IF( lk_degrad ) cvol(:,:,:) = cvol(:,:,:) * facvol(:,:,:) ! degrad option: reduction by facvol |
---|
73 | areatot = glob_sum( cvol(:,:,:) ) |
---|
74 | ENDIF |
---|
75 | ! |
---|
76 | IF( l_trcdm2dc ) CALL trc_mean_qsr( kt ) |
---|
77 | ! |
---|
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 |
---|
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 | ! |
---|
89 | CALL trc_rst_opn ( kt ) ! Open tracer restart file |
---|
90 | IF( lrst_trc ) CALL trc_rst_cal ( kt, 'WRITE' ) ! calendar |
---|
91 | IF( lk_iomput ) THEN ; CALL trc_wri ( kt ) ! output of passive tracers with iom I/O manager |
---|
92 | ELSE ; CALL trc_dia ( kt ) ! output of passive tracers with old I/O manager |
---|
93 | ENDIF |
---|
94 | CALL trc_sms ( kt ) ! tracers: sinks and sources |
---|
95 | CALL trc_trp ( kt ) ! transport of passive tracers |
---|
96 | IF( kt == nittrc000 ) THEN |
---|
97 | CALL iom_close( numrtr ) ! close input tracer restart file |
---|
98 | IF(lwm) CALL FLUSH( numont ) ! flush namelist output |
---|
99 | ENDIF |
---|
100 | IF( lrst_trc ) CALL trc_rst_wri ( kt ) ! write tracer restart file |
---|
101 | IF( lk_trdmxl_trc ) CALL trd_mxl_trc ( kt ) ! trends: Mixed-layer |
---|
102 | ! |
---|
103 | IF( nn_dttrc /= 1 ) CALL trc_sub_reset( kt ) ! resetting physical variables when sub-stepping |
---|
104 | ! |
---|
105 | ENDIF |
---|
106 | ! |
---|
107 | ztrai = 0._wp ! content of all tracers |
---|
108 | DO jn = 1, jptra |
---|
109 | ztrai = ztrai + glob_sum( trn(:,:,:,jn) * cvol(:,:,:) ) |
---|
110 | END DO |
---|
111 | IF( lwp ) WRITE(numstr,9300) kt, ztrai / areatot |
---|
112 | 9300 FORMAT(i10,e18.10) |
---|
113 | ! |
---|
114 | IF( nn_timing == 1 ) CALL timing_stop('trc_stp') |
---|
115 | ! |
---|
116 | END SUBROUTINE trc_stp |
---|
117 | |
---|
118 | SUBROUTINE trc_mean_qsr( kt ) |
---|
119 | !!---------------------------------------------------------------------- |
---|
120 | !! *** ROUTINE trc_mean_qsr *** |
---|
121 | !! |
---|
122 | !! ** Purpose : Compute daily mean qsr for biogeochemical model in case |
---|
123 | !! of diurnal cycle |
---|
124 | !! |
---|
125 | !! ** Method : store in TOP the qsr every hour ( or every time-step if the latter |
---|
126 | !! is greater than 1 hour ) and then, compute the mean with |
---|
127 | !! a moving average over 24 hours. |
---|
128 | !! In coupled mode, the sampling is done at every coupling frequency |
---|
129 | !!---------------------------------------------------------------------- |
---|
130 | INTEGER, INTENT(in) :: kt |
---|
131 | INTEGER :: jn |
---|
132 | |
---|
133 | IF( kt == nittrc000 ) THEN |
---|
134 | IF( ln_cpl ) THEN |
---|
135 | rdt_sampl = 86400. / ncpl_qsr_freq |
---|
136 | nb_rec_per_day = ncpl_qsr_freq |
---|
137 | ELSE |
---|
138 | rdt_sampl = MAX( 3600., rdt * nn_dttrc ) |
---|
139 | nb_rec_per_day = INT( 86400 / rdt_sampl ) |
---|
140 | ENDIF |
---|
141 | ! |
---|
142 | IF( lwp ) THEN |
---|
143 | WRITE(numout,*) |
---|
144 | WRITE(numout,*) ' Sampling frequency dt = ', rdt_sampl, 's',' Number of sampling per day nrec = ', nb_rec_per_day |
---|
145 | WRITE(numout,*) |
---|
146 | ENDIF |
---|
147 | ! |
---|
148 | ! !* Restart: read in restart file |
---|
149 | IF( ln_rsttr .AND. iom_varid( numrtr, 'qsr_mean', ldstop = .FALSE. ) > 0 ) THEN |
---|
150 | IF(lwp) WRITE(numout,*) 'trc_qsr_mean: qsr_mean read in the restart file' |
---|
151 | CALL iom_get( numrtr, jpdom_autoglo, 'qsr_mean', qsr_mean ) ! A mean of qsr |
---|
152 | ELSE !* no restart: set from nit000 values |
---|
153 | IF(lwp) WRITE(numout,*) 'trc_qsr_mean: qsr_mean set to nit000 values' |
---|
154 | qsr_mean(:,:) = qsr(:,:) |
---|
155 | ENDIF |
---|
156 | ! |
---|
157 | ALLOCATE( qsr_arr(jpi,jpj,nb_rec_per_day ) ) |
---|
158 | DO jn = 1, nb_rec_per_day |
---|
159 | qsr_arr(:,:,jn) = qsr_mean(:,:) |
---|
160 | ENDDO |
---|
161 | ! |
---|
162 | isecfst = nsec_year + nsec1jan000 ! number of seconds between Jan. 1st 00h of nit000 year and the middle of time step |
---|
163 | iseclast = isecfst |
---|
164 | ! |
---|
165 | ENDIF |
---|
166 | ! |
---|
167 | iseclast = nsec_year + nsec1jan000 |
---|
168 | llnew = ( iseclast - isecfst ) > INT( rdt_sampl ) ! new shortwave to store |
---|
169 | IF( kt /= nittrc000 .AND. llnew ) THEN |
---|
170 | IF( lwp ) WRITE(numout,*) ' New shortwave to sample for TOP at time kt = ', kt, & |
---|
171 | & ' time = ', (iseclast+rdt*nn_dttrc/2.)/3600.,'hours ' |
---|
172 | isecfst = iseclast |
---|
173 | DO jn = 1, nb_rec_per_day - 1 |
---|
174 | qsr_arr(:,:,jn) = qsr_arr(:,:,jn+1) |
---|
175 | ENDDO |
---|
176 | qsr_arr (:,:,nb_rec_per_day) = qsr(:,:) |
---|
177 | qsr_mean(:,: ) = SUM( qsr_arr(:,:,:), 3 ) / nb_rec_per_day |
---|
178 | ENDIF |
---|
179 | ! |
---|
180 | IF( lrst_trc ) THEN !* Write the mean of qsr in restart file |
---|
181 | IF(lwp) WRITE(numout,*) |
---|
182 | IF(lwp) WRITE(numout,*) 'trc_mean_qsr : write qsr_mean in restart file kt =', kt |
---|
183 | IF(lwp) WRITE(numout,*) '~~~~~~~' |
---|
184 | CALL iom_rstput( kt, nitrst, numrtw, 'qsr_mean', qsr_mean(:,:) ) |
---|
185 | ENDIF |
---|
186 | ! |
---|
187 | END SUBROUTINE trc_mean_qsr |
---|
188 | |
---|
189 | #else |
---|
190 | !!---------------------------------------------------------------------- |
---|
191 | !! Default key NO passive tracers |
---|
192 | !!---------------------------------------------------------------------- |
---|
193 | CONTAINS |
---|
194 | SUBROUTINE trc_stp( kt ) ! Empty routine |
---|
195 | WRITE(*,*) 'trc_stp: You should not have seen this print! error?', kt |
---|
196 | END SUBROUTINE trc_stp |
---|
197 | #endif |
---|
198 | |
---|
199 | !!====================================================================== |
---|
200 | END MODULE trcstp |
---|