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.
linquad.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/linquad.h90 @ 15540

Last change on this file since 15540 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.3 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   LOGICAL FUNCTION linquad( px, py, pxv, pyv )
8      !!----------------------------------------------------------------------
9      !!                    ***  FUNCTION linquad ***
10      !!
11      !! ** Purpose : Determine whether a point P(x,y) lies within or on the
12      !!              boundary of a quadrangle (ABCD) of any shape on a plane.
13      !!
14      !! ** Method  : Check if the vectorial products PA x PC, PB x PA,
15      !!              PC x PD, and PD x PB are all negative.
16      !!
17      !! ** Action  :
18      !!
19      !! History :
20      !!        !  2001-11  (N. Daget, A. Weaver)
21      !!        !  2006-08  (A. Weaver) NEMOVAR migration
22      !!        !  2006-10  (A. Weaver) Cleanup
23      !!----------------------------------------------------------------------
24
25      !! * Arguments
26      REAL(KIND=dp), INTENT(IN) :: px        ! (lon) of the point P(x,y)
27      REAL(KIND=dp), INTENT(IN) :: py        ! (lat) of the point P(x,y)               
28      REAL(KIND=dp), DIMENSION(4), INTENT(IN) ::  pxv, pyv ! (lon, lat) of the surrounding cell
29
30
31
32 
33      !! * Local declarations
34      REAL(KIND=dp) :: zst1
35      REAL(KIND=dp) :: zst2
36      REAL(KIND=dp) :: zst3
37      REAL(KIND=dp) :: zst4
38
39      !-----------------------------------------------------------------------
40      ! Test to see if the point is within the cell
41      !-----------------------------------------------------------------------
42      linquad = .FALSE.
43      zst1 =   ( px - pxv(1) ) * ( py - pyv(4) ) &
44         &   - ( py - pyv(1) ) * ( px - pxv(4) )
45      IF ( zst1 <= 0.0 ) THEN
46         zst2 =   ( px - pxv(4) ) * ( py - pyv(3) ) &
47         &   - ( py - pyv(4) ) * ( px - pxv(3) )
48         IF ( zst2 <= 0.0 ) THEN
49            zst3 =   ( px - pxv(3) ) * ( py - pyv(2) ) &
50               &   - ( py - pyv(3) ) * ( px - pxv(2) )
51            IF ( zst3 <= 0.0) THEN
52               zst4 =   ( px - pxv(2) ) * ( py - pyv(1) ) &
53                  &   - ( py - pyv(2) ) * ( px - pxv(1) )
54               IF ( zst4 <= 0.0 ) linquad = .TRUE.
55            ENDIF
56         ENDIF
57      ENDIF
58
59   END FUNCTION linquad
60
Note: See TracBrowser for help on using the repository browser.