register_tracer_diagnostics does a set of register_diag_field calls for any previously registered in a tracer registry with a value of registry_diags set to .true.
344 type(ocean_grid_type),
intent(in) :: G
345 type(verticalGrid_type),
intent(in) :: GV
346 type(unit_scale_type),
intent(in) :: US
347 type(tracer_registry_type),
pointer :: Reg
348 real,
dimension(SZI_(G),SZJ_(G),SZK_(GV)), &
350 type(time_type),
intent(in) :: Time
351 type(diag_ctrl),
intent(in) :: diag
352 logical,
intent(in) :: use_ALE
355 character(len=24) :: name
356 character(len=24) :: shortnm
358 character(len=72) :: longname
359 character(len=72) :: flux_longname
360 character(len=48) :: units
361 character(len=48) :: flux_units
363 character(len=48) :: conv_units
365 character(len=48) :: unit2
366 character(len=72) :: cmorname
367 character(len=120) :: cmor_longname
368 character(len=120) :: var_lname
369 character(len=120) :: cmor_var_lname
370 character(len=72) :: cmor_varname
371 type(tracer_type),
pointer :: Tr=>null()
372 integer :: i, j, k, is, ie, js, je, nz, m, m2, nTr_in
373 integer :: isd, ied, jsd, jed, IsdB, IedB, JsdB, JedB
374 is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec ; nz = g%ke
375 isd = g%isd ; ied = g%ied ; jsd = g%jsd ; jed = g%jed
376 isdb = g%IsdB ; iedb = g%IedB ; jsdb = g%JsdB ; jedb = g%JedB
378 if (.not.
associated(reg))
call mom_error(fatal,
"register_tracer_diagnostics: "//&
379 "register_tracer must be called before register_tracer_diagnostics")
383 do m=1,ntr_in ;
if (reg%Tr(m)%registry_diags)
then
388 name = tr%name ; units=adjustl(tr%units) ; longname = tr%longname
389 cmorname = tr%cmor_name ; cmor_longname = tr%cmor_longname
390 shortnm = tr%flux_nameroot
391 flux_longname = tr%flux_longname
392 if (len_trim(cmor_longname) == 0) cmor_longname = longname
394 if (len_trim(tr%flux_units) > 0)
then ; flux_units = tr%flux_units
395 elseif (gv%Boussinesq)
then ; flux_units = trim(units)//
" m3 s-1"
396 else ; flux_units = trim(units)//
" kg s-1" ;
endif
398 if (len_trim(tr%conv_units) > 0)
then ; conv_units = tr%conv_units
399 elseif (gv%Boussinesq)
then ; conv_units = trim(units)//
" m s-1"
400 else ; conv_units = trim(units)//
" kg m-2 s-1" ;
endif
402 if (len_trim(cmorname) == 0)
then
403 tr%id_tr = register_diag_field(
"ocean_model", trim(name), diag%axesTL, &
404 time, trim(longname), trim(units))
406 tr%id_tr = register_diag_field(
"ocean_model", trim(name), diag%axesTL, &
407 time, trim(longname), trim(units), cmor_field_name=cmorname, &
408 cmor_long_name=cmor_longname, cmor_units=tr%cmor_units, &
409 cmor_standard_name=cmor_long_std(cmor_longname))
411 tr%id_tr_post_horzn = register_diag_field(
"ocean_model", &
412 trim(name)//
"_post_horzn", diag%axesTL, time, &
413 trim(longname)//
" after horizontal transport (advection/diffusion) "//&
414 "has occurred", trim(units))
415 if (tr%diag_form == 1)
then
416 tr%id_adx = register_diag_field(
"ocean_model", trim(shortnm)//
"_adx", &
417 diag%axesCuL, time, trim(flux_longname)//
" advective zonal flux" , &
418 trim(flux_units), v_extensive = .true., y_cell_method =
'sum', &
419 conversion=tr%flux_scale*(us%L_to_m**2)*us%s_to_T)
420 tr%id_ady = register_diag_field(
"ocean_model", trim(shortnm)//
"_ady", &
421 diag%axesCvL, time, trim(flux_longname)//
" advective meridional flux" , &
422 trim(flux_units), v_extensive = .true., x_cell_method =
'sum', &
423 conversion=tr%flux_scale*(us%L_to_m**2)*us%s_to_T)
424 tr%id_dfx = register_diag_field(
"ocean_model", trim(shortnm)//
"_dfx", &
425 diag%axesCuL, time, trim(flux_longname)//
" diffusive zonal flux" , &
426 trim(flux_units), v_extensive = .true., y_cell_method =
'sum', &
427 conversion=(us%L_to_m**2)*tr%flux_scale*us%s_to_T)
428 tr%id_dfy = register_diag_field(
"ocean_model", trim(shortnm)//
"_dfy", &
429 diag%axesCvL, time, trim(flux_longname)//
" diffusive zonal flux" , &
430 trim(flux_units), v_extensive = .true., x_cell_method =
'sum', &
431 conversion=(us%L_to_m**2)*tr%flux_scale*us%s_to_T)
432 tr%id_lbd_dfx = register_diag_field(
"ocean_model", trim(shortnm)//
"_lbd_diffx", &
433 diag%axesCuL, time, trim(flux_longname)//
" diffusive zonal flux from the lateral boundary diffusion "//&
434 "scheme", trim(flux_units), v_extensive = .true., y_cell_method =
'sum', &
435 conversion=(us%L_to_m**2)*tr%flux_scale*us%s_to_T)
436 tr%id_lbd_dfy = register_diag_field(
"ocean_model", trim(shortnm)//
"_lbd_diffy", &
437 diag%axesCvL, time, trim(flux_longname)//
" diffusive meridional flux from the lateral boundary diffusion "//&
438 "scheme", trim(flux_units), v_extensive = .true., x_cell_method =
'sum', &
439 conversion=(us%L_to_m**2)*tr%flux_scale*us%s_to_T)
441 tr%id_adx = register_diag_field(
"ocean_model", trim(shortnm)//
"_adx", &
442 diag%axesCuL, time,
"Advective (by residual mean) Zonal Flux of "//trim(flux_longname), &
443 flux_units, v_extensive=.true., conversion=tr%flux_scale*(us%L_to_m**2)*us%s_to_T, y_cell_method =
'sum')
444 tr%id_ady = register_diag_field(
"ocean_model", trim(shortnm)//
"_ady", &
445 diag%axesCvL, time,
"Advective (by residual mean) Meridional Flux of "//trim(flux_longname), &
446 flux_units, v_extensive=.true., conversion=tr%flux_scale*(us%L_to_m**2)*us%s_to_T, x_cell_method =
'sum')
447 tr%id_dfx = register_diag_field(
"ocean_model", trim(shortnm)//
"_diffx", &
448 diag%axesCuL, time,
"Diffusive Zonal Flux of "//trim(flux_longname), &
449 flux_units, v_extensive=.true., conversion=(us%L_to_m**2)*tr%flux_scale*us%s_to_T, &
451 tr%id_dfy = register_diag_field(
"ocean_model", trim(shortnm)//
"_diffy", &
452 diag%axesCvL, time,
"Diffusive Meridional Flux of "//trim(flux_longname), &
453 flux_units, v_extensive=.true., conversion=(us%L_to_m**2)*tr%flux_scale*us%s_to_T, &
455 tr%id_lbd_dfx = register_diag_field(
"ocean_model", trim(shortnm)//
"_lbd_diffx", &
456 diag%axesCuL, time,
"Lateral Boundary Diffusive Zonal Flux of "//trim(flux_longname), &
457 flux_units, v_extensive=.true., conversion=(us%L_to_m**2)*tr%flux_scale*us%s_to_T, &
459 tr%id_lbd_dfy = register_diag_field(
"ocean_model", trim(shortnm)//
"_lbd_diffy", &
460 diag%axesCvL, time,
"Lateral Boundary Diffusive Meridional Flux of "//trim(flux_longname), &
461 flux_units, v_extensive=.true., conversion=(us%L_to_m**2)*tr%flux_scale*us%s_to_T, &
464 if (tr%id_adx > 0)
call safe_alloc_ptr(tr%ad_x,isdb,iedb,jsd,jed,nz)
465 if (tr%id_ady > 0)
call safe_alloc_ptr(tr%ad_y,isd,ied,jsdb,jedb,nz)
466 if (tr%id_dfx > 0)
call safe_alloc_ptr(tr%df_x,isdb,iedb,jsd,jed,nz)
467 if (tr%id_dfy > 0)
call safe_alloc_ptr(tr%df_y,isd,ied,jsdb,jedb,nz)
468 if (tr%id_lbd_dfx > 0)
call safe_alloc_ptr(tr%lbd_dfx,isdb,iedb,jsd,jed,nz)
469 if (tr%id_lbd_dfy > 0)
call safe_alloc_ptr(tr%lbd_dfy,isd,ied,jsdb,jedb,nz)
471 tr%id_adx_2d = register_diag_field(
"ocean_model", trim(shortnm)//
"_adx_2d", &
472 diag%axesCu1, time, &
473 "Vertically Integrated Advective Zonal Flux of "//trim(flux_longname), &
474 flux_units, conversion=tr%flux_scale*(us%L_to_m**2)*us%s_to_T, y_cell_method =
'sum')
475 tr%id_ady_2d = register_diag_field(
"ocean_model", trim(shortnm)//
"_ady_2d", &
476 diag%axesCv1, time, &
477 "Vertically Integrated Advective Meridional Flux of "//trim(flux_longname), &
478 flux_units, conversion=tr%flux_scale*(us%L_to_m**2)*us%s_to_T, x_cell_method =
'sum')
479 tr%id_dfx_2d = register_diag_field(
"ocean_model", trim(shortnm)//
"_diffx_2d", &
480 diag%axesCu1, time, &
481 "Vertically Integrated Diffusive Zonal Flux of "//trim(flux_longname), &
482 flux_units, conversion=(us%L_to_m**2)*tr%flux_scale*us%s_to_T, &
484 tr%id_dfy_2d = register_diag_field(
"ocean_model", trim(shortnm)//
"_diffy_2d", &
485 diag%axesCv1, time, &
486 "Vertically Integrated Diffusive Meridional Flux of "//trim(flux_longname), &
487 flux_units, conversion=(us%L_to_m**2)*tr%flux_scale*us%s_to_T, &
489 tr%id_lbd_bulk_dfx = register_diag_field(
"ocean_model", trim(shortnm)//
"_lbd_bulk_diffx", &
490 diag%axesCu1, time, &
491 "Total Bulk Diffusive Zonal Flux of "//trim(flux_longname), &
492 flux_units, conversion=(us%L_to_m**2)*tr%flux_scale*us%s_to_T, &
494 tr%id_lbd_bulk_dfy = register_diag_field(
"ocean_model", trim(shortnm)//
"_lbd_bulk_diffy", &
495 diag%axesCv1, time, &
496 "Total Bulk Diffusive Meridional Flux of "//trim(flux_longname), &
497 flux_units, conversion=(us%L_to_m**2)*tr%flux_scale*us%s_to_T, &
499 tr%id_lbd_dfx_2d = register_diag_field(
"ocean_model", trim(shortnm)//
"_lbd_diffx_2d", &
500 diag%axesCu1, time,
"Vertically-integrated zonal diffusive flux from the lateral boundary diffusion "//&
501 "scheme for "//trim(flux_longname), flux_units, conversion=(us%L_to_m**2)*tr%flux_scale*us%s_to_T, &
502 y_cell_method =
'sum')
503 tr%id_lbd_dfy_2d = register_diag_field(
"ocean_model", trim(shortnm)//
"_lbd_diffy_2d", &
504 diag%axesCv1, time,
"Vertically-integrated meridional diffusive flux from the lateral boundary diffusion "//&
505 "scheme for "//trim(flux_longname), flux_units, conversion=(us%L_to_m**2)*tr%flux_scale*us%s_to_T, &
506 x_cell_method =
'sum')
508 if (tr%id_adx_2d > 0)
call safe_alloc_ptr(tr%ad2d_x,isdb,iedb,jsd,jed)
509 if (tr%id_ady_2d > 0)
call safe_alloc_ptr(tr%ad2d_y,isd,ied,jsdb,jedb)
510 if (tr%id_dfx_2d > 0)
call safe_alloc_ptr(tr%df2d_x,isdb,iedb,jsd,jed)
511 if (tr%id_dfy_2d > 0)
call safe_alloc_ptr(tr%df2d_y,isd,ied,jsdb,jedb)
512 if (tr%id_lbd_bulk_dfx > 0)
call safe_alloc_ptr(tr%lbd_bulk_df_x,isdb,iedb,jsd,jed)
513 if (tr%id_lbd_bulk_dfy > 0)
call safe_alloc_ptr(tr%lbd_bulk_df_y,isd,ied,jsdb,jedb)
514 if (tr%id_lbd_dfx_2d > 0)
call safe_alloc_ptr(tr%lbd_dfx_2d,isdb,iedb,jsd,jed)
515 if (tr%id_lbd_dfy_2d > 0)
call safe_alloc_ptr(tr%lbd_dfy_2d,isd,ied,jsdb,jedb)
517 tr%id_adv_xy = register_diag_field(
'ocean_model', trim(shortnm)//
"_advection_xy", &
519 'Horizontal convergence of residual mean advective fluxes of '//&
520 trim(lowercase(flux_longname)), conv_units, v_extensive=.true., &
521 conversion=tr%conv_scale*us%s_to_T)
522 tr%id_adv_xy_2d = register_diag_field(
'ocean_model', trim(shortnm)//
"_advection_xy_2d", &
524 'Vertical sum of horizontal convergence of residual mean advective fluxes of '//&
525 trim(lowercase(flux_longname)), conv_units, conversion=tr%conv_scale*us%s_to_T)
526 if ((tr%id_adv_xy > 0) .or. (tr%id_adv_xy_2d > 0)) &
527 call safe_alloc_ptr(tr%advection_xy,isd,ied,jsd,jed,nz)
529 tr%id_tendency = register_diag_field(
'ocean_model', trim(shortnm)//
'_tendency', &
531 'Net time tendency for '//trim(lowercase(longname)), trim(units)//
' s-1', conversion=us%s_to_T)
533 if (tr%id_tendency > 0)
then
534 call safe_alloc_ptr(tr%t_prev,isd,ied,jsd,jed,nz)
535 do k=1,nz ;
do j=js,je ;
do i=is,ie
536 tr%t_prev(i,j,k) = tr%t(i,j,k)
537 enddo ;
enddo ;
enddo
541 if (tr%diag_form == 1)
then
542 tr%id_dfxy_cont = register_diag_field(
"ocean_model", trim(shortnm)//
'_dfxy_cont_tendency', &
543 diag%axesTL, time,
"Neutral diffusion tracer content tendency for "//trim(shortnm), &
544 conv_units, conversion=tr%conv_scale*us%s_to_T, x_cell_method=
'sum', y_cell_method=
'sum', v_extensive=.true.)
546 tr%id_dfxy_cont_2d = register_diag_field(
"ocean_model", trim(shortnm)//
'_dfxy_cont_tendency_2d', &
547 diag%axesT1, time,
"Depth integrated neutral diffusion tracer content "//&
548 "tendency for "//trim(shortnm), conv_units, conversion=tr%conv_scale*us%s_to_T, &
549 x_cell_method=
'sum', y_cell_method=
'sum')
551 tr%id_lbdxy_cont = register_diag_field(
"ocean_model", trim(shortnm)//
'_lbdxy_cont_tendency', &
552 diag%axesTL, time,
"Lateral diffusion tracer content tendency for "//trim(shortnm), &
553 conv_units, conversion=tr%conv_scale*us%s_to_T, x_cell_method=
'sum', y_cell_method=
'sum', v_extensive=.true.)
555 tr%id_lbdxy_cont_2d = register_diag_field(
"ocean_model", trim(shortnm)//
'_lbdxy_cont_tendency_2d', &
556 diag%axesT1, time,
"Depth integrated lateral diffusion tracer content "//&
557 "tendency for "//trim(shortnm), conv_units, conversion=tr%conv_scale*us%s_to_T, &
558 x_cell_method=
'sum', y_cell_method=
'sum')
560 cmor_var_lname =
'Tendency of '//trim(lowercase(cmor_longname))//&
561 ' expressed as '//trim(lowercase(flux_longname))//&
562 ' content due to parameterized mesoscale neutral diffusion'
563 tr%id_dfxy_cont = register_diag_field(
"ocean_model", trim(shortnm)//
'_dfxy_cont_tendency', &
564 diag%axesTL, time,
"Neutral diffusion tracer content tendency for "//trim(shortnm), &
565 conv_units, conversion=tr%conv_scale*us%s_to_T, cmor_field_name = trim(tr%cmor_tendprefix)//
'pmdiff', &
566 cmor_long_name = trim(cmor_var_lname), cmor_standard_name = trim(cmor_long_std(cmor_var_lname)), &
567 x_cell_method =
'sum', y_cell_method =
'sum', v_extensive = .true.)
569 cmor_var_lname =
'Tendency of '//trim(lowercase(cmor_longname))//
' expressed as '//&
570 trim(lowercase(flux_longname))//
' content due to parameterized mesoscale neutral diffusion'
571 tr%id_dfxy_cont_2d = register_diag_field(
"ocean_model", trim(shortnm)//
'_dfxy_cont_tendency_2d', &
572 diag%axesT1, time,
"Depth integrated neutral diffusion tracer "//&
573 "content tendency for "//trim(shortnm), conv_units, &
574 conversion=tr%conv_scale*us%s_to_T, cmor_field_name=trim(tr%cmor_tendprefix)//
'pmdiff_2d', &
575 cmor_long_name=trim(cmor_var_lname), cmor_standard_name=trim(cmor_long_std(cmor_var_lname)), &
576 x_cell_method=
'sum', y_cell_method=
'sum')
578 tr%id_lbdxy_cont = register_diag_field(
"ocean_model", trim(shortnm)//
'_lbdxy_cont_tendency', &
579 diag%axesTL, time,
"Lateral diffusion tracer content tendency for "//trim(shortnm), &
580 conv_units, conversion=tr%conv_scale*us%s_to_T, &
581 x_cell_method =
'sum', y_cell_method =
'sum', v_extensive = .true.)
583 tr%id_lbdxy_cont_2d = register_diag_field(
"ocean_model", trim(shortnm)//
'_lbdxy_cont_tendency_2d', &
584 diag%axesT1, time,
"Depth integrated lateral diffusion tracer "//&
585 "content tendency for "//trim(shortnm), conv_units, &
586 conversion=tr%conv_scale*us%s_to_T, x_cell_method=
'sum', y_cell_method=
'sum')
588 tr%id_dfxy_conc = register_diag_field(
"ocean_model", trim(shortnm)//
'_dfxy_conc_tendency', &
589 diag%axesTL, time,
"Neutral diffusion tracer concentration tendency for "//trim(shortnm), &
590 trim(units)//
' s-1', conversion=us%s_to_T)
592 tr%id_lbdxy_conc = register_diag_field(
"ocean_model", trim(shortnm)//
'_lbdxy_conc_tendency', &
593 diag%axesTL, time,
"Lateral diffusion tracer concentration tendency for "//trim(shortnm), &
594 trim(units)//
' s-1', conversion=us%s_to_T)
596 var_lname =
"Net time tendency for "//lowercase(flux_longname)
597 if (len_trim(tr%cmor_tendprefix) == 0)
then
598 tr%id_trxh_tendency = register_diag_field(
'ocean_model', trim(shortnm)//
'h_tendency', &
599 diag%axesTL, time, var_lname, conv_units, v_extensive=.true., &
600 conversion=tr%conv_scale*us%s_to_T)
601 tr%id_trxh_tendency_2d = register_diag_field(
'ocean_model', trim(shortnm)//
'h_tendency_2d', &
602 diag%axesT1, time,
"Vertical sum of "//trim(lowercase(var_lname)), conv_units, &
603 conversion=tr%conv_scale*us%s_to_T)
605 cmor_var_lname =
"Tendency of "//trim(cmor_longname)//
" Expressed as "//&
606 trim(flux_longname)//
" Content"
607 tr%id_trxh_tendency = register_diag_field(
'ocean_model', trim(shortnm)//
'h_tendency', &
608 diag%axesTL, time, var_lname, conv_units, &
609 cmor_field_name=trim(tr%cmor_tendprefix)//
"tend", &
610 cmor_standard_name=cmor_long_std(cmor_var_lname), cmor_long_name=cmor_var_lname, &
611 v_extensive=.true., conversion=tr%conv_scale*us%s_to_T)
612 cmor_var_lname = trim(cmor_var_lname)//
" Vertical Sum"
613 tr%id_trxh_tendency_2d = register_diag_field(
'ocean_model', trim(shortnm)//
'h_tendency_2d', &
614 diag%axesT1, time,
"Vertical sum of "//trim(lowercase(var_lname)), conv_units, &
615 cmor_field_name=trim(tr%cmor_tendprefix)//
"tend_2d", &
616 cmor_standard_name=cmor_long_std(cmor_var_lname), cmor_long_name=cmor_var_lname, &
617 conversion=tr%conv_scale*us%s_to_T)
619 if ((tr%id_trxh_tendency > 0) .or. (tr%id_trxh_tendency_2d > 0))
then
620 call safe_alloc_ptr(tr%Trxh_prev,isd,ied,jsd,jed,nz)
621 do k=1,nz ;
do j=js,je ;
do i=is,ie
622 tr%Trxh_prev(i,j,k) = tr%t(i,j,k) * h(i,j,k)
623 enddo ;
enddo ;
enddo
627 if (use_ale .and. tr%remap_tr)
then
628 var_lname =
"Vertical remapping tracer concentration tendency for "//trim(reg%Tr(m)%name)
629 tr%id_remap_conc= register_diag_field(
'ocean_model', &
630 trim(tr%flux_nameroot)//
'_tendency_vert_remap', diag%axesTL, time, var_lname, &
631 trim(units)//
' s-1', conversion=us%s_to_T)
633 var_lname =
"Vertical remapping tracer content tendency for "//trim(reg%Tr(m)%flux_longname)
634 tr%id_remap_cont = register_diag_field(
'ocean_model', &
635 trim(tr%flux_nameroot)//
'h_tendency_vert_remap', &
636 diag%axesTL, time, var_lname, flux_units, v_extensive=.true., conversion=tr%conv_scale*us%s_to_T)
638 var_lname =
"Vertical sum of vertical remapping tracer content tendency for "//&
639 trim(reg%Tr(m)%flux_longname)
640 tr%id_remap_cont_2d = register_diag_field(
'ocean_model', &
641 trim(tr%flux_nameroot)//
'h_tendency_vert_remap_2d', &
642 diag%axesT1, time, var_lname, flux_units, conversion=tr%conv_scale*us%s_to_T)
646 if (use_ale .and. (reg%ntr<max_fields_) .and. tr%remap_tr)
then
647 unit2 = trim(units)//
"2"
648 if (index(units(1:len_trim(units)),
" ") > 0) unit2 =
"("//trim(units)//
")2"
649 tr%id_tr_vardec = register_diag_field(
'ocean_model', trim(shortnm)//
"_vardec", diag%axesTL, &
650 time,
"ALE variance decay for "//lowercase(longname), trim(unit2)//
" s-1", conversion=us%s_to_T)
651 if (tr%id_tr_vardec > 0)
then
654 tr%ind_tr_squared = m2
655 call safe_alloc_ptr(reg%Tr(m2)%t,isd,ied,jsd,jed,nz) ; reg%Tr(m2)%t(:,:,:) = 0.0
656 reg%Tr(m2)%name = trim(shortnm)//
"2"
657 reg%Tr(m2)%longname =
"Squared "//trim(longname)
658 reg%Tr(m2)%units = unit2
659 reg%Tr(m2)%registry_diags = .false.
660 reg%Tr(m2)%ind_tr_squared = -1
662 reg%ntr = reg%ntr + 1