[3] | 1 | MODULE flxfwb |
---|
| 2 | !!====================================================================== |
---|
| 3 | !! *** MODULE flxfwb *** |
---|
| 4 | !! Ocean fluxes : domain averaged freshwater budget |
---|
| 5 | !!====================================================================== |
---|
[359] | 6 | #if ! defined key_dynspg_rl |
---|
[3] | 7 | !!---------------------------------------------------------------------- |
---|
[359] | 8 | !! NOT 'key_dynspg_rl' Free surface formulation |
---|
[18] | 9 | !!---------------------------------------------------------------------- |
---|
[3] | 10 | !! flx_fwb : freshwater budget for global ocean configurations |
---|
| 11 | !! in free surface and forced mode |
---|
| 12 | !! flx_fwb_init : freshwater budget for global ocean configurations |
---|
| 13 | !!---------------------------------------------------------------------- |
---|
| 14 | !! * Modules used |
---|
| 15 | USE oce ! ocean dynamics and tracers |
---|
| 16 | USE dom_oce ! ocean space and time domain |
---|
[18] | 17 | USE cpl_oce ! coupled atmosphere/ocean |
---|
[3] | 18 | USE phycst ! physical constants |
---|
| 19 | USE in_out_manager ! I/O manager |
---|
| 20 | USE lib_mpp ! distribued memory computing library |
---|
| 21 | USE flxrnf ! ocean runoffs |
---|
| 22 | USE ocesbc ! ocean surface boudaries conditions |
---|
| 23 | USE blk_oce |
---|
| 24 | USE flxblk ! bulk formulea |
---|
| 25 | USE daymod ! calendar |
---|
| 26 | |
---|
| 27 | IMPLICIT NONE |
---|
| 28 | PRIVATE |
---|
| 29 | |
---|
| 30 | !! * Routine accessibility |
---|
| 31 | PUBLIC flx_fwb ! routine called by step |
---|
| 32 | PUBLIC flx_fwb_init ! routine called by opa |
---|
| 33 | |
---|
| 34 | !! * Share module variables |
---|
[18] | 35 | LOGICAL, PUBLIC :: & !!: * namelist * |
---|
| 36 | ln_fwb = .TRUE. !: Flag to activate the fwb computation |
---|
| 37 | REAL(wp), PUBLIC :: & !: |
---|
| 38 | a_fwb_b , & !: annual domain averaged freshwater budget |
---|
| 39 | a_fwb !: for 2 year before (_b) and before year. |
---|
[3] | 40 | |
---|
| 41 | !! * Module variables |
---|
| 42 | REAL(wp) :: & |
---|
| 43 | a_emp , & ! domain averaged evaporation minus precipitation |
---|
| 44 | a_precip, & ! domain averaged precipitation |
---|
| 45 | a_rnf , & ! domain averaged runoff |
---|
| 46 | a_sshb , & ! domain averaged sea surface heigh at nit000 |
---|
| 47 | a_sshend, & ! domain averaged sea surface heigh at nitend |
---|
| 48 | a_sal000, & ! domain averaged ocean salinity at nit000 (before time step) |
---|
| 49 | a_salend, & ! domain averaged ocean salinity at nitend (now time step) |
---|
| 50 | a_aminus, & ! |
---|
| 51 | a_aplus |
---|
| 52 | REAL(wp), DIMENSION(jpi,jpj) :: & |
---|
| 53 | e1e2_i ! area of the interior domain (e1t*e2t*tmask_i) |
---|
| 54 | |
---|
| 55 | !! * Substitutions |
---|
| 56 | # include "domzgr_substitute.h90" |
---|
| 57 | # include "vectopt_loop_substitute.h90" |
---|
| 58 | !!---------------------------------------------------------------------- |
---|
[247] | 59 | !!---------------------------------------------------------------------- |
---|
| 60 | !! OPA 9.0 , LOCEAN-IPSL (2005) |
---|
| 61 | !! $Header$ |
---|
| 62 | !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt |
---|
| 63 | !!---------------------------------------------------------------------- |
---|
[3] | 64 | CONTAINS |
---|
| 65 | |
---|
| 66 | SUBROUTINE flx_fwb( kt ) |
---|
| 67 | !!--------------------------------------------------------------------- |
---|
| 68 | !! *** ROUTINE flx_fwb *** |
---|
| 69 | !! |
---|
| 70 | !! ** Purpose : |
---|
| 71 | !! |
---|
| 72 | !! ** Method : |
---|
| 73 | !! |
---|
| 74 | !! History : |
---|
| 75 | !! 8.2 ! 01-02 (E. Durand) Original code |
---|
| 76 | !! 8.5 ! 02-06 (G. Madec) F90: Free form and module |
---|
| 77 | !!---------------------------------------------------------------------- |
---|
| 78 | !! * Arguments |
---|
| 79 | INTEGER, INTENT( in ) :: kt ! ocean time-step index |
---|
| 80 | |
---|
| 81 | !! * Local declarations |
---|
| 82 | INTEGER :: ji, jj, jk ! dummy loop indices |
---|
| 83 | INTEGER :: inum = 11 ! temporary logical unit |
---|
| 84 | INTEGER :: ikty ! |
---|
| 85 | REAL(wp) :: & |
---|
| 86 | zarea, zvol, zwei, & ! temporary scalars |
---|
| 87 | zsm0, zempnew ! " " |
---|
| 88 | !!---------------------------------------------------------------------- |
---|
| 89 | |
---|
| 90 | ! Mean global salinity |
---|
| 91 | zsm0 = 34.72654 |
---|
| 92 | |
---|
| 93 | ! To compute emp mean value mean emp |
---|
| 94 | |
---|
| 95 | IF( kt == nit000 ) THEN |
---|
| 96 | IF(lwp) THEN |
---|
| 97 | WRITE(numout,*) |
---|
| 98 | WRITE(numout,*) 'flx_fwb : FreshWater Budget correction' |
---|
| 99 | WRITE(numout,*) '~~~~~~~' |
---|
| 100 | ENDIF |
---|
| 101 | |
---|
| 102 | a_emp = 0.e0 |
---|
| 103 | a_precip = 0.e0 |
---|
| 104 | a_rnf = 0.e0 |
---|
| 105 | a_sshb = 0.e0 ! averaged sea surface heigh at nit000 |
---|
| 106 | a_sal000 = 0.e0 ! averaged ocean salinity at nit000 |
---|
| 107 | a_aminus = 0.e0 |
---|
| 108 | a_aplus = 0.e0 |
---|
| 109 | |
---|
| 110 | e1e2_i(:,:) = e1t(:,:) * e2t(:,:) * tmask_i(:,:) |
---|
| 111 | a_sshb = SUM( e1e2_i(:,:) * sshn(:,:) ) |
---|
[18] | 112 | IF( lk_mpp ) CALL mpp_sum( a_sshb ) ! sum over all the global domain |
---|
[3] | 113 | DO jk = 1, jpkm1 |
---|
| 114 | DO jj = 2, jpjm1 |
---|
| 115 | DO ji = fs_2, fs_jpim1 ! vector opt. |
---|
| 116 | zwei = e1e2_i(ji,jj) * fse3t(ji,jj,jk) * tmask(ji,jj,jk) |
---|
| 117 | a_sal000 = a_sal000 + ( sb(ji,jj,jk) - zsm0 ) * zwei |
---|
| 118 | END DO |
---|
| 119 | END DO |
---|
| 120 | END DO |
---|
[18] | 121 | IF( lk_mpp ) CALL mpp_sum( a_sal000 ) ! sum over the global domain |
---|
[3] | 122 | |
---|
| 123 | ENDIF |
---|
| 124 | |
---|
| 125 | ! cumulate surface freshwater budget at each time-step |
---|
| 126 | ! --------------------------------------====---------- |
---|
| 127 | a_emp = SUM( e1e2_i(:,:) * emp (:,:) ) |
---|
[18] | 128 | IF( lk_mpp ) CALL mpp_sum( a_emp ) ! sum over the global domain |
---|
[3] | 129 | #if defined key_flx_bulk_monthly || defined key_flx_bulk_daily |
---|
| 130 | a_precip = SUM( e1e2_i(:,:) * watm (:,:) ) |
---|
[18] | 131 | IF( lk_mpp ) CALL mpp_sum( a_precip ) ! sum over the global domain |
---|
[3] | 132 | #endif |
---|
| 133 | a_rnf = SUM( e1e2_i(:,:) * runoff(:,:) ) |
---|
[18] | 134 | IF( lk_mpp ) CALL mpp_sum( a_rnf ) ! sum over the global domain |
---|
[3] | 135 | |
---|
[84] | 136 | IF( aminus /= 0.e0 ) a_aminus = a_aminus + ( MIN( aplus, aminus ) / aminus ) |
---|
| 137 | IF( aplus /= 0.e0 ) a_aplus = a_aplus + ( MIN( aplus, aminus ) / aplus ) |
---|
[3] | 138 | |
---|
| 139 | |
---|
| 140 | ! Update empold if new year start |
---|
[18] | 141 | ikty = 365 * 86400 / rdttra(1) !!bug use of 365 days leap year or 360d year !!!!!!! |
---|
[3] | 142 | IF( MOD( kt, ikty ) == 0 ) THEN |
---|
[18] | 143 | zarea = SUM( e1e2_i(:,:) ) |
---|
| 144 | IF( lk_mpp ) CALL mpp_sum( zarea ) ! sum over the global domain |
---|
| 145 | a_fwb_b = a_fwb |
---|
| 146 | a_fwb = SUM( e1e2_i(:,:) * sshn(:,:) ) |
---|
| 147 | IF( lk_mpp ) CALL mpp_sum( a_fwb ) ! sum over the global domain |
---|
[3] | 148 | |
---|
[18] | 149 | a_fwb = a_fwb * 1.e+3 / ( zarea * 86400. * 365. ) ! convert in Kg/m3/s = mm/s |
---|
| 150 | ! !!bug 365d year |
---|
[193] | 151 | empold = a_fwb ! current year freshwater budget correction |
---|
| 152 | ! ! estimate from the previous year budget |
---|
[3] | 153 | ENDIF |
---|
| 154 | |
---|
| 155 | |
---|
| 156 | IF( kt == nitend ) THEN |
---|
| 157 | zvol = 0.e0 |
---|
| 158 | zempnew = 0.e0 |
---|
| 159 | ! Mean sea level at nitend |
---|
| 160 | a_sshend = SUM( e1e2_i(:,:) * sshn(:,:) ) |
---|
| 161 | zarea = SUM( e1e2_i(:,:) ) |
---|
| 162 | |
---|
| 163 | a_salend = 0.e0 |
---|
| 164 | DO jk = 1, jpkm1 |
---|
| 165 | DO jj = 2, jpjm1 |
---|
| 166 | DO ji = fs_2, fs_jpim1 ! vector opt. |
---|
| 167 | zwei = e1e2_i(ji,jj) * fse3t(ji,jj,jk) * tmask(ji,jj,jk) |
---|
| 168 | a_salend = a_salend + ( sn(ji,jj,jk) - zsm0 ) * zwei |
---|
| 169 | zvol = zvol + zwei |
---|
| 170 | END DO |
---|
| 171 | END DO |
---|
| 172 | END DO |
---|
[18] | 173 | IF( lk_mpp ) THEN |
---|
| 174 | CALL mpp_sum( zarea ) ! sums over all the global domain |
---|
[622] | 175 | CALL mpp_sum( zvol ) |
---|
[18] | 176 | CALL mpp_sum( a_sshend ) |
---|
| 177 | CALL mpp_sum( a_salend ) |
---|
| 178 | ENDIF |
---|
[3] | 179 | |
---|
| 180 | a_aminus = a_aminus / ( nitend - nit000 + 1 ) |
---|
| 181 | a_aplus = a_aplus / ( nitend - nit000 + 1 ) |
---|
| 182 | |
---|
| 183 | ! Conversion in m3 |
---|
| 184 | a_emp = a_emp * rdttra(1) * 1.e-3 |
---|
| 185 | a_precip = a_precip * rdttra(1) * 1.e-3 / rday |
---|
| 186 | a_rnf = a_rnf * rdttra(1) * 1.e-3 |
---|
| 187 | |
---|
| 188 | ENDIF |
---|
| 189 | |
---|
| 190 | |
---|
| 191 | ! Ecriture des diagnostiques |
---|
| 192 | ! -------------------------- |
---|
| 193 | |
---|
| 194 | IF( kt == nitend ) THEN |
---|
| 195 | |
---|
| 196 | OPEN( inum, FILE='EMPave.dat' ) |
---|
| 197 | WRITE(inum, "(24X,I8,2ES24.16)" ) nyear, a_fwb_b, a_fwb |
---|
| 198 | WRITE(inum,*) |
---|
| 199 | WRITE(inum,*) 'Net freshwater budget ' |
---|
| 200 | WRITE(inum,9010) ' emp = ', a_emp , ' m3 =', a_emp /((nitend-nit000+1)*rdttra(1)) * 1.e-6,' Sv' |
---|
| 201 | WRITE(inum,9010) ' precip = ', a_precip, ' m3 =', a_precip/((nitend-nit000+1)*rdttra(1)) * 1.e-6,' Sv' |
---|
| 202 | WRITE(inum,9010) ' a_rnf = ', a_rnf , ' m3 =', a_rnf /((nitend-nit000+1)*rdttra(1)) * 1.e-6,' Sv' |
---|
| 203 | WRITE(inum,*) |
---|
| 204 | WRITE(inum,9010) ' zarea =',zarea |
---|
| 205 | WRITE(inum,9010) ' zvol =',zvol |
---|
| 206 | WRITE(inum,*) |
---|
| 207 | WRITE(inum,*) 'Mean sea level : ' |
---|
| 208 | WRITE(inum,9010) ' at nit000 = ',a_sshb ,' m3 ' |
---|
| 209 | WRITE(inum,9010) ' at nitend = ',a_sshend ,' m3 ' |
---|
| 210 | WRITE(inum,9010) ' diff = ',(a_sshend-a_sshb),' m3 =', (a_sshend-a_sshb)/((nitend-nit000+1)*rdt) * 1.e-6,' Sv' |
---|
| 211 | WRITE(inum,9020) ' mean sea level elevation =', a_sshend/zarea,' m' |
---|
| 212 | WRITE(inum,*) |
---|
| 213 | WRITE(inum,*) 'Anomaly of salinity content : ' |
---|
| 214 | WRITE(inum,9010) ' at nit000 = ', a_sal000 ,' psu.m3 ' |
---|
| 215 | WRITE(inum,9010) ' at nitend = ', a_salend ,' psu.m3 ' |
---|
| 216 | WRITE(inum,9010) ' diff = ', a_salend - a_sal000,' psu.m3' |
---|
| 217 | WRITE(inum,*) |
---|
| 218 | WRITE(inum,*) 'Mean salinity : ' |
---|
| 219 | WRITE(inum,9020) ' at nit000 = ', a_sal000/zvol+zsm0 ,' psu ' |
---|
| 220 | WRITE(inum,9020) ' at nitend = ', a_salend/zvol+zsm0 ,' psu ' |
---|
| 221 | WRITE(inum,9020) ' diff = ', (a_salend-a_sal000)/zvol,' psu' |
---|
| 222 | WRITE(inum,9020) ' S-SLevitus= ', a_salend /zvol,' psu' |
---|
| 223 | WRITE(inum,*) |
---|
| 224 | WRITE(inum,*) 'Coeff : ' |
---|
| 225 | WRITE(inum,9030) ' Alpha+ = ', a_aplus |
---|
| 226 | WRITE(inum,9030) ' Alpha- = ', a_aminus |
---|
| 227 | WRITE(inum,*) |
---|
| 228 | ENDIF |
---|
| 229 | |
---|
| 230 | 9006 FORMAT(1X,A,ES24.16) |
---|
| 231 | 9010 FORMAT(1X,A,ES12.5,A,F10.5,A) |
---|
| 232 | 9020 FORMAT(1X,A,F10.5,A) |
---|
| 233 | 9030 FORMAT(1X,A,F8.2,A) |
---|
| 234 | |
---|
| 235 | END SUBROUTINE flx_fwb |
---|
| 236 | |
---|
| 237 | |
---|
| 238 | SUBROUTINE flx_fwb_init |
---|
| 239 | !!--------------------------------------------------------------------- |
---|
| 240 | !! *** ROUTINE flx_fwb_init *** |
---|
| 241 | !! |
---|
| 242 | !! ** Purpose : |
---|
| 243 | !! |
---|
| 244 | !! ** Method : |
---|
| 245 | !! |
---|
| 246 | !! History : |
---|
| 247 | !! 9.0 ! 03-09 (G. Madec) Original code |
---|
[359] | 248 | !! " ! 05-11 (V. Garnier) Surface pressure gradient organization |
---|
[3] | 249 | !!---------------------------------------------------------------------- |
---|
| 250 | !! * Local declarations |
---|
| 251 | LOGICAL :: llbon |
---|
| 252 | CHARACTER (len=32) :: & |
---|
| 253 | clname = 'EMPave_old.dat' |
---|
| 254 | INTEGER :: inum = 11 ! temporary logical unit |
---|
| 255 | INTEGER :: iyear |
---|
| 256 | |
---|
| 257 | NAMELIST/namfwb/ ln_fwb |
---|
| 258 | !!---------------------------------------------------------------------- |
---|
| 259 | |
---|
| 260 | ! Read Namelist namfwb : freshWater Budget correction |
---|
| 261 | ! -------------------- |
---|
| 262 | REWIND( numnam ) |
---|
| 263 | READ ( numnam, namfwb ) |
---|
| 264 | |
---|
| 265 | ! Parameter control and print |
---|
| 266 | ! --------------------------- |
---|
| 267 | ! Control print |
---|
| 268 | IF(lwp) THEN |
---|
| 269 | WRITE(numout,*) |
---|
| 270 | WRITE(numout,*) 'flx_fwb_init : FreshWater Budget correction' |
---|
| 271 | WRITE(numout,*) '~~~~~~~~~~~~' |
---|
| 272 | WRITE(numout,*) ' Namelist namfwb : set fwb parameters' |
---|
| 273 | WRITE(numout,*) ' use or not fwb correction ln_fwb = ', ln_fwb |
---|
| 274 | ENDIF |
---|
| 275 | ! Option consistency |
---|
[359] | 276 | #if defined key_dynspg_rl |
---|
[3] | 277 | IF(lwp) WRITE ' Rigid-lid option, fwb correction is useless, but valid' |
---|
| 278 | #endif |
---|
[18] | 279 | IF( lk_cpl ) THEN |
---|
| 280 | IF(lwp) WRITE(numout,*) ' Coupled option, fwb correction is a flux correction ! ' |
---|
| 281 | IF(lwp) WRITE(numout,*) ' ln_fwb = .FALSE. is recommanded' |
---|
| 282 | ENDIF |
---|
[3] | 283 | |
---|
[531] | 284 | IF( nbit_cmp == 1 .AND. ln_fwb ) THEN |
---|
| 285 | CALL ctl_stop( ' Reproductibility tests (nbit_cmp=1) require ln_fwb = .false.' ) |
---|
| 286 | END IF |
---|
| 287 | |
---|
[18] | 288 | ! ! ============================== |
---|
[3] | 289 | IF( ln_fwb ) THEN ! Freshwater budget correction |
---|
[18] | 290 | ! ! ============================== |
---|
[3] | 291 | ! Read the corrective factor on precipitations (empold) |
---|
| 292 | INQUIRE( FILE=clname, EXIST=llbon ) |
---|
| 293 | IF( llbon ) THEN |
---|
| 294 | OPEN ( inum, FILE=clname) |
---|
| 295 | READ ( inum, "(24X,I8,2ES24.16)" ) iyear, a_fwb_b, a_fwb |
---|
| 296 | CLOSE( inum ) |
---|
[193] | 297 | empold = a_fwb ! current year freshwater budget correction |
---|
| 298 | ! ! estimate from the previous year budget |
---|
[3] | 299 | IF(lwp)WRITE(numout,*) |
---|
| 300 | IF(lwp)WRITE(numout,*)'flx_fwb_init : year = ',iyear , ' freshwater budget correction = ', empold |
---|
| 301 | IF(lwp)WRITE(numout,*)' year = ',iyear-1, ' freshwater budget read = ', a_fwb |
---|
| 302 | IF(lwp)WRITE(numout,*)' year = ',iyear-2, ' freshwater budget read = ', a_fwb_b |
---|
| 303 | ELSE |
---|
[474] | 304 | WRITE(ctmp1,*)'flx_fwb_init : unable to read the file', clname |
---|
| 305 | CALL ctl_stop( ctmp1 ) |
---|
[3] | 306 | ENDIF |
---|
| 307 | ! ! ============================== |
---|
| 308 | ELSE ! NO budget correction |
---|
| 309 | ! ! ============================== |
---|
| 310 | IF(lwp) WRITE(numout,*) |
---|
[622] | 311 | IF(lwp) WRITE(numout,*)' NO freshwater budget correction' |
---|
[3] | 312 | empold = 0.e0 |
---|
| 313 | ENDIF |
---|
| 314 | |
---|
| 315 | END SUBROUTINE flx_fwb_init |
---|
| 316 | |
---|
| 317 | #else |
---|
[18] | 318 | !!---------------------------------------------------------------------- |
---|
| 319 | !! Default case : |
---|
| 320 | !!---------------------------------------------------------------------- |
---|
| 321 | LOGICAL, PUBLIC :: ln_fwb = .FALSE. !: no fwb forced |
---|
[3] | 322 | CONTAINS |
---|
[18] | 323 | SUBROUTINE flx_fwb( kt ) ! dummy routine |
---|
| 324 | WRITE(*,*) 'flx_fwb: You should not have seen this print! error?', kt |
---|
[3] | 325 | END SUBROUTINE flx_fwb |
---|
| 326 | SUBROUTINE flx_fwb_init |
---|
| 327 | END SUBROUTINE flx_fwb_init |
---|
| 328 | #endif |
---|
| 329 | !!====================================================================== |
---|
| 330 | END MODULE flxfwb |
---|