ShiftBackWithLapse Subroutine

public subroutine ShiftBackWithLapse(grid, dem, lapse, refelev, dt)

Shift back interpolated field to terrain surface

Arguments

Type IntentOptional Attributes Name
type(grid_real), intent(inout) :: grid
type(grid_real), intent(in) :: dem
type(grid_real), intent(in) :: lapse
real(kind=float), intent(in) :: refelev

ereference elevation

integer(kind=short), intent(in), optional :: dt

Variables

Type Visibility Attributes Name Initial
integer(kind=short), public :: deltat
integer(kind=short), public :: i
integer(kind=short), public :: j

Source Code

SUBROUTINE ShiftBackWithLapse &
!
(grid, dem, lapse, refelev, dt)

IMPLICIT NONE

!arguments with intent in:
TYPE (grid_real), INTENT(IN) :: dem
TYPE (grid_real), INTENT(IN) :: lapse
REAL (KIND = float), INTENT(IN) :: refelev !!ereference elevation
INTEGER (KIND = short), OPTIONAL, INTENT(IN) :: dt

!arguments with intent inout:
TYPE (grid_real), INTENT(INOUT) :: grid

!local declarations:
INTEGER (KIND = short) :: i,j
INTEGER (KIND = short) :: deltat

!------------end of declaration------------------------------------------------

IF (PRESENT (dt)) THEN
   deltat = dt
ELSE
   deltat = 1.
END IF

DO i = 1, grid % idim
    DO j = 1, grid % jdim
			   
				IF (grid % mat(i,j) == grid % nodata) CYCLE
				 
				grid % mat(i,j) = grid % mat(i,j) - &
				              (refelev - dem % mat(i,j)) * &
				              lapse % mat(i,j) * deltat
    END DO
END DO

RETURN
END SUBROUTINE ShiftBackWithLapse