12 use coupler_types_mod,
only : coupler_1d_bc_type, coupler_2d_bc_type
13 use coupler_types_mod,
only : coupler_type_spawn, coupler_type_destructor
15 implicit none ;
private
17 #include <MOM_memory.h>
19 public allocate_surface_state, deallocate_surface_state, mom_thermovar_chksum
29 real,
dimension(:,:,:),
pointer :: p => null()
33 real,
dimension(:,:),
pointer :: p => null()
39 real,
allocatable,
dimension(:,:) :: &
40 sst, & !< The sea surface temperature [degC].
41 sss, & !< The sea surface salinity [ppt ~> psu or gSalt/kg].
42 sfc_density, & !< The mixed layer density [kg m-3].
43 hml, & !< The mixed layer depth [m].
44 u, & !< The mixed layer zonal velocity [m s-1].
45 v, & !< The mixed layer meridional velocity [m s-1].
46 sea_lev, & !< The sea level [m]. If a reduced surface gravity is
55 logical :: t_is_cont = .false.
57 logical :: s_is_abss = .false.
59 real,
pointer,
dimension(:,:) :: &
60 taux_shelf => null(), &
62 real,
pointer,
dimension(:,:) :: frazil => null()
65 real,
pointer,
dimension(:,:) :: tempxpme => null()
69 real,
pointer,
dimension(:,:) :: internal_heat => null()
72 type(coupler_2d_bc_type) :: tr_fields
76 logical :: arrays_allocated = .false.
84 real,
pointer :: t(:,:,:) => null()
85 real,
pointer :: s(:,:,:) => null()
86 type(
eos_type),
pointer :: eqn_of_state => null()
94 logical :: t_is_cont = .false.
96 logical :: s_is_abss = .false.
98 real :: min_salinity = 0.01
101 real,
dimension(:,:),
pointer :: frazil => null()
105 real,
dimension(:,:),
pointer :: salt_deficit => null()
109 real,
dimension(:,:),
pointer :: tempxpme => null()
115 real,
dimension(:,:),
pointer :: internal_heat => null()
127 real,
pointer,
dimension(:,:,:) :: &
133 real,
pointer,
dimension(:,:,:) :: &
136 real,
pointer,
dimension(:,:,:) :: &
145 u_accel_bt => null(), &
147 real,
pointer,
dimension(:,:,:) :: &
158 real,
pointer,
dimension(:,:,:) :: &
165 du_dt_visc => null(), &
166 dv_dt_visc => null(), &
167 du_dt_dia => null(), &
169 real,
pointer,
dimension(:,:,:) :: du_other => null()
172 real,
pointer,
dimension(:,:,:) :: dv_other => null()
177 real,
pointer :: gradkeu(:,:,:) => null()
178 real,
pointer :: gradkev(:,:,:) => null()
179 real,
pointer :: rv_x_v(:,:,:) => null()
180 real,
pointer :: rv_x_u(:,:,:) => null()
188 real,
pointer,
dimension(:,:,:) :: &
195 real,
pointer :: diapyc_vel(:,:,:) => null()
203 real,
pointer,
dimension(:,:) :: &
204 bbl_thick_u => null(), &
205 bbl_thick_v => null(), &
206 kv_bbl_u => null(), &
207 kv_bbl_v => null(), &
209 real,
pointer,
dimension(:,:) :: tke_bbl => null()
213 real,
pointer,
dimension(:,:) :: &
214 taux_shelf => null(), &
216 real,
pointer,
dimension(:,:) :: tbl_thick_shelf_u => null()
218 real,
pointer,
dimension(:,:) :: tbl_thick_shelf_v => null()
220 real,
pointer,
dimension(:,:) :: kv_tbl_shelf_u => null()
222 real,
pointer,
dimension(:,:) :: kv_tbl_shelf_v => null()
224 real,
pointer,
dimension(:,:) :: nkml_visc_u => null()
229 real,
pointer,
dimension(:,:) :: nkml_visc_v => null()
231 real,
pointer,
dimension(:,:) :: &
233 real,
pointer,
dimension(:,:,:) :: &
236 real,
pointer,
dimension(:,:,:) :: kd_extra_t => null()
239 real,
pointer,
dimension(:,:,:) :: kd_extra_s => null()
245 real,
pointer,
dimension(:,:,:) :: kd_shear => null()
248 real,
pointer,
dimension(:,:,:) :: kv_shear => null()
251 real,
pointer,
dimension(:,:,:) :: kv_shear_bu => null()
254 real,
pointer,
dimension(:,:,:) :: kv_slow => null()
257 real,
pointer,
dimension(:,:,:) :: tke_turb => null()
260 logical :: add_kv_slow
267 real,
allocatable :: fa_u_ee(:,:)
269 real,
allocatable :: fa_u_e0(:,:)
271 real,
allocatable :: fa_u_w0(:,:)
273 real,
allocatable :: fa_u_ww(:,:)
275 real,
allocatable :: ubt_ww(:,:)
277 real,
allocatable :: ubt_ee(:,:)
279 real,
allocatable :: fa_v_nn(:,:)
281 real,
allocatable :: fa_v_n0(:,:)
283 real,
allocatable :: fa_v_s0(:,:)
285 real,
allocatable :: fa_v_ss(:,:)
287 real,
allocatable :: vbt_ss(:,:)
289 real,
allocatable :: vbt_nn(:,:)
291 real,
allocatable :: h_u(:,:,:)
292 real,
allocatable :: h_v(:,:,:)
293 type(group_pass_type) :: pass_polarity_bt
294 type(group_pass_type) :: pass_fa_uv
301 subroutine allocate_surface_state(sfc_state, G, use_temperature, do_integrals, &
302 gas_fields_ocn, use_meltpot)
304 type(
surface),
intent(inout) :: sfc_state
305 logical,
optional,
intent(in) :: use_temperature
306 logical,
optional,
intent(in) :: do_integrals
308 type(coupler_1d_bc_type), &
309 optional,
intent(in) :: gas_fields_ocn
314 logical,
optional,
intent(in) :: use_meltpot
317 logical :: use_temp, alloc_integ, use_melt_potential
318 integer :: is, ie, js, je, isd, ied, jsd, jed
319 integer :: isdb, iedb, jsdb, jedb
321 is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec
322 isd = g%isd ; ied = g%ied ; jsd = g%jsd ; jed = g%jed
323 isdb = g%isdB ; iedb = g%iedB; jsdb = g%jsdB ; jedb = g%jedB
325 use_temp = .true. ;
if (
present(use_temperature)) use_temp = use_temperature
326 alloc_integ = .true. ;
if (
present(do_integrals)) alloc_integ = do_integrals
327 use_melt_potential = .false. ;
if (
present(use_meltpot)) use_melt_potential = use_meltpot
329 if (sfc_state%arrays_allocated)
return
332 allocate(sfc_state%SST(isd:ied,jsd:jed)) ; sfc_state%SST(:,:) = 0.0
333 allocate(sfc_state%SSS(isd:ied,jsd:jed)) ; sfc_state%SSS(:,:) = 0.0
335 allocate(sfc_state%sfc_density(isd:ied,jsd:jed)) ; sfc_state%sfc_density(:,:) = 0.0
337 allocate(sfc_state%sea_lev(isd:ied,jsd:jed)) ; sfc_state%sea_lev(:,:) = 0.0
338 allocate(sfc_state%Hml(isd:ied,jsd:jed)) ; sfc_state%Hml(:,:) = 0.0
339 allocate(sfc_state%u(isdb:iedb,jsd:jed)) ; sfc_state%u(:,:) = 0.0
340 allocate(sfc_state%v(isd:ied,jsdb:jedb)) ; sfc_state%v(:,:) = 0.0
342 if (use_melt_potential)
then
343 allocate(sfc_state%melt_potential(isd:ied,jsd:jed)) ; sfc_state%melt_potential(:,:) = 0.0
346 if (alloc_integ)
then
348 allocate(sfc_state%ocean_mass(isd:ied,jsd:jed)) ; sfc_state%ocean_mass(:,:) = 0.0
350 allocate(sfc_state%ocean_heat(isd:ied,jsd:jed)) ; sfc_state%ocean_heat(:,:) = 0.0
351 allocate(sfc_state%ocean_salt(isd:ied,jsd:jed)) ; sfc_state%ocean_salt(:,:) = 0.0
353 allocate(sfc_state%salt_deficit(isd:ied,jsd:jed)) ; sfc_state%salt_deficit(:,:) = 0.0
356 if (
present(gas_fields_ocn)) &
357 call coupler_type_spawn(gas_fields_ocn, sfc_state%tr_fields, &
358 (/is,is,ie,ie/), (/js,js,je,je/), as_needed=.true.)
360 sfc_state%arrays_allocated = .true.
362 end subroutine allocate_surface_state
365 subroutine deallocate_surface_state(sfc_state)
368 if (.not.sfc_state%arrays_allocated)
return
370 if (
allocated(sfc_state%melt_potential))
deallocate(sfc_state%melt_potential)
371 if (
allocated(sfc_state%SST))
deallocate(sfc_state%SST)
372 if (
allocated(sfc_state%SSS))
deallocate(sfc_state%SSS)
373 if (
allocated(sfc_state%sfc_density))
deallocate(sfc_state%sfc_density)
374 if (
allocated(sfc_state%sea_lev))
deallocate(sfc_state%sea_lev)
375 if (
allocated(sfc_state%Hml))
deallocate(sfc_state%Hml)
376 if (
allocated(sfc_state%u))
deallocate(sfc_state%u)
377 if (
allocated(sfc_state%v))
deallocate(sfc_state%v)
378 if (
allocated(sfc_state%ocean_mass))
deallocate(sfc_state%ocean_mass)
379 if (
allocated(sfc_state%ocean_heat))
deallocate(sfc_state%ocean_heat)
380 if (
allocated(sfc_state%ocean_salt))
deallocate(sfc_state%ocean_salt)
381 if (
allocated(sfc_state%salt_deficit))
deallocate(sfc_state%salt_deficit)
383 call coupler_type_destructor(sfc_state%tr_fields)
385 sfc_state%arrays_allocated = .false.
387 end subroutine deallocate_surface_state
390 subroutine alloc_bt_cont_type(BT_cont, G, alloc_faces)
393 logical,
optional,
intent(in) :: alloc_faces
396 integer :: isd, ied, jsd, jed, isdb, iedb, jsdb, jedb
397 isd = g%isd ; ied = g%ied ; jsd = g%jsd ; jed = g%jed
398 isdb = g%IsdB ; iedb = g%IedB ; jsdb = g%JsdB ; jedb = g%JedB
400 if (
associated(bt_cont))
call mom_error(fatal, &
401 "alloc_BT_cont_type called with an associated BT_cont_type pointer.")
404 allocate(bt_cont%FA_u_WW(isdb:iedb,jsd:jed)) ; bt_cont%FA_u_WW(:,:) = 0.0
405 allocate(bt_cont%FA_u_W0(isdb:iedb,jsd:jed)) ; bt_cont%FA_u_W0(:,:) = 0.0
406 allocate(bt_cont%FA_u_E0(isdb:iedb,jsd:jed)) ; bt_cont%FA_u_E0(:,:) = 0.0
407 allocate(bt_cont%FA_u_EE(isdb:iedb,jsd:jed)) ; bt_cont%FA_u_EE(:,:) = 0.0
408 allocate(bt_cont%uBT_WW(isdb:iedb,jsd:jed)) ; bt_cont%uBT_WW(:,:) = 0.0
409 allocate(bt_cont%uBT_EE(isdb:iedb,jsd:jed)) ; bt_cont%uBT_EE(:,:) = 0.0
411 allocate(bt_cont%FA_v_SS(isd:ied,jsdb:jedb)) ; bt_cont%FA_v_SS(:,:) = 0.0
412 allocate(bt_cont%FA_v_S0(isd:ied,jsdb:jedb)) ; bt_cont%FA_v_S0(:,:) = 0.0
413 allocate(bt_cont%FA_v_N0(isd:ied,jsdb:jedb)) ; bt_cont%FA_v_N0(:,:) = 0.0
414 allocate(bt_cont%FA_v_NN(isd:ied,jsdb:jedb)) ; bt_cont%FA_v_NN(:,:) = 0.0
415 allocate(bt_cont%vBT_SS(isd:ied,jsdb:jedb)) ; bt_cont%vBT_SS(:,:) = 0.0
416 allocate(bt_cont%vBT_NN(isd:ied,jsdb:jedb)) ; bt_cont%vBT_NN(:,:) = 0.0
418 if (
present(alloc_faces))
then ;
if (alloc_faces)
then
419 allocate(bt_cont%h_u(isdb:iedb,jsd:jed,1:g%ke)) ; bt_cont%h_u(:,:,:) = 0.0
420 allocate(bt_cont%h_v(isd:ied,jsdb:jedb,1:g%ke)) ; bt_cont%h_v(:,:,:) = 0.0
423 end subroutine alloc_bt_cont_type
426 subroutine dealloc_bt_cont_type(BT_cont)
429 if (.not.
associated(bt_cont))
return
431 deallocate(bt_cont%FA_u_WW) ;
deallocate(bt_cont%FA_u_W0)
432 deallocate(bt_cont%FA_u_E0) ;
deallocate(bt_cont%FA_u_EE)
433 deallocate(bt_cont%uBT_WW) ;
deallocate(bt_cont%uBT_EE)
435 deallocate(bt_cont%FA_v_SS) ;
deallocate(bt_cont%FA_v_S0)
436 deallocate(bt_cont%FA_v_N0) ;
deallocate(bt_cont%FA_v_NN)
437 deallocate(bt_cont%vBT_SS) ;
deallocate(bt_cont%vBT_NN)
439 if (
allocated(bt_cont%h_u))
deallocate(bt_cont%h_u)
440 if (
allocated(bt_cont%h_v))
deallocate(bt_cont%h_v)
444 end subroutine dealloc_bt_cont_type
447 subroutine mom_thermovar_chksum(mesg, tv, G)
448 character(len=*),
intent(in) :: mesg
455 if (
associated(tv%T)) &
456 call hchksum(tv%T, mesg//
" tv%T", g%HI)
457 if (
associated(tv%S)) &
458 call hchksum(tv%S, mesg//
" tv%S", g%HI)
459 if (
associated(tv%frazil)) &
460 call hchksum(tv%frazil, mesg//
" tv%frazil", g%HI)
461 if (
associated(tv%salt_deficit)) &
462 call hchksum(tv%salt_deficit, mesg//
" tv%salt_deficit", g%HI)
463 if (
associated(tv%TempxPmE)) &
464 call hchksum(tv%TempxPmE, mesg//
" tv%TempxPmE", g%HI)
465 end subroutine mom_thermovar_chksum