-
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
Adding the fms_diag_object container. #867
Conversation
linked_list library, some changes to diag_manger to initialize the container and to use the container upon field registration, related Makefile.am changes.
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.
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 |
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.
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.
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 a unit test. Can you come up with a test or tests for this?
diag_manager/Makefile.am
Outdated
fms_diag_yaml_object.F90 | ||
fms_diag_yaml_object.F90 \ | ||
fms_diag_object_container.F90 \ | ||
fms_doubly_linked_list.F90 |
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 other comment about naming this module/file
diag_manager/diag_manager.F90
Outdated
@@ -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 |
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.
Delete this. No need to keep it around if it's not being used
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.
Done.
diag_manager/diag_manager.F90
Outdated
@@ -261,6 +263,8 @@ MODULE diag_manager_mod | |||
|
|||
type(time_type) :: Time_end | |||
|
|||
TYPE(fms_diag_object_container), ALLOCATABLE :: the_diag_object_container |
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 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
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 variable should be documented
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.
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" ?
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 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.
diag_manager/diag_manager.F90
Outdated
class(fms_diag_object), allocatable , target :: a_diag_obj | ||
type(fms_diag_object), pointer :: diag_obj_ptr |
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.
These variables should be documented
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 initial pointer should point to null
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.
done.
class(literator), intent(in) :: this | ||
class(*), pointer :: rd |
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.
Variables need to be documented in doxygen style
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.
done!
!! 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 |
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 function needs a doxygen description.
Variables need to be documented in doxygen style
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.
Done.
! 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! |
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 function needs a doxygen description.
Variables need to be documented in doxygen style
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.
Done
iter = this%remove(nd) | ||
pdata => iter%get() | ||
if (associated(pdata) .eqv. .false.) then | ||
print *, "clear all. pdata is not associated" |
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.
Use mpp_error or some other routine to print
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.
Done.
nd%data => d | ||
nd%prev => t_nd%prev | ||
nd%next => t_nd | ||
t_nd%prev%next => nd | ||
t_nd%prev => nd |
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 give some description of what's happening here?
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.
Done. Added explanation with diagrams.
on 12/7/01. Mostly documentation, logging, and type name improvements.
@thomas-robinson
|
@ngs333 |
…low convention and documentation.
@thomas-robinson |
@thomas-robinson , @uramirez |
@bensonr , @thomas-robinson , @uramirez8707 |
@thomas-robinson , @uramirez8707 , @GFDL-Eric 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. |
compile on Intel.
…eral in several types. Improved several comments.
.vscode/launch.json
Outdated
@@ -0,0 +1,27 @@ | |||
{ |
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 didn't mean to commit this file.
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.
@uramirez8707
Done. Thanks.
We shoudl consider putting a good one in.
.vscode/tasks.json
Outdated
@@ -0,0 +1,39 @@ | |||
{ |
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 didn't mean to commit this file.
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.
Done. Thanks.
We shoudl consider putting a good one in.
@thomas-robinson , @uramirez8707 |
!! Create a diag object, initialize it with the registered data, and insert | ||
!! it ino the diag_obj_container singleton. | ||
|
||
allocate( diag_obj ) |
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 deallocated?
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.
Contents of the container are deallocated by the container.
Either by the container destructor or the user calling the clear() function.
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 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.
diag_manager/diag_manager.F90
Outdated
endif | ||
|
||
!! *** ERROR MISSING ENDIF ??? *** endif |
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 is this comment about?
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.
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. |
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 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 |
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 to be corrected
@ngs333 You have some unchecked boxes at the top.
Are you generating new warnings with this code? And are the new tests passing? All of the boxes should be checked. |
@thomas-robinson I think I made the requested changes. I also pulled and merged the upstream branch into mine. |
diag_manager/fms_diag_object.F90
Outdated
@@ -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 | |||
! |
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 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.
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.
Done.
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:
make distcheck
passes