anchor.diff:          complex(C_DOUBLE_COMPLEX),intent(in)    :: fourier_terrain(:,:) ! FFT(terrain)
           type(linear_theory_type), intent(inout) :: lt_data          ! intermediate arrays needed for LT calc
   
  -        integer :: n_steps, i
  +        integer :: n_steps, i, nx,ny
           real    :: step_size, current_z, start_z, end_z
           real,   allocatable :: layer_count(:,:), layer_fraction(:,:)
           real,   allocatable :: internal_z_top(:,:), internal_z_bottom(:,:)
  
positive.code:         real,allocatable :: u1d(:),v1d(:)
          integer :: ims, ime, jms, jme, ims_u, ime_u, jms_v, jme_v, kms, kme
          real :: dweight, nweight, sweight, curspd, curdir, curnsq, wind_first, wind_second
          real :: blocked
  
          ! pointers to the u/v data to be updated so they can point to different places depending on the update flag
          real, pointer :: u3d(:,:,:), v3d(:,:,:), nsquared(:,:,:)
  
negative.code:                 u1d(i)  = sum(u3d(i+ims_u-1,:,uk+jms-1)) / nz
                  v1d(i)  = sum(v3d(vi+ims-1, :,k+jms_v-1)) / nz
              enddo
              ! if (this_image()==5) then
              !     if (k==nyv/2) print*, u1d(1:3)
              !     if (k==nyv/2) print*, v1d(1:3)
              ! endif
              do j=1, nz
                  do i=1, nxu
  
  