61 function getdat( filen,infmt,modebc,nspln,ideriv,norm,lumsg,
62 # comment,ncmts,spndat,bi,delb,stddev,xraw,yraw,
70 integer getdat,ideriv,infmt,lumsg,modebc,norm,nspln,ncmts
71 double precision bi,delb,stddev,spndat(nspln),xraw(
mxinp),
75 character*80 comment(
mxcmt)
77 integer i,k,iret,npts,nend
78 double precision anorm,c0,c1,yntgrl,ybase
82 double precision sglint,dblint
83 external getasc,getbin,sglint,dblint
90 if (lumsg.ne.0)
write(lumsg,1005) filen
94 if (infmt .eq. 1)
then
95 iret=getbin(filen,xraw,yraw,npts,comment,ncmts,
mxinp)
100 iret=getasc(filen,xraw,yraw,npts,comment,ncmts,
mxcmt,
mxinp)
106 if (iret .ne. 0)
then
111 if (npts.gt.
mxinp)
then
112 if (lumsg.ne.0)
write (lumsg,1013)
mxinp,npts-
mxinp
118 write(lumsg,1006) npts,xraw(1),xraw(npts)
120 write(lumsg,1007) npts,xraw(1),xraw(npts)
126 if ((xraw(1).ge.xraw(npts)) .or. 0.5d0*(xraw(1)+xraw(npts))
127 # .lt. abs(xraw(npts)-xraw(1)) )
then
128 if (lumsg.ne.0)
write(lumsg,1012)
140 call linebc( xraw,yraw,npts,modebc,c0,c1,stddev )
141 if (modebc.ne.0)
then
142 if (lumsg.ne.0)
write (lumsg,1008) modebc,c0,c1,stddev
144 if (lumsg.ne.0)
write (lumsg,1009) stddev
151 if (nspln .gt. 0)
then
153 delb=(xraw(npts)-xraw(1))/(nspln-1)
154 call ncspln(xraw,yraw,npts,y2 )
155 call splnay(xraw,yraw,y2,npts,bi,delb,spndat,nspln)
156 if (lumsg.ne.0)
write(lumsg,1010) nspln
162 delb=(xraw(npts)-xraw(1))/(npts-1)
167 if (lumsg.ne.0)
write (lumsg,1011)
175 call normlz( spndat,nspln,delb,ideriv,lumsg,anorm )
176 if (anorm.ne.0.0d0) stddev=stddev/anorm
184 1005
format(//
'Opening file ',a/)
185 1006
format(i6,
' raw data points read in PC-GENPLOT binary format'/
186 #
' Field range:',f10.2,
' to ',f10.2)
187 1007
format(i6,
' raw data points read in ASCII format'/
188 #
' Field range:',f10.2,
' to ',f10.2/)
189 1008
format(
' Data baseline-corrected using linear fit to ',i3,
190 #
' points at each end'/
' Intercept=',g14.7,
' Slope=',g14.7,
192 1009
format(
' Spectral noise: ',g14.7)
193 1010
format(
' Data splined to ',i4,
' points')
194 1011
format(
' Input data not splined')
195 1012
format(
' *** Questionable field range ***')
196 1013
format(
' *** Maximum of ',i5,
' input pts reached: remaining',i5,
197 #
' pts ignored ***')
220 function getasc(filen,x,y,n,comment,ncmt,maxcmt,maxinp)
225 integer getasc,n,ncmt,maxcmt,maxinp,lth
228 double precision x(*),y(*),xin,yin
231 character*80 comment(maxcmt),line
239 open(
ludisk,file=filen,status=
'old',
240 # access=
'sequential',form=
'formatted',err=99 )
242 7
read (
ludisk,1007,end=10,err=99) line
243 if ( line(1:1) .eq.
'c'
244 # .or. line(1:1) .eq.
'C'
245 # .or. line(1:1) .eq.
'!' )
then
246 if (ncmt .lt. maxcmt)
then
254 call gettkn(line,numstr,lth)
255 if (.not.ftoken(numstr,lth,x(1)) )
go to 99
256 call gettkn(line,numstr,lth)
257 if (.not.ftoken(numstr,lth,y(1)) )
go to 99
264 8
read (
ludisk,1007,end=10,err=99) line
265 if ( line(1:1) .eq.
'c'
266 # .or. line(1:1) .eq.
'C'
267 # .or. line(1:1) .eq.
'!' )
then
268 if (ncmt .lt. maxcmt)
then
275 call gettkn(line,numstr,lth)
276 if (.not.ftoken(numstr,lth,xin) )
go to 99
277 call gettkn(line,numstr,lth)
278 if (.not.ftoken(numstr,lth,yin) )
go to 99
280 if (n.le.maxinp)
then
313 function sglint( arry, n )
316 double precision arry(n), dx, sglint
320 sglint=sglint+arry(i)
322 sglint=sglint-0.5d0*(arry(1)+arry(n))
336 function dblint( arry, n )
339 double precision arry(n),dx,sglint,dblint
344 sglint=sglint+arry(i)
347 dblint=dblint-0.5*(arry(1)+sglint)
376 subroutine linebc(x,y,n,modebc,c0,c1,stddev)
379 double precision x(n),y(n),c0,c1,stddev
380 double precision d,sn,sx,sx2,sxy,sy
383 double precision ZERO,TWO
384 parameter(zero=0.0d0,two=2.0d0)
386 nend=min0(modebc,n/3)
387 if (nend.le.0) nend=max0(10,n/20)
397 sx2=sx2 + x(i)**2 + x(k)**2
398 sxy=sxy + x(i)*y(i) + x(k)*y(k)
407 c0=(sx2*sy - sx*sxy) / d
408 c1=(sn*sxy-sx*sy) / d
417 stddev=stddev+((y(i)+y(k))-two*c0-c1*(x(i)+x(k)))**2
419 stddev=dsqrt(stddev/dfloat(2*nend-1))
425 if (modebc.gt.0)
then
427 y(i)=y(i)-(c0+c1*x(i))
445 subroutine ncspln(x,y,n,y2)
449 double precision ZERO,ONE,TWO,SIX
450 parameter(zero=0.0d0,one=1.0d0,two=2.0d0,six=6.0d0)
453 double precision x(n),y(n),y2(n),u(nmax),sig,p
458 sig=(x(i)-x(i-1))/(x(i+1)-x(i-1))
461 u(i)=(six*( (y(i+1)-y(i))/(x(i+1)-x(i))
462 & -(y(i)-y(i-1))/(x(i)-x(i-1)) )
468 y2(k)=y2(k)*y2(k+1)+u(k)
487 subroutine splnay(xa,ya,y2a,n,x0,dx,y,ns)
489 integer i,klo,khi,n,ns
490 double precision xa(n),ya(n),y2a(n),y(ns),x,x0,dx,h,a,b
492 if (x0 .lt. xa(1) .or. x0+dx*(ns-1) .gt. xa(n))
then
493 print *,
'SPLNAY: Bad interpolated X range.'
494 print *,
'[execution paused, press enter to continue]'
502 2
if (x.gt.xa(khi) .and. khi.lt.n)
then
508 if (h .eq. 0.0d0)
then
509 print *,
'SPLNAY: Bad XA input.'
510 print *,
'[execution paused, press enter to continue]'
515 y(i)=a*ya(klo) + b*ya(khi) +
516 * ((a**3-a)*y2a(klo) + (b**3-b)*y2a(khi))*(h**2)/6.0d0
544 subroutine normlz(arry,n,dx,ideriv,lumsg,anorm)
546 integer n,ideriv,lumsg
547 double precision arry(n),dx,anorm
549 double precision base,sntgrl
552 double precision sglint,dblint
553 external sglint,dblint
555 if (ideriv.eq.0)
then
560 anorm=dx*sglint(arry,n)
568 sntgrl=sglint(arry,n)
569 base=sntgrl/dfloat(n)
573 if (lumsg.ne.0)
write(lumsg,1008) base
578 anorm=dx*dx*dblint(arry,n)
581 if (lumsg.ne.0)
write (lumsg,1012) anorm
582 if (anorm.ne.0.0d0)
then
584 arry(i)=arry(i)/anorm
590 1008
format(
' Baseline adjusted by subtracting ',g14.7,
591 #
' before normalization')
592 1012
format(
' Data normalized: integral = ',g14.7)
integer function getdat(filen, infmt, modebc, nspln, ideriv, norm, lumsg, comment, ncmts, spndat, bi, delb, stddev, xraw, yraw, y2)
double precision function sglint(arry, n)
double precision function dblint(arry, n)
subroutine gettkn(line, token, lth)
Written for free-form input of parameters for slow-motional calculations. Returns a token consisting ...
subroutine ncspln(x, y, n, y2)
subroutine normlz(arry, n, dx, ideriv, lumsg, anorm)
integer function getasc(filen, x, y, n, comment, ncmt, maxcmt, maxinp)
subroutine splnay(xa, ya, y2a, n, x0, dx, y, ns)
integer, parameter ludisk
subroutine linebc(x, y, n, modebc, c0, c1, stddev)