[Dart-dev] DART/branches Revision: 11879

dart at ucar.edu dart at ucar.edu
Fri Aug 4 15:07:07 MDT 2017


hendric at ucar.edu
2017-08-04 15:07:07 -0600 (Fri, 04 Aug 2017)
255
Adding routines clm_to_dart to mark missing r8 values 
in the clm_restart file that is going to be read into dart.  
Similarly added dart_to_clm to replace missing r8 values
with the original clm values.  Everything appears to be
bitwise besides H2OSNO.




Modified: DART/branches/rma_fix_clm_restarts/assimilation_code/modules/io/direct_netcdf_mod.f90
===================================================================
--- DART/branches/rma_fix_clm_restarts/assimilation_code/modules/io/direct_netcdf_mod.f90	2017-08-04 17:36:18 UTC (rev 11878)
+++ DART/branches/rma_fix_clm_restarts/assimilation_code/modules/io/direct_netcdf_mod.f90	2017-08-04 21:07:07 UTC (rev 11879)
@@ -149,6 +149,7 @@
 !> (but we don't remember for sure if this was the reason.)
 
 logical :: overwrite_time_in_output_file = .false.
+logical :: allow_missing_in_clm = .true.
 
 contains
 
@@ -854,6 +855,7 @@
    allocate(dims(get_io_num_dims(domain, i)))
 
    dims = get_io_dim_lengths(domain, i)
+
    ret = nf90_inq_varid(ncfile_in, get_variable_name(domain, i), var_id)
    call nc_check(ret, 'read_variables: nf90_inq_varid',trim(get_variable_name(domain,i)) )
 
@@ -1426,7 +1428,8 @@
 minclamp = get_io_clamping_minval(dom_id, var_index)
 maxclamp = get_io_clamping_maxval(dom_id, var_index)
 
-if (minclamp == missing_r8 .and. maxclamp == missing_r8) return
+! comment out just for testing
+!if (minclamp == missing_r8 .and. maxclamp == missing_r8) return
 
 ! if we get here, either the min, max or both have a clamping value.
   
@@ -1440,14 +1443,14 @@
 ! if we allow missing values in the state (which jeff has never
 ! liked because it makes the statistics funny), then these next
 ! two lines need to be:
-!if (allow_missing_in_clm) then
-!   my_minmax(1) = minval(variable, mask=(variable /= missing_r8))
-!   my_minmax(2) = maxval(variable, mask=(variable /= missing_r8))
-!else
+if (allow_missing_in_clm) then
+   my_minmax(1) = minval(variable, mask=(variable /= missing_r8))
+   my_minmax(2) = maxval(variable, mask=(variable /= missing_r8))
+else
    ! get the min/max for this variable before we start
    my_minmax(1) = minval(variable)
    my_minmax(2) = maxval(variable)
-!endif
+endif
      
 varname = get_variable_name(dom_id, var_index)
 
@@ -1454,10 +1457,13 @@
 ! is lower bound set?
 if ( minclamp /= missing_r8 ) then
    if ( my_minmax(1) < minclamp ) then
+
       !>@todo again, if we're allowing missing in state, this has to be masked:
-      ! if (allow_missing_in_clm) then
-      !    variable = max(minclamp, variable, mask=(variable /= missing_r8))
-      variable = max(minclamp, variable)
+       if (allow_missing_in_clm) then
+          where(variable /= missing_r8) variable = max(minclamp, variable)
+       else
+          variable = max(minclamp, variable)
+       endif
    
       write(msgstring, *) trim(varname)// ' lower bound ', minclamp, ' min value ', my_minmax(1)
       call error_handler(E_ALLMSG, 'clamp_variable', msgstring, &
@@ -1466,12 +1472,14 @@
 endif ! min range set
 
 ! is upper bound set?
-if ( maxclamp /= missing_r8 ) then
+if ( maxclamp /= missing_r8 ) then ! missing_r8 is flag for no clamping
    if ( my_minmax(2) > maxclamp ) then
       !>@todo again, if we're allowing missing in state, this has to be masked:
-      ! if (allow_missing_in_clm) then
-      !    variable = min(maxclamp, variable, mask=(variable /= missing_r8))
-      variable = min(maxclamp, variable)
+      if (allow_missing_in_clm) then
+         where(variable /= missing_r8) variable = max(maxclamp, variable)
+      else
+         variable = min(maxclamp, variable)
+      endif
 
       write(msgstring, *) trim(varname)// ' upper bound ', maxclamp, ' max value ', my_minmax(2)
       call error_handler(E_ALLMSG, 'clamp_variable', msgstring, &
@@ -1480,6 +1488,9 @@
 
 endif ! max range set
 
+! fixme
+!where (variable == missing_r8) variable = 1.0e+36 ! or whatever fill value is
+
 end subroutine clamp_variable
 
 

Modified: DART/branches/rma_fix_clm_restarts/models/clm/model_mod.f90
===================================================================
--- DART/branches/rma_fix_clm_restarts/models/clm/model_mod.f90	2017-08-04 17:36:18 UTC (rev 11878)
+++ DART/branches/rma_fix_clm_restarts/models/clm/model_mod.f90	2017-08-04 21:07:07 UTC (rev 11879)


More information about the Dart-dev mailing list