-
I've noticed that a few types have public procedures named As an example, here's the one from type, public :: topo_type
...
contains
...
procedure, public :: Clean
...
end type topo_type
...
subroutine Clean(this)
! !ARGUMENTS:
class(topo_type), intent(inout) :: this
!
! !LOCAL VARIABLES:
character(len=*), parameter :: subname = 'Clean'
!-----------------------------------------------------------------------
deallocate(this%topo_col)
deallocate(this%needs_downscaling_col)
end subroutine Clean |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Maybe from , for example, this: main/test/topo_test/test_topo.pf: call this%topo%Clean() |
Beta Was this translation helpful? Give feedback.
-
What @olyson is pointing out is that sometimes we don't use the Clean in the main code, because we don't free memory until the program is finished. So we don't always explicitly call a Clean on everything created. But, the Clean is used in some unit-testers where you do want to clean memory for these objects. We do have a finalize routine used for CTSM, but in practice there isn't much there. But, we should be calling all the Cleans for objects like this. |
Beta Was this translation helpful? Give feedback.
-
Ah yes, sorry, this is what I get for posting this the day after my deep dive. I did see they're called in unit tests, thanks for reminding me @olyson. I was wondering why they're only called there. @ekluzek, that reasoning makes sense—if objects are in scope until the program ends, there's no need for a separate finalizer. Thanks! |
Beta Was this translation helpful? Give feedback.
What @olyson is pointing out is that sometimes we don't use the Clean in the main code, because we don't free memory until the program is finished. So we don't always explicitly call a Clean on everything created. But, the Clean is used in some unit-testers where you do want to clean memory for these objects.
We do have a finalize routine used for CTSM, but in practice there isn't much there. But, we should be calling all the Cleans for objects like this.