-
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
diag_axis io #982
diag_axis io #982
Conversation
@@ -85,6 +87,7 @@ module fms_diag_axis_object_mod | |||
CHARACTER(len=:), ALLOCATABLE, private :: long_name !< Long_name attribute of the axis | |||
CHARACTER(len=1) , private :: cart_name !< Cartesian name "X", "Y", "Z", "T", "U", "N" | |||
CLASS(*), ALLOCATABLE, private :: axis_data(:) !< Data of the axis | |||
CHARACTER(len=:), ALLOCATABLE, private :: data_type !< The type of the axis_data |
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.
Is this real4, real8, integer4, etc? You should put the possible values.
I also think you should rename it to type_of_data
because _type
is for type definitions.
@@ -99,17 +102,17 @@ module fms_diag_axis_object_mod | |||
TYPE(diag_atttype),allocatable , private :: attributes(:) !< Array to hold user definable attributes | |||
INTEGER , private :: num_attributes !< Number of defined attibutes | |||
INTEGER , private :: domain_position !< The position in the doman (NORTH, EAST or CENTER) | |||
INTEGER , private :: fileobj_type !< The fileobj to use for variables in this axis |
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 mention the possible values here in the comments.
Also, shouldn't this be named file_domain
or axis_domain
? This is telling you information about the domain. You aren't getting any information about the file object here, and the axis shouldn't have any information about the file. I understand this information is needed for the file object, but that should be handled at a file level, not at the axis level.
I don't think it's a good idea to add _type
to the end of a variable because the style guide reserves that suffix for type definitions.
@@ -154,14 +157,17 @@ subroutine register_diag_axis_obj(obj, axis_name, axis_data, units, cart_name, l | |||
type is (real(kind=r8_kind)) | |||
allocate(real(kind=r8_kind) :: obj%axis_data(size(axis_data))) | |||
obj%axis_data = axis_data | |||
obj%data_type = "double" !< This is what fms2_io expects in the register_field call |
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.
My favorite part about this is that you had to put this comment in because you knew I would see it and comment about using "double" instead of something like "real_kind8". There was a very loud sigh.
call register_variable_attribute(fileobj, axis_name, "units", obj%units, str_len=len_trim(obj%units)) | ||
|
||
select case (obj%direction) | ||
case (-1) |
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 needs to be a parameterized integer
select case (obj%direction) | ||
case (-1) | ||
call register_variable_attribute(fileobj, axis_name, "positive", "up", str_len=2) | ||
case (1) |
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 needs to be a parameterized integer
class(FmsNetcdfFile_t), INTENT(INOUT) :: fileobj !< Fms2_io fileobj to write the data to | ||
integer, OPTIONAL, INTENT(IN) :: sub_axis_id !< ID of the sub_axis, if it exists | ||
|
||
character(len=:), ALLOCATABLE :: axis_name !< Name of the axis |
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.
See comment below. Remove.
end subroutine write_axis_metadata | ||
|
||
!> @brief Write the axis data to an open fileobj | ||
subroutine write_axis_data(obj, fileobj, sub_axis_id) |
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 also needs a routine to call it from the file object level.
!< If they are different domains, one of them can be NO_DOMAIN | ||
!! i.e a variable can have axis that are domain decomposed (x,y) and an axis that isn't (z) | ||
if (fileobj_type .eq. NO_DOMAIN .or. axis_obj(j)%fileobj_type .eq. NO_DOMAIN ) then | ||
!< Update the filobj_type and domain, if needed |
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.
typo: fileobj
!! and return the domain | ||
subroutine determine_the_fileobj_type(axis_id, fileobj_type, domain, var_name) | ||
integer, INTENT(IN) :: axis_id(:) !< Array of axis ids | ||
integer, INTENT(OUT) :: fileobj_type !< fileobj_type to use |
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 another case of the _type
suffix on a variable that should be avoided.
|
||
!> @brief Loop through a variable's axis_id to determine and set the fms2_io filobj type to use | ||
!! and return the domain | ||
subroutine determine_the_fileobj_type(axis_id, fileobj_type, domain, var_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.
Where is this being called?
Why is domain
a pointer? I'm not 100% sure it's thread safe because of the pointer (I think it is thread safe, but I am just not totally positive).
The description says "to determine and set the fms2_io filobj type to use" but it uses axis_obj(j)%fileobj_type
which is already set. So nothing is being set here.
This doesn't return a fileobj type; it returns an integer. If it didn't have the domain pointer as an intent (out)
argument, this could be a pure integer function instead of a subroutine.
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.
Where is this being called?
This is going to be called in register_diag_field
, the field has an array of axis ids, this function is going to return the domain and the "fileobj_type" (the type of fms2_io fileobj the variable needs). This then has to be passed on to the diag_files. so we can know what fms2_io obj to open and we have the domain to open the file with.
I think I should rename "fileobj_type" to "type_of_domain"
Why is domain a pointer? I'm not 100% sure it's thread safe because of the pointer (I think it is thread safe, but I am just not totally positive).
This is going to be called the init, so there is no openmp(?). If it is not a pointer, then it has to be a copy ...
The description says "to determine and set the fms2_io filobj type to use" but it uses axis_obj(j)%fileobj_type which is already set. So nothing is being set here.
what if it says "to determine and return the domain and domain_type to use"
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.
OK, so what happens to this domain pointer? Is the domain pointer you pass in part of the diag_object? I think if you had the actual call to this routine somewhere (even commented out for now), it would be more helpful for me to understand it.
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 the domain_pointer is part of the diag_object
This is part of the next steps
f395714
I think we finally have all pieces for register_diag_field to be completely done.
@thomas-robinson I think all your comments have been addressed. |
@@ -384,6 +484,38 @@ subroutine check_if_valid_edges(edges) | |||
call mpp_error(FATAL, "diag_axit_init: The edge axis has not been defined. "& | |||
"Call diag_axis_init for the edge axis first") | |||
end subroutine check_if_valid_edges | |||
|
|||
!> @brief Loop through a variable's axis_id to determine and return the domain type and domain to use |
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 still think this description is lacking. The \brief describes what this subroutine does, but there is no explanation for it's use. I think with the next update, you should have a \description instead of \brief that explains why you use this. In the larger plan, this routine is necessary. If you're just looking at this module, you will scratch your head and wonder why this exists.
* Add the io procedures for the axis * add sub_axis info to the write_axis_metadata and write_data
* Add the io procedures for the axis * add sub_axis info to the write_axis_metadata and write_data
Description
Adds procedure to the axis_object that write the axis metadata and the axis data.
Adds a subroutine to determine the fms2_io fileobj to use
Fixes # (issue)
How Has This Been Tested?
CI
Checklist:
make distcheck
passes