source: NEMO/trunk/src/OCE/OBS/grt_cir_dis.h90

Last change on this file was 13226, checked in by orioltp, 10 months ago

Merging dev_r12512_HPC-04_mcastril_Mixed_Precision_implementation into the trunk

  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-fortran
File size: 1.6 KB
Line 
1   !!----------------------------------------------------------------------
2   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
3   !! $Id$
4   !! Software governed by the CeCILL license (see ./LICENSE)
5   !!----------------------------------------------------------------------
6
7   REAL(KIND=wp) FUNCTION grt_cir_dis( pa1, pa2, pb1, pb2, pc1, pc2 )
8      !!----------------------------------------------------------------------
9      !!                     *** FUNCTION grt_cir_dis ***
10      !!
11      !! ** Purpose : Great circle distance between pts (lat1,lon1)
12      !!               & (lat2,lon2)
13      !!                   
14      !! ** Method   : Geometry.
15      !!
16      !! History :
17      !!        !  1995-12 (G. Madec, E. Durand, A. Weaver, N. Daget) Original
18      !!        !  2006-03 (A. Vidard) Migration to NEMOVAR
19      !!        !  2006-10 (A. Weaver) Cleanup
20      !!----------------------------------------------------------------------
21     
22      !! * Arguments
23      REAL(KIND=wp) :: pa1   !  sin(lat1)
24      REAL(KIND=wp) :: pa2   !  sin(lat2)
25      REAL(KIND=wp) :: pb1   !  cos(lat1) * cos(lon1)
26      REAL(KIND=wp) :: pb2   !  cos(lat2) * cos(lon2)
27      REAL(KIND=wp) :: pc1   !  cos(lat1) * sin(lon1)
28      REAL(KIND=wp) :: pc2   !  cos(lat2) * sin(lon2)
29
30      REAL(KIND=wp) :: cosdist ! cosine of great circle distance
31
32      ! Compute cosine of great circle distance, constraining it to be between
33      ! -1 and 1 (rounding errors can take it slightly outside this range
34      cosdist = MAX( MIN( pa1 * pa2 + pb1 * pb2 + pc1 * pc2, 1.0_wp), -1.0_wp )
35
36      grt_cir_dis = &
37         &  ASIN( SQRT( 1.0_wp - cosdist**2.0_wp ) )
38     
39   END FUNCTION grt_cir_dis
Note: See TracBrowser for help on using the repository browser.