-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetmean2.f90
195 lines (168 loc) · 6.76 KB
/
getmean2.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
!=============================================================================!
subroutine getmean2( vm, y, eta, g2vm, g22vm, lny, iver)
!
! Input the mean flow profile assuming parallel flow.
! (i.e. v-velocity is forced to zero).
!
! This version of getmean also reads in the first and second derivatives
! of the boundary-layer profiles.
!=============================================================================!
use stuff
implicit none
integer :: lny
real :: vm(lny,ndof,nx), eta(lny), y(lny), ymaxm
real :: g2vm(lny,ndof,nx), g22vm(lny,ndof,nx)
real, allocatable :: ym(:,:), vt(:,:,:), vs(:,:,:)
integer :: i, j, k, nxm, nym, ndofm, ier, iver
character(80) :: base, fname
character(256) :: tmp
!=============================================================================!
!.... read the mean field and spline to the new grid
base = 'profile'
call makename(base,iver,fname)
if (verbose) then
write(*,"(' Reading mean flow from: ',a)") fname
endif
open (unit=10, file=fname, form='formatted', status='old',err=1000)
! read (10,*) nxm, nym, ndofm, ymaxm
! if (ndofm .ne. ndof) then
! write (*,*) 'NDOF in mean field is incorrect ',ndofm
! call exit(1)
! end if
nxm = 1
nym = 0
20 continue
read(10,'(a)',end=30) tmp
if (tmp(1:1).ne.'#') then
nym = nym + 1
endif
goto 20
30 continue
rewind(10)
allocate( ym(nym,nxm), vt(nym,nxm,ndof), vs(nym,nxm,ndof), &
STAT=ier )
if (ier .ne. 0) then
write(*,*) 'Error allocating mean field'
call exit(1)
end if
do i = 1, nxm
j = 1
40 continue
read (10,'(a)',end=50) tmp
if (tmp(1:1).ne.'#') then
read (tmp,*) ym(j,i), (vt(j,i,k),k=1,ndof)
vt(j,i,3) = zero ! parallel flow assumption
j = j + 1
endif
goto 40
50 continue
!ym(j,i) = ym(j,i)
call SPLINE(nym, ym(1,i), vt(1,i,1), vs(1,i,1))
call SPLINE(nym, ym(1,i), vt(1,i,2), vs(1,i,2))
call SPLINE(nym, ym(1,i), vt(1,i,3), vs(1,i,3))
call SPLINE(nym, ym(1,i), vt(1,i,4), vs(1,i,4))
call SPLINE(nym, ym(1,i), vt(1,i,5), vs(1,i,5))
end do
close (10)
ymaxm = ym(nym,1)
!.... Evaluate the mean field on the disturbance grid
do i = 1, nxm
do j = 1, lny
if (y(j) .le. ymaxm) then
call SPEVAL(nym, ym(1,i), vt(1,i,1), vs(1,i,1), y(j), vm(j,1,i))
call SPEVAL(nym, ym(1,i), vt(1,i,2), vs(1,i,2), y(j), vm(j,2,i))
call SPEVAL(nym, ym(1,i), vt(1,i,3), vs(1,i,3), y(j), vm(j,3,i))
call SPEVAL(nym, ym(1,i), vt(1,i,4), vs(1,i,4), y(j), vm(j,4,i))
call SPEVAL(nym, ym(1,i), vt(1,i,5), vs(1,i,5), y(j), vm(j,5,i))
else
vm(j,1,i) = vt(nym,i,1)
vm(j,2,i) = vt(nym,i,2)
vm(j,3,i) = vt(nym,i,3)
vm(j,4,i) = vt(nym,i,4)
vm(j,5,i) = vt(nym,i,5)
end if
! write (69,10) eta(j), (vm(j,k,i), k = 1, ndof)
end do
end do
!.... read the first derivative and spline to the new grid
base = 'first'
call makename(base,iver,fname)
if (verbose) then
write(*,"(' Reading first derivative from: ',a)") fname
endif
open (unit=10, file=fname, form='formatted', status='old',err=1000)
do i = 1, nxm
do j = 1, nym
read (10,*) ym(j,i), (vt(j,i,k),k=1,ndof)
vt(j,i,3) = zero ! parallel flow assumption
end do
!ym(j,i) = ym(j,i)
call SPLINE(nym, ym(1,i), vt(1,i,1), vs(1,i,1))
call SPLINE(nym, ym(1,i), vt(1,i,2), vs(1,i,2))
call SPLINE(nym, ym(1,i), vt(1,i,3), vs(1,i,3))
call SPLINE(nym, ym(1,i), vt(1,i,4), vs(1,i,4))
call SPLINE(nym, ym(1,i), vt(1,i,5), vs(1,i,5))
end do
close (10)
!.... Evaluate the mean derivative field on the disturbance grid
do i = 1, nxm
do j = 1, lny
if (y(j) .le. ymaxm) then
call SPEVAL(nym,ym(1,i), vt(1,i,1), vs(1,i,1), y(j), g2vm(j,1,i))
call SPEVAL(nym,ym(1,i), vt(1,i,2), vs(1,i,2), y(j), g2vm(j,2,i))
call SPEVAL(nym,ym(1,i), vt(1,i,3), vs(1,i,3), y(j), g2vm(j,3,i))
call SPEVAL(nym,ym(1,i), vt(1,i,4), vs(1,i,4), y(j), g2vm(j,4,i))
call SPEVAL(nym,ym(1,i), vt(1,i,5), vs(1,i,5), y(j), g2vm(j,5,i))
else
g2vm(j,1,i) = vt(nym,i,1)
g2vm(j,2,i) = vt(nym,i,2)
g2vm(j,3,i) = vt(nym,i,3)
g2vm(j,4,i) = vt(nym,i,4)
g2vm(j,5,i) = vt(nym,i,5)
end if
end do
end do
!.... read the second derivative and spline to the new grid
base = 'second'
call makename(base,iver,fname)
if (verbose) then
write(*,"(' Reading second derivative from: ',a)") fname
endif
open (unit=10, file=fname, form='formatted', status='old',err=1000)
do i = 1, nxm
do j = 1, nym
read (10,*) ym(j,i), (vt(j,i,k),k=1,ndof)
vt(j,i,3) = zero ! parallel flow assumption
end do
!ym(j,i) = ym(j,i)
call SPLINE(nym, ym(1,i), vt(1,i,1), vs(1,i,1))
call SPLINE(nym, ym(1,i), vt(1,i,2), vs(1,i,2))
call SPLINE(nym, ym(1,i), vt(1,i,3), vs(1,i,3))
call SPLINE(nym, ym(1,i), vt(1,i,4), vs(1,i,4))
call SPLINE(nym, ym(1,i), vt(1,i,5), vs(1,i,5))
end do
close (10)
!.... Evaluate the mean derivative field on the disturbance grid
do i = 1, nxm
do j = 1, lny
if (y(j) .le. ymaxm) then
call SPEVAL(nym,ym(1,i),vt(1,i,1), vs(1,i,1), y(j), g22vm(j,1,i))
call SPEVAL(nym,ym(1,i),vt(1,i,2), vs(1,i,2), y(j), g22vm(j,2,i))
call SPEVAL(nym,ym(1,i),vt(1,i,3), vs(1,i,3), y(j), g22vm(j,3,i))
call SPEVAL(nym,ym(1,i),vt(1,i,4), vs(1,i,4), y(j), g22vm(j,4,i))
call SPEVAL(nym,ym(1,i),vt(1,i,5), vs(1,i,5), y(j), g22vm(j,5,i))
else
g22vm(j,1,i) = vt(nym,i,1)
g22vm(j,2,i) = vt(nym,i,2)
g22vm(j,3,i) = vt(nym,i,3)
g22vm(j,4,i) = vt(nym,i,4)
g22vm(j,5,i) = vt(nym,i,5)
end if
end do
end do
deallocate( ym, vt, vs )
return
10 format(8(1pe13.6,1x))
1000 write(*,*) 'Error reading profile...'
call exit(1)
end subroutine getmean2