Fortran library for Geodesics  1.40
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
Geodesic routines implemented in Fortran
Author
Charles F. F. Karney (charl.nosp@m.es@k.nosp@m.arney.nosp@m..com)
Version
1.40

Abstract

This is a Fortran implementation of the geodesic algorithms from GeographicLib. This is a self-contained library which makes it easy to do geodesic computations for an ellipsoid of revolution in a Fortran program. It is written in Fortran 77 (avoiding features which are now deprecated) and should compile correctly with just about any Fortran compiler.

Download

The Fortran library is part of GeographicLib which available for download at

as either a compressed tar file (tar.gz) or a zip file. After unpacking the source, the Fortran library can be found in GeographicLib-1.40/legacy/Fortran. The library consists of the file geodesic.for.

Library documentation

The interface to the library is documented via doxygen in the source file. To access this, see geodesic.for.

Sample programs

Also included are 3 small test programs:

Here, for example, is geodinverse.for

*> @file geodinverse.for
*! @brief A test program for invers()
*> A simple program to solve the inverse geodesic problem.
*!
*! This program reads in lines with lat1, lon1, lon2, lat2 and prints
*! out lines with azi1, azi2, s12 (for the WGS84 ellipsoid).
program geodinverse
implicit none
include 'geodesic.inc'
double precision a, f, lat1, lon1, azi1, lat2, lon2, azi2, s12,
+ dummy
integer omask
* WGS84 values
a = 6378137d0
f = 1/298.257223563d0
omask = 0
10 continue
read(*, *, end=90, err=90) lat1, lon1, lat2, lon2
call invers(a, f, lat1, lon1, lat2, lon2,
+ s12, azi1, azi2, omask, dummy, dummy, dummy, dummy, dummy)
print 20, azi1, azi2, s12
20 format(f20.15, 1x, f20.15, 1x, f19.10)
go to 10
90 continue
stop
end

To compile, link, and run this, you would typically use

f95 -o geodinverse geodinverse.for geodesic.for
echo 30 0 29.5 179.5 | ./geodinverse 

These sample programs can also be built with the supplied cmake file, CMakeLists.txt, as follows

mkdir BUILD
cd BUILD
cmake ..
make
echo 30 0 29.5 179.5 | ./geodinverse 

Finally, the two programs

which are also built with cmake, provide drop-in replacements for replacements for the NGS tools FORWARD and INVERSE available from http://www.ngs.noaa.gov/PC_PROD/Inv_Fwd/. These cure two problems of the Vincenty algorithms used by NGS:

The corresponding source files

are derived from the NGS source files

and are therefore in the public domain.

Using the library

External links