21 #include <MOM_memory.h>
54 #ifdef _USE_GENERIC_TRACER
55 use mom_generic_tracer,
only : register_mom_generic_tracer, initialize_mom_generic_tracer
56 use mom_generic_tracer,
only : mom_generic_tracer_column_physics, mom_generic_tracer_surface_state
57 use mom_generic_tracer,
only : end_mom_generic_tracer, mom_generic_tracer_get, mom_generic_flux_init
58 use mom_generic_tracer,
only : mom_generic_tracer_stock, mom_generic_tracer_min_max, mom_generic_tracer_cs
68 implicit none ;
private
76 logical :: use_user_tracer_example = .false.
77 logical :: use_dome_tracer = .false.
78 logical :: use_isomip_tracer = .false.
79 logical :: use_rgc_tracer =.false.
80 logical :: use_ideal_age = .false.
81 logical :: use_regional_dyes = .false.
82 logical :: use_oil = .false.
83 logical :: use_advection_test_tracer = .false.
84 logical :: use_ocmip2_cfc = .false.
85 logical :: use_mom_generic_tracer = .false.
86 logical :: use_pseudo_salt_tracer = .false.
87 logical :: use_boundary_impulse_tracer = .false.
88 logical :: use_dyed_obc_tracer = .false.
99 #ifdef _USE_GENERIC_TRACER
100 type(mom_generic_tracer_cs),
pointer :: mom_generic_tracer_csp => null()
117 integer,
optional,
intent(in) :: verbosity
120 character(len=40) :: mdl =
"call_tracer_flux_init"
121 logical :: use_ocmip_cfcs, use_mom_generic_tracer
127 call get_param(param_file, mdl,
"USE_OCMIP2_CFC", use_ocmip_cfcs, &
128 default=.false., do_not_log=.true.)
129 call get_param(param_file, mdl,
"USE_generic_tracer", use_mom_generic_tracer,&
130 default=.false., do_not_log=.true.)
133 if (use_ocmip_cfcs)
call flux_init_ocmip2_cfc(verbosity=verbosity)
134 if (use_mom_generic_tracer)
then
135 #ifdef _USE_GENERIC_TRACER
136 call mom_generic_flux_init(verbosity=verbosity)
139 "call_tracer_flux_init: use_MOM_generic_tracer=.true. but MOM6 was "//&
140 "not compiled with _USE_GENERIC_TRACER")
167 # include "version_variable.h"
168 character(len=40) :: mdl =
"MOM_tracer_flow_control"
170 if (
associated(cs))
then
171 call mom_error(warning,
"call_tracer_register called with an associated "// &
172 "control structure.")
174 else ;
allocate(cs) ;
endif
178 call get_param(param_file, mdl,
"USE_USER_TRACER_EXAMPLE", &
179 cs%use_USER_tracer_example, &
180 "If true, use the USER_tracer_example tracer package.", &
182 call get_param(param_file, mdl,
"USE_DOME_TRACER", cs%use_DOME_tracer, &
183 "If true, use the DOME_tracer tracer package.", &
185 call get_param(param_file, mdl,
"USE_ISOMIP_TRACER", cs%use_ISOMIP_tracer, &
186 "If true, use the ISOMIP_tracer tracer package.", &
188 call get_param(param_file, mdl,
"USE_RGC_TRACER", cs%use_RGC_tracer, &
189 "If true, use the RGC_tracer tracer package.", &
191 call get_param(param_file, mdl,
"USE_IDEAL_AGE_TRACER", cs%use_ideal_age, &
192 "If true, use the ideal_age_example tracer package.", &
194 call get_param(param_file, mdl,
"USE_REGIONAL_DYES", cs%use_regional_dyes, &
195 "If true, use the regional_dyes tracer package.", &
197 call get_param(param_file, mdl,
"USE_OIL_TRACER", cs%use_oil, &
198 "If true, use the oil_tracer tracer package.", &
200 call get_param(param_file, mdl,
"USE_ADVECTION_TEST_TRACER", cs%use_advection_test_tracer, &
201 "If true, use the advection_test_tracer tracer package.", &
203 call get_param(param_file, mdl,
"USE_OCMIP2_CFC", cs%use_OCMIP2_CFC, &
204 "If true, use the MOM_OCMIP2_CFC tracer package.", &
206 call get_param(param_file, mdl,
"USE_generic_tracer", cs%use_MOM_generic_tracer, &
207 "If true and _USE_GENERIC_TRACER is defined as a "//&
208 "preprocessor macro, use the MOM_generic_tracer packages.", &
210 call get_param(param_file, mdl,
"USE_PSEUDO_SALT_TRACER", cs%use_pseudo_salt_tracer, &
211 "If true, use the pseudo salt tracer, typically run as a diagnostic.", &
213 call get_param(param_file, mdl,
"USE_BOUNDARY_IMPULSE_TRACER", cs%use_boundary_impulse_tracer, &
214 "If true, use the boundary impulse tracer.", &
216 call get_param(param_file, mdl,
"USE_DYED_OBC_TRACER", cs%use_dyed_obc_tracer, &
217 "If true, use the dyed_obc_tracer tracer package.", &
220 #ifndef _USE_GENERIC_TRACER
221 if (cs%use_MOM_generic_tracer)
call mom_error(fatal, &
222 "call_tracer_register: use_MOM_generic_tracer=.true. but MOM6 was "//&
223 "not compiled with _USE_GENERIC_TRACER")
229 if (cs%use_USER_tracer_example) cs%use_USER_tracer_example = &
230 user_register_tracer_example(hi, gv, param_file, cs%USER_tracer_example_CSp, &
232 if (cs%use_DOME_tracer) cs%use_DOME_tracer = &
233 register_dome_tracer(hi, gv, param_file, cs%DOME_tracer_CSp, &
235 if (cs%use_ISOMIP_tracer) cs%use_ISOMIP_tracer = &
236 register_isomip_tracer(hi, gv, param_file, cs%ISOMIP_tracer_CSp, &
238 if (cs%use_RGC_tracer) cs%use_RGC_tracer = &
239 register_rgc_tracer(hi, gv, param_file, cs%RGC_tracer_CSp, &
241 if (cs%use_ideal_age) cs%use_ideal_age = &
242 register_ideal_age_tracer(hi, gv, param_file, cs%ideal_age_tracer_CSp, &
244 if (cs%use_regional_dyes) cs%use_regional_dyes = &
245 register_dye_tracer(hi, gv, us, param_file, cs%dye_tracer_CSp, &
247 if (cs%use_oil) cs%use_oil = &
248 register_oil_tracer(hi, gv, us, param_file, cs%oil_tracer_CSp, &
250 if (cs%use_advection_test_tracer) cs%use_advection_test_tracer = &
251 register_advection_test_tracer(hi, gv, param_file, cs%advection_test_tracer_CSp, &
253 if (cs%use_OCMIP2_CFC) cs%use_OCMIP2_CFC = &
254 register_ocmip2_cfc(hi, gv, param_file, cs%OCMIP2_CFC_CSp, &
256 #ifdef _USE_GENERIC_TRACER
257 if (cs%use_MOM_generic_tracer) cs%use_MOM_generic_tracer = &
258 register_mom_generic_tracer(hi, gv, param_file, cs%MOM_generic_tracer_CSp, &
261 if (cs%use_pseudo_salt_tracer) cs%use_pseudo_salt_tracer = &
262 register_pseudo_salt_tracer(hi, gv, param_file, cs%pseudo_salt_tracer_CSp, &
264 if (cs%use_boundary_impulse_tracer) cs%use_boundary_impulse_tracer = &
265 register_boundary_impulse_tracer(hi, gv, param_file, cs%boundary_impulse_tracer_CSp, &
267 if (cs%use_dyed_obc_tracer) cs%use_dyed_obc_tracer = &
268 register_dyed_obc_tracer(hi, gv, param_file, cs%dyed_obc_tracer_CSp, &
277 CS, sponge_CSp, ALE_sponge_CSp, tv)
278 logical,
intent(in) :: restart
280 type(time_type),
target,
intent(in) :: day
285 real,
dimension(NIMEM_,NJMEM_,NKMEM_),
intent(in) :: h
288 type(
diag_ctrl),
target,
intent(in) :: diag
306 if (.not.
associated(cs))
call mom_error(fatal,
"tracer_flow_control_init: "// &
307 "Module must be initialized via call_tracer_register before it is used.")
310 if (cs%use_USER_tracer_example) &
311 call user_initialize_tracer(restart, day, g, gv, h, diag, obc, cs%USER_tracer_example_CSp, &
313 if (cs%use_DOME_tracer) &
314 call initialize_dome_tracer(restart, day, g, gv, us, h, diag, obc, cs%DOME_tracer_CSp, &
315 sponge_csp, param_file)
316 if (cs%use_ISOMIP_tracer) &
317 call initialize_isomip_tracer(restart, day, g, gv, h, diag, obc, cs%ISOMIP_tracer_CSp, &
319 if (cs%use_RGC_tracer) &
320 call initialize_rgc_tracer(restart, day, g, gv, h, diag, obc, &
321 cs%RGC_tracer_CSp, sponge_csp, ale_sponge_csp)
322 if (cs%use_ideal_age) &
323 call initialize_ideal_age_tracer(restart, day, g, gv, us, h, diag, obc, cs%ideal_age_tracer_CSp, &
325 if (cs%use_regional_dyes) &
326 call initialize_dye_tracer(restart, day, g, gv, h, diag, obc, cs%dye_tracer_CSp, &
329 call initialize_oil_tracer(restart, day, g, gv, us, h, diag, obc, cs%oil_tracer_CSp, &
331 if (cs%use_advection_test_tracer) &
332 call initialize_advection_test_tracer(restart, day, g, gv, h, diag, obc, cs%advection_test_tracer_CSp, &
334 if (cs%use_OCMIP2_CFC) &
335 call initialize_ocmip2_cfc(restart, day, g, gv, us, h, diag, obc, cs%OCMIP2_CFC_CSp, &
337 #ifdef _USE_GENERIC_TRACER
338 if (cs%use_MOM_generic_tracer) &
339 call initialize_mom_generic_tracer(restart, day, g, gv, us, h, param_file, diag, obc, &
340 cs%MOM_generic_tracer_CSp, sponge_csp, ale_sponge_csp)
342 if (cs%use_pseudo_salt_tracer) &
343 call initialize_pseudo_salt_tracer(restart, day, g, gv, h, diag, obc, cs%pseudo_salt_tracer_CSp, &
345 if (cs%use_boundary_impulse_tracer) &
346 call initialize_boundary_impulse_tracer(restart, day, g, gv, h, diag, obc, cs%boundary_impulse_tracer_CSp, &
348 if (cs%use_dyed_obc_tracer) &
349 call initialize_dyed_obc_tracer(restart, day, g, gv, h, diag, obc, cs%dyed_obc_tracer_CSp)
355 real,
dimension(NIMEM_,NJMEM_,NKMEM_), &
356 intent(out) :: chl_array
362 #ifdef _USE_GENERIC_TRACER
363 if (cs%use_MOM_generic_tracer)
then
364 call mom_generic_tracer_get(
'chl',
'field',chl_array, cs%MOM_generic_tracer_CSp)
366 call mom_error(fatal,
"get_chl_from_model was called in a configuration "// &
367 "that is unable to provide a sensible model-based value.\n"// &
368 "CS%use_MOM_generic_tracer is false and no other viable options are on.")
371 call mom_error(fatal,
"get_chl_from_model was called in a configuration "// &
372 "that is unable to provide a sensible model-based value.\n"// &
373 "_USE_GENERIC_TRACER is undefined and no other options "//&
374 "are currently viable.")
383 type(
surface),
intent(inout) :: state
386 type(
forcing),
intent(inout) :: fluxes
389 type(time_type),
intent(in) :: day_start
390 type(time_type),
intent(in) :: day_interval
396 if (.not.
associated(cs))
call mom_error(fatal,
"call_tracer_set_forcing"// &
397 "Module must be initialized via call_tracer_register before it is used.")
405 subroutine call_tracer_column_fns(h_old, h_new, ea, eb, fluxes, Hml, dt, G, GV, US, tv, optics, CS, &
406 debug, evap_CFL_limit, minimum_forcing_depth)
407 real,
dimension(NIMEM_,NJMEM_,NKMEM_),
intent(in) :: h_old
409 real,
dimension(NIMEM_,NJMEM_,NKMEM_),
intent(in) :: h_new
411 real,
dimension(NIMEM_,NJMEM_,NKMEM_),
intent(in) :: ea
414 real,
dimension(NIMEM_,NJMEM_,NKMEM_),
intent(in) :: eb
417 type(
forcing),
intent(in) :: fluxes
420 real,
dimension(NIMEM_,NJMEM_),
intent(in) :: hml
421 real,
intent(in) :: dt
429 type(optics_type),
pointer :: optics
434 logical,
intent(in) :: debug
435 real,
optional,
intent(in) :: evap_cfl_limit
438 real,
optional,
intent(in) :: minimum_forcing_depth
441 if (.not.
associated(cs))
call mom_error(fatal,
"call_tracer_column_fns: "// &
442 "Module must be initialized via call_tracer_register before it is used.")
445 if (
present(evap_cfl_limit) .and.
present(minimum_forcing_depth))
then
447 if (cs%use_USER_tracer_example) &
448 call tracer_column_physics(h_old, h_new, ea, eb, fluxes, dt, &
449 g, gv, us, cs%USER_tracer_example_CSp)
450 if (cs%use_DOME_tracer) &
451 call dome_tracer_column_physics(h_old, h_new, ea, eb, fluxes, dt, &
452 g, gv, us, cs%DOME_tracer_CSp, &
453 evap_cfl_limit=evap_cfl_limit, &
454 minimum_forcing_depth=minimum_forcing_depth)
455 if (cs%use_ISOMIP_tracer) &
456 call isomip_tracer_column_physics(h_old, h_new, ea, eb, fluxes, dt, &
457 g, gv, us, cs%ISOMIP_tracer_CSp, &
458 evap_cfl_limit=evap_cfl_limit, &
459 minimum_forcing_depth=minimum_forcing_depth)
460 if (cs%use_RGC_tracer) &
461 call rgc_tracer_column_physics(h_old, h_new, ea, eb, fluxes, dt, &
462 g, gv, us, cs%RGC_tracer_CSp, &
463 evap_cfl_limit=evap_cfl_limit, &
464 minimum_forcing_depth=minimum_forcing_depth)
465 if (cs%use_ideal_age) &
466 call ideal_age_tracer_column_physics(h_old, h_new, ea, eb, fluxes, dt, &
467 g, gv, us, cs%ideal_age_tracer_CSp, &
468 evap_cfl_limit=evap_cfl_limit, &
469 minimum_forcing_depth=minimum_forcing_depth)
470 if (cs%use_regional_dyes) &
471 call dye_tracer_column_physics(h_old, h_new, ea, eb, fluxes, dt, &
472 g, gv, us, cs%dye_tracer_CSp, &
473 evap_cfl_limit=evap_cfl_limit, &
474 minimum_forcing_depth=minimum_forcing_depth)
476 call oil_tracer_column_physics(h_old, h_new, ea, eb, fluxes, dt, &
477 g, gv, us, cs%oil_tracer_CSp, tv, &
478 evap_cfl_limit=evap_cfl_limit, &
479 minimum_forcing_depth=minimum_forcing_depth)
481 if (cs%use_advection_test_tracer) &
482 call advection_test_tracer_column_physics(h_old, h_new, ea, eb, fluxes, dt, &
483 g, gv, us, cs%advection_test_tracer_CSp, &
484 evap_cfl_limit=evap_cfl_limit, &
485 minimum_forcing_depth=minimum_forcing_depth)
486 if (cs%use_OCMIP2_CFC) &
487 call ocmip2_cfc_column_physics(h_old, h_new, ea, eb, fluxes, dt, &
488 g, gv, us, cs%OCMIP2_CFC_CSp, &
489 evap_cfl_limit=evap_cfl_limit, &
490 minimum_forcing_depth=minimum_forcing_depth)
491 #ifdef _USE_GENERIC_TRACER
492 if (cs%use_MOM_generic_tracer) &
493 call mom_generic_tracer_column_physics(h_old, h_new, ea, eb, fluxes, hml, us%T_to_s*dt, &
494 g, gv, cs%MOM_generic_tracer_CSp, tv, optics, &
495 evap_cfl_limit=evap_cfl_limit, &
496 minimum_forcing_depth=minimum_forcing_depth)
498 if (cs%use_pseudo_salt_tracer) &
499 call pseudo_salt_tracer_column_physics(h_old, h_new, ea, eb, fluxes, dt, &
500 g, gv, us, cs%pseudo_salt_tracer_CSp, tv, debug, &
501 evap_cfl_limit=evap_cfl_limit, &
502 minimum_forcing_depth=minimum_forcing_depth)
503 if (cs%use_boundary_impulse_tracer) &
504 call boundary_impulse_tracer_column_physics(h_old, h_new, ea, eb, fluxes, dt, &
505 g, gv, us, cs%boundary_impulse_tracer_CSp, tv, debug, &
506 evap_cfl_limit=evap_cfl_limit, &
507 minimum_forcing_depth=minimum_forcing_depth)
508 if (cs%use_dyed_obc_tracer) &
509 call dyed_obc_tracer_column_physics(h_old, h_new, ea, eb, fluxes, dt, &
510 g, gv, us, cs%dyed_obc_tracer_CSp, &
511 evap_cfl_limit=evap_cfl_limit, &
512 minimum_forcing_depth=minimum_forcing_depth)
516 if (cs%use_USER_tracer_example) &
517 call tracer_column_physics(h_old, h_new, ea, eb, fluxes, dt, &
518 g, gv, us, cs%USER_tracer_example_CSp)
519 if (cs%use_DOME_tracer) &
520 call dome_tracer_column_physics(h_old, h_new, ea, eb, fluxes, dt, &
521 g, gv, us, cs%DOME_tracer_CSp)
522 if (cs%use_ISOMIP_tracer) &
523 call isomip_tracer_column_physics(h_old, h_new, ea, eb, fluxes, dt, &
524 g, gv, us, cs%ISOMIP_tracer_CSp)
525 if (cs%use_RGC_tracer) &
526 call rgc_tracer_column_physics(h_old, h_new, ea, eb, fluxes, dt, &
527 g, gv, us, cs%RGC_tracer_CSp)
528 if (cs%use_ideal_age) &
529 call ideal_age_tracer_column_physics(h_old, h_new, ea, eb, fluxes, dt, &
530 g, gv, us, cs%ideal_age_tracer_CSp)
531 if (cs%use_regional_dyes) &
532 call dye_tracer_column_physics(h_old, h_new, ea, eb, fluxes, dt, &
533 g, gv, us, cs%dye_tracer_CSp)
535 call oil_tracer_column_physics(h_old, h_new, ea, eb, fluxes, dt, &
536 g, gv, us, cs%oil_tracer_CSp, tv)
537 if (cs%use_advection_test_tracer) &
538 call advection_test_tracer_column_physics(h_old, h_new, ea, eb, fluxes, dt, &
539 g, gv, us, cs%advection_test_tracer_CSp)
540 if (cs%use_OCMIP2_CFC) &
541 call ocmip2_cfc_column_physics(h_old, h_new, ea, eb, fluxes, dt, &
542 g, gv, us, cs%OCMIP2_CFC_CSp)
543 #ifdef _USE_GENERIC_TRACER
544 if (cs%use_MOM_generic_tracer) &
545 call mom_generic_tracer_column_physics(h_old, h_new, ea, eb, fluxes, hml, us%T_to_s*dt, &
546 g, gv, cs%MOM_generic_tracer_CSp, tv, optics)
548 if (cs%use_pseudo_salt_tracer) &
549 call pseudo_salt_tracer_column_physics(h_old, h_new, ea, eb, fluxes, dt, &
550 g, gv, us, cs%pseudo_salt_tracer_CSp, tv, debug)
551 if (cs%use_boundary_impulse_tracer) &
552 call boundary_impulse_tracer_column_physics(h_old, h_new, ea, eb, fluxes, dt, &
553 g, gv, us, cs%boundary_impulse_tracer_CSp, tv, debug)
554 if (cs%use_dyed_obc_tracer) &
555 call dyed_obc_tracer_column_physics(h_old, h_new, ea, eb, fluxes, dt, &
556 g, gv, us, cs%dyed_obc_tracer_CSp)
566 num_stocks, stock_index, got_min_max, global_min, global_max, &
567 xgmin, ygmin, zgmin, xgmax, ygmax, zgmax)
568 real,
dimension(NIMEM_,NJMEM_,NKMEM_), &
570 real,
dimension(:),
intent(out) :: stock_values
577 character(len=*),
dimension(:), &
578 optional,
intent(out) :: stock_names
579 character(len=*),
dimension(:), &
580 optional,
intent(out) :: stock_units
581 integer,
optional,
intent(out) :: num_stocks
582 integer,
optional,
intent(in) :: stock_index
585 logical,
dimension(:), &
586 optional,
intent(inout) :: got_min_max
588 real,
dimension(:),
optional,
intent(out) :: global_min
589 real,
dimension(:),
optional,
intent(out) :: global_max
590 real,
dimension(:),
optional,
intent(out) :: xgmin
591 real,
dimension(:),
optional,
intent(out) :: ygmin
592 real,
dimension(:),
optional,
intent(out) :: zgmin
593 real,
dimension(:),
optional,
intent(out) :: xgmax
594 real,
dimension(:),
optional,
intent(out) :: ygmax
595 real,
dimension(:),
optional,
intent(out) :: zgmax
598 character(len=200),
dimension(MAX_FIELDS_) :: names, units
599 character(len=200) :: set_pkg_name
600 real,
dimension(MAX_FIELDS_) :: values
601 integer :: max_ns, ns_tot, ns, index, pkg, max_pkgs, nn
603 if (.not.
associated(cs))
call mom_error(fatal,
"call_tracer_stocks: "// &
604 "Module must be initialized via call_tracer_register before it is used.")
606 index = -1 ;
if (
present(stock_index)) index = stock_index
608 max_ns =
size(stock_values)
609 if (
present(stock_names)) max_ns = min(max_ns,
size(stock_names))
610 if (
present(stock_units)) max_ns = min(max_ns,
size(stock_units))
613 if (cs%use_USER_tracer_example)
then
614 ns = user_tracer_stock(h, values, g, gv, cs%USER_tracer_example_CSp, &
615 names, units, stock_index)
616 call store_stocks(
"tracer_example", ns, names, units, values, index, stock_values, &
617 set_pkg_name, max_ns, ns_tot, stock_names, stock_units)
625 if (cs%use_ideal_age)
then
627 names, units, stock_index)
628 call store_stocks(
"ideal_age_example", ns, names, units, values, index, &
629 stock_values, set_pkg_name, max_ns, ns_tot, stock_names, stock_units)
631 if (cs%use_regional_dyes)
then
632 ns =
dye_stock(h, values, g, gv, cs%dye_tracer_CSp, &
633 names, units, stock_index)
634 call store_stocks(
"regional_dyes", ns, names, units, values, index, &
635 stock_values, set_pkg_name, max_ns, ns_tot, stock_names, stock_units)
638 ns =
oil_stock(h, values, g, gv, cs%oil_tracer_CSp, &
639 names, units, stock_index)
640 call store_stocks(
"oil_tracer", ns, names, units, values, index, &
641 stock_values, set_pkg_name, max_ns, ns_tot, stock_names, stock_units)
643 if (cs%use_OCMIP2_CFC)
then
644 ns =
ocmip2_cfc_stock(h, values, g, gv, cs%OCMIP2_CFC_CSp, names, units, stock_index)
645 call store_stocks(
"MOM_OCMIP2_CFC", ns, names, units, values, index, stock_values, &
646 set_pkg_name, max_ns, ns_tot, stock_names, stock_units)
649 if (cs%use_advection_test_tracer)
then
651 names, units, stock_index )
652 call store_stocks(
"advection_test_tracer", ns, names, units, values, index, &
653 stock_values, set_pkg_name, max_ns, ns_tot, stock_names, stock_units)
656 #ifdef _USE_GENERIC_TRACER
657 if (cs%use_MOM_generic_tracer)
then
658 ns = mom_generic_tracer_stock(h, values, g, gv, cs%MOM_generic_tracer_CSp, &
659 names, units, stock_index)
660 call store_stocks(
"MOM_generic_tracer", ns, names, units, values, index, stock_values, &
661 set_pkg_name, max_ns, ns_tot, stock_names, stock_units)
663 nn=mom_generic_tracer_min_max(nn, got_min_max, global_min, global_max, &
664 xgmin, ygmin, zgmin, xgmax, ygmax, zgmax ,&
665 g, cs%MOM_generic_tracer_CSp,names, units)
669 if (cs%use_pseudo_salt_tracer)
then
671 names, units, stock_index)
672 call store_stocks(
"pseudo_salt_tracer", ns, names, units, values, index, &
673 stock_values, set_pkg_name, max_ns, ns_tot, stock_names, stock_units)
676 if (cs%use_boundary_impulse_tracer)
then
677 ns = boundary_impulse_stock(h, values, g, gv, cs%boundary_impulse_tracer_CSp, &
678 names, units, stock_index)
679 call store_stocks(
"boundary_impulse_tracer", ns, names, units, values, index, &
680 stock_values, set_pkg_name, max_ns, ns_tot, stock_names, stock_units)
683 if (ns_tot == 0) stock_values(1) = 0.0
685 if (
present(num_stocks)) num_stocks = ns_tot
690 subroutine store_stocks(pkg_name, ns, names, units, values, index, stock_values, &
691 set_pkg_name, max_ns, ns_tot, stock_names, stock_units)
692 character(len=*),
intent(in) :: pkg_name
693 integer,
intent(in) :: ns
694 character(len=*),
dimension(:), &
696 character(len=*),
dimension(:), &
698 real,
dimension(:),
intent(in) :: values
699 integer,
intent(in) :: index
702 real,
dimension(:),
intent(inout) :: stock_values
703 character(len=*),
intent(inout) :: set_pkg_name
706 integer,
intent(in) :: max_ns
707 integer,
intent(inout) :: ns_tot
708 character(len=*),
dimension(:), &
709 optional,
intent(inout) :: stock_names
710 character(len=*),
dimension(:), &
711 optional,
intent(inout) :: stock_units
714 character(len=16) :: ind_text, ns_text, max_text
717 if ((index > 0) .and. (ns > 0))
then
718 write(ind_text,
'(i8)') index
720 call mom_error(fatal,
"Tracer package "//trim(pkg_name)//&
721 " is not permitted to return more than one value when queried"//&
722 " for specific stock index "//trim(adjustl(ind_text))//
".")
723 elseif (ns+ns_tot > 1)
then
724 call mom_error(fatal,
"Tracer packages "//trim(pkg_name)//
" and "//&
725 trim(set_pkg_name)//
" both attempted to set values for"//&
726 " specific stock index "//trim(adjustl(ind_text))//
".")
728 set_pkg_name = pkg_name
732 if (ns_tot+ns > max_ns)
then
733 write(ns_text,
'(i8)') ns_tot+ns ;
write(max_text,
'(i8)') max_ns
734 call mom_error(fatal,
"Attempted to return more tracer stock values (at least "//&
735 trim(adjustl(ns_text))//
") than the size "//trim(adjustl(max_text))//&
736 "of the smallest value, name, or units array.")
740 stock_values(ns_tot+n) = values(n)
741 if (
present(stock_names)) stock_names(ns_tot+n) = names(n)
742 if (
present(stock_units)) stock_units(ns_tot+n) = units(n)
753 real,
dimension(NIMEM_,NJMEM_,NKMEM_), &
759 if (.not.
associated(cs))
call mom_error(fatal,
"call_tracer_surface_state: "// &
760 "Module must be initialized via call_tracer_register before it is used.")
763 if (cs%use_USER_tracer_example) &
764 call user_tracer_surface_state(state, h, g, cs%USER_tracer_example_CSp)
765 if (cs%use_DOME_tracer) &
766 call dome_tracer_surface_state(state, h, g, cs%DOME_tracer_CSp)
767 if (cs%use_ISOMIP_tracer) &
768 call isomip_tracer_surface_state(state, h, g, cs%ISOMIP_tracer_CSp)
769 if (cs%use_ideal_age) &
770 call ideal_age_tracer_surface_state(state, h, g, cs%ideal_age_tracer_CSp)
771 if (cs%use_regional_dyes) &
772 call dye_tracer_surface_state(state, h, g, cs%dye_tracer_CSp)
774 call oil_tracer_surface_state(state, h, g, cs%oil_tracer_CSp)
775 if (cs%use_advection_test_tracer) &
776 call advection_test_tracer_surface_state(state, h, g, cs%advection_test_tracer_CSp)
777 if (cs%use_OCMIP2_CFC) &
778 call ocmip2_cfc_surface_state(state, h, g, cs%OCMIP2_CFC_CSp)
779 #ifdef _USE_GENERIC_TRACER
780 if (cs%use_MOM_generic_tracer) &
781 call mom_generic_tracer_surface_state(state, h, g, cs%MOM_generic_tracer_CSp)
790 if (cs%use_USER_tracer_example) &
800 #ifdef _USE_GENERIC_TRACER
801 if (cs%use_MOM_generic_tracer)
call end_mom_generic_tracer(cs%MOM_generic_tracer_CSp)
804 if (cs%use_boundary_impulse_tracer)
call boundary_impulse_tracer_end(cs%boundary_impulse_tracer_CSp)
807 if (
associated(cs))
deallocate(cs)