Replies: 1 comment
-
|
Here's an example of using finalize from John Dennis. This is where the compiler will remember to call the final method for you, which can make deallocating memory happen automatically. type :: Coords1D
…
procedure :: finalize ! User-callable
final :: finalize_Coords1D ! Auto-finalize
end type Coords1D
subroutine finalize(this)
class(Coords1D), intent(inout) :: this
call finalize_Coords1D(this)
end subroutine finalize
! Deallocate and reset to initial state.
subroutine finalize_Coords1D(this)
type(Coords1D) :: this
this%n = 0; this%d = 0
…
if(allocated(this%rdst)) deallocate(this%rdst)
end subroutine finalize_Coords1D |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I learned about this in some of the conferences I've been to (US-RSE, SEA ISS) as well as working with John D. in CISL. There are a lot of useful Fortran features that we should start taking advantage of, that will help us get better, more robust code for CTSM.
For example here are some keywords to start using more:
For functions and subroutines:
Data in OO types:
Beta Was this translation helpful? Give feedback.
All reactions