Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion diag_manager/fms_diag_axis_object.F90
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ module fms_diag_axis_object_mod
INTEGER , private :: direction !< Direction of the axis 0, 1, -1
CHARACTER(len=:), ALLOCATABLE, private :: edges_name !< Name for the previously defined "edges axis"
!! This will be written as an attribute
CHARACTER(len=128) , private :: aux !< Auxiliary name, can only be <TT>geolon_t</TT>
CHARACTER(len=:), ALLOCATABLE, private :: aux !< Auxiliary name, can only be <TT>geolon_t</TT>
!! or <TT>geolat_t</TT>
CHARACTER(len=128) , private :: req !< Required field names.
INTEGER , private :: tile_count !< The number of tiles
Expand All @@ -174,6 +174,8 @@ module fms_diag_axis_object_mod
PROCEDURE :: get_compute_domain
PROCEDURE :: get_indices
PROCEDURE :: get_global_io_domain
PROCEDURE :: get_aux
PROCEDURE :: has_aux
! TO DO:
! Get/has/is subroutines as needed
END TYPE fmsDiagFullAxis_type
Expand Down Expand Up @@ -560,6 +562,28 @@ function get_axis_length(this) &

end function


!> @brief Determine if an axis object has an auxiliary name
!! @return .true. if an axis object has an auxiliary name
pure function has_aux(this) &
result(rslt)
class(fmsDiagFullAxis_type), intent(in) :: this !< diag_axis obj
logical :: rslt

rslt = .false.
if (allocated(this%aux)) rslt = trim(this%aux) .ne. ""
end function has_aux

!> @brief Get the auxiliary name of an axis object
!! @return the auxiliary name of an axis object
pure function get_aux(this) &
result(rslt)
class(fmsDiagFullAxis_type), intent(in) :: this !< diag_axis obj
character(len=:), allocatable :: rslt

rslt = this%aux
end function get_aux

!> @brief Set the axis_id
subroutine set_axis_id(this, axis_id)
class(fmsDiagFullAxis_type), intent(inout) :: this !< diag_axis obj
Expand Down
41 changes: 41 additions & 0 deletions diag_manager/fms_diag_field_object.F90
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ module fms_diag_field_object_mod
procedure :: get_var_skind
procedure :: get_longname_to_write
procedure :: write_field_metadata
procedure :: write_coordinate_attribute
procedure :: get_math_needs_to_be_done
end type fmsDiagField_type
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! variables !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Expand Down Expand Up @@ -1141,7 +1142,47 @@ subroutine write_field_metadata(this, fileobj, file_id, yaml_id, diag_axis, unli
call register_variable_attribute(fileobj, var_name, "cell_methods", &
trim(adjustl(cell_measures)), str_len=len_trim(adjustl(cell_measures)))

!< Write out the standard_name (this was defined in the register call)
if (this%has_standname()) &
call register_variable_attribute(fileobj, var_name, "standard_name", &
trim(this%get_standname()), str_len=len_trim(this%get_standname()))

call this%write_coordinate_attribute(fileobj, var_name, diag_axis)
end subroutine write_field_metadata

!> @brief Writes the coordinate attribute of a field if any of the field's axis has an
!! auxiliary axis
subroutine write_coordinate_attribute (this, fileobj, var_name, diag_axis)
CLASS(fmsDiagField_type), intent(in) :: this !< The field object
class(FmsNetcdfFile_t), INTENT(INOUT) :: fileobj !< Fms2_io fileobj to write to
character(len=*), intent(in) :: var_name !< Variable name
class(fmsDiagAxisContainer_type), intent(in) :: diag_axis(:) !< Diag_axis object

integer :: i !< For do loops
character(len = 252) :: aux_coord !< Auxuliary axis name

!> If the variable is a scalar, go away
if (.not. allocated(this%axis_ids)) return

!> Determine if any of the field's axis has an auxiliary axis and the
!! axis_names as a variable attribute
aux_coord = ""
do i = 1, size(this%axis_ids)
select type (obj => diag_axis(this%axis_ids(i))%axis)
type is (fmsDiagFullAxis_type)
if (obj%has_aux()) then
aux_coord = trim(aux_coord)//" "//obj%get_aux()
endif
end select
enddo

if (trim(aux_coord) .eq. "") return

call register_variable_attribute(fileobj, var_name, "coordinates", &
trim(adjustl(aux_coord)), str_len=len_trim(adjustl(aux_coord)))

end subroutine write_coordinate_attribute

!> @brief Gets a fields data buffer
!! @return a pointer to the data buffer
function get_data_buffer (this) &
Expand Down
2 changes: 1 addition & 1 deletion diag_manager/fms_diag_time_utils.F90
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ END FUNCTION diag_forecast_time_inc
!! This string is used as suffix in output file name
!! @return Character(len=128) get_time_string
CHARACTER(len=128) FUNCTION get_time_string(filename, current_time)
CHARACTER(len=128), INTENT(in) :: filename !< File name.
CHARACTER(len=*), INTENT(in) :: filename !< File name.
TYPE(time_type), INTENT(in) :: current_time !< Current model time.

INTEGER :: yr1 !< get from current time
Expand Down
8 changes: 6 additions & 2 deletions diag_manager/fms_diag_yaml.F90
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ module fms_diag_yaml_mod
use, intrinsic :: iso_c_binding, only : c_ptr, c_null_char
use fms_string_utils_mod, only: fms_array_to_pointer, fms_find_my_string, fms_sort_this, fms_find_unique
use platform_mod, only: r4_kind, i4_kind
use fms_mod, only: lowercase

implicit none

Expand Down Expand Up @@ -413,7 +414,8 @@ subroutine diag_yaml_object_init(diag_subset_output)
call fill_in_diag_files(diag_yaml_id, diag_file_ids(i), diag_yaml%diag_files(file_count))

!> Save the file name in the file_list
file_list%file_name(file_count) = trim(diag_yaml%diag_files(file_count)%file_fname)//c_null_char
!! The diag_table is not case sensitive (so we are saving it as lowercase)
file_list%file_name(file_count) = lowercase(trim(diag_yaml%diag_files(file_count)%file_fname)//c_null_char)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would we impose this? Why can't users have capital letters in the file names?

file_list%diag_file_indices(file_count) = file_count

nvars = 0
Expand Down Expand Up @@ -441,6 +443,8 @@ subroutine diag_yaml_object_init(diag_subset_output)
!> Save the variable name and the module name in the variable_list
variable_list%var_name(var_count) = trim(diag_yaml%diag_fields(var_count)%var_varname)//&
":"//trim(diag_yaml%diag_fields(var_count)%var_module)//c_null_char
!! The diag_table is not case sensitive (so we are saving it as lowercase)
variable_list%var_name(var_count) = lowercase(variable_list%var_name(var_count))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why can't users have a capital letter for the var name? I always think of temperature as T and time as t

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They can have capital letters.

This is for when we are searching for the variable name in the diag_table.yaml. The old diag manager was not case sensitive. So in the register_diag_field call the variable name could be "Temperature", and in the diag_table.yaml "TEMPERATURE" or whatever. Without this the code won't be able to find the variable because "Temperature" != "TEMPERATURE"

The variable_list is the sorted list of variables, in the diag_yaml it saved at whatever is in the diag_table.yaml

variable_list%diag_field_indices(var_count) = var_count
enddo nvars_loop
deallocate(var_ids)
Expand Down Expand Up @@ -1434,7 +1438,7 @@ function find_diag_field(diag_field_name, module_name) &
integer, allocatable :: indices(:)

indices = fms_find_my_string(variable_list%var_pointer, size(variable_list%var_pointer), &
& trim(diag_field_name)//":"//trim(module_name)//c_null_char)
& lowercase(trim(diag_field_name))//":"//lowercase(trim(module_name)//c_null_char))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one I actually agree with because the actual modules are all lower case (i think)

end function find_diag_field

!> @brief Gets the diag_field entries corresponding to the indices of the sorted variable_list
Expand Down