[e200b7a] | 1 | !********************************************************************** |
---|
| 2 | ! Copyright 1998,1999,2000,2001,2002,2005,2007,2008,2009,2010 * |
---|
| 3 | ! Andreas Stohl, Petra Seibert, A. Frank, Gerhard Wotawa, * |
---|
| 4 | ! Caroline Forster, Sabine Eckhardt, John Burkhart, Harald Sodemann * |
---|
| 5 | ! * |
---|
| 6 | ! This file is part of FLEXPART. * |
---|
| 7 | ! * |
---|
| 8 | ! FLEXPART is free software: you can redistribute it and/or modify * |
---|
| 9 | ! it under the terms of the GNU General Public License as published by* |
---|
| 10 | ! the Free Software Foundation, either version 3 of the License, or * |
---|
| 11 | ! (at your option) any later version. * |
---|
| 12 | ! * |
---|
| 13 | ! FLEXPART is distributed in the hope that it will be useful, * |
---|
| 14 | ! but WITHOUT ANY WARRANTY; without even the implied warranty of * |
---|
| 15 | ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
---|
| 16 | ! GNU General Public License for more details. * |
---|
| 17 | ! * |
---|
| 18 | ! You should have received a copy of the GNU General Public License * |
---|
| 19 | ! along with FLEXPART. If not, see <http://www.gnu.org/licenses/>. * |
---|
| 20 | !********************************************************************** |
---|
| 21 | |
---|
| 22 | !----------------------------------------------------------------------- |
---|
| 23 | function distance(rlat1,rlon1,rlat2,rlon2) |
---|
| 24 | |
---|
| 25 | !$$$ SUBPROGRAM DOCUMENTATION BLOCK |
---|
| 26 | ! |
---|
| 27 | ! SUBPROGRAM: GCDIST COMPUTE GREAT CIRCLE DISTANCE |
---|
| 28 | ! PRGMMR: IREDELL ORG: W/NMC23 DATE: 96-04-10 |
---|
| 29 | ! |
---|
| 30 | ! ABSTRACT: THIS SUBPROGRAM COMPUTES GREAT CIRCLE DISTANCE |
---|
| 31 | ! BETWEEN TWO POINTS ON THE EARTH. |
---|
| 32 | ! |
---|
| 33 | ! PROGRAM HISTORY LOG: |
---|
| 34 | ! 96-04-10 IREDELL |
---|
| 35 | ! |
---|
| 36 | ! USAGE: ...GCDIST(RLAT1,RLON1,RLAT2,RLON2) |
---|
| 37 | ! |
---|
| 38 | ! INPUT ARGUMENT LIST: |
---|
| 39 | !rlat1 - REAL LATITUDE OF POINT 1 IN DEGREES |
---|
| 40 | !rlon1 - REAL LONGITUDE OF POINT 1 IN DEGREES |
---|
| 41 | !rlat2 - REAL LATITUDE OF POINT 2 IN DEGREES |
---|
| 42 | !rlon2 - REAL LONGITUDE OF POINT 2 IN DEGREES |
---|
| 43 | ! |
---|
| 44 | ! OUTPUT ARGUMENT LIST: |
---|
| 45 | !distance - REAL GREAT CIRCLE DISTANCE IN KILOMETERS |
---|
| 46 | ! |
---|
| 47 | ! ATTRIBUTES: |
---|
| 48 | ! LANGUAGE: Fortran 90 |
---|
| 49 | ! |
---|
| 50 | !$$$ |
---|
| 51 | |
---|
| 52 | use par_mod, only: dp |
---|
| 53 | |
---|
| 54 | implicit none |
---|
| 55 | |
---|
| 56 | real :: rlat1,rlon1,rlat2,rlon2,distance |
---|
| 57 | real(kind=dp) :: clat1,clat2,slat1,slat2,cdlon,crd |
---|
| 58 | real(kind=dp),parameter :: rerth=6.3712e6_dp |
---|
| 59 | real(kind=dp),parameter :: pi=3.14159265358979_dp, dpr=180.0_dp/pi |
---|
| 60 | ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
---|
| 61 | if ((abs(rlat1-rlat2).lt.0.03).and. & |
---|
| 62 | (abs(rlon1-rlon2).lt.0.03)) then |
---|
| 63 | distance=0. |
---|
| 64 | else |
---|
| 65 | clat1=cos(real(rlat1,kind=dp)/dpr) |
---|
| 66 | slat1=sin(real(rlat1,kind=dp)/dpr) |
---|
| 67 | clat2=cos(real(rlat2,kind=dp)/dpr) |
---|
| 68 | slat2=sin(real(rlat2,kind=dp)/dpr) |
---|
| 69 | cdlon=cos(real((rlon1-rlon2),kind=dp)/dpr) |
---|
| 70 | crd=slat1*slat2+clat1*clat2*cdlon |
---|
| 71 | distance=real(rerth*acos(crd)/1000.0_dp) |
---|
| 72 | endif |
---|
| 73 | ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
---|
| 74 | end function distance |
---|