forked from dnowacki-usgs/swanmod
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SwanBndStruc.f90
232 lines (232 loc) · 7.04 KB
/
SwanBndStruc.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
subroutine SwanBndStruc ( xcgrid, ycgrid )
!
! --|-----------------------------------------------------------|--
! | Delft University of Technology |
! | Faculty of Civil Engineering |
! | Environmental Fluid Mechanics Section |
! | P.O. Box 5048, 2600 GA Delft, The Netherlands |
! | |
! | Programmers: The SWAN team |
! --|-----------------------------------------------------------|--
!
!
! SWAN (Simulating WAves Nearshore); a third generation wave model
! Copyright (C) 1993-2015 Delft University of Technology
!
! This program is free software; you can redistribute it and/or
! modify it under the terms of the GNU General Public License as
! published by the Free Software Foundation; either version 2 of
! the License, or (at your option) any later version.
!
! This program is distributed in the hope that it will be useful,
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
!
! A copy of the GNU General Public License is available at
! http://www.gnu.org/copyleft/gpl.html#SEC3
! or by writing to the Free Software Foundation, Inc.,
! 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
!
!
! Authors
!
! 41.14: Nico Booij
!
! Updates
!
! 41.14, Aug. 2010: New subroutine
!
! Purpose
!
! Generates output curves 'BOUNDARY' and 'BOUND_01' until 'BOUND_04'
! in the case of a structured grid (both regular and curvilinear).
!
! Method
!
! The procedure starts at the origin of the grid, and then moves
! around the grid in counterclockwise order.
!
! Modules used
!
use ocpcomm4
use SWCOMM1
use SWCOMM2
use SWCOMM3
use OUTP_DATA
!
implicit none
!
! Argument variables
!
real, dimension(MXC,MYC), intent(in) :: xcgrid ! x-coordinate of computational grid
real, dimension(MXC,MYC), intent(in) :: ycgrid ! y-coordinate of computational grid
!
! Local variables
!
integer :: ix, iy ! point index
integer :: ibnd ! number of valid points along boundary
integer :: iside ! side counter (1..4)
integer :: lside ! number of points on one side
integer :: ispt ! number of valid points on one side
integer :: mip ! number of output points
integer :: xstep, ystep
integer :: ix0, ix1, iy0, iy1
integer :: ii, jj ! counters
integer, save :: ient = 0 ! number of entries in this subroutine
!
logical, save :: done=.false. ! if true procedure has been done
logical :: EQREAL ! function
!
real :: xp, yp ! one boundary point
real, allocatable, dimension (:) :: xbnd, ybnd ! points of whole boundary
real, allocatable, dimension (:) :: xsid, ysid ! points of one side
!
character(80) :: msgstr ! string to pass message
character(len=8) :: psname ! name assigned to output curve
!
TYPE(OPSDAT), POINTER :: OPSTMP, ROPS
!
! Structure
!
! Description of the pseudo code
!
! Source text
!
if (ltrace) call strace (ient,'SwanBndStruc')
!
! if list of boundary vertices is already filled, return
!
if (done) return
!
if (.not.allocated(xbnd)) allocate (xbnd(1:2*(mxc+myc-2)))
if (.not.allocated(ybnd)) allocate (ybnd(1:2*(mxc+myc-2)))
ibnd = 0
do iside = 1, 4
if (iside==1) then
ix0 = 1
ix1 = mxc
xstep = 1
iy0 = 1
iy1 = 1
ystep = 0
lside = mxc
elseif (iside==2) then
ix0 = mxc
ix1 = mxc
xstep = 0
iy0 = 1
iy1 = myc
ystep = 1
lside = myc
elseif (iside==3) then
ix0 = mxc
ix1 = 1
xstep = -1
iy0 = myc
iy1 = myc
ystep = 0
lside = mxc
elseif (iside==4) then
ix0 = 1
ix1 = 1
xstep = 0
iy0 = myc
iy1 = 1
ystep = -1
lside = myc
endif
!
if (.not.allocated(xsid)) allocate (xsid(1:lside))
if (.not.allocated(ysid)) allocate (ysid(1:lside))
ix = ix0
iy = iy0
ispt = 0
!
do ii = 1, lside
!
! loop over points of one side of the grid
!
xp = xcgrid(ix,iy)
yp = ycgrid(ix,iy)
if (.not.(EQREAL(xp,OVEXCV(1)).or.EQREAL(yp,OVEXCV(2)))) then
! point has valid coordinates
ispt = ispt + 1
xsid(ispt) = xp
ysid(ispt) = yp
if (ii<lside) then
! corner point appears only once in curve BOUNDARY
ibnd = ibnd + 1
xbnd(ibnd) = xp
ybnd(ibnd) = yp
endif
endif
if (ystep==0) then
ix = ix + xstep
else
iy = iy + ystep
endif
enddo
!
write (psname, '(A6, I2.2)') 'BOUND_', iside
mip = ispt
if (mip>0) then
allocate(OPSTMP)
OPSTMP%PSNAME = psname
OPSTMP%PSTYPE = 'C'
OPSTMP%MIP = mip
allocate(OPSTMP%XP(mip))
allocate(OPSTMP%YP(mip))
do jj = 1, mip
OPSTMP%XP(jj) = xsid(jj)
OPSTMP%YP(jj) = ysid(jj)
enddo
deallocate (xsid, ysid)
nullify (OPSTMP%NEXTOPS)
if ( .not.LOPS ) then
FOPS = OPSTMP
COPS => FOPS
LOPS = .TRUE.
else
COPS%NEXTOPS => OPSTMP
COPS => OPSTMP
endif
if (ITEST>=10) write (PRTEST, *) 'Output curve ', psname, &
' with ', mip, ' points is generated'
else
call MSGERR(1,'No output points found in '//psname)
endif
enddo
!
psname = 'BOUNDARY'
mip = ibnd
if (mip>0) then
allocate(OPSTMP)
OPSTMP%PSNAME = psname
OPSTMP%PSTYPE = 'C'
OPSTMP%MIP = mip
allocate(OPSTMP%XP(mip))
allocate(OPSTMP%YP(mip))
do jj = 1, mip
OPSTMP%XP(jj) = xbnd(jj)
OPSTMP%YP(jj) = ybnd(jj)
enddo
deallocate(xbnd,ybnd)
nullify (OPSTMP%NEXTOPS)
if ( .not.LOPS ) then
FOPS = OPSTMP
COPS => FOPS
LOPS = .TRUE.
else
COPS%NEXTOPS => OPSTMP
COPS => OPSTMP
endif
if (ITEST>=10) write (PRTEST, *) 'Output curve ', psname, &
' with ', mip, ' points is generated'
else
call MSGERR(1,'No output points found in '//psname)
endif
!
done = .true. ! prevents second entry into this subroutine
!
end subroutine SwanBndStruc