[1457] | 1 | MODULE 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 |
---|
[6487] | 34 | INTEGER :: nb_rec_per_day |
---|
[5385] | 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) |
---|
[6486] | 42 | !! $Id$ |
---|
[2528] | 43 | !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt) |
---|
[1457] | 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 | !!------------------------------------------------------------------- |
---|
[8280] | 57 | |
---|
| 58 | USE dom_oce, ONLY: narea |
---|
| 59 | |
---|
[3294] | 60 | INTEGER, INTENT( in ) :: kt ! ocean time-step index |
---|
| 61 | INTEGER :: jk, jn ! dummy loop indices |
---|
| 62 | REAL(wp) :: ztrai |
---|
[4306] | 63 | CHARACTER (len=25) :: charout |
---|
| 64 | |
---|
[2528] | 65 | !!------------------------------------------------------------------- |
---|
[3294] | 66 | ! |
---|
| 67 | IF( nn_timing == 1 ) CALL timing_start('trc_stp') |
---|
| 68 | ! |
---|
[4990] | 69 | IF( kt == nittrc000 .AND. lk_trdmxl_trc ) CALL trd_mxl_trc_init ! trends: Mixed-layer |
---|
[3294] | 70 | ! |
---|
[3319] | 71 | IF( lk_vvl ) THEN ! update ocean volume due to ssh temporal evolution |
---|
[3294] | 72 | DO jk = 1, jpk |
---|
| 73 | cvol(:,:,jk) = e1e2t(:,:) * fse3t(:,:,jk) * tmask(:,:,jk) |
---|
| 74 | END DO |
---|
[3319] | 75 | IF( lk_degrad ) cvol(:,:,:) = cvol(:,:,:) * facvol(:,:,:) ! degrad option: reduction by facvol |
---|
[3294] | 76 | areatot = glob_sum( cvol(:,:,:) ) |
---|
| 77 | ENDIF |
---|
[5385] | 78 | ! |
---|
| 79 | IF( l_trcdm2dc ) CALL trc_mean_qsr( kt ) |
---|
[3294] | 80 | ! |
---|
[4306] | 81 | IF( nn_dttrc /= 1 ) CALL trc_sub_stp( kt ) ! averaging physical variables for sub-stepping |
---|
| 82 | ! |
---|
| 83 | IF( MOD( kt , nn_dttrc ) == 0 ) THEN ! only every nn_dttrc time step |
---|
[2528] | 84 | ! |
---|
| 85 | IF(ln_ctl) THEN |
---|
| 86 | WRITE(charout,FMT="('kt =', I4,' d/m/y =',I2,I2,I4)") kt, nday, nmonth, nyear |
---|
| 87 | CALL prt_ctl_trc_info(charout) |
---|
| 88 | ENDIF |
---|
| 89 | ! |
---|
| 90 | tra(:,:,:,:) = 0.e0 |
---|
| 91 | ! |
---|
[8280] | 92 | # if defined key_debug_medusa |
---|
| 93 | IF(lwp) WRITE(numout,*) ' MEDUSA trc_stp begins at kt =', kt |
---|
| 94 | CALL flush(numout) |
---|
| 95 | # endif |
---|
[3294] | 96 | CALL trc_rst_opn ( kt ) ! Open tracer restart file |
---|
[8280] | 97 | # if defined key_debug_medusa |
---|
| 98 | CALL trc_rst_stat |
---|
| 99 | CALL trc_rst_tra_stat |
---|
| 100 | # endif |
---|
[3680] | 101 | IF( lrst_trc ) CALL trc_rst_cal ( kt, 'WRITE' ) ! calendar |
---|
[3294] | 102 | IF( lk_iomput ) THEN ; CALL trc_wri ( kt ) ! output of passive tracers with iom I/O manager |
---|
| 103 | ELSE ; CALL trc_dia ( kt ) ! output of passive tracers with old I/O manager |
---|
[2528] | 104 | ENDIF |
---|
[3294] | 105 | CALL trc_sms ( kt ) ! tracers: sinks and sources |
---|
[8280] | 106 | # if defined key_debug_medusa |
---|
| 107 | IF(lwp) WRITE(numout,*) ' MEDUSA trc_stp SMS complete at kt =', kt |
---|
| 108 | CALL trc_rst_stat |
---|
| 109 | CALL trc_rst_tra_stat |
---|
| 110 | CALL flush(numout) |
---|
| 111 | # endif |
---|
[3294] | 112 | CALL trc_trp ( kt ) ! transport of passive tracers |
---|
[8280] | 113 | # if defined key_debug_medusa |
---|
| 114 | IF(lwp) WRITE(numout,*) ' MEDUSA trc_stp transport complete at kt =', kt |
---|
| 115 | CALL trc_rst_stat |
---|
| 116 | CALL trc_rst_tra_stat |
---|
| 117 | CALL flush(numout) |
---|
| 118 | # endif |
---|
[4147] | 119 | IF( kt == nittrc000 ) THEN |
---|
| 120 | CALL iom_close( numrtr ) ! close input tracer restart file |
---|
[4624] | 121 | IF(lwm) CALL FLUSH( numont ) ! flush namelist output |
---|
[4147] | 122 | ENDIF |
---|
[3294] | 123 | IF( lrst_trc ) CALL trc_rst_wri ( kt ) ! write tracer restart file |
---|
[4990] | 124 | IF( lk_trdmxl_trc ) CALL trd_mxl_trc ( kt ) ! trends: Mixed-layer |
---|
[2528] | 125 | ! |
---|
[3294] | 126 | IF( nn_dttrc /= 1 ) CALL trc_sub_reset( kt ) ! resetting physical variables when sub-stepping |
---|
[8280] | 127 | # if defined key_debug_medusa |
---|
| 128 | IF(lwp) WRITE(numout,*) ' MEDUSA trc_stp ends at kt =', kt |
---|
| 129 | CALL flush(numout) |
---|
| 130 | # endif |
---|
[3294] | 131 | ! |
---|
[1457] | 132 | ENDIF |
---|
[3294] | 133 | ! |
---|
[8280] | 134 | IF (ln_ctl) THEN |
---|
| 135 | ! The following code is very expensive since it involves multiple |
---|
| 136 | ! reproducible global sums over all tracer fields and is potentially |
---|
| 137 | ! called on every timestep. The results it produces are purely for |
---|
| 138 | ! informational purposes and do not affect model evolution. |
---|
| 139 | ! Hence we restrict its use by protecting it with the ln_ctl RTL |
---|
| 140 | ! which should normally only be used under debugging conditions |
---|
| 141 | ! and not in operational runs. We also need to restrict output |
---|
| 142 | ! to the master PE since there's no point duplicating the same results |
---|
| 143 | ! on all processors. |
---|
| 144 | ztrai = 0._wp ! content of all tracers |
---|
| 145 | DO jn = 1, jptra |
---|
| 146 | ztrai = ztrai + glob_sum( trn(:,:,:,jn) * cvol(:,:,:) ) |
---|
| 147 | END DO |
---|
| 148 | IF( numstr /= -1 ) WRITE(numstr,9300) kt, ztrai / areatot |
---|
| 149 | 9300 FORMAT(i10,e18.10) |
---|
| 150 | ENDIF |
---|
[3294] | 151 | ! |
---|
| 152 | IF( nn_timing == 1 ) CALL timing_stop('trc_stp') |
---|
| 153 | ! |
---|
[1457] | 154 | END SUBROUTINE trc_stp |
---|
| 155 | |
---|
[5385] | 156 | SUBROUTINE trc_mean_qsr( kt ) |
---|
| 157 | !!---------------------------------------------------------------------- |
---|
| 158 | !! *** ROUTINE trc_mean_qsr *** |
---|
| 159 | !! |
---|
| 160 | !! ** Purpose : Compute daily mean qsr for biogeochemical model in case |
---|
| 161 | !! of diurnal cycle |
---|
| 162 | !! |
---|
[6487] | 163 | !! ** Method : store in TOP the qsr every hour ( or every time-step if the latter |
---|
[5385] | 164 | !! is greater than 1 hour ) and then, compute the mean with |
---|
| 165 | !! a moving average over 24 hours. |
---|
| 166 | !! In coupled mode, the sampling is done at every coupling frequency |
---|
| 167 | !!---------------------------------------------------------------------- |
---|
| 168 | INTEGER, INTENT(in) :: kt |
---|
| 169 | INTEGER :: jn |
---|
| 170 | |
---|
| 171 | IF( kt == nittrc000 ) THEN |
---|
[5407] | 172 | IF( ln_cpl ) THEN |
---|
[5385] | 173 | rdt_sampl = 86400. / ncpl_qsr_freq |
---|
[6487] | 174 | nb_rec_per_day = ncpl_qsr_freq |
---|
[5385] | 175 | ELSE |
---|
| 176 | rdt_sampl = MAX( 3600., rdt * nn_dttrc ) |
---|
[6487] | 177 | nb_rec_per_day = INT( 86400 / rdt_sampl ) |
---|
[5385] | 178 | ENDIF |
---|
| 179 | ! |
---|
| 180 | IF( lwp ) THEN |
---|
| 181 | WRITE(numout,*) |
---|
[6487] | 182 | WRITE(numout,*) ' Sampling frequency dt = ', rdt_sampl, 's',' Number of sampling per day nrec = ', nb_rec_per_day |
---|
[5385] | 183 | WRITE(numout,*) |
---|
| 184 | ENDIF |
---|
| 185 | ! |
---|
[6487] | 186 | ! !* Restart: read in restart file |
---|
| 187 | IF( ln_rsttr .AND. iom_varid( numrtr, 'qsr_mean', ldstop = .FALSE. ) > 0 ) THEN |
---|
| 188 | IF(lwp) WRITE(numout,*) 'trc_qsr_mean: qsr_mean read in the restart file' |
---|
| 189 | CALL iom_get( numrtr, jpdom_autoglo, 'qsr_mean', qsr_mean ) ! A mean of qsr |
---|
| 190 | ELSE !* no restart: set from nit000 values |
---|
| 191 | IF(lwp) WRITE(numout,*) 'trc_qsr_mean: qsr_mean set to nit000 values' |
---|
| 192 | qsr_mean(:,:) = qsr(:,:) |
---|
| 193 | ENDIF |
---|
| 194 | ! |
---|
| 195 | ALLOCATE( qsr_arr(jpi,jpj,nb_rec_per_day ) ) |
---|
| 196 | DO jn = 1, nb_rec_per_day |
---|
| 197 | qsr_arr(:,:,jn) = qsr_mean(:,:) |
---|
[5385] | 198 | ENDDO |
---|
| 199 | ! |
---|
| 200 | isecfst = nsec_year + nsec1jan000 ! number of seconds between Jan. 1st 00h of nit000 year and the middle of time step |
---|
| 201 | iseclast = isecfst |
---|
| 202 | ! |
---|
| 203 | ENDIF |
---|
| 204 | ! |
---|
| 205 | iseclast = nsec_year + nsec1jan000 |
---|
| 206 | llnew = ( iseclast - isecfst ) > INT( rdt_sampl ) ! new shortwave to store |
---|
| 207 | IF( kt /= nittrc000 .AND. llnew ) THEN |
---|
| 208 | IF( lwp ) WRITE(numout,*) ' New shortwave to sample for TOP at time kt = ', kt, & |
---|
| 209 | & ' time = ', (iseclast+rdt*nn_dttrc/2.)/3600.,'hours ' |
---|
| 210 | isecfst = iseclast |
---|
[6487] | 211 | DO jn = 1, nb_rec_per_day - 1 |
---|
[5385] | 212 | qsr_arr(:,:,jn) = qsr_arr(:,:,jn+1) |
---|
| 213 | ENDDO |
---|
[6487] | 214 | qsr_arr (:,:,nb_rec_per_day) = qsr(:,:) |
---|
| 215 | qsr_mean(:,: ) = SUM( qsr_arr(:,:,:), 3 ) / nb_rec_per_day |
---|
[5385] | 216 | ENDIF |
---|
| 217 | ! |
---|
[6487] | 218 | IF( lrst_trc ) THEN !* Write the mean of qsr in restart file |
---|
| 219 | IF(lwp) WRITE(numout,*) |
---|
| 220 | IF(lwp) WRITE(numout,*) 'trc_mean_qsr : write qsr_mean in restart file kt =', kt |
---|
| 221 | IF(lwp) WRITE(numout,*) '~~~~~~~' |
---|
| 222 | CALL iom_rstput( kt, nitrst, numrtw, 'qsr_mean', qsr_mean(:,:) ) |
---|
| 223 | ENDIF |
---|
| 224 | ! |
---|
[5385] | 225 | END SUBROUTINE trc_mean_qsr |
---|
| 226 | |
---|
[1457] | 227 | #else |
---|
| 228 | !!---------------------------------------------------------------------- |
---|
| 229 | !! Default key NO passive tracers |
---|
| 230 | !!---------------------------------------------------------------------- |
---|
| 231 | CONTAINS |
---|
| 232 | SUBROUTINE trc_stp( kt ) ! Empty routine |
---|
| 233 | WRITE(*,*) 'trc_stp: You should not have seen this print! error?', kt |
---|
| 234 | END SUBROUTINE trc_stp |
---|
| 235 | #endif |
---|
| 236 | |
---|
| 237 | !!====================================================================== |
---|
| 238 | END MODULE trcstp |
---|