Changeset 2554 in lmdz_wrf for trunk/tools/module_scientific.f90
- Timestamp:
- May 24, 2019, 8:57:12 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/module_scientific.f90
r2553 r2554 4941 4941 REAL(r_k), DIMENSION(2,2) :: face, faceA 4942 4942 LOGICAL, DIMENSION(dx,dy) :: within 4943 REAL(r_k), DIMENSION(:,:), ALLOCATABLE :: gridpoly 4943 4944 4944 4945 !!!!!!! Variables … … 4990 4991 END DO 4991 4992 4992 ! Getting grid faces4993 DO iv=1, Nvertexmax-14994 IF (.NOT.within(ix,iy)) THEN4995 IF (xBvals(ix,iy,iv) /= fillvalI) THEN4996 face(1,:) = (/ xBvals(ix,iy,iv), yBvals(ix,iy,iv) /)4997 face(2,:) = (/ xBvals(ix,iy,iv+1), yBvals(ix,iy,iv+1) /)4998 DO ivA=1, NvertexA-14999 faceA(1,:) = (/ polygonA(ivA,1), polygonA(ivA,2) /)5000 faceA(2,:) = (/polygonA(ivA+1,1), polygonA(ivA+1,2) /)5001 CALL intersectfaces(face, faceA, cross, crosspoint)5002 IF (cross /= 0) THEN5003 Ngridsin = Ngridsin + 15004 ! Getting coordinates5005 gridsin(Ngridsin,1) = ix5006 gridsin(Ngridsin,2) = iy5007 within(ix,iy) = .TRUE.5008 CYCLE5009 END IF5010 END DO5011 IF (.NOT.within(ix,iy)) THEN5012 faceA(1,:) = (/ polygonA(NvertexA,1), polygonA(NvertexA,2) /)5013 faceA(2,:) = (/polygonA(1,1), polygonA(1,2) /)5014 CALL intersectfaces(face, faceA, cross, crosspoint)5015 IF (cross /= 0) THEN5016 Ngridsin = Ngridsin + 15017 ! Getting coordinates5018 gridsin(Ngridsin,1) = ix5019 gridsin(Ngridsin,2) = iy5020 within(ix,iy) = .TRUE.5021 END IF5022 END IF5023 END IF5024 END IF5025 END DO5026 iv = Nvertexmax5027 IF (.NOT.within(ix,iy)) THEN5028 IF (xBvals(ix,iy,iv) /= fillvalI) THEN5029 face(1,:) = (/ xBvals(ix,iy,iv), yBvals(ix,iy,iv) /)5030 face(2,:) = (/ xBvals(ix,iy,1), yBvals(ix,iy,1) /)5031 DO ivA=1, NvertexA-15032 faceA(1,:) = (/ polygonA(ivA,1), polygonA(ivA,2) /)5033 faceA(2,:) = (/polygonA(ivA+1,1), polygonA(ivA+1,2) /)5034 CALL intersectfaces(face, faceA, cross, crosspoint)5035 IF (cross /= 0) THEN5036 Ngridsin = Ngridsin + 15037 ! Getting coordinates5038 gridsin(Ngridsin,1) = ix5039 gridsin(Ngridsin,2) = iy5040 within(ix,iy) = .TRUE.5041 CYCLE5042 END IF5043 END DO5044 IF (.NOT.within(ix,iy)) THEN5045 faceA(1,:) = (/ polygonA(NvertexA,1), polygonA(NvertexA,2) /)5046 faceA(2,:) = (/polygonA(1,1), polygonA(1,2) /)5047 CALL intersectfaces(face, faceA, cross, crosspoint)5048 IF (cross /= 0) THEN5049 Ngridsin = Ngridsin + 15050 ! Getting coordinates5051 gridsin(Ngridsin,1) = ix5052 gridsin(Ngridsin,2) = iy5053 within(ix,iy) = .TRUE.5054 5055 END IF5056 END IF5057 END IF4993 ! ! Getting grid faces 4994 ! DO iv=1, Nvertexmax-1 4995 ! IF (.NOT.within(ix,iy)) THEN 4996 ! IF (xBvals(ix,iy,iv) /= fillvalI) THEN 4997 ! face(1,:) = (/ xBvals(ix,iy,iv), yBvals(ix,iy,iv) /) 4998 ! face(2,:) = (/ xBvals(ix,iy,iv+1), yBvals(ix,iy,iv+1) /) 4999 ! DO ivA=1, NvertexA-1 5000 ! faceA(1,:) = (/ polygonA(ivA,1), polygonA(ivA,2) /) 5001 ! faceA(2,:) = (/polygonA(ivA+1,1), polygonA(ivA+1,2) /) 5002 ! CALL intersectfaces(face, faceA, cross, crosspoint) 5003 ! IF (cross /= 0) THEN 5004 ! Ngridsin = Ngridsin + 1 5005 ! ! Getting coordinates 5006 ! gridsin(Ngridsin,1) = ix 5007 ! gridsin(Ngridsin,2) = iy 5008 ! within(ix,iy) = .TRUE. 5009 ! CYCLE 5010 ! END IF 5011 ! END DO 5012 ! IF (.NOT.within(ix,iy)) THEN 5013 ! faceA(1,:) = (/ polygonA(NvertexA,1), polygonA(NvertexA,2) /) 5014 ! faceA(2,:) = (/polygonA(1,1), polygonA(1,2) /) 5015 ! CALL intersectfaces(face, faceA, cross, crosspoint) 5016 ! IF (cross /= 0) THEN 5017 ! Ngridsin = Ngridsin + 1 5018 ! ! Getting coordinates 5019 ! gridsin(Ngridsin,1) = ix 5020 ! gridsin(Ngridsin,2) = iy 5021 ! within(ix,iy) = .TRUE. 5022 ! END IF 5023 ! END IF 5024 ! END IF 5025 ! END IF 5026 ! END DO 5027 ! iv = Nvertexmax 5028 ! IF (.NOT.within(ix,iy)) THEN 5029 ! IF (xBvals(ix,iy,iv) /= fillvalI) THEN 5030 ! face(1,:) = (/ xBvals(ix,iy,iv), yBvals(ix,iy,iv) /) 5031 ! face(2,:) = (/ xBvals(ix,iy,1), yBvals(ix,iy,1) /) 5032 ! DO ivA=1, NvertexA-1 5033 ! faceA(1,:) = (/ polygonA(ivA,1), polygonA(ivA,2) /) 5034 ! faceA(2,:) = (/polygonA(ivA+1,1), polygonA(ivA+1,2) /) 5035 ! CALL intersectfaces(face, faceA, cross, crosspoint) 5036 ! IF (cross /= 0) THEN 5037 ! Ngridsin = Ngridsin + 1 5038 ! ! Getting coordinates 5039 ! gridsin(Ngridsin,1) = ix 5040 ! gridsin(Ngridsin,2) = iy 5041 ! within(ix,iy) = .TRUE. 5042 ! CYCLE 5043 ! END IF 5044 ! END DO 5045 ! IF (.NOT.within(ix,iy)) THEN 5046 ! faceA(1,:) = (/ polygonA(NvertexA,1), polygonA(NvertexA,2) /) 5047 ! faceA(2,:) = (/polygonA(1,1), polygonA(1,2) /) 5048 ! CALL intersectfaces(face, faceA, cross, crosspoint) 5049 ! IF (cross /= 0) THEN 5050 ! Ngridsin = Ngridsin + 1 5051 ! ! Getting coordinates 5052 ! gridsin(Ngridsin,1) = ix 5053 ! gridsin(Ngridsin,2) = iy 5054 ! within(ix,iy) = .TRUE. 5055 ! END IF 5056 ! END IF 5057 ! END IF 5058 ! END IF 5058 5059 5059 5060 ! Inverting process, look polygon within grid 5060 5061 IF (.NOT.within(ix,iy)) THEN 5061 DO iv = 1, NvertexA 5062 vertex = polygonA(iv,:) 5063 IF (point_inside(vertex, Nvertexmax, xBvals(ix,iy,:))) THEN 5064 Ngridsin = Ngridsin + 1 5065 ! Getting coordinates 5066 gridsin(Ngridsin,1) = ix 5067 gridsin(Ngridsin,2) = iy 5068 within(ix,iy) = .TRUE. 5069 CYCLE 5062 IF (ALLOCATED(gridpoly)) DEALLOCATE(gridpoly) 5063 ALLOCATE(gridpoly(Nvertexmax,2)) 5064 DO iv = 1, Nvertexmax 5065 gridpoly(iv,1) = xBvals(ix,iy,iv) 5066 gridpoly(iv,2) = yBvals(ix,iy,iv) 5067 END DO 5068 print *,ix,iy,'gridpoly :', gridpoly 5069 DO ivA = 1, NvertexA 5070 IF (.NOT.within(ix,iy)) THEN 5071 vertex = polygonA(ivA,:) 5072 print *,' ', ivA, 'vertex :', vertex 5073 PRINT *,' ',point_inside(vertex, Nvertexmax, gridpoly) 5074 IF (point_inside(vertex, Nvertexmax, gridpoly)) THEN 5075 Ngridsin = Ngridsin + 1 5076 ! Getting coordinates 5077 gridsin(Ngridsin,1) = ix 5078 gridsin(Ngridsin,2) = iy 5079 within(ix,iy) = .TRUE. 5080 CYCLE 5081 END IF 5070 5082 END IF 5071 5083 END DO … … 5074 5086 END DO 5075 5087 END DO 5088 5089 IF (ALLOCATED(gridpoly)) DEALLOCATE(gridpoly) 5076 5090 5077 5091 END SUBROUTINE grid_within_polygon
Note: See TracChangeset
for help on using the changeset viewer.