[2148] | 1 | MODULE diahsb |
---|
| 2 | !!====================================================================== |
---|
| 3 | !! *** MODULE diahsb *** |
---|
[2334] | 4 | !! Ocean diagnostics: Heat, salt and volume budgets |
---|
[2148] | 5 | !!====================================================================== |
---|
[2334] | 6 | !! History : 3.3 ! 2010-09 (M. Leclair) Original code |
---|
[4161] | 7 | !! ! 2012-10 (C. Rousset) add iom_put |
---|
[2148] | 8 | !!---------------------------------------------------------------------- |
---|
[2334] | 9 | |
---|
| 10 | !!---------------------------------------------------------------------- |
---|
[4990] | 11 | !! dia_hsb : Diagnose the conservation of ocean heat and salt contents, and volume |
---|
| 12 | !! dia_hsb_rst : Read or write DIA file in restart file |
---|
| 13 | !! dia_hsb_init : Initialization of the conservation diagnostic |
---|
| 14 | !!---------------------------------------------------------------------- |
---|
[9168] | 15 | USE oce ! ocean dynamics and tracers |
---|
| 16 | USE dom_oce ! ocean space and time domain |
---|
| 17 | USE phycst ! physical constants |
---|
| 18 | USE sbc_oce ! surface thermohaline fluxes |
---|
| 19 | USE sbcrnf ! river runoff |
---|
| 20 | USE sbcisf ! ice shelves |
---|
| 21 | USE domvvl ! vertical scale factors |
---|
| 22 | USE traqsr ! penetrative solar radiation |
---|
| 23 | USE trabbc ! bottom boundary condition |
---|
| 24 | USE trabbc ! bottom boundary condition |
---|
| 25 | USE restart ! ocean restart |
---|
| 26 | USE bdy_oce , ONLY : ln_bdy |
---|
[4990] | 27 | ! |
---|
[9168] | 28 | USE iom ! I/O manager |
---|
| 29 | USE in_out_manager ! I/O manager |
---|
| 30 | USE lib_fortran ! glob_sum |
---|
| 31 | USE lib_mpp ! distributed memory computing library |
---|
| 32 | USE timing ! preformance summary |
---|
[2148] | 33 | |
---|
| 34 | IMPLICIT NONE |
---|
| 35 | PRIVATE |
---|
| 36 | |
---|
[2334] | 37 | PUBLIC dia_hsb ! routine called by step.F90 |
---|
[4161] | 38 | PUBLIC dia_hsb_init ! routine called by nemogcm.F90 |
---|
[2148] | 39 | |
---|
[4147] | 40 | LOGICAL, PUBLIC :: ln_diahsb !: check the heat and salt budgets |
---|
[2148] | 41 | |
---|
[4990] | 42 | REAL(wp) :: surf_tot ! ocean surface |
---|
| 43 | REAL(wp) :: frc_t, frc_s, frc_v ! global forcing trends |
---|
| 44 | REAL(wp) :: frc_wn_t, frc_wn_s ! global forcing trends |
---|
| 45 | ! |
---|
[6140] | 46 | REAL(wp), DIMENSION(:,:) , ALLOCATABLE :: surf |
---|
| 47 | REAL(wp), DIMENSION(:,:) , ALLOCATABLE :: surf_ini , ssh_ini ! |
---|
[4990] | 48 | REAL(wp), DIMENSION(:,:) , ALLOCATABLE :: ssh_hc_loc_ini, ssh_sc_loc_ini ! |
---|
| 49 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: hc_loc_ini, sc_loc_ini, e3t_ini ! |
---|
[2148] | 50 | |
---|
| 51 | !! * Substitutions |
---|
| 52 | # include "vectopt_loop_substitute.h90" |
---|
| 53 | !!---------------------------------------------------------------------- |
---|
[2287] | 54 | !! NEMO/OPA 3.3 , NEMO Consortium (2010) |
---|
[2281] | 55 | !! $Id$ |
---|
[2334] | 56 | !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt) |
---|
[2148] | 57 | !!---------------------------------------------------------------------- |
---|
| 58 | CONTAINS |
---|
| 59 | |
---|
| 60 | SUBROUTINE dia_hsb( kt ) |
---|
| 61 | !!--------------------------------------------------------------------------- |
---|
| 62 | !! *** ROUTINE dia_hsb *** |
---|
| 63 | !! |
---|
[2334] | 64 | !! ** Purpose: Compute the ocean global heat content, salt content and volume conservation |
---|
[2148] | 65 | !! |
---|
| 66 | !! ** Method : - Compute the deviation of heat content, salt content and volume |
---|
[2334] | 67 | !! at the current time step from their values at nit000 |
---|
| 68 | !! - Compute the contribution of forcing and remove it from these deviations |
---|
| 69 | !! |
---|
[2148] | 70 | !!--------------------------------------------------------------------------- |
---|
| 71 | INTEGER, INTENT(in) :: kt ! ocean time-step index |
---|
[4990] | 72 | ! |
---|
| 73 | INTEGER :: ji, jj, jk ! dummy loop indice |
---|
| 74 | REAL(wp) :: zdiff_hc , zdiff_sc ! heat and salt content variations |
---|
| 75 | REAL(wp) :: zdiff_hc1 , zdiff_sc1 ! - - - - |
---|
| 76 | REAL(wp) :: zdiff_v1 , zdiff_v2 ! volume variation |
---|
| 77 | REAL(wp) :: zerr_hc1 , zerr_sc1 ! heat and salt content misfit |
---|
| 78 | REAL(wp) :: zvol_tot ! volume |
---|
| 79 | REAL(wp) :: z_frc_trd_t , z_frc_trd_s ! - - |
---|
| 80 | REAL(wp) :: z_frc_trd_v ! - - |
---|
| 81 | REAL(wp) :: z_wn_trd_t , z_wn_trd_s ! - - |
---|
| 82 | REAL(wp) :: z_ssh_hc , z_ssh_sc ! - - |
---|
[9124] | 83 | REAL(wp), DIMENSION(jpi,jpj) :: z2d0, z2d1 ! 2D workspace |
---|
[2148] | 84 | !!--------------------------------------------------------------------------- |
---|
[9124] | 85 | IF( ln_timing ) CALL timing_start('dia_hsb') |
---|
[7646] | 86 | ! |
---|
[7753] | 87 | tsn(:,:,:,1) = tsn(:,:,:,1) * tmask(:,:,:) ; tsb(:,:,:,1) = tsb(:,:,:,1) * tmask(:,:,:) ; |
---|
| 88 | tsn(:,:,:,2) = tsn(:,:,:,2) * tmask(:,:,:) ; tsb(:,:,:,2) = tsb(:,:,:,2) * tmask(:,:,:) ; |
---|
[2148] | 89 | ! ------------------------- ! |
---|
| 90 | ! 1 - Trends due to forcing ! |
---|
| 91 | ! ------------------------- ! |
---|
[5643] | 92 | z_frc_trd_v = r1_rau0 * glob_sum( - ( emp(:,:) - rnf(:,:) + fwfisf(:,:) ) * surf(:,:) ) ! volume fluxes |
---|
[4990] | 93 | z_frc_trd_t = glob_sum( sbc_tsc(:,:,jp_tem) * surf(:,:) ) ! heat fluxes |
---|
| 94 | z_frc_trd_s = glob_sum( sbc_tsc(:,:,jp_sal) * surf(:,:) ) ! salt fluxes |
---|
[5120] | 95 | ! Add runoff heat & salt input |
---|
[4558] | 96 | IF( ln_rnf ) z_frc_trd_t = z_frc_trd_t + glob_sum( rnf_tsc(:,:,jp_tem) * surf(:,:) ) |
---|
| 97 | IF( ln_rnf_sal) z_frc_trd_s = z_frc_trd_s + glob_sum( rnf_tsc(:,:,jp_sal) * surf(:,:) ) |
---|
[5120] | 98 | ! Add ice shelf heat & salt input |
---|
[6140] | 99 | IF( ln_isf ) z_frc_trd_t = z_frc_trd_t + glob_sum( risf_tsc(:,:,jp_tem) * surf(:,:) ) |
---|
[2148] | 100 | ! Add penetrative solar radiation |
---|
[4558] | 101 | IF( ln_traqsr ) z_frc_trd_t = z_frc_trd_t + r1_rau0_rcp * glob_sum( qsr (:,:) * surf(:,:) ) |
---|
[2148] | 102 | ! Add geothermal heat flux |
---|
[4558] | 103 | IF( ln_trabbc ) z_frc_trd_t = z_frc_trd_t + glob_sum( qgh_trd0(:,:) * surf(:,:) ) |
---|
[4161] | 104 | ! |
---|
[6140] | 105 | IF( ln_linssh ) THEN |
---|
| 106 | IF( ln_isfcav ) THEN |
---|
[5120] | 107 | DO ji=1,jpi |
---|
| 108 | DO jj=1,jpj |
---|
| 109 | z2d0(ji,jj) = surf(ji,jj) * wn(ji,jj,mikt(ji,jj)) * tsb(ji,jj,mikt(ji,jj),jp_tem) |
---|
| 110 | z2d1(ji,jj) = surf(ji,jj) * wn(ji,jj,mikt(ji,jj)) * tsb(ji,jj,mikt(ji,jj),jp_sal) |
---|
[6140] | 111 | END DO |
---|
| 112 | END DO |
---|
[5120] | 113 | ELSE |
---|
[7753] | 114 | z2d0(:,:) = surf(:,:) * wn(:,:,1) * tsb(:,:,1,jp_tem) |
---|
| 115 | z2d1(:,:) = surf(:,:) * wn(:,:,1) * tsb(:,:,1,jp_sal) |
---|
[5120] | 116 | END IF |
---|
[4990] | 117 | z_wn_trd_t = - glob_sum( z2d0 ) |
---|
| 118 | z_wn_trd_s = - glob_sum( z2d1 ) |
---|
[4558] | 119 | ENDIF |
---|
| 120 | |
---|
[2148] | 121 | frc_v = frc_v + z_frc_trd_v * rdt |
---|
| 122 | frc_t = frc_t + z_frc_trd_t * rdt |
---|
| 123 | frc_s = frc_s + z_frc_trd_s * rdt |
---|
[4558] | 124 | ! ! Advection flux through fixed surface (z=0) |
---|
[6140] | 125 | IF( ln_linssh ) THEN |
---|
[4558] | 126 | frc_wn_t = frc_wn_t + z_wn_trd_t * rdt |
---|
| 127 | frc_wn_s = frc_wn_s + z_wn_trd_s * rdt |
---|
| 128 | ENDIF |
---|
[2148] | 129 | |
---|
[4161] | 130 | ! ------------------------ ! |
---|
[4558] | 131 | ! 2 - Content variations ! |
---|
[4161] | 132 | ! ------------------------ ! |
---|
[6140] | 133 | ! glob_sum_full is needed because you keep the full interior domain to compute the sum (iscpl) |
---|
[4990] | 134 | zdiff_v2 = 0._wp |
---|
| 135 | zdiff_hc = 0._wp |
---|
| 136 | zdiff_sc = 0._wp |
---|
[4558] | 137 | |
---|
[2148] | 138 | ! volume variation (calculated with ssh) |
---|
[6140] | 139 | zdiff_v1 = glob_sum_full( surf(:,:) * sshn(:,:) - surf_ini(:,:) * ssh_ini(:,:) ) |
---|
[4558] | 140 | |
---|
| 141 | ! heat & salt content variation (associated with ssh) |
---|
[6140] | 142 | IF( ln_linssh ) THEN |
---|
| 143 | IF( ln_isfcav ) THEN |
---|
[5120] | 144 | DO ji = 1, jpi |
---|
| 145 | DO jj = 1, jpj |
---|
| 146 | z2d0(ji,jj) = surf(ji,jj) * ( tsn(ji,jj,mikt(ji,jj),jp_tem) * sshn(ji,jj) - ssh_hc_loc_ini(ji,jj) ) |
---|
| 147 | z2d1(ji,jj) = surf(ji,jj) * ( tsn(ji,jj,mikt(ji,jj),jp_sal) * sshn(ji,jj) - ssh_sc_loc_ini(ji,jj) ) |
---|
| 148 | END DO |
---|
[4990] | 149 | END DO |
---|
[5120] | 150 | ELSE |
---|
[7753] | 151 | z2d0(:,:) = surf(:,:) * ( tsn(:,:,1,jp_tem) * sshn(:,:) - ssh_hc_loc_ini(:,:) ) |
---|
| 152 | z2d1(:,:) = surf(:,:) * ( tsn(:,:,1,jp_sal) * sshn(:,:) - ssh_sc_loc_ini(:,:) ) |
---|
[5120] | 153 | END IF |
---|
[6140] | 154 | z_ssh_hc = glob_sum_full( z2d0 ) |
---|
| 155 | z_ssh_sc = glob_sum_full( z2d1 ) |
---|
[4558] | 156 | ENDIF |
---|
| 157 | |
---|
[2148] | 158 | DO jk = 1, jpkm1 |
---|
[4161] | 159 | ! volume variation (calculated with scale factors) |
---|
[6140] | 160 | zdiff_v2 = zdiff_v2 + glob_sum_full( surf(:,:) * tmask(:,:,jk) & |
---|
| 161 | & * e3t_n(:,:,jk) - surf_ini(:,:) * e3t_ini(:,:,jk) ) |
---|
[2148] | 162 | ! heat content variation |
---|
[6140] | 163 | zdiff_hc = zdiff_hc + glob_sum_full( surf(:,:) * tmask(:,:,jk) & |
---|
| 164 | & * e3t_n(:,:,jk) * tsn(:,:,jk,jp_tem) - surf_ini(:,:) * hc_loc_ini(:,:,jk) ) |
---|
[2148] | 165 | ! salt content variation |
---|
[6140] | 166 | zdiff_sc = zdiff_sc + glob_sum_full( surf (:,:) * tmask(:,:,jk) & |
---|
| 167 | * e3t_n(:,:,jk) * tsn(:,:,jk,jp_sal) - surf_ini(:,:) * sc_loc_ini(:,:,jk) ) |
---|
[2148] | 168 | ENDDO |
---|
| 169 | |
---|
[7646] | 170 | ! ------------------------ ! |
---|
| 171 | ! 3 - Drifts ! |
---|
| 172 | ! ------------------------ ! |
---|
[4558] | 173 | zdiff_v1 = zdiff_v1 - frc_v |
---|
[6140] | 174 | IF( .NOT.ln_linssh ) zdiff_v2 = zdiff_v2 - frc_v |
---|
[4558] | 175 | zdiff_hc = zdiff_hc - frc_t |
---|
| 176 | zdiff_sc = zdiff_sc - frc_s |
---|
[6140] | 177 | IF( ln_linssh ) THEN |
---|
[4558] | 178 | zdiff_hc1 = zdiff_hc + z_ssh_hc |
---|
| 179 | zdiff_sc1 = zdiff_sc + z_ssh_sc |
---|
| 180 | zerr_hc1 = z_ssh_hc - frc_wn_t |
---|
| 181 | zerr_sc1 = z_ssh_sc - frc_wn_s |
---|
[4162] | 182 | ENDIF |
---|
[4558] | 183 | |
---|
[2148] | 184 | ! ----------------------- ! |
---|
[7646] | 185 | ! 4 - Diagnostics writing ! |
---|
[4161] | 186 | ! ----------------------- ! |
---|
[4990] | 187 | zvol_tot = 0._wp ! total ocean volume (calculated with scale factors) |
---|
[4161] | 188 | DO jk = 1, jpkm1 |
---|
[6140] | 189 | zvol_tot = zvol_tot + glob_sum_full( surf(:,:) * tmask(:,:,jk) * e3t_n(:,:,jk) ) |
---|
[4558] | 190 | END DO |
---|
| 191 | |
---|
[4990] | 192 | !!gm to be added ? |
---|
[6140] | 193 | ! IF( ln_linssh ) THEN ! fixed volume, add the ssh contribution |
---|
[4990] | 194 | ! zvol_tot = zvol_tot + glob_sum( surf(:,:) * sshn(:,:) ) |
---|
| 195 | ! ENDIF |
---|
| 196 | !!gm end |
---|
| 197 | |
---|
[7646] | 198 | CALL iom_put( 'bgfrcvol' , frc_v * 1.e-9 ) ! vol - surface forcing (km3) |
---|
| 199 | CALL iom_put( 'bgfrctem' , frc_t * rau0 * rcp * 1.e-20 ) ! hc - surface forcing (1.e20 J) |
---|
| 200 | CALL iom_put( 'bgfrchfx' , frc_t * rau0 * rcp / & ! hc - surface forcing (W/m2) |
---|
| 201 | & ( surf_tot * kt * rdt ) ) |
---|
| 202 | CALL iom_put( 'bgfrcsal' , frc_s * 1.e-9 ) ! sc - surface forcing (psu*km3) |
---|
| 203 | |
---|
| 204 | IF( .NOT. ln_linssh ) THEN |
---|
| 205 | CALL iom_put( 'bgtemper' , zdiff_hc / zvol_tot ) ! Temperature drift (C) |
---|
| 206 | CALL iom_put( 'bgsaline' , zdiff_sc / zvol_tot ) ! Salinity drift (pss) |
---|
| 207 | CALL iom_put( 'bgheatco' , zdiff_hc * 1.e-20 * rau0 * rcp ) ! Heat content drift (1.e20 J) |
---|
| 208 | CALL iom_put( 'bgheatfx' , zdiff_hc * rau0 * rcp / & ! Heat flux drift (W/m2) |
---|
| 209 | & ( surf_tot * kt * rdt ) ) |
---|
| 210 | CALL iom_put( 'bgsaltco' , zdiff_sc * 1.e-9 ) ! Salt content drift (psu*km3) |
---|
| 211 | CALL iom_put( 'bgvolssh' , zdiff_v1 * 1.e-9 ) ! volume ssh drift (km3) |
---|
| 212 | CALL iom_put( 'bgvole3t' , zdiff_v2 * 1.e-9 ) ! volume e3t drift (km3) |
---|
| 213 | ELSE |
---|
| 214 | CALL iom_put( 'bgtemper' , zdiff_hc1 / zvol_tot) ! Heat content drift (C) |
---|
| 215 | CALL iom_put( 'bgsaline' , zdiff_sc1 / zvol_tot) ! Salt content drift (pss) |
---|
| 216 | CALL iom_put( 'bgheatco' , zdiff_hc1 * 1.e-20 * rau0 * rcp ) ! Heat content drift (1.e20 J) |
---|
| 217 | CALL iom_put( 'bgheatfx' , zdiff_hc1 * rau0 * rcp / & ! Heat flux drift (W/m2) |
---|
| 218 | & ( surf_tot * kt * rdt ) ) |
---|
| 219 | CALL iom_put( 'bgsaltco' , zdiff_sc1 * 1.e-9 ) ! Salt content drift (psu*km3) |
---|
| 220 | CALL iom_put( 'bgvolssh' , zdiff_v1 * 1.e-9 ) ! volume ssh drift (km3) |
---|
[6140] | 221 | CALL iom_put( 'bgmistem' , zerr_hc1 / zvol_tot ) ! hc - error due to free surface (C) |
---|
| 222 | CALL iom_put( 'bgmissal' , zerr_sc1 / zvol_tot ) ! sc - error due to free surface (psu) |
---|
[4162] | 223 | ENDIF |
---|
[4558] | 224 | ! |
---|
| 225 | IF( lrst_oce ) CALL dia_hsb_rst( kt, 'WRITE' ) |
---|
[6140] | 226 | ! |
---|
[9124] | 227 | IF( ln_timing ) CALL timing_stop('dia_hsb') |
---|
[6140] | 228 | ! |
---|
[2148] | 229 | END SUBROUTINE dia_hsb |
---|
| 230 | |
---|
[2334] | 231 | |
---|
[4161] | 232 | SUBROUTINE dia_hsb_rst( kt, cdrw ) |
---|
[9169] | 233 | !!--------------------------------------------------------------------- |
---|
| 234 | !! *** ROUTINE dia_hsb_rst *** |
---|
| 235 | !! |
---|
| 236 | !! ** Purpose : Read or write DIA file in restart file |
---|
| 237 | !! |
---|
| 238 | !! ** Method : use of IOM library |
---|
| 239 | !!---------------------------------------------------------------------- |
---|
| 240 | INTEGER , INTENT(in) :: kt ! ocean time-step |
---|
| 241 | CHARACTER(len=*), INTENT(in) :: cdrw ! "READ"/"WRITE" flag |
---|
| 242 | ! |
---|
| 243 | INTEGER :: ji, jj, jk ! dummy loop indices |
---|
| 244 | !!---------------------------------------------------------------------- |
---|
| 245 | ! |
---|
| 246 | IF( TRIM(cdrw) == 'READ' ) THEN ! Read/initialise |
---|
| 247 | IF( ln_rstart ) THEN !* Read the restart file |
---|
| 248 | ! |
---|
| 249 | IF(lwp) WRITE(numout,*) |
---|
| 250 | IF(lwp) WRITE(numout,*) ' dia_hsb_rst : read hsb restart at it= ', kt,' date= ', ndastp |
---|
| 251 | IF(lwp) WRITE(numout,*) |
---|
| 252 | CALL iom_get( numror, 'frc_v', frc_v ) |
---|
| 253 | CALL iom_get( numror, 'frc_t', frc_t ) |
---|
| 254 | CALL iom_get( numror, 'frc_s', frc_s ) |
---|
| 255 | IF( ln_linssh ) THEN |
---|
| 256 | CALL iom_get( numror, 'frc_wn_t', frc_wn_t ) |
---|
| 257 | CALL iom_get( numror, 'frc_wn_s', frc_wn_s ) |
---|
| 258 | ENDIF |
---|
| 259 | CALL iom_get( numror, jpdom_autoglo, 'surf_ini', surf_ini ) ! ice sheet coupling |
---|
| 260 | CALL iom_get( numror, jpdom_autoglo, 'ssh_ini', ssh_ini(:,:) ) |
---|
| 261 | CALL iom_get( numror, jpdom_autoglo, 'e3t_ini', e3t_ini(:,:,:) ) |
---|
| 262 | CALL iom_get( numror, jpdom_autoglo, 'hc_loc_ini', hc_loc_ini(:,:,:) ) |
---|
| 263 | CALL iom_get( numror, jpdom_autoglo, 'sc_loc_ini', sc_loc_ini(:,:,:) ) |
---|
| 264 | IF( ln_linssh ) THEN |
---|
| 265 | CALL iom_get( numror, jpdom_autoglo, 'ssh_hc_loc_ini', ssh_hc_loc_ini(:,:) ) |
---|
| 266 | CALL iom_get( numror, jpdom_autoglo, 'ssh_sc_loc_ini', ssh_sc_loc_ini(:,:) ) |
---|
| 267 | ENDIF |
---|
| 268 | ELSE |
---|
| 269 | IF(lwp) WRITE(numout,*) |
---|
| 270 | IF(lwp) WRITE(numout,*) ' dia_hsb_rst : initialise hsb at initial state ' |
---|
| 271 | IF(lwp) WRITE(numout,*) |
---|
| 272 | surf_ini(:,:) = e1e2t(:,:) * tmask_i(:,:) ! initial ocean surface |
---|
| 273 | ssh_ini(:,:) = sshn(:,:) ! initial ssh |
---|
| 274 | DO jk = 1, jpk |
---|
| 275 | ! if ice sheet/oceqn coupling, need to mask ini variables here (mask could change at the next NEMO instance). |
---|
| 276 | e3t_ini (:,:,jk) = e3t_n(:,:,jk) * tmask(:,:,jk) ! initial vertical scale factors |
---|
| 277 | hc_loc_ini(:,:,jk) = tsn(:,:,jk,jp_tem) * e3t_n(:,:,jk) * tmask(:,:,jk) ! initial heat content |
---|
| 278 | sc_loc_ini(:,:,jk) = tsn(:,:,jk,jp_sal) * e3t_n(:,:,jk) * tmask(:,:,jk) ! initial salt content |
---|
| 279 | END DO |
---|
| 280 | frc_v = 0._wp ! volume trend due to forcing |
---|
| 281 | frc_t = 0._wp ! heat content - - - - |
---|
| 282 | frc_s = 0._wp ! salt content - - - - |
---|
| 283 | IF( ln_linssh ) THEN |
---|
| 284 | IF( ln_isfcav ) THEN |
---|
| 285 | DO ji = 1, jpi |
---|
| 286 | DO jj = 1, jpj |
---|
| 287 | ssh_hc_loc_ini(ji,jj) = tsn(ji,jj,mikt(ji,jj),jp_tem) * sshn(ji,jj) ! initial heat content in ssh |
---|
| 288 | ssh_sc_loc_ini(ji,jj) = tsn(ji,jj,mikt(ji,jj),jp_sal) * sshn(ji,jj) ! initial salt content in ssh |
---|
| 289 | END DO |
---|
| 290 | END DO |
---|
| 291 | ELSE |
---|
| 292 | ssh_hc_loc_ini(:,:) = tsn(:,:,1,jp_tem) * sshn(:,:) ! initial heat content in ssh |
---|
| 293 | ssh_sc_loc_ini(:,:) = tsn(:,:,1,jp_sal) * sshn(:,:) ! initial salt content in ssh |
---|
| 294 | END IF |
---|
| 295 | frc_wn_t = 0._wp ! initial heat content misfit due to free surface |
---|
| 296 | frc_wn_s = 0._wp ! initial salt content misfit due to free surface |
---|
| 297 | ENDIF |
---|
| 298 | ENDIF |
---|
| 299 | ! |
---|
| 300 | ELSEIF( TRIM(cdrw) == 'WRITE' ) THEN ! Create restart file |
---|
| 301 | ! ! ------------------- |
---|
| 302 | IF(lwp) WRITE(numout,*) |
---|
| 303 | IF(lwp) WRITE(numout,*) ' dia_hsb_rst : write restart at it= ', kt,' date= ', ndastp |
---|
| 304 | IF(lwp) WRITE(numout,*) |
---|
| 305 | ! |
---|
| 306 | CALL iom_rstput( kt, nitrst, numrow, 'frc_v' , frc_v ) |
---|
| 307 | CALL iom_rstput( kt, nitrst, numrow, 'frc_t' , frc_t ) |
---|
| 308 | CALL iom_rstput( kt, nitrst, numrow, 'frc_s' , frc_s ) |
---|
| 309 | IF( ln_linssh ) THEN |
---|
| 310 | CALL iom_rstput( kt, nitrst, numrow, 'frc_wn_t', frc_wn_t ) |
---|
| 311 | CALL iom_rstput( kt, nitrst, numrow, 'frc_wn_s', frc_wn_s ) |
---|
| 312 | ENDIF |
---|
| 313 | CALL iom_rstput( kt, nitrst, numrow, 'surf_ini', surf_ini ) ! ice sheet coupling |
---|
| 314 | CALL iom_rstput( kt, nitrst, numrow, 'ssh_ini', ssh_ini(:,:) ) |
---|
| 315 | CALL iom_rstput( kt, nitrst, numrow, 'e3t_ini', e3t_ini(:,:,:) ) |
---|
| 316 | CALL iom_rstput( kt, nitrst, numrow, 'hc_loc_ini', hc_loc_ini(:,:,:) ) |
---|
| 317 | CALL iom_rstput( kt, nitrst, numrow, 'sc_loc_ini', sc_loc_ini(:,:,:) ) |
---|
| 318 | IF( ln_linssh ) THEN |
---|
| 319 | CALL iom_rstput( kt, nitrst, numrow, 'ssh_hc_loc_ini', ssh_hc_loc_ini(:,:) ) |
---|
| 320 | CALL iom_rstput( kt, nitrst, numrow, 'ssh_sc_loc_ini', ssh_sc_loc_ini(:,:) ) |
---|
| 321 | ENDIF |
---|
| 322 | ! |
---|
| 323 | ENDIF |
---|
| 324 | ! |
---|
[4161] | 325 | END SUBROUTINE dia_hsb_rst |
---|
[2148] | 326 | |
---|
[4990] | 327 | |
---|
| 328 | SUBROUTINE dia_hsb_init |
---|
| 329 | !!--------------------------------------------------------------------------- |
---|
| 330 | !! *** ROUTINE dia_hsb *** |
---|
| 331 | !! |
---|
| 332 | !! ** Purpose: Initialization for the heat salt volume budgets |
---|
| 333 | !! |
---|
| 334 | !! ** Method : Compute initial heat content, salt content and volume |
---|
| 335 | !! |
---|
| 336 | !! ** Action : - Compute initial heat content, salt content and volume |
---|
| 337 | !! - Initialize forcing trends |
---|
| 338 | !! - Compute coefficients for conversion |
---|
| 339 | !!--------------------------------------------------------------------------- |
---|
[9169] | 340 | INTEGER :: ierror, ios ! local integer |
---|
[7646] | 341 | !! |
---|
[4990] | 342 | NAMELIST/namhsb/ ln_diahsb |
---|
| 343 | !!---------------------------------------------------------------------- |
---|
[7646] | 344 | ! |
---|
[9169] | 345 | IF(lwp) THEN |
---|
| 346 | WRITE(numout,*) |
---|
| 347 | WRITE(numout,*) 'dia_hsb_init : heat and salt budgets diagnostics' |
---|
| 348 | WRITE(numout,*) '~~~~~~~~~~~~ ' |
---|
| 349 | ENDIF |
---|
[4990] | 350 | REWIND( numnam_ref ) ! Namelist namhsb in reference namelist |
---|
| 351 | READ ( numnam_ref, namhsb, IOSTAT = ios, ERR = 901) |
---|
[9168] | 352 | 901 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namhsb in reference namelist', lwp ) |
---|
[4990] | 353 | REWIND( numnam_cfg ) ! Namelist namhsb in configuration namelist |
---|
| 354 | READ ( numnam_cfg, namhsb, IOSTAT = ios, ERR = 902 ) |
---|
[9168] | 355 | 902 IF( ios > 0 ) CALL ctl_nam ( ios , 'namhsb in configuration namelist', lwp ) |
---|
[9169] | 356 | IF(lwm) WRITE( numond, namhsb ) |
---|
[4990] | 357 | |
---|
[7646] | 358 | IF(lwp) THEN |
---|
[9168] | 359 | WRITE(numout,*) ' Namelist namhsb :' |
---|
| 360 | WRITE(numout,*) ' check the heat and salt budgets (T) or not (F) ln_diahsb = ', ln_diahsb |
---|
[4990] | 361 | ENDIF |
---|
[7646] | 362 | ! |
---|
[4990] | 363 | IF( .NOT. ln_diahsb ) RETURN |
---|
| 364 | |
---|
| 365 | ! ------------------- ! |
---|
| 366 | ! 1 - Allocate memory ! |
---|
| 367 | ! ------------------- ! |
---|
[6140] | 368 | ALLOCATE( hc_loc_ini(jpi,jpj,jpk), sc_loc_ini(jpi,jpj,jpk), surf_ini(jpi,jpj), & |
---|
| 369 | & e3t_ini(jpi,jpj,jpk), surf(jpi,jpj), ssh_ini(jpi,jpj), STAT=ierror ) |
---|
[4990] | 370 | IF( ierror > 0 ) THEN |
---|
[7646] | 371 | CALL ctl_stop( 'dia_hsb_init: unable to allocate hc_loc_ini' ) ; RETURN |
---|
[4990] | 372 | ENDIF |
---|
| 373 | |
---|
[6140] | 374 | IF( ln_linssh ) ALLOCATE( ssh_hc_loc_ini(jpi,jpj), ssh_sc_loc_ini(jpi,jpj),STAT=ierror ) |
---|
[4990] | 375 | IF( ierror > 0 ) THEN |
---|
[7646] | 376 | CALL ctl_stop( 'dia_hsb: unable to allocate ssh_hc_loc_ini' ) ; RETURN |
---|
[4990] | 377 | ENDIF |
---|
| 378 | |
---|
| 379 | ! ----------------------------------------------- ! |
---|
| 380 | ! 2 - Time independant variables and file opening ! |
---|
| 381 | ! ----------------------------------------------- ! |
---|
[7753] | 382 | surf(:,:) = e1t(:,:) * e2t(:,:) * tmask_i(:,:) ! masked surface grid cell area |
---|
[7646] | 383 | surf_tot = glob_sum( surf(:,:) ) ! total ocean surface area |
---|
[4990] | 384 | |
---|
[7646] | 385 | IF( ln_bdy ) CALL ctl_warn( 'dia_hsb_init: heat/salt budget does not consider open boundary fluxes' ) |
---|
[4990] | 386 | ! |
---|
| 387 | ! ---------------------------------- ! |
---|
| 388 | ! 4 - initial conservation variables ! |
---|
| 389 | ! ---------------------------------- ! |
---|
| 390 | CALL dia_hsb_rst( nit000, 'READ' ) !* read or initialize all required files |
---|
| 391 | ! |
---|
| 392 | END SUBROUTINE dia_hsb_init |
---|
| 393 | |
---|
[2148] | 394 | !!====================================================================== |
---|
| 395 | END MODULE diahsb |
---|