-
Notifications
You must be signed in to change notification settings - Fork 136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dm diag_yaml #866
Dm diag_yaml #866
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a discussion on renaming of region to sub-region. I see much of the code still uses the region nomenclature with a smattering of sub-region. For consistency sake we should refer to it all the same.
|
||
type sub_region_type | ||
character (len=:), allocatable :: grid_type !< Flag indicating the type of region, | ||
!!acceptable values are "latlon" and "index" | ||
real :: lat_lon_region (NUM_REGION_ARRAY) !< Bounds of the regional section to capture if in "latlon" mode | ||
integer :: index_region (NUM_REGION_ARRAY) !< Bounds of the regional section to capture if in "index" mode | ||
end type sub_region_type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the sub-regions, I want to ensure I understand the intent. This storage object will accommodate the use of four pairs of lat-lon values or i-j indexes. What I don't see is some way of constraining or limiting the vertical extent nor specifying the particular tile for the index option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I don't see is some way of constraining or limiting the vertical extent
I am not sure I understand what you mean. The *_region
arrays store the bounds for all four of the possible dimensions: [dim1_min, dim1_max, dim2_min, dim2_max, dim3_min, dim3_max, dim4_min, dim4_max].
specifying the particular tile for the index option.
Yes, I forgot to add the "tile". It will be a required key if using the "index" approach. This will be added in the next commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is where confusion comes in on how a sub-region is being defined. I know in the past we've always defined the sub-region to have sides of constant lat or lon. I saw the eight entries here and thought maybe we were expanding the capability to create somewhat irregular sub-regiosn denoted by either (i,j) or (lat,lon) for each fo the corners of the sub-region se, sw, ne, nw.
real :: lat_lon_region (NUM_REGION_ARRAY) !< Bounds of the regional section to capture if in "latlon" mode | ||
integer :: index_region (NUM_REGION_ARRAY) !< Bounds of the regional section to capture if in "index" mode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you extend the sub_region_type instead of using a flag?
type sub_region_type
end type
type, extends (sub_region_type) :: lat_lon_sub_region_type
real :: lat_lon_region (NUM_REGION_ARRAY) !< Bounds of the regional section to capture if in "latlon" mode
end type lat_lon_sub_region_type
type, extends (sub_region_type) :: index_sub_region_type
integer :: index_region (NUM_REGION_ARRAY) !< Bounds of the regional section to capture if in "index" mode
end type index_sub_region_type
Then your variables can be class (sub_region_type)
. I think this is better/faster/more extendable than reading a string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand. How will the code know which sub_region_type is inside in each diag_yaml%diag_files(:)
type?
diag_manager/fms_diag_yaml.F90
Outdated
do i = 1, size(diag_yaml%diag_files, 1) | ||
if(allocated(diag_yaml%diag_files(i)%file_global_meta)) deallocate(diag_yaml%diag_files(i)%file_global_meta) | ||
enddo | ||
if(allocated(diag_yaml%diag_files)) deallocate(diag_yaml%diag_files) | ||
|
||
do i = 1, size(diag_yaml%diag_fields, 1) | ||
if(allocated(diag_yaml%diag_fields(i)%var_attributes)) deallocate(diag_yaml%diag_fields(i)%var_attributes) | ||
enddo | ||
if(allocated(diag_yaml%diag_fields)) deallocate(diag_yaml%diag_fields) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like work that could be shared between 2 threads because one loop doesn't depend on the other.
…1,2,3,4 when setting the subregion, label do loops, removes hardcodded string lengths in types
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename the yaml file that is used for diagnostic input without "table" in the name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The type names need to follow the style guide https://github.com/NOAA-GFDL/FMS/blob/main/CODE_STYLE.md#derived-types
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3 things, and they're all in diag_manager/fms_diag_yaml_object.F90
- in
type subRegion_type
the arrays should be allocatable because this set up is wasting memory. You may be able to removegrid_type
if you are only allocating one of them. Alternatively, you could also use two types that extendtype subRegion_type
, They would be named something liketype subRegionIndicies_type
andtype subRegionLatLon_type
, and each would have the correct variable defined on the stack like how you have it now. - Line 81 should have a comment about why the character length is set and not allocatable. In the future, someone will look at this and change it to a
:
without any context for why it's set up like this. - Same as 2 but line 117.
real :: lat_lon_sub_region (NUM_SUB_REGION_ARRAY) !< Array that stores the grid point bounds for the sub region | ||
!! to use if grid_type is set to "latlon" | ||
!! [dim1_begin, dim1_end, dim2_begin, dim2_end, | ||
!! dim3_begin, dim3_end, dim4_begin, dim4_end] | ||
integer :: index_sub_region (NUM_SUB_REGION_ARRAY) !< Array that stores the index bounds for the sub region to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you need both of them. But they should be allocatable
, and only one should be allocated. Then you shouldn't need the grid_type
variable because only one will be allocated (unless the string is used downstream for some reason).
With this set up where they are both on the stack, you are just wasting memory.
class (diag_yaml_files_var_type), intent(in) :: diag_var_obj !< The object being inquiried | ||
character (len=:), allocatable :: res (:) !< What is returned | ||
class (diagYamlFilesVar_type), intent(in) :: diag_var_obj !< The object being inquiried | ||
character (len=MAX_STR_LEN), allocatable :: res (:,:) !< What is returned |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should add a comment about why len=MAX_STR_LEN and not : for someone else who will have to deal with this in the future.
Description
fms_diag_yaml_mod
,diag_yaml_object_init
which fills in the diag_yaml_obj anddiag_yaml_object_end
, which destroys the diag_yaml_obj. They are called in diag_manager_init and diag_manager_end respectively.fms_diag_yaml_mod
is hidden inside the -Duse_yaml macro because yaml_parser_mod won't compile without itFixes # (issue)
Still to do:
How Has This Been Tested?
make check
still passes with intel/gnumake check
passes with --with-yaml on skylake with intelChecklist:
make distcheck
passes