New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
maxdist.h90 in NEMO/branches/2021/dev_r14116_HPC-10_mcastril_Mixed_Precision_implementation/src/OCE/OBS – NEMO

source: NEMO/branches/2021/dev_r14116_HPC-10_mcastril_Mixed_Precision_implementation/src/OCE/OBS/maxdist.h90 @ 15607

Last change on this file since 15607 was 15540, checked in by sparonuz, 3 years ago

Mixed precision version, tested up to 30 years on ORCA2.

  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-fortran
File size: 2.5 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(dp) FUNCTION maxdist( pxv, pyv )
8      !!----------------------------------------------------------------------
9      !!                    ***  FUNCTION maxdist ***
10      !!
11      !! ** Purpose : Compute the maximum distance between any points within
12      !!              a cell
13      !!
14      !! ** Method  : Call to grt_cir_dis
15      !!
16      !! ** Action  :
17      !!
18      !! History :
19      !!        !  2006-08  (K. Mogensen)
20      !!        !  2006-10  (A. Weaver) Cleanup
21      !!----------------------------------------------------------------------
22
23      !! * Arguments
24      REAL(KIND=wp), DIMENSION(4), INTENT(IN) :: &
25          & pxv, &                 ! (lon, lat) of the surrounding cell
26          & pyv   
27
28      !! * Local declarations
29      REAL(KIND=dp), DIMENSION(4) ::  zxv, zyv, za, zb, zc
30
31
32
33
34
35
36      REAL(KIND=dp) :: zdist
37     
38      INTEGER :: ji
39      INTEGER :: jj
40     
41      !-----------------------------------------------------------------------
42      ! Convert data to radians
43      !-----------------------------------------------------------------------
44      DO ji = 1, 4
45         zxv(ji) = pxv(ji) * rad
46         zyv(ji) = pyv(ji) * rad
47      END DO
48
49      !-----------------------------------------------------------------------
50      ! Prepare input to grt_cir_dis
51      !-----------------------------------------------------------------------
52      DO ji = 1, 4
53         za(ji) = SIN( zyv(ji) )
54         zb(ji) = COS( zyv(ji) ) * COS( zxv(ji) )
55         zc(ji) = COS( zyv(ji) ) * SIN( zxv(ji) )
56      END DO
57     
58      !-----------------------------------------------------------------------
59      ! Get max distance between any points in the area
60      !-----------------------------------------------------------------------
61      maxdist = 0.0
62      DO jj = 1, 4
63         DO ji = jj+1, 4
64            zdist = grt_cir_dis( za(jj), za(ji), zb(jj), &
65               &                 zb(ji), zc(jj), zc(ji))
66            IF ( zdist > maxdist ) THEN
67               maxdist = zdist
68            ENDIF
69         END DO
70      END DO
71     
72      !-----------------------------------------------------------------------
73      ! Convert to degrees.
74      !-----------------------------------------------------------------------
75      maxdist = maxdist / rad
76
77   END FUNCTION maxdist
Note: See TracBrowser for help on using the repository browser.