anchor.diff:                  end do
               end do
           endif
  -!       allocate(real_terrain(nx,ny))
  -!       real_terrain=buffer_topo
  -!       call io_write2d("complex_terrain.nc","data",real_terrain)
  -!       deallocate(real_terrain)
  +        
  +        if (present(debug)) then
  +            if (debug) then
  +                allocate(real_terrain(nx,ny))
  +                real_terrain=buffer_topo
  +                call io_write2d("buffered_terrain.nc","data",real_terrain)
  +                deallocate(real_terrain)
  +            endif
  +        endif
           
       end subroutine add_buffer_topo
       
  
positive.code:             buffer_topo(:,ny-pos) =buffer_topo(:,buffer+1)*(  weight) + buffer_topo(:,ny-buffer)*(1-weight)
          enddo
          
          if (smooth_window>0) then
              do j=1,buffer
                  window=min(j,smooth_window)
                  do i=1,nx
                      xs=max(1, i-window)
                      xe=min(nx,i+window)
  
negative.code:         
          if (.not.data_allocated) then
              if (debug) then
                  write(*,"(A,A)") char(13),"Allocating Linear Wind Data and FFTW plans"
              endif
              ! using fftw_alloc routines to ensure better allignment for vectorization
              n_elements=nx*ny*nz
  