Make a real 3-d array diagnostic available for averaging or output.
1459 integer,
intent(in) :: diag_field_id
1461 real,
intent(in) :: field(:,:,:)
1462 type(diag_ctrl),
target,
intent(in) :: diag_CS
1463 logical,
optional,
intent(in) :: is_static
1464 real,
optional,
intent(in) :: mask(:,:,:)
1465 real,
dimension(:,:,:), &
1466 target,
optional,
intent(in) :: alt_h
1470 type(diag_type),
pointer :: diag => null()
1471 integer :: nz, i, j, k
1472 real,
dimension(:,:,:),
allocatable :: remapped_field
1473 logical :: staggered_in_x, staggered_in_y
1474 real,
dimension(:,:,:),
pointer :: h_diag => null()
1476 if (
present(alt_h))
then
1482 if (id_clock_diag_mediator>0)
call cpu_clock_begin(id_clock_diag_mediator)
1486 call assert(diag_field_id < diag_cs%next_free_diag_id, &
1487 'post_data_3d: Unregistered diagnostic id')
1488 diag => diag_cs%diags(diag_field_id)
1489 do while (
associated(diag))
1490 call assert(
associated(diag%axes),
'post_data_3d: axes is not associated')
1492 staggered_in_x = diag%axes%is_u_point .or. diag%axes%is_q_point
1493 staggered_in_y = diag%axes%is_v_point .or. diag%axes%is_q_point
1495 if (diag%v_extensive .and. .not.diag%axes%is_native)
then
1497 if (
present(mask))
then
1498 call mom_error(fatal,
"post_data_3d: no mask for regridded field.")
1501 if (id_clock_diag_remap>0)
call cpu_clock_begin(id_clock_diag_remap)
1502 allocate(remapped_field(
size(field,1),
size(field,2), diag%axes%nz))
1503 call vertically_reintegrate_diag_field( &
1504 diag_cs%diag_remap_cs(diag%axes%vertical_coordinate_number), &
1505 diag_cs%G, h_diag, staggered_in_x, staggered_in_y, &
1506 diag%axes%mask3d, diag_cs%missing_value, field, remapped_field)
1507 if (id_clock_diag_remap>0)
call cpu_clock_end(id_clock_diag_remap)
1508 if (
associated(diag%axes%mask3d))
then
1511 call post_data_3d_low(diag, remapped_field, diag_cs, is_static, &
1512 mask=diag%axes%mask3d)
1514 call post_data_3d_low(diag, remapped_field, diag_cs, is_static)
1516 if (id_clock_diag_remap>0)
call cpu_clock_begin(id_clock_diag_remap)
1517 deallocate(remapped_field)
1518 if (id_clock_diag_remap>0)
call cpu_clock_end(id_clock_diag_remap)
1519 elseif (diag%axes%needs_remapping)
then
1521 if (
present(mask))
then
1522 call mom_error(fatal,
"post_data_3d: no mask for regridded field.")
1525 if (id_clock_diag_remap>0)
call cpu_clock_begin(id_clock_diag_remap)
1526 allocate(remapped_field(
size(field,1),
size(field,2), diag%axes%nz))
1527 call diag_remap_do_remap(diag_cs%diag_remap_cs( &
1528 diag%axes%vertical_coordinate_number), &
1529 diag_cs%G, diag_cs%GV, h_diag, staggered_in_x, staggered_in_y, &
1530 diag%axes%mask3d, diag_cs%missing_value, field, remapped_field)
1531 if (id_clock_diag_remap>0)
call cpu_clock_end(id_clock_diag_remap)
1532 if (
associated(diag%axes%mask3d))
then
1535 call post_data_3d_low(diag, remapped_field, diag_cs, is_static, &
1536 mask=diag%axes%mask3d)
1538 call post_data_3d_low(diag, remapped_field, diag_cs, is_static)
1540 if (id_clock_diag_remap>0)
call cpu_clock_begin(id_clock_diag_remap)
1541 deallocate(remapped_field)
1542 if (id_clock_diag_remap>0)
call cpu_clock_end(id_clock_diag_remap)
1543 elseif (diag%axes%needs_interpolating)
then
1545 if (
present(mask))
then
1546 call mom_error(fatal,
"post_data_3d: no mask for regridded field.")
1549 if (id_clock_diag_remap>0)
call cpu_clock_begin(id_clock_diag_remap)
1550 allocate(remapped_field(
size(field,1),
size(field,2), diag%axes%nz+1))
1551 call vertically_interpolate_diag_field(diag_cs%diag_remap_cs( &
1552 diag%axes%vertical_coordinate_number), &
1553 diag_cs%G, h_diag, staggered_in_x, staggered_in_y, &
1554 diag%axes%mask3d, diag_cs%missing_value, field, remapped_field)
1555 if (id_clock_diag_remap>0)
call cpu_clock_end(id_clock_diag_remap)
1556 if (
associated(diag%axes%mask3d))
then
1559 call post_data_3d_low(diag, remapped_field, diag_cs, is_static, &
1560 mask=diag%axes%mask3d)
1562 call post_data_3d_low(diag, remapped_field, diag_cs, is_static)
1564 if (id_clock_diag_remap>0)
call cpu_clock_begin(id_clock_diag_remap)
1565 deallocate(remapped_field)
1566 if (id_clock_diag_remap>0)
call cpu_clock_end(id_clock_diag_remap)
1568 call post_data_3d_low(diag, field, diag_cs, is_static, mask)
1572 if (id_clock_diag_mediator>0)
call cpu_clock_end(id_clock_diag_mediator)