Skip to content

Commit

Permalink
+Add unit_scale_type argument to diag_remap_update
Browse files Browse the repository at this point in the history
  Added a unit_scale_type argument to diag_remap_update and a pointer to a
unit_scale_type structure to diag_mediator_init and store a this pointer in
the diag_ctrl type, all to accomodate rescaling of depths via US%Z_to_m instead
of G%Zd_to_m.  All answers are bitwise identical.
  • Loading branch information
Hallberg-NOAA committed Nov 14, 2018
1 parent 9ac67cc commit d2bfd73
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/core/MOM.F90
Original file line number Diff line number Diff line change
Expand Up @@ -2256,7 +2256,7 @@ subroutine initialize_MOM(Time, Time_init, param_file, dirs, CS, restart_CSp, &

diag => CS%diag
! Initialize the diag mediator.
call diag_mediator_init(G, GV, GV%ke, param_file, diag, doc_file_dir=dirs%output_directory)
call diag_mediator_init(G, GV, US, GV%ke, param_file, diag, doc_file_dir=dirs%output_directory)
if (present(diag_ptr)) diag_ptr => CS%diag

! Initialize the diagnostics masks for native arrays.
Expand Down
9 changes: 6 additions & 3 deletions src/framework/MOM_diag_mediator.F90
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module MOM_diag_mediator
use MOM_safe_alloc, only : safe_alloc_ptr, safe_alloc_alloc
use MOM_string_functions, only : lowercase
use MOM_time_manager, only : time_type
use MOM_unit_scaling, only : unit_scale_type
use MOM_unit_scaling, only : unit_scale_type
use MOM_verticalGrid, only : verticalGrid_type
use MOM_EOS, only : EOS_type
use MOM_diag_remap, only : diag_remap_ctrl
Expand Down Expand Up @@ -223,6 +223,7 @@ module MOM_diag_mediator
type(EOS_type), pointer :: eqn_of_state => null() !< The equation of state type
type(ocean_grid_type), pointer :: G => null() !< The ocean grid type
type(verticalGrid_type), pointer :: GV => null() !< The model's vertical ocean grid
type(unit_scale_type), pointer :: US => null() !< A dimensional unit scaling type

!> The volume cell measure (special diagnostic) manager id
integer :: volume_cell_measure_dm_id = -1
Expand Down Expand Up @@ -2177,9 +2178,10 @@ end subroutine diag_mediator_infrastructure_init

!> diag_mediator_init initializes the MOM diag_mediator and opens the available
!! diagnostics file, if appropriate.
subroutine diag_mediator_init(G, GV, nz, param_file, diag_cs, doc_file_dir)
subroutine diag_mediator_init(G, GV, US, nz, param_file, diag_cs, doc_file_dir)
type(ocean_grid_type), target, intent(inout) :: G !< The ocean grid type.
type(verticalGrid_type), target, intent(in) :: GV !< The ocean vertical grid structure
type(unit_scale_type), target, intent(in) :: US !< A dimensional unit scaling type
integer, intent(in) :: nz !< The number of layers in the model's native grid.
type(param_file_type), intent(in) :: param_file !< Parameter file structure
type(diag_ctrl), intent(inout) :: diag_cs !< A pointer to a type with many variables
Expand Down Expand Up @@ -2251,6 +2253,7 @@ subroutine diag_mediator_init(G, GV, nz, param_file, diag_cs, doc_file_dir)
! Keep pointers grid, h, T, S needed diagnostic remapping
diag_cs%G => G
diag_cs%GV => GV
diag_cs%US => US
diag_cs%h => null()
diag_cs%T => null()
diag_cs%S => null()
Expand Down Expand Up @@ -2404,7 +2407,7 @@ subroutine diag_update_remap_grids(diag_cs, alt_h, alt_T, alt_S)

do i=1, diag_cs%num_diag_coords
call diag_remap_update(diag_cs%diag_remap_cs(i), &
diag_cs%G, diag_cs%GV, h_diag, T_diag, S_diag, &
diag_cs%G, diag_cs%GV, diag_cs%US, h_diag, T_diag, S_diag, &
diag_cs%eqn_of_state)
enddo

Expand Down
9 changes: 5 additions & 4 deletions src/framework/MOM_diag_remap.F90
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,11 @@ function diag_remap_axes_configured(remap_cs)
!! height or layer thicknesses changes. In the case of density-based
!! coordinates then technically we should also regenerate the
!! target grid whenever T/S change.
subroutine diag_remap_update(remap_cs, G, GV, h, T, S, eqn_of_state)
subroutine diag_remap_update(remap_cs, G, GV, US, h, T, S, eqn_of_state)
type(diag_remap_ctrl), intent(inout) :: remap_cs !< Diagnostic coordinate control structure
type(ocean_grid_type), pointer :: G !< The ocean's grid type
type(verticalGrid_type), intent(in) :: GV !< ocean vertical grid structure
type(unit_scale_type), intent(in) :: US !< A dimensional unit scaling type
real, dimension(:, :, :), intent(in) :: h !< New thickness
real, dimension(:, :, :), intent(in) :: T !< New T
real, dimension(:, :, :), intent(in) :: S !< New S
Expand Down Expand Up @@ -278,15 +279,15 @@ subroutine diag_remap_update(remap_cs, G, GV, h, T, S, eqn_of_state)
GV%Z_to_H*G%bathyT(i,j), sum(h(i,j,:)), zInterfaces)
elseif (remap_cs%vertical_coord == coordinateMode('RHO')) then
call build_rho_column(get_rho_CS(remap_cs%regrid_cs), G%ke, &
G%Zd_to_m*G%bathyT(i,j), h(i,j,:), T(i,j,:), S(i,j,:), &
US%Z_to_m*G%bathyT(i,j), h(i,j,:), T(i,j,:), S(i,j,:), &
eqn_of_state, zInterfaces, h_neglect, h_neglect_edge)
elseif (remap_cs%vertical_coord == coordinateMode('SLIGHT')) then
! call build_slight_column(remap_cs%regrid_cs,remap_cs%remap_cs, nz, &
! G%Zd_to_m*G%bathyT(i,j), sum(h(i,j,:)), zInterfaces)
! US%Z_to_m*G%bathyT(i,j), sum(h(i,j,:)), zInterfaces)
call MOM_error(FATAL,"diag_remap_update: SLIGHT coordinate not coded for diagnostics yet!")
elseif (remap_cs%vertical_coord == coordinateMode('HYCOM1')) then
! call build_hycom1_column(remap_cs%regrid_cs, nz, &
! G%Zd_to_m*G%bathyT(i,j), sum(h(i,j,:)), zInterfaces)
! US%Z_to_m*G%bathyT(i,j), sum(h(i,j,:)), zInterfaces)
call MOM_error(FATAL,"diag_remap_update: HYCOM1 coordinate not coded for diagnostics yet!")
endif
remap_cs%h(i,j,:) = zInterfaces(1:nz) - zInterfaces(2:nz+1)
Expand Down

0 comments on commit d2bfd73

Please sign in to comment.