[Dart-dev] [4547] DART/trunk/ensemble_manager/ensemble_manager_mod.f90: Change a large array on the stack to one that is only allocated

nancy at ucar.edu nancy at ucar.edu
Fri Nov 5 14:59:39 MDT 2010


Revision: 4547
Author:   nancy
Date:     2010-11-05 14:59:39 -0600 (Fri, 05 Nov 2010)
Log Message:
-----------
Change a large array on the stack to one that is only allocated
on task 0 and only when it is actually going to be used.  This
three line change fixed a core dump a pop/dart user at lanl was
getting when filter was writing out the inflation restart file.

Modified Paths:
--------------
    DART/trunk/ensemble_manager/ensemble_manager_mod.f90

-------------- next part --------------
Modified: DART/trunk/ensemble_manager/ensemble_manager_mod.f90
===================================================================
--- DART/trunk/ensemble_manager/ensemble_manager_mod.f90	2010-11-01 20:26:36 UTC (rev 4546)
+++ DART/trunk/ensemble_manager/ensemble_manager_mod.f90	2010-11-05 20:59:39 UTC (rev 4547)
@@ -277,8 +277,7 @@
 logical, optional,    intent(in)    :: force_single_file
 
 ! Large temporary storage to be avoided if possible
-! LARGE ARRAY ON STACK -- make this a pointer and allocate it from heap?
-real(r8)                            :: ens(ens_handle%num_vars)
+real(r8), pointer                   :: ens(:)
 type(time_type)                     :: ens_time
 integer                             :: iunit, i, global_index
 integer                             :: owner, owners_index
@@ -300,8 +299,9 @@
    ! Single restart file is written only by the master_pe
    if(my_pe == 0) then
       iunit = open_restart_write(file_name)
-      
+
       ! Loop to write each ensemble member
+      allocate(ens(ens_handle%num_vars))   ! used to be on stack.
       do i = start_copy, end_copy
          ! Figure out where this ensemble member is being stored
          call get_copy_owner_index(i, owner, owners_index)
@@ -318,6 +318,7 @@
             call awrite_state_restart(ens_time, ens, iunit)
          endif
       end do
+      deallocate(ens)
       call close_restart(iunit)
    else
       ! If I'm not the master pe with a single restart, I must send my copies


More information about the Dart-dev mailing list