Skip to content

Commit

Permalink
Correct available_diags for vertically remapped diagnostics. mom-ocea…
Browse files Browse the repository at this point in the history
  • Loading branch information
nichannah committed Jul 20, 2016
1 parent 76dd200 commit b1c6d1c
Showing 1 changed file with 43 additions and 13 deletions.
56 changes: 43 additions & 13 deletions src/framework/MOM_diag_mediator.F90
Original file line number Diff line number Diff line change
Expand Up @@ -806,15 +806,19 @@ function register_diag_field(module_name, field_name, axes, init_time, &

diag_cs => axes%diag_cs
primary_id = DIAG_FIELD_NOT_FOUND
diag => null()

do i=1,size(vertical_coords)
if (vertical_coord_strings(i) /= 'LAYER') then
! For now we don't support remapping diagnostics onto interfaces.
if (is_interface_axis(diag_cs, axes)) then
cycle
endif
new_module_name = trim(module_name//'_'//lowercase(trim(vertical_coord_strings(i))))
else
new_module_name = module_name
endif

diag => null()
if (get_diag_field_id_fms(new_module_name, field_name) /= DIAG_FIELD_NOT_FOUND) then
if (primary_id == DIAG_FIELD_NOT_FOUND) then
primary_id = get_new_primary_diag_id(diag_cs)
Expand All @@ -841,19 +845,23 @@ function register_diag_field(module_name, field_name, axes, init_time, &
'register_diag_field: Could not register diag')
diag%fms_diag_id = fms_id

if (is_root_pe() .and. diag_CS%doc_unit > 0) then
msg = ''
if (present(cmor_field_name)) msg = 'CMOR equivalent is "'//trim(cmor_field_name)//'"'
call log_available_diag(associated(diag), module_name, field_name, cm_string, &
msg, diag_CS, long_name, units, standard_name)
endif
endif
! This diag is being registered, so it is available.
print*, 'registering ', new_module_name, field_name
if (is_root_pe() .and. diag_CS%doc_unit > 0) then
msg = ''
print*, 'calling log_available_diag'
if (present(cmor_field_name)) msg = 'CMOR equivalent is "'//trim(cmor_field_name)//'"'
call log_available_diag(associated(diag), new_module_name, field_name, cm_string, &
msg, diag_CS, long_name, units, standard_name)
endif

if (.not. present(cmor_field_name)) then
cycle
endif

! Set up the CMOR variation of the native diagnostic
diag => null()
if (get_diag_field_id_fms(new_module_name, cmor_field_name) /= DIAG_FIELD_NOT_FOUND) then
! Fallback values for strings set to "NULL"
! Values might be able to be replaced with a CS%missing field?
Expand Down Expand Up @@ -898,12 +906,12 @@ function register_diag_field(module_name, field_name, axes, init_time, &
'register_diag_field: Could not register diag')
diag%fms_diag_id = fms_id

if (is_root_pe() .and. diag_CS%doc_unit > 0) then
msg = 'native name is "'//trim(field_name)//'"'
call log_available_diag(associated(diag), module_name, cmor_field_name, cm_string, &
msg, diag_CS, posted_cmor_long_name, posted_cmor_units, &
posted_cmor_standard_name)
endif
endif
if (is_root_pe() .and. diag_CS%doc_unit > 0) then
msg = 'native name is "'//trim(field_name)//'"'
call log_available_diag(associated(diag), new_module_name, cmor_field_name, cm_string, &
msg, diag_CS, posted_cmor_long_name, posted_cmor_units, &
posted_cmor_standard_name)
endif
enddo

Expand Down Expand Up @@ -1624,6 +1632,28 @@ subroutine set_diag_mask_and_axes(diag, diag_cs, axes)

end subroutine set_diag_mask_and_axes

function is_interface_axis(diag_cs, axes)
type(diag_ctrl), target, intent(in) :: diag_cs
type(axes_grp), intent(in) :: axes

logical :: is_interface_axis

is_interface_axis = .false.

if (axes%rank .eq. 3) then
if ((axes%id .eq. diag_cs%axesTi%id)) then
is_interface_axis = .true.
elseif(axes%id .eq. diag_cs%axesBi%id) then
is_interface_axis = .true.
elseif(axes%id .eq. diag_cs%axesCui%id ) then
is_interface_axis = .true.
elseif(axes%id .eq. diag_cs%axesCvi%id) then
is_interface_axis = .true.
endif
endif

end function is_interface_axis

! Allocate a new diagnostic id, it may be necessary to expand the diagnostics
! array.
function get_new_primary_diag_id(diag_cs)
Expand Down

0 comments on commit b1c6d1c

Please sign in to comment.