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 branches/nemo_v3_3_beta/NEMOGCM/NEMO/OPA_SRC/OBS – NEMO

source: branches/nemo_v3_3_beta/NEMOGCM/NEMO/OPA_SRC/OBS/linquad.h90 @ 2281

Last change on this file since 2281 was 2281, checked in by smasson, 14 years ago

set proper svn properties to all files...

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