[Dart-dev] DART/branches Revision: 10731

dart at ucar.edu dart at ucar.edu
Mon Nov 7 11:59:17 MST 2016


hendric at ucar.edu
2016-11-07 11:59:17 -0700 (Mon, 07 Nov 2016)
54
only output inflation files only if it is turned on.




Modified: DART/branches/rma_fixed_filenames/adaptive_inflate/adaptive_inflate_mod.f90
===================================================================
--- DART/branches/rma_fixed_filenames/adaptive_inflate/adaptive_inflate_mod.f90	2016-11-04 18:01:52 UTC (rev 10730)
+++ DART/branches/rma_fixed_filenames/adaptive_inflate/adaptive_inflate_mod.f90	2016-11-07 18:59:17 UTC (rev 10731)
@@ -55,7 +55,8 @@
    ! Depricating 1:obs_inflate, there is concerns how the observation space inflation
    ! is happening. JPH.
    integer               :: inflation_flavor, obs_diag_unit
-   logical               :: output_restart, deterministic
+   logical               :: output_restart = .false.
+   logical               :: deterministic
    real(r8)              :: inflate, sd, sd_lower_bound, inf_lower_bound, inf_upper_bound
    ! Include a random sequence type in case non-deterministic inflation is used
    type(random_seq_type) :: ran_seq
@@ -167,7 +168,7 @@
 !------------------------------------------------------------------
 
 subroutine adaptive_inflate_init(inflate_handle, inf_flavor, mean_from_restart, &
-   sd_from_restart, output_restart, deterministic, & 
+   sd_from_restart, deterministic, & 
    inf_initial, sd_initial, inf_lower_bound, inf_upper_bound, &
    sd_lower_bound, ens_handle, ss_inflate_index, ss_inflate_sd_index, missing_ok, label)
 
@@ -177,7 +178,6 @@
 integer,                     intent(in)    :: inf_flavor
 logical,                     intent(in)    :: mean_from_restart
 logical,                     intent(in)    :: sd_from_restart
-logical,                     intent(in)    :: output_restart
 logical,                     intent(in)    :: deterministic
 real(r8),                    intent(in)    :: inf_initial, sd_initial
 real(r8),                    intent(in)    :: inf_lower_bound, inf_upper_bound
@@ -205,7 +205,6 @@
 
 ! Load up the structure first to keep track of all details of this inflation type
 inflate_handle%inflation_flavor   = inf_flavor
-inflate_handle%output_restart     = output_restart
 inflate_handle%deterministic      = deterministic
 inflate_handle%inflate            = inf_initial
 inflate_handle%sd                 = sd_initial
@@ -222,6 +221,10 @@
 ! Set obs_diag unit to -1 indicating it has not been opened yet
 inflate_handle%obs_diag_unit = -1
 
+if (inf_flavor > 1) then
+   inflate_handle%output_restart  = .true.
+endif
+
 ! Cannot support non-determistic inflation and an inf_lower_bound < 1
 if(.not. deterministic .and. inf_lower_bound < 1.0_r8) then
    write(msgstring, *) 'Cannot have non-deterministic inflation and inf_lower_bound < 1'
@@ -260,7 +263,7 @@
 
 do_obs_inflate = (inflate_handle%inflation_flavor == 1)
 
-if (do_obs_inflate .eqv. .true.) then
+if (do_obs_inflate) then
   write(msgstring,  *) 'observation space inflation not suppported (i.e. inf_flavor = 1)'
   write(msgstring2, *) 'please contact dart if you would like to use this functionality'
   call error_handler(E_ERR, 'do_obs_inflate', &

Modified: DART/branches/rma_fixed_filenames/filter/filter_mod.f90
===================================================================
--- DART/branches/rma_fixed_filenames/filter/filter_mod.f90	2016-11-04 18:01:52 UTC (rev 10730)
+++ DART/branches/rma_fixed_filenames/filter/filter_mod.f90	2016-11-07 18:59:17 UTC (rev 10731)
@@ -48,7 +48,7 @@
                                   get_single_copy, put_single_copy, deallocate_single_copy
 use adaptive_inflate_mod,  only : do_varying_ss_inflate,                &
                                   do_single_ss_inflate, inflate_ens, adaptive_inflate_init,   &
-                                  do_obs_inflate, adaptive_inflate_type,                      &
+                                  adaptive_inflate_type,                      &
                                   log_inflation_info, &
                                   get_minmax_task_zero
 use mpi_utilities_mod,     only : my_task_id, task_sync, broadcast_send, broadcast_recv,      &
@@ -62,8 +62,7 @@
 use random_seq_mod,        only : random_seq_type, init_random_seq, random_gaussian
 
 use state_vector_io_mod,   only : state_vector_io_init, read_state, write_state, &
-                                  get_output_preassim, get_output_inflation, &
-                                  get_output_mean, get_output_sd
+                                  get_output_preassim, get_output_mean, get_output_sd
 
 use io_filenames_mod,      only : io_filenames_init, file_info_type
 
@@ -103,6 +102,9 @@
 
 ! Defining whether diagnostics are for prior or posterior
 integer, parameter :: PRIOR_DIAG = 0, POSTERIOR_DIAG = 2
+! Maximum number of domains. This is arbitrarily set based on 
+! the maximum number of domains in WRF.  
+integer, parameter :: MAX_NUM_DOMS = 10
 
 !----------------------------------------------------------------
 ! Namelist input with default values
@@ -134,10 +136,13 @@
 logical  :: distributed_state = .true. ! Default to do state complete forward operators.
 
 ! IO options
-character(len=512) :: input_restart_file_list(10)  = 'null'  ! name of files containing a list of input restart files, 1 file per domain
-character(len=512) :: output_restart_file_list(10) = 'null'  ! name of files containing a list of output restart files, 1 file per domain
-logical            :: perturb_from_single_instance = .false. ! Read in a single file and perturb this to create an ensemble
+! Name of files containing a list of {input,output} restart files, 1 file per domain
+character(len=512) :: input_restart_file_list(MAX_NUM_DOMS)  = 'null'  
+character(len=512) :: output_restart_file_list(MAX_NUM_DOMS) = 'null'
+! Read in a single file and perturb this to create an ensemble
+logical            :: perturb_from_single_instance = .false.
 real(r8)           :: perturbation_amplitude       = 0.2_r8
+! File options.  Single vs. Multiple.
 logical            :: single_file_in               = .false. ! all copies read from 1 file
 logical            :: single_file_out              = .false. ! all copies written to 1 file
 
@@ -153,9 +158,6 @@
 logical              :: inf_initial_from_restart(2)    = .false.
 logical              :: inf_sd_initial_from_restart(2) = .false.
 
-! old way
-logical              :: inf_output_restart(2)     = .false. ! only if adaptive inflation is turned on 2,3
-                                                            ! whether it adapts is complicated
 ! new way
 !logical              :: inf_output_prior(2) = .false. ! mean sd
 !logical              :: inf_output_post(2)  = .false. ! mean sd
@@ -177,7 +179,7 @@
    output_interval, num_groups, trace_execution,                 &
    output_forward_op_errors, output_timestamps,                 &
    inf_flavor, inf_initial_from_restart, inf_sd_initial_from_restart,               &
-   inf_output_restart, inf_deterministic, inf_damping,            &
+   inf_deterministic, inf_damping,            &
    inf_initial, inf_sd_initial, &
    inf_lower_bound, inf_upper_bound, inf_sd_lower_bound,           &
    silence, output_restart_file_list, &
@@ -225,7 +227,7 @@
 
 type(file_info_type) :: file_info
 
-logical                 :: ds, all_gone, allow_missing
+logical                 :: ds, all_gone, allow_missing, do_inflation
 
 ! real(r8), allocatable   :: temp_ens(:) ! for smoother
 real(r8), allocatable   :: prior_qc_copy(:)
@@ -282,13 +284,13 @@
 
 ! Initialize the adaptive inflation module
 call adaptive_inflate_init(prior_inflate, inf_flavor(1), inf_initial_from_restart(1), &
-   inf_sd_initial_from_restart(1), inf_output_restart(1), inf_deterministic(1),       &
+   inf_sd_initial_from_restart(1), inf_deterministic(1),       &
    inf_initial(1), inf_sd_initial(1), inf_lower_bound(1), inf_upper_bound(1),         &
    inf_sd_lower_bound(1), state_ens_handle, PRIOR_INF_COPY, PRIOR_INF_SD_COPY,        &
    allow_missing, 'Prior')
 
 call adaptive_inflate_init(post_inflate, inf_flavor(2), inf_initial_from_restart(2),  &
-   inf_sd_initial_from_restart(2), inf_output_restart(2), inf_deterministic(2),       &
+   inf_sd_initial_from_restart(2), inf_deterministic(2),       &
    inf_initial(2),  inf_sd_initial(2), inf_lower_bound(2), inf_upper_bound(2),        &
    inf_sd_lower_bound(2), state_ens_handle, POST_INF_COPY, POST_INF_SD_COPY,          &
    allow_missing, 'Posterior')
@@ -562,6 +564,8 @@
       call trace_message('Before prior inflation damping and prep')
       !call test_state_copies(state_ens_handle, 'before_prior_inflation')
 
+      do_inflation = .true.
+
       if (inf_damping(1) /= 1.0_r8) then
          call prepare_to_update_copies(state_ens_handle)
          state_ens_handle%copies(PRIOR_INF_COPY, :) = 1.0_r8 + &
@@ -612,7 +616,8 @@
 
       if (get_output_preassim()) then
         call write_preassim_files(state_ens_handle, file_info, &
-              ENS_MEAN_COPY, ENS_SD_COPY, PRIOR_INF_COPY, PRIOR_INF_SD_COPY)
+              ENS_MEAN_COPY, ENS_SD_COPY, PRIOR_INF_COPY, PRIOR_INF_SD_COPY, &
+              do_inflation)
       endif
    endif
 
@@ -929,16 +934,10 @@
 ! Next two slots are for inflation mean and sd metadata
 ! To avoid writing out inflation values to the Prior and Posterior netcdf files,
 ! set output_inflation to false in the filter section of input.nml 
-if(get_output_inflation()) then
-   if(get_output_mean()) then
-      num_state_copies = num_state_copies + 1
-      state_meta(num_state_copies-1) = 'inflation mean'
-   endif
-
-   if(get_output_sd()) then
-      state_meta(num_state_copies)   = 'inflation sd'
-      num_state_copies = num_state_copies + 1
-   endif
+if(do_single_ss_inflate(prior_inflate) .or. do_varying_ss_inflate(prior_inflate)) then
+   num_state_copies = num_state_copies + 2
+   state_meta(num_state_copies-1) = 'inflation mean'
+   state_meta(num_state_copies)   = 'inflation sd'
 endif
 
 ! Set the metadata for the observations.

Modified: DART/branches/rma_fixed_filenames/io/io_filenames_mod.f90
===================================================================
--- DART/branches/rma_fixed_filenames/io/io_filenames_mod.f90	2016-11-04 18:01:52 UTC (rev 10730)
+++ DART/branches/rma_fixed_filenames/io/io_filenames_mod.f90	2016-11-07 18:59:17 UTC (rev 10731)
@@ -408,7 +408,7 @@
 
    if (query_copy_present(SPARE_POST_INF_SPREAD)) &
       call write_output_file_info(file_info%restart_files_out, SPARE_POST_INF_SPREAD, idom, &
-             'postassim_inf_sd', 'dart posterior inflation sd', dom_str)
+             'postassim_priorinf_sd', 'dart posterior inflation sd', dom_str)
 
    !-----------------------------------
 
@@ -467,9 +467,9 @@
 elseif (trim(list_type) == trim('output_restarts')) then
    allocate(restart_list(size(file_info%options%output_restart_list)))
    restart_list = file_info%options%output_restart_list
-   read_write = "writting restarts to  : "
+   read_write = "writing restarts to  : "
 else
-   write(msgstring,*) 'list_type must be either "input_restarts" or "ouput_restarts"', &
+   write(msgstring,*) 'list_type must be either "input_restarts" or "output_restarts"', &
                       'you have ', trim(list_type)
    call error_handler(E_ERR,'read_file_lists', msgstring, &
                       source, revision, revdate)

Modified: DART/branches/rma_fixed_filenames/io/state_space_diag_mod.f90
===================================================================
--- DART/branches/rma_fixed_filenames/io/state_space_diag_mod.f90	2016-11-04 18:01:52 UTC (rev 10730)
+++ DART/branches/rma_fixed_filenames/io/state_space_diag_mod.f90	2016-11-07 18:59:17 UTC (rev 10731)
@@ -80,8 +80,7 @@
 use io_filenames_mod,     only : file_info_type
 use state_vector_io_mod,  only : setup_read_write, end_read_write, turn_write_copy_off, &
                                  turn_write_copy_on, filter_write_restart_direct, &
-                                 set_output_files, get_output_inflation, get_output_mean, &
-                                 get_output_sd
+                                 set_output_files, get_output_mean, get_output_sd
 
 use state_structure_mod, only : get_num_domains, create_diagnostic_structure, &
                                 get_num_variables, get_num_dims, set_var_id, &
@@ -317,18 +316,19 @@
 !> and num_output_state_members > 0. If this is single time step and the
 !> posterior, then the output members are the restart files.
 subroutine write_preassim_files(ens_handle, file_info, &
-             ENS_MEAN_COPY, ENS_SD_COPY, INF_COPY, INF_SD_COPY)
+             ENS_MEAN_COPY, ENS_SD_COPY, INF_COPY, INF_SD_COPY, do_inflation)
 
 type(ensemble_type),  intent(inout) :: ens_handle
 type(file_info_type), intent(in)    :: file_info
 integer,              intent(in)    :: ENS_MEAN_COPY, ENS_SD_COPY, INF_COPY, INF_SD_COPY
+logical,              intent(in)    :: do_inflation
 
 if (num_output_state_members > 0 ) then
    call setup_read_write(ens_handle%num_copies)
    call turn_write_copy_on(1, num_output_state_members)
    if (get_output_mean()) call turn_write_copy_on(ENS_MEAN_COPY)
    if (get_output_sd()  ) call turn_write_copy_on(ENS_SD_COPY)
-   if (get_output_inflation()) then
+   if (do_inflation) then
       call turn_write_copy_on(INF_COPY)
       call turn_write_copy_on(INF_SD_COPY)
    endif

Modified: DART/branches/rma_fixed_filenames/io/state_vector_io_mod.f90
===================================================================
--- DART/branches/rma_fixed_filenames/io/state_vector_io_mod.f90	2016-11-04 18:01:52 UTC (rev 10730)
+++ DART/branches/rma_fixed_filenames/io/state_vector_io_mod.f90	2016-11-07 18:59:17 UTC (rev 10731)
@@ -110,7 +110,6 @@
           end_read_write, &
           set_output_files, &
           get_output_restart, &
-          get_output_inflation, &
           get_output_preassim, &
           get_output_postassim, &
           get_output_mean, &
@@ -380,24 +379,15 @@
 
    ! PRIOR
    if (do_ss_inflate(prior_inflate_handle)) then
-      print *, "DO SS INFLATE"
       ! These two copies are input for the next run of filter
-      if ( get_output_inflation() ) then
-         print *, "OUTPUT INFLATION RESTART"
-         call turn_write_copy_on(PRIOR_INF_COPY)
-         call turn_write_copy_on(PRIOR_INF_SD_COPY)
-      endif
+      !>@todo FIXME JPH: Only write out inflation if values have changes.
+      call turn_write_copy_on(PRIOR_INF_COPY)
+      call turn_write_copy_on(PRIOR_INF_SD_COPY)
 
       ! These two copies are the inflation values that would have gone in the Prior_Diag.nc file
       ! Assume if they are there, they need to be written out
-      if (query_copy_present(SPARE_PRIOR_INF_MEAN)) then 
-         call turn_write_copy_on(SPARE_PRIOR_INF_MEAN)
-         print *, "OUTPUT SPARE INFLATION MEAN RESTART"
-      endif 
-      if (query_copy_present(SPARE_PRIOR_INF_SPREAD)) then
-         call turn_write_copy_on(SPARE_PRIOR_INF_SPREAD)
-         print *, "OUTPUT SPARE INFLATION SD RESTART"
-      endif 
+      if (query_copy_present(SPARE_PRIOR_INF_MEAN))   call turn_write_copy_on(SPARE_PRIOR_INF_MEAN)
+      if (query_copy_present(SPARE_PRIOR_INF_SPREAD)) call turn_write_copy_on(SPARE_PRIOR_INF_SPREAD)
 
    endif
 
@@ -405,10 +395,8 @@
    if (do_ss_inflate(post_inflate_handle)) then
 
       ! These two copies are input for the next run of filter
-      if ( get_output_inflation() ) then
-         call turn_write_copy_on(POST_INF_COPY)
-         call turn_write_copy_on(POST_INF_SD_COPY)
-      endif
+      call turn_write_copy_on(POST_INF_COPY)
+      call turn_write_copy_on(POST_INF_SD_COPY)
 
       ! These two copies are the inflation values that would have gone in the Posterior_Diag.nc file
       ! Assume if they are there, they need to be written out
@@ -967,14 +955,6 @@
 end function
 
 !-----------------------------------------------------------------------
-function get_output_inflation()
-logical :: get_output_inflation
-
-get_output_inflation = io_output_inflation
-
-end function
-
-!-----------------------------------------------------------------------
 function get_output_preassim()
 logical :: get_output_preassim
 

Modified: DART/branches/rma_fixed_filenames/smoother/smoother_mod.f90
===================================================================
--- DART/branches/rma_fixed_filenames/smoother/smoother_mod.f90	2016-11-04 18:01:52 UTC (rev 10730)
+++ DART/branches/rma_fixed_filenames/smoother/smoother_mod.f90	2016-11-07 18:59:17 UTC (rev 10731)
@@ -123,7 +123,7 @@
 
 ! Initialize a null adaptive_inflate type since inflation is not done at lags
 ! NOTE: Using ens_handle here (not lag_handle) so it doesn't die for 0 lag choice
-if(num_lags > 0) call adaptive_inflate_init(lag_inflate, 0, .false., .false., .false., &
+if(num_lags > 0) call adaptive_inflate_init(lag_inflate, 0, .false., .false., &
    .true., 1.0_r8, 0.0_r8,       &
    1.0_r8, 1.0_r8, 0.0_r8, ens_handle, POST_INF_COPY, POST_INF_SD_COPY, allow_missing, "Lag")
 


More information about the Dart-dev mailing list