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, ktdcy |
---|
35 | REAL(wp) :: rsecfst, rseclast |
---|
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 | IF( nn_timing == 1 ) CALL timing_start('trc_stp') |
---|
64 | ! |
---|
65 | IF( kt == nittrc000 .AND. lk_trdmxl_trc ) CALL trd_mxl_trc_init ! trends: Mixed-layer |
---|
66 | ! |
---|
67 | IF( lk_vvl ) THEN ! update ocean volume due to ssh temporal evolution |
---|
68 | DO jk = 1, jpk |
---|
69 | cvol(:,:,jk) = e1e2t(:,:) * fse3t(:,:,jk) * tmask(:,:,jk) |
---|
70 | END DO |
---|
71 | IF( lk_degrad ) cvol(:,:,:) = cvol(:,:,:) * facvol(:,:,:) ! degrad option: reduction by facvol |
---|
72 | areatot = glob_sum( cvol(:,:,:) ) |
---|
73 | ENDIF |
---|
74 | ! |
---|
75 | IF( l_trcdm2dc ) CALL trc_mean_qsr( kt ) |
---|
76 | ! |
---|
77 | IF( nn_dttrc /= 1 ) CALL trc_sub_stp( kt ) ! averaging physical variables for sub-stepping |
---|
78 | ! |
---|
79 | IF( MOD( kt , nn_dttrc ) == 0 ) THEN ! only every nn_dttrc time step |
---|
80 | ! |
---|
81 | IF(ln_ctl) THEN |
---|
82 | WRITE(charout,FMT="('kt =', I4,' d/m/y =',I2,I2,I4)") kt, nday, nmonth, nyear |
---|
83 | CALL prt_ctl_trc_info(charout) |
---|
84 | ENDIF |
---|
85 | ! |
---|
86 | tra(:,:,:,:) = 0.e0 |
---|
87 | ! |
---|
88 | IF( .NOT.lk_offline ) CALL trc_rst_opn ( kt ) ! Open tracer restart file |
---|
89 | IF( lrst_trc ) CALL trc_rst_cal ( kt, 'WRITE' ) ! calendar |
---|
90 | IF( lk_iomput ) THEN ; CALL trc_wri ( kt ) ! output of passive tracers with iom I/O manager |
---|
91 | ELSE ; CALL trc_dia ( kt ) ! output of passive tracers with old I/O manager |
---|
92 | ENDIF |
---|
93 | CALL trc_sms ( kt ) ! tracers: sinks and sources |
---|
94 | CALL trc_trp ( kt ) ! transport of passive tracers |
---|
95 | |
---|
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 | |
---|
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 |
---|
113 | 9300 FORMAT(i10,D23.16) |
---|
114 | ! |
---|
115 | IF( nn_timing == 1 ) CALL timing_stop('trc_stp') |
---|
116 | ! |
---|
117 | END SUBROUTINE trc_stp |
---|
118 | |
---|
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 if 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 | REAL(wp) :: zkt, zrec |
---|
134 | CHARACTER(len=1) :: cl1 ! 1 character |
---|
135 | CHARACTER(len=2) :: cl2 ! 2 characters |
---|
136 | |
---|
137 | IF( kt == nittrc000 ) THEN |
---|
138 | IF( ln_cpl ) THEN |
---|
139 | rdt_sampl = rday / ncpl_qsr_freq |
---|
140 | nb_rec_per_day = ncpl_qsr_freq |
---|
141 | ELSE |
---|
142 | rdt_sampl = MAX( 3600., rdttrc(1) ) |
---|
143 | nb_rec_per_day = INT( rday / rdt_sampl ) |
---|
144 | ENDIF |
---|
145 | ! |
---|
146 | IF( lwp ) THEN |
---|
147 | WRITE(numout,*) |
---|
148 | WRITE(numout,*) ' Sampling frequency dt = ', rdt_sampl, 's',' Number of sampling per day nrec = ', nb_rec_per_day |
---|
149 | WRITE(numout,*) |
---|
150 | ENDIF |
---|
151 | ! |
---|
152 | ALLOCATE( qsr_arr(jpi,jpj,nb_rec_per_day ) ) |
---|
153 | ! |
---|
154 | ! !* Restart: read in restart file |
---|
155 | IF( ln_rsttr .AND. iom_varid( numrtr, 'qsr_mean' , ldstop = .FALSE. ) > 0 & |
---|
156 | & .AND. iom_varid( numrtr, 'qsr_arr_1', ldstop = .FALSE. ) > 0 & |
---|
157 | & .AND. iom_varid( numrtr, 'ktdcy' , ldstop = .FALSE. ) > 0 & |
---|
158 | & .AND. iom_varid( numrtr, 'nrdcy' , ldstop = .FALSE. ) > 0 ) THEN |
---|
159 | |
---|
160 | CALL iom_get( numrtr, 'ktdcy', zkt ) |
---|
161 | rsecfst = INT( zkt ) * rdttrc(1) |
---|
162 | IF(lwp) WRITE(numout,*) 'trc_qsr_mean: qsr_mean read in the restart file at time-step rsecfst =', rsecfst, ' s ' |
---|
163 | CALL iom_get( numrtr, jpdom_autoglo, 'qsr_mean', qsr_mean ) ! A mean of qsr |
---|
164 | CALL iom_get( numrtr, 'nrdcy', zrec ) ! Number of record per days |
---|
165 | IF( INT( zrec ) == nb_rec_per_day ) THEN |
---|
166 | DO jn = 1, nb_rec_per_day |
---|
167 | IF( jn <= 9 ) THEN |
---|
168 | WRITE(cl1,'(i1)') jn |
---|
169 | CALL iom_get( numrtr, jpdom_autoglo, 'qsr_arr_'//cl1, qsr_arr(:,:,jn) ) ! A mean of qsr |
---|
170 | ELSE |
---|
171 | WRITE(cl2,'(i2.2)') jn |
---|
172 | CALL iom_get( numrtr, jpdom_autoglo, 'qsr_arr_'//cl2, qsr_arr(:,:,jn) ) ! A mean of qsr |
---|
173 | ENDIF |
---|
174 | ENDDO |
---|
175 | ELSE |
---|
176 | DO jn = 1, nb_rec_per_day |
---|
177 | qsr_arr(:,:,jn) = qsr_mean(:,:) |
---|
178 | ENDDO |
---|
179 | ENDIF |
---|
180 | ELSE !* no restart: set from nit000 values |
---|
181 | IF(lwp) WRITE(numout,*) 'trc_qsr_mean: qsr_mean set to nit000 values' |
---|
182 | rsecfst = kt * rdttrc(1) |
---|
183 | ! |
---|
184 | qsr_mean(:,:) = qsr(:,:) |
---|
185 | DO jn = 1, nb_rec_per_day |
---|
186 | qsr_arr(:,:,jn) = qsr_mean(:,:) |
---|
187 | ENDDO |
---|
188 | ENDIF |
---|
189 | ! |
---|
190 | ENDIF |
---|
191 | ! |
---|
192 | rseclast = kt * rdttrc(1) |
---|
193 | ! |
---|
194 | llnew = ( rseclast - rsecfst ) .ge. rdt_sampl ! new shortwave to store |
---|
195 | IF( llnew ) THEN |
---|
196 | ktdcy = kt |
---|
197 | IF( lwp .AND. kt < nittrc000 + 100 ) WRITE(numout,*) ' New shortwave to sample for TOP at time kt = ', ktdcy, & |
---|
198 | & ' time = ', rseclast/3600.,'hours ' |
---|
199 | rsecfst = rseclast |
---|
200 | DO jn = 1, nb_rec_per_day - 1 |
---|
201 | qsr_arr(:,:,jn) = qsr_arr(:,:,jn+1) |
---|
202 | ENDDO |
---|
203 | qsr_arr (:,:,nb_rec_per_day) = qsr(:,:) |
---|
204 | qsr_mean(:,: ) = SUM( qsr_arr(:,:,:), 3 ) / nb_rec_per_day |
---|
205 | ENDIF |
---|
206 | ! |
---|
207 | IF( lrst_trc ) THEN !* Write the mean of qsr in restart file |
---|
208 | IF(lwp) WRITE(numout,*) |
---|
209 | IF(lwp) WRITE(numout,*) 'trc_mean_qsr : write qsr_mean in restart file kt =', kt |
---|
210 | IF(lwp) WRITE(numout,*) '~~~~~~~' |
---|
211 | zkt = REAL( ktdcy, wp ) |
---|
212 | zrec = REAL( nb_rec_per_day, wp ) |
---|
213 | CALL iom_rstput( kt, nitrst, numrtw, 'ktdcy', zkt ) |
---|
214 | CALL iom_rstput( kt, nitrst, numrtw, 'nrdcy', zrec ) |
---|
215 | DO jn = 1, nb_rec_per_day |
---|
216 | IF( jn <= 9 ) THEN |
---|
217 | WRITE(cl1,'(i1)') jn |
---|
218 | CALL iom_rstput( kt, nitrst, numrtw, 'qsr_arr_'//cl1, qsr_arr(:,:,jn) ) |
---|
219 | ELSE |
---|
220 | WRITE(cl2,'(i2.2)') jn |
---|
221 | CALL iom_rstput( kt, nitrst, numrtw, 'qsr_arr_'//cl2, qsr_arr(:,:,jn) ) |
---|
222 | ENDIF |
---|
223 | ENDDO |
---|
224 | CALL iom_rstput( kt, nitrst, numrtw, 'qsr_mean', qsr_mean(:,:) ) |
---|
225 | ENDIF |
---|
226 | ! |
---|
227 | END SUBROUTINE trc_mean_qsr |
---|
228 | |
---|
229 | #else |
---|
230 | !!---------------------------------------------------------------------- |
---|
231 | !! Default key NO passive tracers |
---|
232 | !!---------------------------------------------------------------------- |
---|
233 | CONTAINS |
---|
234 | SUBROUTINE trc_stp( kt ) ! Empty routine |
---|
235 | WRITE(*,*) 'trc_stp: You should not have seen this print! error?', kt |
---|
236 | END SUBROUTINE trc_stp |
---|
237 | #endif |
---|
238 | |
---|
239 | !!====================================================================== |
---|
240 | END MODULE trcstp |
---|