[Users] [Commits] [svn:einsteintoolkit] GRHydro/trunk/ (Rev. 301)

Erik Schnetter schnetter at cct.lsu.edu
Mon Nov 21 10:06:04 CST 2011


I may be overlooking something, but doesn't Fortran already keep track
of whether arrays are allocated? There is no need to introduce a
logical variable, one can call "allocated" instead.

Another point is that explicit memory management at shutdown isn't
really useful. It adds more code, adds complexity to keep track of
things, and delays the shutdown because extra things happen.

I would simply call "allocate" in ENOSetup, schedule the routine such
that it is called only once, and leave it at this, removing about 20
or 30 lines of code and the possibility of error.

-erik

On Mon, Nov 21, 2011 at 10:45 AM,  <roland.haas at physics.gatech.edu> wrote:
> User: rhaas
> Date: 2011/11/21 09:45 AM
>
> Modified:
>  /trunk/
>  schedule.ccl
>  /trunk/src/
>  GRHydro_ENOReconstruct.F90
>
> Log:
>  allocate/deallocate ENO scalars in global mode
>
>  really all I need is that this happens only once. Allocation was already
>  protected by a grid scalar, unfortunately deallocation did not check/reset
>  this scalar
>
> File Changes:
>
> Directory: /trunk/src/
> ======================
>
> File [modified]: GRHydro_ENOReconstruct.F90
> Delta lines: +5 -2
> ===================================================================
> --- trunk/src/GRHydro_ENOReconstruct.F90        2011-11-21 15:43:52 UTC (rev 300)
> +++ trunk/src/GRHydro_ENOReconstruct.F90        2011-11-21 15:45:12 UTC (rev 301)
> @@ -128,8 +128,11 @@
>
>   CCTK_INT :: deallocstat
>
> -  deallocate(eno_coeffs, STAT = deallocstat)
> -  if (deallocstat .ne. 0) call CCTK_WARN(0, "Failed to deallocate ENO coefficients.")
> +  if(coeffs_allocated) then
> +     deallocate(eno_coeffs, STAT = deallocstat)
> +     if (deallocstat .ne. 0) call CCTK_WARN(0, "Failed to deallocate ENO coefficients.")
> +     coeffs_allocated = .false.
> +  endif
>
>  end subroutine GRHydro_ENOShutdown
>
>
> Directory: /trunk/
> ==================
>
> File [modified]: schedule.ccl
> Delta lines: +2 -0
> ===================================================================
> --- trunk/schedule.ccl  2011-11-21 15:43:52 UTC (rev 300)
> +++ trunk/schedule.ccl  2011-11-21 15:45:12 UTC (rev 301)
> @@ -377,11 +377,13 @@
>
>   schedule GRHydro_ENOSetup AT CCTK_Basegrid
>   {
> +    OPTIONS: global
>     LANG:Fortran
>   } "Coefficients for ENO reconstruction"
>
>   schedule GRHydro_ENOShutdown AT CCTK_Terminate BEFORE Driver_Terminate
>   {
> +    OPTIONS: global
>     LANG:Fortran
>   } "Deallocate ENO coefficients"
>
>
> _______________________________________________
> Commits mailing list
> Commits at einsteintoolkit.org
> http://lists.einsteintoolkit.org/mailman/listinfo/commits
>



-- 
Erik Schnetter <schnetter at cct.lsu.edu>   http://www.cct.lsu.edu/~eschnett/


More information about the Users mailing list