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