[J3] [EXTERNAL] Re: Clarification on F18/017
Clune, Thomas L. (GSFC-6101)
thomas.l.clune at nasa.gov
Tue Jun 9 10:46:03 EDT 2020
Neil,
Sorry that I missed that. The initial discussion of that example in the thread you cite was just talking about the order without referencing the more severe consequences. I skimmed past your subsequent elaboration there.
- Tom
On Jun 9, 2020, at 9:55 AM, Carlson, Neil via J3 <j3 at mailman.j3-fortran.org<mailto:j3 at mailman.j3-fortran.org>> wrote:
Thomas wrote:
> What is really needed to further the argument is a concrete example in which the undesired order will lead to a surprising (or incorrect) result _beyond_ merely the order being surprising. E.g., some handle to a non Fortran resource is obliterated before the resource is properly released.
Yes, that is exactly the case described at this link already mentioned several times in this thread: https://github.com/j3-fortran/fortran_proposals/issues/146#issuecomment-589857885<https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_j3-2Dfortran_fortran-5Fproposals_issues_146-23issuecomment-2D589857885&d=DwMFAw&c=ApwzowJNAKKw3xye91w7BE1XMRKi2LN9kiMk5Csz9Zk&r=EDCdNzkccJ25Co3sjWrr1HlJQ3_CoIFWfekFE1ulcLI&m=J6HN-gN36ZdmdqRbeK0F3jI7-7z4EqJ2W3Bc8X9Cd7o&s=hppxK1NHLH5S_Xo6-dnanvAIyuXKYBR-MWPV9vAPrus&e=>
But for clarity here is a code skeleton for the described case. Here amrex is a third party library written in C++ that provides a Fortran interface. It is a framework that must be started and stopped and its objects depend on that framework. The amrex-provided class amrex_obj is finalizable. Stopping the framework obliterates resources that its finalizer needs, and so it must be finalized before the framework is stopped.
module m
use amrex_module
type :: amrex_env
contains
final :: finalize_amrex_env
end type
type, extends(amrex_env) :: solver
class(amrex_obj), allocatable :: obj
contains
procedure :: init
end type
contains
subroutine finalize_amrex_env(this)
type(amrex_env), intent(inout) :: this
call amrex_finalize()
end subroutine
subroutine solver_init(this)
class(solver), intent(out) :: this
call amrex_init()
call amrex_alloc_obj(this%obj)
end subroutine
end module
program main
use m
call run
contains
subroutine run
type(solver) :: s
call s%init
end subroutine
end program
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20200609/6e00498f/attachment.htm>
More information about the J3
mailing list