program heron
  implicit none
  interface
    logical function triangleTest(a,b,c)
      real,intent(in)::a,b,c
    end function triangleTest
    real function area(a,b,c)
      real,intent(in)::a,b,c
    endfunction area
  endinterface

  real::a,b,c,triangleArea
  do
    read(*,*) a,b,c
    if(triangleTest(a,b,c)) exit
    write(*,*) 'your input CAN NOT form a triangle. Try again please'
  enddo
  triangleArea=area(a,b,c)
  write(*,*) 'Triangle area is',triangleArea
endprogram heron

!-----here goes definition of functions declared in the interface
!-----below declarations can be external (in another file) as well
!----- subroutines can also go here the same way functions go

logical function triangleTest(a,b,c)
  implicit none
  real,intent(in)::a,b,c
  logical :: test1,test2
  test1=(a>0.0) .and. (b>0.0) .and. (c>0.0)
  test2=(a+b>c) .and. (b+c>a) .and. (c+a>b)
  triangleTest= test1 .and. test2
endfunction triangleTest

real function area(a,b,c)
  implicit none
  real,intent(in)::a,b,c
  real::s
  s=(a+b+c)/2.0
  area=sqrt(s*(s-a)*(s-b)*(s-c))
endfunction area
