[Dart-dev] DART/branches Revision: 11078

dart at ucar.edu dart at ucar.edu
Thu Feb 9 14:29:45 MST 2017


nancy at ucar.edu
2017-02-09 14:29:45 -0700 (Thu, 09 Feb 2017)
100
clean up the print ensemble handle routine - add option
to print the contents as well as the type.




Modified: DART/branches/rma_single_file/ensemble_manager/ensemble_manager_mod.f90
===================================================================
--- DART/branches/rma_single_file/ensemble_manager/ensemble_manager_mod.f90	2017-02-09 21:27:47 UTC (rev 11077)
+++ DART/branches/rma_single_file/ensemble_manager/ensemble_manager_mod.f90	2017-02-09 21:29:45 UTC (rev 11078)
@@ -14,7 +14,7 @@
 ! have been placed here for efficiency even though they might be more 
 ! appropriately abstracted at a higher level of code.
 
-use types_mod,         only : r8, i8,  MISSING_R8
+use types_mod,         only : r8, i4, i8,  MISSING_R8
 use utilities_mod,     only : register_module, do_nml_file, do_nml_term, &
                               error_handler, E_ERR, E_MSG, do_output, &
                               nmlfileunit, find_namelist_in_file,        &
@@ -1534,15 +1534,24 @@
 end subroutine timestamp_message
 
 !--------------------------------------------------------------------------------
+! print an ensemble handle file type.  normally won't print unless 'debug' in the
+! namelist is true, but 'force' will override that and print no matter what.
+! if 'contents' is true, print the %copies and %vars arrays.  set integer 'limit'
+! to print only the first N values for each.
 
-subroutine print_ens_handle(ens_handle, force, label)
+subroutine print_ens_handle(ens_handle, force, label, contents, limit)
  type(ensemble_type),        intent(in) :: ens_handle
  logical,          optional, intent(in) :: force
  character(len=*), optional, intent(in) :: label
+ logical,          optional, intent(in) :: contents
+ integer,          optional, intent(in) :: limit
 
 logical :: print_anyway
 logical :: has_label
+logical :: do_contents
+integer :: limit_count
 integer :: i,j
+
 print_anyway = .false.
 if (present(force)) then
    print_anyway = force
@@ -1553,6 +1562,16 @@
    has_label = .true.
 endif
 
+do_contents = .false.
+if (present(contents)) then
+   do_contents = contents
+endif
+
+limit_count = HUGE(1_i4)
+if (present(limit)) then
+   limit_count = limit
+endif
+
 ! print out contents of an ensemble handle derived type
 if (.not. debug .and. .not. print_anyway) return
 
@@ -1582,20 +1601,23 @@
    call error_handler(E_MSG, 'ensemble handle: ', msgstring, source, revision, revdate)
 endif
 
-if (allocated(ens_handle%copies)) then
-do j = 1, ens_handle%my_num_vars
-do i = 1, ens_handle%num_copies
-   print*, 'ens_handle%copies(i,j) : ', i, j, ens_handle%copies(i,j)
-enddo
-enddo
+! warning - for large state vectors this is a lot of output
+if (do_contents .and. allocated(ens_handle%copies)) then
+   do j = 1, min(ens_handle%my_num_vars, limit_count)
+      do i = 1, min(ens_handle%num_copies, limit_count)
+         write(msgstring, *) 'ens_handle%copies(i,j) : ', i, j, ens_handle%copies(i,j)
+         call error_handler(E_MSG, 'ensemble handle: ', msgstring, source, revision, revdate)
+      enddo
+   enddo
 endif
 
-if (allocated(ens_handle%vars)) then
-do j = 1, ens_handle%my_num_copies
-do i = 1, ens_handle%num_vars
-   print*, 'ens_handle%vars(i,j) : ', i, j, ens_handle%vars(i,j)
-enddo
-enddo
+if (do_contents .and. allocated(ens_handle%vars)) then
+   do j = 1, min(ens_handle%my_num_copies, limit_count)
+      do i = 1, min(ens_handle%num_vars, limit_count)
+         write(msgstring, *) 'ens_handle%vars(i,j) : ', i, j, ens_handle%vars(i,j)
+         call error_handler(E_MSG, 'ensemble handle: ', msgstring, source, revision, revdate)
+      enddo
+   enddo
 endif
 
 end subroutine print_ens_handle


More information about the Dart-dev mailing list