[Dart-dev] [9480] DART/trunk/models/ROMS: Added the _FillValue to the prognostic variables in the DART diagnostic output .

nancy at ucar.edu nancy at ucar.edu
Fri Jan 8 16:38:05 MST 2016


Revision: 9480
Author:   thoar
Date:     2016-01-08 16:38:05 -0700 (Fri, 08 Jan 2016)
Log Message:
-----------
Added the _FillValue to the prognostic variables in the DART diagnostic output.

Removed some impossible messages since the ocean_time coordinate is mandatory.
Put in a test location that is known to be water.

I have no understanding of how the land/sea mask may or may not be applied.

Modified Paths:
--------------
    DART/trunk/models/ROMS/model_mod.f90
    DART/trunk/models/ROMS/model_mod_check.f90
    DART/trunk/models/ROMS/work/input.nml

-------------- next part --------------
Modified: DART/trunk/models/ROMS/model_mod.f90
===================================================================
--- DART/trunk/models/ROMS/model_mod.f90	2016-01-08 23:13:05 UTC (rev 9479)
+++ DART/trunk/models/ROMS/model_mod.f90	2016-01-08 23:38:05 UTC (rev 9480)
@@ -22,6 +22,7 @@
 !> subsequently modified by the DART team.
 !>
 !> \todo
+!> @todo really check the land masking and _FillValue processing
 !----------------------------------------------------------------
 
 module model_mod
@@ -142,15 +143,16 @@
 character(len=NF90_MAX_NAME) :: roms_state_bounds(num_bounds_table_columns, max_state_variables ) = ' '
 character(len=NF90_MAX_NAME) :: variable_table(max_state_variables, num_state_table_columns )
 
+integer :: nfields   ! This is the number of variables in the DART state vector.
 
-integer :: nfields
+!> Everything needed to describe a variable. Basically all the metadata from
+!> a netCDF file is stored here as well as all the information about where
+!> the variable is stored in the DART state vector.
+!> @todo FIXME ... replace numxi and numeta with simply nx or something.
+!>       since the structure is an array - one for each variable -
+!>       it doesn't make sense to declare a number of horizontal 
+!>       locations of the edges for a variable that is on cell centers ...
 
-! Everything needed to describe a variable
-! TJH FIXME ... replace numxi and numeta with simply nx or something.
-! TJH FIXME ... since the structure is an array - one for each variable -
-! TJH FIXME ... it doesn't make sense to declare a number of horizontal 
-! TJH FIXME ... locations of the edges for a variable that is on cell centers ...
-
 type progvartype
    private
    character(len=NF90_MAX_NAME) :: varname
@@ -186,9 +188,11 @@
 
 ! nx, ny and nz are the size of the rho grids.
 integer :: Nx = -1, Ny = -1, Nz = -1
-real(r8), allocatable :: ULAT(:,:), ULON(:,:), TLAT(:,:), TLON(:,:),     &
-                         VLAT(:,:), VLON(:,:),PM(:,:),PN(:,:),ANGL(:,:), &
-                         HT(:,:),ZC(:,:,:)
+real(r8), allocatable :: ULAT(:,:), ULON(:,:), &
+                         TLAT(:,:), TLON(:,:), &
+                         VLAT(:,:), VLON(:,:), &
+                           PM(:,:),   PN(:,:), &
+                         ANGL(:,:),   HT(:,:), ZC(:,:,:)
 
 real(r8)        :: ocean_dynamics_timestep = 900.0_r4
 type(time_type) :: model_timestep
@@ -196,12 +200,18 @@
 integer :: model_size    ! the state vector length
 real(r8), allocatable :: ens_mean(:)
 
+!> Reshapes a part of the DART vector back to the original variable shape.
+!> @todo FIXME Replaces the DART MISSING value with the original _FillValue value.
+
 INTERFACE vector_to_prog_var
       MODULE PROCEDURE vector_to_1d_prog_var
       MODULE PROCEDURE vector_to_2d_prog_var
       MODULE PROCEDURE vector_to_3d_prog_var
 END INTERFACE
 
+!> Packs a ROMS variable into the DART vector.
+!> @todo FIXME Replaces the original _FillValue value with the DART MISSING value.
+
 INTERFACE prog_var_to_vector
       MODULE PROCEDURE prog_var_1d_to_vector
       MODULE PROCEDURE prog_var_2d_to_vector
@@ -209,6 +219,8 @@
       MODULE PROCEDURE prog_var_4d_to_vector
 END INTERFACE
 
+!> Return the first and last index into the DART array for a specific variable.
+
 INTERFACE get_index_range
       MODULE PROCEDURE get_index_range_int
       MODULE PROCEDURE get_index_range_string
@@ -587,14 +599,6 @@
 
 TimeDimID = find_time_dimension( ncid, model_restart_filename )
 
-if (TimeDimID < 0 ) then
-   write(*,*) 'CAUTION: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'
-   write(*,*)'unable to find a dimension named Time.'
-   write(*,*)'check time dimension name in the restart files'
-   write(*,*) 'CAUTION: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'
-endif
-
-
 index1  = 1;
 indexN  = 0;
 do ivar = 1, nfields
@@ -1078,6 +1082,16 @@
               trim(progvar(ivar)%units)), &
               'nc_write_model_atts', trim(string1)//' put_att units' )
 
+      if     (progvar(ivar)%has_fill_value_r4) then
+         call nc_check(nf90_put_att(ncFileID, VarID, '_FillValue', &
+                                         progvar(ivar)%fill_value_r4), &
+              'nc_write_model_atts', trim(string1)//' put_att _FillValue' )
+      elseif (progvar(ivar)%has_fill_value_r8) then
+         call nc_check(nf90_put_att(ncFileID, VarID, '_FillValue', &
+                                         progvar(ivar)%fill_value_r8), &
+              'nc_write_model_atts', trim(string1)//' put_att _FillValue' )
+      endif
+
    enddo
 
    ! Finished with dimension/variable definitions, must end 'define' mode to fill.
@@ -1634,11 +1648,6 @@
 
 TimeDimID = find_time_dimension(ncid, filename, last_file_time)
 
-if (TimeDimID < 0) then
-   write(string1,*) trim(filename)//' has no "ocean_time" coordinate variable.'
-   call error_handler(E_ERR,'restart_file_to_sv:',string1,source,revision,revdate)
-endif
-
 if (TimeDimID /= unlimitedDimID) then
    write(string1,*)'Time dimension is not the unlimited dimension in '//trim(filename)
    write(string2,*)'Time      dimension is dimension ID ',TimeDimID
@@ -1821,12 +1830,8 @@
 
 TimeDimID = find_time_dimension( ncFileID, filename )
 
-if ( TimeDimID > 0 ) then
-   call nc_check(nf90_inquire_dimension(ncFileID, TimeDimID, len=TimeDimLength), &
-            'sv_to_restart_file', 'inquire timedimlength '//trim(filename))
-else
-   TimeDimLength = 0
-endif
+call nc_check(nf90_inquire_dimension(ncFileID, TimeDimID, len=TimeDimLength), &
+              'sv_to_restart_file', 'inquire timedimlength '//trim(filename))
 
 PROGVARLOOP : do ivar=1, nfields
 
@@ -2360,11 +2365,11 @@
 
 subroutine verify_variables( state_variables, ncid, filename, ngood, table )
 
-character(len=*), intent(in)    :: state_variables(:)
-integer,          intent(in)    :: ncid
-character(len=*), intent(in)    :: filename
-integer,          intent(out)   :: ngood
-character(len=*), intent(inout) :: table(:,:)
+character(len=*), intent(in)  :: state_variables(:)
+integer,          intent(in)  :: ncid
+character(len=*), intent(in)  :: filename
+integer,          intent(out) :: ngood
+character(len=*), intent(out) :: table(:,:)
 
 integer :: nrows, ncols, i, VarID
 character(len=NF90_MAX_NAME) :: varname
@@ -3618,7 +3623,8 @@
 !> @param x the DART state vector.
 !> @param var_type the DART KIND of interest.
 !>
-!> @ todo FIXME Johnny has a better way to do this.
+!> @ todo FIXME Johnny may have a better way to do this if everything stays
+!>        rectangular. (i.e. not squeezing out the dry columns)
 
 function get_val(lon_index, lat_index, level_index, x, var_type)
 
@@ -3648,7 +3654,6 @@
    enddo
 enddo
 
-
 end function get_val
 
 

Modified: DART/trunk/models/ROMS/model_mod_check.f90
===================================================================
--- DART/trunk/models/ROMS/model_mod_check.f90	2016-01-08 23:13:05 UTC (rev 9479)
+++ DART/trunk/models/ROMS/model_mod_check.f90	2016-01-08 23:38:05 UTC (rev 9480)
@@ -262,11 +262,7 @@
    write(*,*)
    write(*,*)'------------------ Test #7 - find_closest_gridpoint() --------------'
 
-   if ( loc_of_interest(1) > 0.0_r8 ) then
-      write(*,*)'Skipping test because loc_of_interest not fully specified.'
-   else
-      call find_closest_gridpoint( loc_of_interest )
-   endif
+   call find_closest_gridpoint( loc_of_interest )
 
    write(*,*)'------------------ Test #7 complete --------------------------------'
 

Modified: DART/trunk/models/ROMS/work/input.nml
===================================================================
--- DART/trunk/models/ROMS/work/input.nml	2016-01-08 23:13:05 UTC (rev 9479)
+++ DART/trunk/models/ROMS/work/input.nml	2016-01-08 23:38:05 UTC (rev 9480)
@@ -281,7 +281,7 @@
    advance_time_present  = .FALSE.
    verbose               = .TRUE.
    test1thru             = 11
-   loc_of_interest       = 320.0, 18.0, 5.0
+   loc_of_interest       = 289.6, 37.0, 50.0
    kind_of_interest      = 'KIND_U_CURRENT_COMPONENT'
    interp_test_lonrange  = 0.0, 359.0
    interp_test_dlon      = 1.0


More information about the Dart-dev mailing list