[Dart-dev] DART/branches Revision: 10800

dart at ucar.edu dart at ucar.edu
Thu Dec 15 16:12:12 MST 2016


hendric at ucar.edu
2016-12-15 16:12:12 -0700 (Thu, 15 Dec 2016)
266
need to assert that you have a valid copy number before 
accessing the file_info metadata.  this is essential for
writting with multiple processors since the copy loop 
has situations where the queried copy can be greater than
the number of copies in the ensemble.




Modified: DART/branches/rma_fixed_filenames/io/copies_on_off_mod.f90
===================================================================
--- DART/branches/rma_fixed_filenames/io/copies_on_off_mod.f90	2016-12-15 22:47:24 UTC (rev 10799)
+++ DART/branches/rma_fixed_filenames/io/copies_on_off_mod.f90	2016-12-15 23:12:12 UTC (rev 10800)
@@ -82,6 +82,9 @@
 logical :: query_read_copy
 
 query_read_copy = .false.
+
+if (.not. assert_valid_copy(name_handle, c)) return
+
 if (name_handle%io_flag(c) == READ_COPY .or. name_handle%io_flag(c) == READ_WRITE_COPY) then
    query_read_copy = .true.
 endif
@@ -100,6 +103,9 @@
 logical :: query_write_copy
 
 query_write_copy = .false.
+
+if (.not. assert_valid_copy(name_handle, c)) return
+
 if (name_handle%io_flag(c) == WRITE_COPY .or. name_handle%io_flag(c) == READ_WRITE_COPY) then
    query_write_copy = .true.
 endif
@@ -115,6 +121,8 @@
 type(stage_metadata_type), intent(inout) :: name_handle !< stage name handle
 integer,                   intent(in) :: c           !< copy number
 
+if (.not. assert_valid_copy(name_handle, c)) return
+
 name_handle%io_flag(c) = READ_COPY
 
 end subroutine turn_read_copy_on_single
@@ -128,6 +136,8 @@
 type(stage_metadata_type), intent(inout) :: name_handle !< stage name handle
 integer,                   intent(in) :: c           !< copy number
 
+if (.not. assert_valid_copy(name_handle, c)) return
+
 name_handle%io_flag(c) = WRITE_COPY
 
 end subroutine turn_write_copy_on_single
@@ -166,6 +176,9 @@
 
 integer :: i
 
+if (.not. assert_valid_copy(name_handle, c1)) return
+if (.not. assert_valid_copy(name_handle, c2)) return
+
 do i = c1, c2
   name_handle%io_flag(i) = WRITE_COPY 
 enddo
@@ -202,6 +215,9 @@
 
 integer :: i
 
+if (.not. assert_valid_copy(name_handle, c1)) return
+if (.not. assert_valid_copy(name_handle, c2)) return
+
 do i = c1, c2
   name_handle%io_flag(i) = NO_IO 
 enddo
@@ -230,7 +246,7 @@
 integer, intent(in) :: copy
 logical :: query_copy_present
 
-if (copy == COPY_NOT_PRESENT) then
+if (copy == COPY_NOT_PRESENT .and. copy <= 0 ) then
    query_copy_present = .false.
 else
    query_copy_present = .true.
@@ -238,6 +254,25 @@
 
 end function
 
+!------------------------------------------------------------------
+!> Assert if a copy is in a valid range
+
+
+function assert_valid_copy(name_handle, copy) result(valid_copy)
+type(stage_metadata_type), intent(in) :: name_handle !< stage name handle
+integer,                   intent(in) :: copy
+logical :: valid_copy
+
+integer :: size_fnames
+
+size_fnames = size(name_handle%io_flag(:),1)
+
+valid_copy = .false.
+if(copy <= size_fnames .and. copy > 0) valid_copy = .true.
+print*, "SIZE FNAMES = " , size_fnames, copy, valid_copy
+
+end function assert_valid_copy
+
 !> @}
 !-------------------------------------------------------
 end module copies_on_off_mod


More information about the Dart-dev mailing list