~abenson/galacticus/v0.9.0

« back to all changes in this revision

Viewing changes to source/galacticus.output.merger_tree.F90

  • Committer: Andrew Benson
  • Date: 2012-06-21 20:13:57 UTC
  • Revision ID: abenson@obs.carnegiescience.edu-20120621201357-xqpn07j03u6zxu4u
* Fix bug in closing Output groups in HDF5 file (previously could
  attempt to close groups that were never opened, resulting in
  segfaults).

Show diffs side-by-side

added added

removed removed

Lines of Context:
257
257
    if (present(isLastOutput)) then
258
258
       if (isLastOutput) then
259
259
          ! Close any open output groups.
260
 
          do iGroup=1,size(outputGroups)
261
 
             if (outputGroups(iGroup)%nodeDataGroup%isOpen()) call outputGroups(iGroup)%nodeDataGroup%close()
262
 
             if (outputGroups(iGroup)%hdf5Group    %isOpen()) call outputGroups(iGroup)%hdf5Group    %close()
 
260
          do iGroup=1,outputGroupsCount
 
261
             if (outputGroups(iGroup)%opened) then
 
262
                if (outputGroups(iGroup)%nodeDataGroup%isOpen()) call outputGroups(iGroup)%nodeDataGroup%close()
 
263
                if (outputGroups(iGroup)%hdf5Group    %isOpen()) call outputGroups(iGroup)%hdf5Group    %close()
 
264
             end if
263
265
          end do
264
266
          if (outputsGroup%isOpen()) call outputsGroup%close()
265
267
          ! Close the file.
275
277
    integer :: iGroup
276
278
    
277
279
    ! Close any open output groups.
278
 
    do iGroup=1,size(outputGroups)
279
 
       if (outputGroups(iGroup)%nodeDataGroup%isOpen()) call outputGroups(iGroup)%nodeDataGroup%close()
280
 
       if (outputGroups(iGroup)%hdf5Group    %isOpen()) call outputGroups(iGroup)%hdf5Group    %close()
 
280
    !$omp critical(HDF5_Access)
 
281
    do iGroup=1,outputGroupsCount
 
282
       if (outputGroups(iGroup)%opened) then
 
283
          if (outputGroups(iGroup)%nodeDataGroup%isOpen()) call outputGroups(iGroup)%nodeDataGroup%close()
 
284
          if (outputGroups(iGroup)%hdf5Group    %isOpen()) call outputGroups(iGroup)%hdf5Group    %close()
 
285
       end if
281
286
    end do
282
287
    if (outputsGroup%isOpen()) call outputsGroup%close()
 
288
    !$omp end critical(HDF5_Access)
283
289
    return
284
290
  end subroutine Galacticus_Merger_Tree_Output_Finalize
285
291