planimeter.for 955 Bytes
Newer Older
Valentin Platzgummer's avatar
Valentin Platzgummer committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
*> @file planimeter.for
*! @brief A test program for area()

*> A simple program to compute the area of a geodesic polygon.
*!
*! This program reads in up to 100000 lines with lat, lon for each vertex
*! of a polygon.  At the end of input, the program prints the number of
*! vertices, the perimeter of the polygon and its area (for the WGS84
*! ellipsoid).

      program planimeter
      implicit none

      include 'geodesic.inc'

      integer maxpts
      parameter (maxpts = 100000)
      double precision a, f, lats(maxpts), lons(maxpts), S, P
      integer n

* WGS84 values
      a = 6378137d0
      f = 1/298.257223563d0

      n = 0
 10   continue
      if (n .ge. maxpts) go to 20
      read(*, *, end=20, err=20) lats(n+1), lons(n+1)
      n = n+1
      go to 10
 20   continue
      call area(a, f, lats, lons, n, S, P)
      print 30, n, P, S
 30   format(i6, 1x, f20.8, 1x, f20.3)
      stop
      end