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

Adding the fms_diag_object container. #867

Merged
merged 32 commits into from
Jan 4, 2022

Conversation

ngs333
Copy link
Contributor

@ngs333 ngs333 commented Dec 6, 2021

Description

This PR is for the initial commit of the fms_diag_object_container. Includes the underlying linked_list library,
some changes to diag_manger to initialize the container and to use the container upon field registration, and related Makefile.am changes.

Note that the project had decided on 11/29 that the singleton diag_object_container would be placed in the
diag_data module. This was not possible because it introduced circular dependecies between the
diag_data and diag_object modules, and so the singleton was placed in the diag_manager module.

Fixes # (issue)
This is in support of the new diag manager.

How Has This Been Tested?
The code was build with gcc 9.3. "make check" passes the same number if tests (31/33) with as
without this item. Tests for the new functionality is a TBD.

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

linked_list library, some changes to diag_manger to initialize the container
and to use the container upon field registration, related Makefile.am changes.
Copy link
Member

@thomas-robinson thomas-robinson left a comment

Choose a reason for hiding this comment

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

Please add some tests to the code and address the comments I've made.

!! \description A double linked list module that is rougly a fortran translation of the C++
!! boubly linked list from the book ``Data Structures And Algorithm Analysis in C++", 3rd Edition,
!! by Mark Allen Weiss
module fms_doubly_linked_list_mod
Copy link
Member

Choose a reason for hiding this comment

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

If this is specific for the diag manager, then it should be named fms_diag_doubly_linked_list_mod. If you expect that it could be used more generally, then you should create a new folder in FMS with it's own Makefile.

Copy link
Member

Choose a reason for hiding this comment

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

This needs a unit test. Can you come up with a test or tests for this?

fms_diag_yaml_object.F90
fms_diag_yaml_object.F90 \
fms_diag_object_container.F90 \
fms_doubly_linked_list.F90
Copy link
Member

Choose a reason for hiding this comment

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

See other comment about naming this module/file

@@ -223,9 +223,11 @@ MODULE diag_manager_mod
& use_mpp_io, use_modern_diag
USE diag_data_mod, ONLY: fileobj, fileobjU, fnum_for_domain, fileobjND
USE diag_table_mod, ONLY: parse_diag_table
!!USE diag_data_mod, ONLY : the_diag_object_container
Copy link
Member

Choose a reason for hiding this comment

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

Delete this. No need to keep it around if it's not being used

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -261,6 +263,8 @@ MODULE diag_manager_mod

type(time_type) :: Time_end

TYPE(fms_diag_object_container), ALLOCATABLE :: the_diag_object_container
Copy link
Member

Choose a reason for hiding this comment

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

The naming conventions for FMS have this line as

TYPE(fms_diag_object_container_type), ALLOCATABLE :: diag_object_container

Where the type has _type at the end

Copy link
Member

Choose a reason for hiding this comment

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

This variable should be documented

Copy link
Contributor Author

@ngs333 ngs333 Dec 7, 2021

Choose a reason for hiding this comment

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

Refactored in VS Code to added the _type.
There are some classes that are are missing the "_type", or are following another convention.
Let me know if you want to refactor those also.
BTW, is it possible to use just "_t" and not "_type" ?

Copy link
Member

Choose a reason for hiding this comment

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

I just reread the style guide: https://github.com/NOAA-GFDL/FMS/blob/main/CODE_STYLE.md#derived-types . It looks like we all have some updating to do. Pretty much everything needs to be updated, although I will bring this up at the FMS code meeting next week.

Comment on lines 433 to 434
class(fms_diag_object), allocatable , target :: a_diag_obj
type(fms_diag_object), pointer :: diag_obj_ptr
Copy link
Member

Choose a reason for hiding this comment

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

These variables should be documented

Copy link
Member

Choose a reason for hiding this comment

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

The initial pointer should point to null

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

Comment on lines 235 to 236
class(literator), intent(in) :: this
class(*), pointer :: rd
Copy link
Member

Choose a reason for hiding this comment

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

Variables need to be documented in doxygen style

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done!

Comment on lines 242 to 248
!! Iterate over all the nodes, remove them and deallocate the client data
!! that the node was holding.
subroutine clear_all( this )
class(linked_list), intent(inout) :: this
class(node), pointer :: nd
class(literator), allocatable :: iter
class(*), pointer :: pdata
Copy link
Member

Choose a reason for hiding this comment

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

The function needs a doxygen description.
Variables need to be documented in doxygen style

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Comment on lines 262 to 264
! A destructor that deallocates every node and each nodes data element.
subroutine destructor(this)
type(linked_list ) :: this !Note for destructors its needs to be type and not class!
Copy link
Member

Choose a reason for hiding this comment

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

The function needs a doxygen description.
Variables need to be documented in doxygen style

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

iter = this%remove(nd)
pdata => iter%get()
if (associated(pdata) .eqv. .false.) then
print *, "clear all. pdata is not associated"
Copy link
Member

Choose a reason for hiding this comment

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

Use mpp_error or some other routine to print

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Comment on lines 74 to 78
nd%data => d
nd%prev => t_nd%prev
nd%next => t_nd
t_nd%prev%next => nd
t_nd%prev => nd
Copy link
Member

Choose a reason for hiding this comment

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

Can you give some description of what's happening here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Added explanation with diagrams.

on  12/7/01. Mostly documentation, logging, and type name improvements.
@ngs333
Copy link
Contributor Author

ngs333 commented Dec 8, 2021

@thomas-robinson
Thanks for the great review. I made the changes relating to comments, type names, and error
logging. Some work still todo:

  • I still havent decided on where to put the fms_doubly_linked_list.
  • I have unit tests
    in the old diag_manager2 prototype project and will move them over soon.
  • Not sure about the interface issue you raise in ( Adding the fms_diag_object container. #867 (comment) ) . Will investigate later.

@ngs333
Copy link
Contributor Author

ngs333 commented Dec 8, 2021

@ngs333
TODO: investigate fortran class access controls. Only end client interfaces public?

@ngs333
Copy link
Contributor Author

ngs333 commented Dec 9, 2021

@thomas-robinson
The unit test was added.

@ngs333
Copy link
Contributor Author

ngs333 commented Dec 9, 2021

@thomas-robinson , @uramirez
Just finished cleaning up the unit test for the diag object container.

@ngs333
Copy link
Contributor Author

ngs333 commented Dec 9, 2021

@bensonr , @thomas-robinson , @uramirez8707
FYI : I had to change the unfinished/prototype function is_filed_type_null() in file fms_diag_yaml.F90.
This is because the way it was prototyped (always returning .false.) would not allow the creation of a diag object
with a non-zero ID. Diag objects with varying ids are needed to test. BTW, I added a "TODO:" in front of the prototype funciton.

@ngs333
Copy link
Contributor Author

ngs333 commented Dec 13, 2021

@thomas-robinson , @uramirez8707 , @GFDL-Eric
I just did another update, hopefully the last before merge. I builds with cmake and gnu tools.
The parser and yaml related files were added to the CMakeList.txt.

There is a unit test for fms_diag_object_container but not for fms_diag_dlinked_list - the former is is wrapper over the latter and everythig is tested as is.

FInally I did not change the constructors as per the review. I hope this can be delaed until we establish a convention.

@@ -0,0 +1,27 @@
{
Copy link
Contributor

@uramirez8707 uramirez8707 Dec 21, 2021

Choose a reason for hiding this comment

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

I think you didn't mean to commit this file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@uramirez8707
Done. Thanks.
We shoudl consider putting a good one in.

@@ -0,0 +1,39 @@
{
Copy link
Contributor

@uramirez8707 uramirez8707 Dec 21, 2021

Choose a reason for hiding this comment

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

I think you didn't mean to commit this file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Thanks.
We shoudl consider putting a good one in.

@ngs333
Copy link
Contributor Author

ngs333 commented Dec 21, 2021

@thomas-robinson , @uramirez8707
In the last half hour I pushed a large update. Includes a test for the linked list,
improvments or additions ot/of many comments, and some minor code cleanup.

!! Create a diag object, initialize it with the registered data, and insert
!! it ino the diag_obj_container singleton.

allocate( diag_obj )
Copy link
Contributor

Choose a reason for hiding this comment

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

Where is this deallocated?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Contents of the container are deallocated by the container.
Either by the container destructor or the user calling the clear() function.

Copy link
Member

@thomas-robinson thomas-robinson left a comment

Choose a reason for hiding this comment

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

There is a comment handing about an endif on line 614 of diag_manager.F90 that should be deleted I think?
In fms_diag_object_container.F90, line 59 and 73 have a !! when I think it shoul be a !<. Please fix these.

endif

!! *** ERROR MISSING ENDIF ??? *** endif
Copy link
Member

Choose a reason for hiding this comment

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

What is this comment about?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Its a bad comment. Deleted.

!! This version does not enforce uniqueness of ID keys (I.e. it is not a set).
!!
type, public:: FmsDiagObjectContainer_t
TYPE (FmsDlList_t), ALLOCATABLE :: the_linked_list !!This version based on the FDS linked_list.
Copy link
Member

Choose a reason for hiding this comment

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

This still need to be corrected


!> \brief Iterator used to traverse the objects of the container.
type, public :: FmsDiagObjIterator_t
type(FmsDllIterator_t) :: liter !!this version based on the FDS linked_list
Copy link
Member

Choose a reason for hiding this comment

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

This also needs to be corrected

@thomas-robinson
Copy link
Member

@ngs333 You have some unchecked boxes at the top.

  • 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

Are you generating new warnings with this code? And are the new tests passing? All of the boxes should be checked.

@ngs333
Copy link
Contributor Author

ngs333 commented Jan 4, 2022

@thomas-robinson I think I made the requested changes. I also pulled and merged the upstream branch into mine.

diag_manager/fms_diag_dlinked_list.F90 Show resolved Hide resolved
@@ -158,6 +159,7 @@ subroutine diag_obj_init(ob)
end subroutine diag_obj_init
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!> \description Fills in and allocates (when necessary) the values in the diagnostic object
!
Copy link
Contributor

Choose a reason for hiding this comment

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

This added line should be removed, since it's only 1 ! doxygen won't read the line and it probably won't match the description to the routine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@thomas-robinson thomas-robinson merged commit 60c5e12 into NOAA-GFDL:dmUpdate Jan 4, 2022
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.

5 participants