Skip to content
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 get fns #885

Merged
merged 10 commits into from
Feb 7, 2022
Merged

Dm get fns #885

merged 10 commits into from
Feb 7, 2022

Conversation

thomas-robinson
Copy link
Member

@thomas-robinson thomas-robinson commented Jan 11, 2022

Description

  • Uses a class(*) variable for missing_value and data_RANGE
  • Fills in CMOR_MISSING_VALUE for missing_value if none is given
  • Adds rountines for fmsDiagObject_type

Fixes #884

How Has This Been Tested?
make with intel compilers

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules
  • New check tests, if applicable, are included
  • make distcheck passes

@thomas-robinson thomas-robinson changed the base branch from main to dmUpdate January 11, 2022 19:14
Copy link
Contributor

@ngs333 ngs333 left a comment

Choose a reason for hiding this comment

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

@thomas-robinson
I added several comments but you may first want to read the longer one for
function "get_metadata". If you want we can discuss these in a meeting, etc.

@@ -396,17 +422,323 @@ function diag_obj_is_static (obj) result (rslt)
rslt = obj%static
Copy link
Contributor

Choose a reason for hiding this comment

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

This whole function looks wierd to me. is member "static" and id ?
This mayneed a "!TODO:"

end function get_metadata
!> @brief Gets static
!! @return true if the variable is static
function get_static (obj) &
Copy link
Contributor

Choose a reason for hiding this comment

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

What you have works, but we should discuss if its a good idea to follow a convention that adds
a function ( doesn;t get rig of the get_satic, but adds another ) named is_static
It is used like

if (obj%is_static() ) then

In the end, waht you ahve passes the litmus test that these two statements be
equivalent (if static had been public)

 s = obj%static
s = obj%get_static()

(this is because staic is another intrisic (logical) like int, real etc.

end function get_static
!> @brief Gets regisetered
!! @return true if the object is registered
function get_registered (obj) &
Copy link
Contributor

Choose a reason for hiding this comment

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

See get_static comment. Do we want a user to have if (obj%is_registered() ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, we WANT the user to check if something is allocated or registered. What happens if they don't?

@@ -35,7 +35,7 @@ module fms_diag_object_mod
integer, allocatable, private :: diag_id !< unique id for varable
class(FmsNetcdfFile_t), dimension (:), pointer :: fileob => NULL() !< A pointer to all of the
!! file objects for this variable
character(len=:), allocatable, dimension(:) :: metadata !< metedata for the variable
character(len=:), allocatable, dimension(:) :: metadata !< metadata for the variable
logical, private :: static !< true is this is a static var
logical, allocatable, private :: registered !< true when registered
Copy link
Contributor

Choose a reason for hiding this comment

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

I think its less complex and more efficient if the intrinsic primitives (like logical, integer, real) are not allocatable
and have a default set in the type definiition. E.g. like this

logical, private    ::  registered => .false.

it would help to add functions like logical is_registered() (see comments below). Probably, type fms_dia_object
may nedd one or more initialize functions that the constructor calls.

Copy link
Member Author

Choose a reason for hiding this comment

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

There was a reason I did it this way, but I can't remember now. I think it was so that objects could be unregistered and without deallocating the object. Also, I think some of the optional variables were left allocatable so that someone could check if they were allocated first.

if (obj%allocated_metadata()) metadata = obj%get_metadata()

I actually just finished the allocated functions. We should still discuss.

!! @return the variable name
function get_varname (obj) &
result(rslt)
class (fmsDiagObject_type), intent(in) :: obj !< diag object
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess in this case the getter litterally returns the member field (seems to pass the litmus test). But I will read (or as) what exatly does the assignemnt (=) do. Hope we dont have to look at assemberr :-)

!> @brief Gets longname
!! @return the variable long name or a single string if there is no long name
function get_longname (obj) &
result(rslt)
Copy link
Contributor

Choose a reason for hiding this comment

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

And in this case we dont follow the litmus test with the else = " " statement. Too confusing to not follow one rule for such getters. BTW, One possibility is again with the default values in the type definition. Where
fields like longName is initialized (with =>) to "" or " " or some class or saystem default.

Copy link
Member Author

Choose a reason for hiding this comment

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

I added a varaible called diag_null_sring that is a parameter and has the value " ". This can be used in if statments

if (obj%get_longname() .ne. diag_null_string) longname = obj%get_longname()

procedure :: get_interp_method
procedure :: get_frequency
procedure :: get_output_units
procedure :: get_t
Copy link
Contributor

Choose a reason for hiding this comment

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

Wat is "t" ? Is this a good name? Are there comments somewhere?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it was something that was temporarily being used. It should probably get deleted.

Copy link
Member Author

Choose a reason for hiding this comment

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

I will remove it in a later PR.

@thomas-robinson thomas-robinson merged commit 08205c6 into NOAA-GFDL:dmUpdate Feb 7, 2022
@thomas-robinson thomas-robinson deleted the dmGetFns branch August 17, 2022 12:49
rem1776 pushed a commit to rem1776/FMS that referenced this pull request May 1, 2024
rem1776 pushed a commit to rem1776/FMS that referenced this pull request May 1, 2024
rem1776 pushed a commit to rem1776/FMS that referenced this pull request May 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adding get functions to the diag objects
3 participants