anchor.diff:              do j=1,ny
                   do i=1,nz
                       ! slp = pressure(:,i,j) / (1 - 2.25577E-5 * z_lo(:,i,j))**5.25588
  -                    pressure(:,i,j) = pressure(:,i,j) * (1 - 2.25577e-5 * (z_hi(:,i,j)-z_lo(:,i,j)))**5.25588
  +                    pressure(:,i,j) = pressure(:,i,j) * (1 - 2.25577e-5 * (z_hi(:,i,j)-z_lo(:,min(i, nz_lo),j)))**5.25588
                   enddo
               enddo
               !$omp end do
  
positive.code: !                     e = qv(:,:,j) * pressure(:,:,j) / (0.62197+qv(:,:,j))
  
                      ! change in elevation (note reverse direction from "expected" because the formula is an SLP reduction)
                      dz   = (z_lo(:,i,j) - z_hi(:,i,j))
  
                      ! lapse rate (not sure if this should be positive or negative)
                      ! dTdz = (loresT(:,:,j) - hiresT(:,:,j)) / dz
                      ! mean temperature between levels
                      if (present(hiresT)) then
                          tmean= (hiresT(:,i,j) + lowresT(:,i,j)) / 2
                      else
                          tmean= lowresT(:,i,j)
                      endif
  
                      ! Actual pressure adjustment
  
negative.code:         real,dimension(:),allocatable::slp !sea level pressure [Pa]
          ! vapor pressure, change in height, change in temperature with height and mean temperature
          real,dimension(:),allocatable:: dz, tmean !, e, dTdz
          integer :: nx, ny, nz, i, j, nz_lo
          nx = size(pressure,1)
          nz = size(pressure,2)
          nz_lo = size(z_lo, 2)
          ny = size(pressure,3)
  
          if (present(lowresT)) then
  