1 # 1 "/Users/miesch/JEDI/code/working_copy/internal/mpas-bundle/saber/src/saber/bump/tools_fit.fypp"
2 # 1 "/Users/miesch/JEDI/code/working_copy/internal/mpas-bundle/saber/src/saber/bump/../instrumentation.fypp" 1
3 # 1 "/Users/miesch/JEDI/code/working_copy/internal/mpas-bundle/saber/src/saber/bump/../subr_list.fypp" 1
12 # 926 "/Users/miesch/JEDI/code/working_copy/internal/mpas-bundle/saber/src/saber/bump/../subr_list.fypp"
13 # 2 "/Users/miesch/JEDI/code/working_copy/internal/mpas-bundle/saber/src/saber/bump/../instrumentation.fypp" 2
22 # 112 "/Users/miesch/JEDI/code/working_copy/internal/mpas-bundle/saber/src/saber/bump/../instrumentation.fypp"
23 # 2 "/Users/miesch/JEDI/code/working_copy/internal/mpas-bundle/saber/src/saber/bump/tools_fit.fypp" 2
69 integer,
intent(in) :: n
70 integer,
intent(in) :: iz
71 real(kind_real),
intent(in) :: dist(n)
72 real(kind_real),
intent(in) :: raw(n)
73 real(kind_real),
intent(out) :: fit_r
76 integer :: di,i,im,ip,iter
77 real(kind_real) :: th,thinv,dthinv,thtest
78 real(kind_real) :: fit_rm,fit_rp,distmin
79 real(kind_real) :: raw_tmp(n)
87 if (any(dist<
zero))
call mpl%abort(
'fit_fast_fit',
'negative distance')
89 if (raw(iz)>
zero)
then
92 raw_tmp = mpl%msv%valr
96 if (
inf(raw(i),raw(iz))) raw_tmp(i) = raw(i)/raw(iz)
100 if (count(mpl%msv%isnot(raw_tmp))>1)
then
101 if (count(raw_tmp>
zero)>1)
then
103 th =
half*(
one+minval(raw_tmp,mask=(raw_tmp>
zero)))
110 if (
sup(th,thtest))
then
119 fit_rm = mpl%msv%valr
123 if (mpl%msv%is(fit_rm))
then
130 if (raw_tmp(im)>
zero)
then
132 if (
inf(raw_tmp(im),th))
then
134 fit_rm = dist(im)+(dist(ip)-dist(im))*(th-raw_tmp(im))/(raw_tmp(ip)-raw_tmp(im))
145 fit_rp = mpl%msv%valr
149 if (mpl%msv%is(fit_rp))
then
156 if (raw_tmp(ip)>
zero)
then
158 if (
inf(raw_tmp(ip),th))
then
160 fit_rp = dist(im)+(dist(ip)-dist(im))*(th-raw_tmp(im))/(raw_tmp(ip)-raw_tmp(im))
171 if (mpl%msv%isnot(fit_rm).and.mpl%msv%isnot(fit_rp))
then
172 fit_r =
half*(fit_rm+fit_rp)
173 elseif (mpl%msv%isnot(fit_rm))
then
175 elseif (mpl%msv%isnot(fit_rp))
then
180 if (mpl%msv%isnot(fit_r)) fit_r = fit_r/thinv
183 if (
inf(fit_r,
zero)) fit_r = mpl%msv%valr
194 if (mpl%msv%isnot(fit_r))
then
196 if (iz>1) distmin = min(distmin,1.0e-6_kind_real*abs(dist(iz-1)-dist(iz)))
197 if (iz<n) distmin = min(distmin,1.0e-6_kind_real*abs(dist(iz+1)-dist(iz)))
198 fit_r = max(fit_r,distmin)
224 integer,
intent(in) :: n
225 real(kind_real),
intent(in) :: x(n)
226 real(kind_real),
intent(in) :: rv
227 real(kind_real),
intent(inout) :: profile(n)
231 real(kind_real) :: kernel(n,n),distnorm,profile_init(n),norm
240 if (rv<
zero)
call mpl%abort(
'fit_ver_smooth',
'negative filtering support radius')
242 if ((rv>
zero).and.mpl%msv%isanynot(profile))
then
247 if (mpl%msv%isnot(profile(i)).and.mpl%msv%isnot(profile(j)))
then
249 distnorm = abs(x(j)-x(i))/rv
250 kernel(i,j) =
fit_func(mpl,distnorm)
256 profile_init = profile
261 profile(i) = profile(i)+kernel(i,j)*profile_init(j)
262 norm = norm+kernel(i,j)
265 profile(i) = profile(i)/norm
267 profile(i) = mpl%msv%valr
288 integer,
intent(in) :: n
289 real(kind_real),
intent(in) :: x(n)
290 real(kind_real),
intent(inout) :: profile(n)
293 integer :: i,j,iinf,isup
294 real(kind_real) :: profile_init(n)
302 if (mpl%msv%isanynot(profile))
then
304 profile_init = profile
308 if (mpl%msv%isnot(profile_init(i)))
then
315 do while ((j<=n).and.(mpl%msv%is(isup)))
316 if (mpl%msv%isnot(profile_init(j))) isup = j
320 if (mpl%msv%isnot(iinf).and.mpl%msv%isnot(isup))
then
322 profile(i) = profile_init(iinf)+(x(i)-x(iinf))*(profile_init(isup)-profile_init(iinf))/(x(isup)-x(iinf))
323 elseif (mpl%msv%isnot(isup))
then
325 profile(i) = profile(isup)
326 elseif (mpl%msv%isnot(iinf))
then
328 profile(i) = profile(iinf)
330 call mpl%abort(
'fit_ver_fill',
'too many missing values')
Generic ranks, dimensions and types.