anchor.diff:          endif
   
           if (use_spatial_linear_fields) then
  -            if ((.not.allocated(hi_u_LUT) .and. (.not.reverse)) .or. ((.not.allocated(rev_u_LUT)) .and. reverse)) then
  -                ! Need linear_contribution to be 1 for initialize_spatial_winds, it will be applied at "real" time. 
  -                ! should probably set linear_mask to 1 too... for not linear_mask is set at LUT creation. 
  -                if (.not.allocated(linear_mask)) then
  -                    allocate(linear_mask(nx,ny))
  -                    linear_mask = linear_contribution
  -                endif
  -                linear_mask = linear_mask / linear_contribution
  -                saved_linear_contribution = linear_contribution
  -                linear_contribution = 1.0
  +            if    ((.not.allocated(hi_u_LUT)  .and. (.not.reverse)) &
  +             .or.  (.not.allocated(rev_u_LUT) .and. reverse)) then
  +
  +                write(*,*) "Generating a spatially variable linear perturbation look up table"
  +                call initialize_spatial_winds(domain, options, reverse)
                   
  -                write(*,*) "Generating a spatially variable linear perturbation look up table"
  -                call initialize_spatial_winds(domain, options, reverse, useDensity)
  -                
  -                linear_contribution = saved_linear_contribution
  -                linear_mask = linear_mask * linear_contribution
  -                
  -                if (reverse) then
  -                    rev_u_LUT = rev_u_LUT * linear_contribution
  -                    rev_v_LUT = rev_v_LUT * linear_contribution
  -                else
  -                    hi_u_LUT = hi_u_LUT * linear_contribution
  -                    hi_v_LUT = hi_v_LUT * linear_contribution
  -                endif
  -            endif
  -            if (minval(linear_mask) > linear_contribution) then
  -                print*, minval(linear_mask), maxval(linear_mask), linear_contribution
  -                write(*,*) " "
  -                write(*,*) "  ---------------  !!!WARNING!!!  --------------- "
  -                write(*,*) " Spatially variable linear mask is fixed at LUT creation"
  -                write(*,*) " If the LUT was read from disk it could be 'wrong' "
  -                write(*,*) "  ---------------  !!!WARNING!!!  --------------- "
  -                write(*,*) " "
               endif
           endif
   
  
positive.code:         end do
          !$omp end do
          !$omp end parallel
  
      end subroutine spatial_winds
  
      !>----------------------------------------------------------
  
negative.code:                                                                 +domain%qrain(i,j,k)+domain%qsnow(i,j,k))
                          domain%nsquared(i,j,k) = max(min(domain%nsquared(i,j,k) * nsq_calibration(i,k), max_stability), min_stability)
                      else
                          ! Low-res boundary condition variables will be in a different array format.  It should be 
                          ! easy enough to call calc_stability after e.g. transposing z and y dimension, but some
                          ! e.g. pii will not be set in the forcing data, so this may need a little thought. 
                          domain%nsquared(i,j,k) = 3e-6
                      endif
                  end do
  