[Dart-dev] [6218] DART/branches/development/assim_tools/assim_tools_mod.f90: make it an error to have sort_obs_inc=.true.

nancy at ucar.edu nancy at ucar.edu
Fri May 31 16:48:18 MDT 2013


Revision: 6218
Author:   nancy
Date:     2013-05-31 16:48:17 -0600 (Fri, 31 May 2013)
Log Message:
-----------
make it an error to have sort_obs_inc=.true. in the cases
where the increments are already sorted as part of the
filter kind.  this routine is called a lot and an extra
sort just wastes time.  this means people may have to
change their namelists; it should be noted in the release
notes.  also fix one more type/kind mixup, and suggest
a possible alternative for the missing_r8 code (currently
commented out) depending on what the performance measurements
show about having the any() always being executed even for
models which will never have missing values in the state.

Modified Paths:
--------------
    DART/branches/development/assim_tools/assim_tools_mod.f90

-------------- next part --------------
Modified: DART/branches/development/assim_tools/assim_tools_mod.f90
===================================================================
--- DART/branches/development/assim_tools/assim_tools_mod.f90	2013-05-31 22:30:22 UTC (rev 6217)
+++ DART/branches/development/assim_tools/assim_tools_mod.f90	2013-05-31 22:48:17 UTC (rev 6218)
@@ -353,6 +353,18 @@
    module_initialized = .true.
 endif
 
+! filter kinds 1 and 8 return sorted increments, however non-deterministic
+! inflation can scramble these. the sort is expensive, so help users get better 
+! performance by rejecting namelist combinations that do unneeded work.
+if (sort_obs_inc) then
+   if(deterministic_inflate(inflate) .and. ((filter_kind == 1) .or. (filter_kind == 8))) then
+      write(msgstring,  *) 'sort_obs_inc is unneeded with deterministic filter_kind ', filter_kind
+      write(msgstring2, *) 'the increments are already sorted when inflation is deterministic'
+      call error_handler(E_ERR,'filter_assim:', msgstring, source, revision, revdate, &
+                         text2=msgstring2)
+   endif
+endif
+
 !GSR open the dignostics file
 if(output_localization_diagnostics .and. my_task_id() == 0) then
   localization_unit = open_file(localization_diagnostics_file, action = 'append')
@@ -659,8 +671,8 @@
    ! set the cutoff default, keep a copy of the original value, and avoid
    ! looking up the cutoff in a list if the incoming obs is an identity ob
    ! (and therefore has a negative kind).
-   if (base_obs_kind > 0) then
-      cutoff_orig = cutoff_list(base_obs_kind)
+   if (base_obs_type > 0) then
+      cutoff_orig = cutoff_list(base_obs_type)
    else
       cutoff_orig = cutoff
    endif
@@ -761,6 +773,17 @@
    STATE_UPDATE: do j = 1, num_close_states
       state_index = close_state_ind(j)
 
+      !! or this, for performance reasons?  it won't warn you if there are missing
+      ! values when you don't expect them, but it also won't do the any() unless
+      ! the namelist says you might expect to see them.
+      !if ( allow_missing_in_state ) then
+      !   ! Some models can take evasive action if one or more of the ensembles have
+      !   ! a missing value. Generally means 'do nothing' (as opposed to DIE) 
+      !   missing_in_state = any(ens_handle%copies(1:ens_size, state_index) == MISSING_R8)
+      !   if ( missing_in_state ) then
+      !      cycle STATE_UPDATE
+      !endif
+
       ! Some models can take evasive action if one or more of the ensembles have
       ! a missing value. Generally means 'do nothing' (as opposed to DIE) 
       missing_in_state = any(ens_handle%copies(1:ens_size, state_index) == MISSING_R8)
@@ -1091,19 +1114,13 @@
 ! plus non-deterministic obs space covariance inflation. This is expensive, so
 ! don't use it if it's not needed.
 if (sort_obs_inc) then
-   if (filter_kind == 1) then
-      ! sort does nothing and we skip the code
-      ! FIXME: are there other kinds where the sort has no effect?
-      ! add more cases here.
-   else
-      new_val = ens_in + obs_inc
-      ! Sorting to make increments as small as possible
-      call index_sort(ens_in, ens_index, ens_size)
-      call index_sort(new_val, new_index, ens_size)
-      do i = 1, ens_size
-         obs_inc(ens_index(i)) = new_val(new_index(i)) - ens_in(ens_index(i))
-      end do
-   endif
+   new_val = ens_in + obs_inc
+   ! Sorting to make increments as small as possible
+   call index_sort(ens_in, ens_index, ens_size)
+   call index_sort(new_val, new_index, ens_size)
+   do i = 1, ens_size
+      obs_inc(ens_index(i)) = new_val(new_index(i)) - ens_in(ens_index(i))
+   end do
 endif
 
 ! Get the net change in spread if obs space inflation was used


More information about the Dart-dev mailing list