Skip to content

Commit

Permalink
Update IS_IN_UNGRID to handle if grid lon defintions are mismatched (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
JessicaMeixner-NOAA authored Dec 13, 2024
1 parent d82913b commit 488e3c8
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions model/src/w3triamd.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1716,7 +1716,7 @@ SUBROUTINE IS_IN_UNGRID(IMOD, XTIN, YTIN, ITOUT, IS, JS, RW)
!/ ------------------------------------------------------------------- /
!local parameters

DOUBLE PRECISION :: x1, x2, x3
DOUBLE PRECISION :: x1, x2, x3, XTINmod, xavg
DOUBLE PRECISION :: y1, y2, y3
DOUBLE PRECISION :: s1, s2, s3, sg1, sg2, sg3
REAL*8 :: PT(3,2)
Expand Down Expand Up @@ -1748,19 +1748,26 @@ SUBROUTINE IS_IN_UNGRID(IMOD, XTIN, YTIN, ITOUT, IS, JS, RW)
!coordinates of the 3rd vertex C
x3 = PT(3,1)
y3 = PT(3,2)
!with M = (XTIN,YTIN) the target point ...
!ensure XTIN is defined with same coordinates as element
xavg=(x1+x2+x3)/3
IF (ABS(XTIN-xavg).GT.180) THEN
XTINmod=XTIN-SIGN(360.0d0,(XTIN-xavg))
ELSE
XTINmod=XTIN
END IF
!with M = (XTINmod,YTIN) the target point ...
!vector product of AB and AC
sg3=(y3-y1)*(x2-x1)-(x3-x1)*(y2-y1)
!vector product of AB and AM
s3=(YTIN-y1)*(x2-x1)-(XTIN-x1)*(y2-y1)
s3=(YTIN-y1)*(x2-x1)-(XTINmod-x1)*(y2-y1)
!vector product of BC and BA
sg1=(y1-y2)*(x3-x2)-(x1-x2)*(y3-y2)
!vector product of BC and BM
s1=(YTIN-y2)*(x3-x2)-(XTIN-x2)*(y3-y2)
s1=(YTIN-y2)*(x3-x2)-(XTINmod-x2)*(y3-y2)
!vector product of CA and CB
sg2=(y2-y3)*(x1-x3)-(x2-x3)*(y1-y3)
!vector product of CA and CM
s2=(YTIN-y3)*(x1-x3)-(XTIN-x3)*(y1-y3)
s2=(YTIN-y3)*(x1-x3)-(XTINmod-x3)*(y1-y3)
IF ((s1*sg1.GE.0).AND.(s2*sg2.GE.0).AND.(s3*sg3.GE.0)) THEN
itout=ITRI
nbFound=nbFound+1
Expand Down

0 comments on commit 488e3c8

Please sign in to comment.