Perimeter Function

public function Perimeter(grid) result(p)

find the cells that are springs, defined as those cells that have not any other cells upstream

Arguments

Type IntentOptional Attributes Name
type(grid_integer), intent(in) :: grid

Return Value real(kind=float)


Variables

Type Visibility Attributes Name Initial
type(grid_integer), public :: border
integer, public :: i
integer, public :: j

Source Code

FUNCTION Perimeter &
!
(grid) &
!
RESULT (p)

IMPLICIT NONE

! Arguments with intent(in):
TYPE (grid_integer), INTENT(IN) :: grid

! Local variables:
REAL (KIND = float) :: p
TYPE (grid_integer) :: border
INTEGER :: i,j

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


CALL ExtractBorder (grid, border, cardinal = .TRUE.)

p = 0.

DO i = 1, border % idim
    DO j = 1, border % jdim
        IF (border % mat (i,j) /= border % nodata ) THEN
            p = p + CellLength (border, i,j)
        END IF
    END DO
END DO

!increase a default value of 9% to consider diagonal length

p = p * 1.09

CALL GridDestroy (border)


RETURN
END FUNCTION Perimeter