[Dart-dev] DART/branches Revision: 11499

dart at ucar.edu dart at ucar.edu
Fri Apr 14 16:03:30 MDT 2017


hendric at ucar.edu
2017-04-14 16:03:29 -0600 (Fri, 14 Apr 2017)
243
minor changes from code review.

only write true_state.nc if the file has cycling for pmo.
return a default time of -1 for get_num_times in the case
that the variable does not have a time dimension.

fixed the logic for setting input copies.




Modified: DART/branches/rma_output_files/assimilation_code/modules/assimilation/filter_mod.f90
===================================================================
--- DART/branches/rma_output_files/assimilation_code/modules/assimilation/filter_mod.f90	2017-04-14 19:58:02 UTC (rev 11498)
+++ DART/branches/rma_output_files/assimilation_code/modules/assimilation/filter_mod.f90	2017-04-14 22:03:29 UTC (rev 11499)
@@ -189,9 +189,8 @@
 logical            :: single_file_out              = .false. ! all copies written to 1 file
 ! Stages to write.  Valid values include:
 !    input, preassim, postassim, output
-character(len=10)  :: stages_to_write(NUM_SCOPIES) = (/"output    ", "null      ", "null      ", &
-                                                       "null      ", "null      ", "null      ", &
-                                                       "null      ", "null      "/)
+character(len=10)  :: stages_to_write(6) = (/"output    ", "null      ", "null      ", &
+                                             "null      ", "null      ", "null      " /)
 
 !>@todo FIXME
 !> for preassim and postassim output it might be we should
@@ -268,7 +267,7 @@
 
 integer,    allocatable :: keys(:)
 integer(i8)             :: model_size
-integer                 :: i, iunit, io, time_step_number, num_obs_in_set
+integer                 :: i, iunit, io, time_step_number, num_obs_in_set, ntimes
 integer                 :: last_key_used, key_bounds(2)
 integer                 :: in_obs_copy, obs_val_index
 integer                 :: prior_obs_mean_index, posterior_obs_mean_index
@@ -581,13 +580,21 @@
    if (write_all_stages_at_end) then
       call store_input(state_ens_handle, prior_inflate, post_inflate)
    else
-      if (single_file_out .and. get_num_times_netcdf(file_info_input%stage_metadata%filenames(1,1)) == 1 ) then
-         call write_augmented_state(state_ens_handle, file_info_input)
-      ! else
-      !    ! create new file(s) containing input mean and sd
-      else if (.not. single_file_out) then
-         call write_state(state_ens_handle, file_info_mean_sd)
-      endif
+      ! if there is only one timestep in your input file insert the mean and sd if requested
+      ntimes = get_num_times_netcdf(file_info_input%stage_metadata%filenames(1,1))
+      if (single_file_out) then
+        if ( ntimes == 1 ) then
+           call write_augmented_state(state_ens_handle, file_info_input)
+        else
+           call error_handler(E_ERR,'filter_main', &
+                              'can not insert mean or spread into input files that have multiple time steps',  &
+                              source, revision, revdate, &
+                              text2='please remove "input" from stages_to_write')
+        endif
+     else ! muti file case
+        ! write out input_mean.nc and input_sd.nc if requested
+        call write_state(state_ens_handle, file_info_mean_sd)
+     endif
    endif
 
    call timestamp_message('After  input state space output')
@@ -1059,10 +1066,6 @@
 
 ! close the diagnostic/restart netcdf files
 if (single_file_out) then
-   ! if you did not open the original input file close the new
-   ! file containing input mean and sd info
-   if (get_stage_to_write('input') .and. get_num_times_netcdf(file_info_input%stage_metadata%filenames(1,1)) /= 1)  &
-      call finalize_singlefile_output(file_info_mean_sd)
 
    if (get_stage_to_write('forecast')) &
       call finalize_singlefile_output(file_info_forecast)
@@ -1937,12 +1940,12 @@
    if (query_copy_present( INPUT_COPIES(ENS_MEAN)) ) &
       ens_handle%copies(   INPUT_COPIES(ENS_MEAN), :) = ens_handle%copies(ENS_MEAN_COPY, :)
 
-   if ( do_prior_inflate .and. sd_from_restart( prior_inflate) ) then
+   if ( do_prior_inflate .and. mean_from_restart( prior_inflate) ) then
      if (query_copy_present( INPUT_COPIES(PRIORINF_MEAN)) ) &
         ens_handle%copies(   INPUT_COPIES(PRIORINF_MEAN), :) = ens_handle%copies(PRIOR_INF_COPY, :)
    endif 
 
-   if ( do_posterior_inflate .and. sd_from_restart(post_inflate) ) then
+   if ( do_posterior_inflate .and. mean_from_restart(post_inflate) ) then
       if (query_copy_present( INPUT_COPIES(POSTINF_MEAN)) ) &
          ens_handle%copies(   INPUT_COPIES(POSTINF_MEAN), :) = ens_handle%copies(POST_INF_COPY, :)
    endif
@@ -2090,18 +2093,18 @@
    !   INPUT_MEAN
    !   INPUT_SD  
    if (output_mean) then
-      INPUT_COPIES(ENS_MEAN)      = ENS_MEAN_COPY
-      if ( do_prior_inflate .and. mean_from_restart(prior_inflate) ) then
+      INPUT_COPIES(ENS_MEAN) = ENS_MEAN_COPY
+      if ( do_prior_inflate     .and. mean_from_restart(prior_inflate) ) then
          INPUT_COPIES(PRIORINF_MEAN) = PRIOR_INF_COPY
       endif
-      if ( do_posterior_inflate.and. mean_from_restart(post_inflate) ) then
+      if ( do_posterior_inflate .and. mean_from_restart(post_inflate) ) then
          INPUT_COPIES(POSTINF_MEAN)  = POST_INF_COPY
       endif
    endif
 
    if (output_sd) then
-      INPUT_COPIES(ENS_SD)        = ENS_SD_COPY
-      if ( do_prior_inflate .and. sd_from_restart(post_inflate) ) then
+      INPUT_COPIES(ENS_SD) = ENS_SD_COPY
+      if ( do_prior_inflate     .and. sd_from_restart(prior_inflate) ) then


More information about the Dart-dev mailing list