anchor.diff:          integer :: num_output_steps = 0
               ! Track number of output steps
   
  -        logical :: record_max_U
  -            !! Flag for whether we store max stage, etc
  -
  -        logical :: time_var_store_flag(4) = [.true. , .true., .true., .true.]
  +        !
  +        ! Time-varying variables to store.
  +        !
  +        integer :: time_var_id(4)
  +            !! netcdf variable id's for stage, uh, vh, elev
  +        character(len=charlen) :: time_var_names(4) = gridded_output_variables_time
  +            !! Names of the time-varying variables - do not change this. We turn on/off storage by
  +            !! adjusting the corresponding entry of time_var_store_flag
  +        logical :: time_var_store_flag(4) = .true. 
               !! Options to store stage/uh/vh/elev over time.
               !! .true. or .false. for STG, UH, VH, ELV
               !! For example, if we didn't want to store ELV every time-step, we
               !! would do "nc_grid_output%time_var_store_flag(ELV) = .false."
  +
  +        !
  +        ! Static variables that can be stored. These describe the solution, are real, and are only
  +        ! stored once (i.e. no time evolution)
  +        !
  +        integer :: static_var_id(6)
  +        character(len=charlen) :: static_var_names(6) = &
  +            [gridded_output_variables_max_U, gridded_output_variables_other]
  +            !! Names of solution variables that can be stored once. We turn on/off storeage
  +            !! by adjusting the static_var_store_flag
  +        logical :: static_var_store_flag(6) = .true.
  +            !! True if we want to store the corresponding variable in static_var_names, false otherwise.
   
           integer :: spatial_stride = 1
               !! Allow only storing every n'th point in x/y space.
  
positive.code:     end subroutine
  
      subroutine initialise(nc_grid_output, filename, output_precision, &
          record_max_U, xs, ys, attribute_names, attribute_values)
          !!
          !! Create nc file to hold gridded outputs
          !!
  
          class(nc_grid_output_type), intent(inout) :: nc_grid_output !!type with nc_grid_output info
          character(len=charlen), intent(in) :: filename !! Name of the output netcdf file
          integer(ip), intent(in) :: output_precision !! Fortran real kind denoting precision of output (either C_FLOAT or C_DOUBLE)
          logical, intent(in) :: record_max_U !! Do we record the max-stage ?
          real(dp), intent(in) :: xs(:), ys(:) !! array of grid x/y coordinates
          character(charlen), optional, intent(in):: attribute_names(:) !! global attribute names for netcdf file
          character(charlen), optional, intent(in):: attribute_values(:)
              !! values for global attributes of netcdf file (same length as attribute_names)
  
  
negative.code:     end subroutine
  
  
      subroutine store_static_variable(nc_grid_output, variable_name, values)
          !!
          !! Store a static flow variable (e.g. 'max-stage'), which is a variable desribing the flow that we only store once.
          !!
          class(nc_grid_output_type), intent(in) :: nc_grid_output
          character(*), intent(in) :: variable_name
          real(dp), intent(in) :: values(:,:)
  
          integer :: iNcid, spatial_start(2), nxy(2), spatial_stride(2), j, my_j
          logical :: found_var
  
          ! Gracefully compile in case we don't link with netcdf
  #ifndef NONETCDF
          spatial_start = nc_grid_output%spatial_start
          spatial_stride = nc_grid_output%spatial_stride
          nxy(1) = size(values, dim=1)
          nxy(2) = size(values, dim=2)
  
          ! Shorthand
          iNcid = nc_grid_output%nc_file_id
  
          found_var = .false.
          do j = 1, size(nc_grid_output%static_var_names)
              ! Only one 'j' will correspond to 'variable_name'
              if((trim(variable_name) == nc_grid_output%static_var_names(j)) .and. &
                 nc_grid_output%static_var_store_flag(j)) then
  
                  ! Save the variable
                  call check(nf90_put_var(&
                      iNcid, &
                      nc_grid_output%static_var_id(j), &
                      values(spatial_start(1):nxy(1):spatial_stride(1), spatial_start(2):nxy(2):spatial_stride(2))), &
                      __LINE__)
  
                  found_var = .true. ! If this is never set, we know that no variable was saved.
                  exit
              end if
          end do
  
          if(.not. found_var) then
              write(log_output_unit, *) "Cannot store static variable: ", trim(variable_name)
              call generic_stop
          end if
  
  #endif
  