70 INTEGER,
INTENT(IN) :: iarg
71 REAL :: dergb(10),derlc(2),par(10)
72 INTEGER,
PARAMETER :: nplan=10
73 REAL :: x(nplan),y(nplan),sigma(nplan),bias(nplan),heff(nplan)
75 DATA x/5.0,9.0,20.0,25.0,30.0,35.0,40.0,45.0,50.0,55.0/
76 DATA sigma/2*0.0020,8*0.0300/
77 DATA bias /0.00,-0.04,0.15,0.03,-0.075,0.045,0.035,-0.08,0.09,-0.05/
78 DATA heff/4*0.9,0.50,5*0.9/
86 frot(i)=1.0/(x(i)-x(1))
99 CALL gener(y,a,b,x,sigma,bias,heff)
106 CALL equloc(dergb,derlc,y(i),sigma(i))
117SUBROUTINE gener(y,a,b,x,sigma,bias,heff)
119 INTEGER,
PARAMETER :: nplan=10
121 REAL,
INTENT(OUT) :: y(*)
122 REAL,
INTENT(OUT) :: a
123 REAL,
INTENT(OUT) :: b
124 REAL,
INTENT(IN) :: x(nplan)
125 REAL,
INTENT(IN) :: sigma(nplan)
126 REAL,
INTENT(IN) :: bias(nplan)
127 REAL,
INTENT(IN) :: heff(nplan)
134 IF(
zrand() < heff(i))
THEN
135 y(i)=a+b*x(i) + bias(i)+sigma(i)*
znorm()
145 parameter(ia=205,ic=29573,im=139968)
147 last=mod(ia*last+ic,im)
148 IF(last == 0) last=mod(ia*last+ic,im)
149 zrand=float(last)/float(im)
155 parameter(ia=205,ic=29573,im=139968)
159 last=mod(ia*last+ic,im)
170SUBROUTINE initgl(nagbar,nalcar,nstd,iprlim)
173 parameter(mglobl=1400,mlocal=10,nstore=10000,mcs=10)
174 parameter(mgl=mglobl+mcs)
176 parameter(msymgb =(mglobl*mglobl+mglobl)/2, msym =(mgl*mgl+mgl)/2, &
177 msymlc=(mlocal*mlocal+mlocal)/2, mrecta= mglobl*mlocal, &
178 mglocs= mglobl*mcs, msymcs= (mcs*mcs+mcs)/2 )
179 DOUBLE PRECISION :: cgmat,clmat,clcmat,bgvec,blvec, &
180 corrm,corrv,summ,diag,scdiag,pparm,dparm,adercs, arhs
182 common/lsqred/cgmat(msym),clmat(msymlc),clcmat(mrecta), &
183 diag(mgl),bgvec(mgl),blvec(mlocal), &
184 corrm(msymgb),corrv(mglobl),psigm(mglobl), &
185 pparm(mglobl),adercs(mglocs),arhs(mcs), dparm(mglobl), &
186 scdiag(mglobl),summ,scflag(mglobl), &
187 indgb(mglobl),indlc(mlocal),loctot,locrej, &
188 nagb,nalc,nsum,nhist,mhist(51),khist(51),lhist(51), &
189 nst,nfl,indst(nstore),arest(nstore),itert,lunit,ncs, &
190 nlnpa(mglobl),nstdev,cfactr,icnpr,icnlim, indnz(mglobl),indbk(mglobl)
193 DATA ndr/1,2,5,10,20,50,100/
196 IF(icnlim >= 0)
WRITE(*,199)
200 ' o ooooo o o o oo ooo oo ooo oo '/ &
201 ' o o o o o o o o o o o o o o o o '/ &
202 ' o o o o o o oooo o o oooo o o oooo '/ &
203 ' o o o o o o o ooo o o o o '/ &
204 ' o o o o oo oo oo o oo ooo oo starting'/ &
213 nstdev=max(0,min(nstd,3))
219 WRITE(*,*)
'Number of global parameters ',nagb
220 WRITE(*,*)
'Number of local parameters ',nalc
221 WRITE(*,*)
' Number of standard deviations ',nstdev
222 WRITE(*,*)
' Number of test printouts ',icnlim
224 IF(nagb > mglobl.OR.nalc > mlocal)
THEN
225 WRITE(*,*)
'Too many parameter - STOP'
228 IF(nstdev /= 0.AND.icnlim >= 0)
THEN
229 WRITE(*,*)
'Final cut corresponds to',nstdev,
' standard deviations.'
230 WRITE(*,*)
'The actual cuts are made in Chisquare/Ndf at:'
232 WRITE(*,101) ndr(i),
chindl(nstdev,ndr(i))
233101
FORMAT(20x,
'Ndf =',i4,
' Limit =',f8.2)
244 DO i=1,(nagb*nagb+nagb)/2
260 DO i=1,(nalc*nalc+nalc)/2
273 parameter(mglobl=1400,mlocal=10,nstore=10000,mcs=10)
274 parameter(mgl=mglobl+mcs)
276 parameter(msymgb =(mglobl*mglobl+mglobl)/2, msym =(mgl*mgl+mgl)/2, &
277 msymlc=(mlocal*mlocal+mlocal)/2, mrecta= mglobl*mlocal, &
278 mglocs= mglobl*mcs, msymcs= (mcs*mcs+mcs)/2 )
279 DOUBLE PRECISION :: cgmat,clmat,clcmat,bgvec,blvec, &
280 corrm,corrv,summ,diag,scdiag,pparm,dparm,adercs, arhs
282 common/lsqred/cgmat(msym),clmat(msymlc),clcmat(mrecta), &
283 diag(mgl),bgvec(mgl),blvec(mlocal), &
284 corrm(msymgb),corrv(mglobl),psigm(mglobl), &
285 pparm(mglobl),adercs(mglocs),arhs(mcs), dparm(mglobl), &
286 scdiag(mglobl),summ,scflag(mglobl), &
287 indgb(mglobl),indlc(mlocal),loctot,locrej, &
288 nagb,nalc,nsum,nhist,mhist(51),khist(51),lhist(51), &
289 nst,nfl,indst(nstore),arest(nstore),itert,lunit,ncs, &
290 nlnpa(mglobl),nstdev,cfactr,icnpr,icnlim, indnz(mglobl),indbk(mglobl)
302 parameter(mglobl=1400,mlocal=10,nstore=10000,mcs=10)
303 parameter(mgl=mglobl+mcs)
305 parameter(msymgb =(mglobl*mglobl+mglobl)/2, msym =(mgl*mgl+mgl)/2, &
306 msymlc=(mlocal*mlocal+mlocal)/2, mrecta= mglobl*mlocal, &
307 mglocs= mglobl*mcs, msymcs= (mcs*mcs+mcs)/2 )
308 DOUBLE PRECISION :: cgmat,clmat,clcmat,bgvec,blvec, &
309 corrm,corrv,summ,diag,scdiag,pparm,dparm,adercs, arhs
311 common/lsqred/cgmat(msym),clmat(msymlc),clcmat(mrecta), &
312 diag(mgl),bgvec(mgl),blvec(mlocal), &
313 corrm(msymgb),corrv(mglobl),psigm(mglobl), &
314 pparm(mglobl),adercs(mglocs),arhs(mcs), dparm(mglobl), &
315 scdiag(mglobl),summ,scflag(mglobl), &
316 indgb(mglobl),indlc(mlocal),loctot,locrej, &
317 nagb,nalc,nsum,nhist,mhist(51),khist(51),lhist(51), &
318 nst,nfl,indst(nstore),arest(nstore),itert,lunit,ncs, &
319 nlnpa(mglobl),nstdev,cfactr,icnpr,icnlim, indnz(mglobl),indbk(mglobl)
321 IF(index < 1.OR.index > nagb)
RETURN
322 IF(sigma < 0.0)
RETURN
330 parameter(mglobl=1400,mlocal=10,nstore=10000,mcs=10)
331 parameter(mgl=mglobl+mcs)
333 parameter(msymgb =(mglobl*mglobl+mglobl)/2, msym =(mgl*mgl+mgl)/2, &
334 msymlc=(mlocal*mlocal+mlocal)/2, mrecta= mglobl*mlocal, &
335 mglocs= mglobl*mcs, msymcs= (mcs*mcs+mcs)/2 )
336 DOUBLE PRECISION :: cgmat,clmat,clcmat,bgvec,blvec, &
337 corrm,corrv,summ,diag,scdiag,pparm,dparm,adercs, arhs
339 common/lsqred/cgmat(msym),clmat(msymlc),clcmat(mrecta), &
340 diag(mgl),bgvec(mgl),blvec(mlocal), &
341 corrm(msymgb),corrv(mglobl),psigm(mglobl), &
342 pparm(mglobl),adercs(mglocs),arhs(mcs), dparm(mglobl), &
343 scdiag(mglobl),summ,scflag(mglobl), &
344 indgb(mglobl),indlc(mlocal),loctot,locrej, &
345 nagb,nalc,nsum,nhist,mhist(51),khist(51),lhist(51), &
346 nst,nfl,indst(nstore),arest(nstore),itert,lunit,ncs, &
347 nlnpa(mglobl),nstdev,cfactr,icnpr,icnlim, indnz(mglobl),indbk(mglobl)
349 IF(index < 1.OR.index > nagb)
RETURN
357 parameter(mglobl=1400,mlocal=10,nstore=10000,mcs=10)
358 parameter(mgl=mglobl+mcs)
360 parameter(msymgb =(mglobl*mglobl+mglobl)/2, msym =(mgl*mgl+mgl)/2, &
361 msymlc=(mlocal*mlocal+mlocal)/2, mrecta= mglobl*mlocal, &
362 mglocs= mglobl*mcs, msymcs= (mcs*mcs+mcs)/2 )
363 DOUBLE PRECISION :: cgmat,clmat,clcmat,bgvec,blvec, &
364 corrm,corrv,summ,diag,scdiag,pparm,dparm,adercs, arhs
366 common/lsqred/cgmat(msym),clmat(msymlc),clcmat(mrecta), &
367 diag(mgl),bgvec(mgl),blvec(mlocal), &
368 corrm(msymgb),corrv(mglobl),psigm(mglobl), &
369 pparm(mglobl),adercs(mglocs),arhs(mcs), dparm(mglobl), &
370 scdiag(mglobl),summ,scflag(mglobl), &
371 indgb(mglobl),indlc(mlocal),loctot,locrej, &
372 nagb,nalc,nsum,nhist,mhist(51),khist(51),lhist(51), &
373 nst,nfl,indst(nstore),arest(nstore),itert,lunit,ncs, &
374 nlnpa(mglobl),nstdev,cfactr,icnpr,icnlim, indnz(mglobl),indbk(mglobl)
378 INQUIRE(unit=lun,opened=opn,iostat=ios)
380 stop
'<INITUN: Inquire error>'
384 OPEN(unit=lun,form=
'UNFORMATTED',status=
'SCRATCH',iostat=ios)
386 stop
'<INITUN: Open error>'
388 IF(icnlim >= 0)
WRITE(*,*)
'Scratch file opened'
391 cfactr=max(1.0,cutfac)
392 IF(icnlim >= 0)
WRITE(*,*)
'Initial cut factor is',cfactr
400 parameter(mglobl=1400,mlocal=10,nstore=10000,mcs=10)
401 parameter(mgl=mglobl+mcs)
403 parameter(msymgb =(mglobl*mglobl+mglobl)/2, msym =(mgl*mgl+mgl)/2, &
404 msymlc=(mlocal*mlocal+mlocal)/2, mrecta= mglobl*mlocal, &
405 mglocs= mglobl*mcs, msymcs= (mcs*mcs+mcs)/2 )
406 DOUBLE PRECISION :: cgmat,clmat,clcmat,bgvec,blvec, &
407 corrm,corrv,summ,diag,scdiag,pparm,dparm,adercs, arhs
409 common/lsqred/cgmat(msym),clmat(msymlc),clcmat(mrecta), &
410 diag(mgl),bgvec(mgl),blvec(mlocal), &
411 corrm(msymgb),corrv(mglobl),psigm(mglobl), &
412 pparm(mglobl),adercs(mglocs),arhs(mcs), dparm(mglobl), &
413 scdiag(mglobl),summ,scflag(mglobl), &
414 indgb(mglobl),indlc(mlocal),loctot,locrej, &
415 nagb,nalc,nsum,nhist,mhist(51),khist(51),lhist(51), &
416 nst,nfl,indst(nstore),arest(nstore),itert,lunit,ncs, &
417 nlnpa(mglobl),nstdev,cfactr,icnpr,icnlim, indnz(mglobl),indbk(mglobl)
420 IF(ncs >= mcs) stop
'<INITCS> too many constraints'
422 adercs(nagb*ncs+i)=dercs(i)
426 WRITE(*,*)
'Number of constraints increased to ',ncs
436SUBROUTINE equloc(dergb,derlc,rrmeas,sigma)
439 parameter(mglobl=1400,mlocal=10,nstore=10000,mcs=10)
440 parameter(mgl=mglobl+mcs)
442 parameter(msymgb =(mglobl*mglobl+mglobl)/2, msym =(mgl*mgl+mgl)/2, &
443 msymlc=(mlocal*mlocal+mlocal)/2, mrecta= mglobl*mlocal, &
444 mglocs= mglobl*mcs, msymcs= (mcs*mcs+mcs)/2 )
445 DOUBLE PRECISION :: cgmat,clmat,clcmat,bgvec,blvec, &
446 corrm,corrv,summ,diag,scdiag,pparm,dparm,adercs, arhs
448 common/lsqred/cgmat(msym),clmat(msymlc),clcmat(mrecta), &
449 diag(mgl),bgvec(mgl),blvec(mlocal), &
450 corrm(msymgb),corrv(mglobl),psigm(mglobl), &
451 pparm(mglobl),adercs(mglocs),arhs(mcs), dparm(mglobl), &
452 scdiag(mglobl),summ,scflag(mglobl), &
453 indgb(mglobl),indlc(mlocal),loctot,locrej, &
454 nagb,nalc,nsum,nhist,mhist(51),khist(51),lhist(51), &
455 nst,nfl,indst(nstore),arest(nstore),itert,lunit,ncs, &
456 nlnpa(mglobl),nstdev,cfactr,icnpr,icnlim, indnz(mglobl),indbk(mglobl)
458 REAL :: dergb(*),derlc(*)
461 IF(sigma <= 0.0)
THEN
475 IF(derlc(i) /= 0.0)
THEN
484 IF(dergb(i) /= 0.0)
THEN
490 IF(nst+nonzer+2 >= nstore)
THEN
498 IF(derlc(i) /= 0.0)
THEN
509 IF(dergb(i) /= 0.0)
THEN
525 parameter(mglobl=1400,mlocal=10,nstore=10000,mcs=10)
526 parameter(mgl=mglobl+mcs)
528 parameter(msymgb =(mglobl*mglobl+mglobl)/2, msym =(mgl*mgl+mgl)/2, &
529 msymlc=(mlocal*mlocal+mlocal)/2, mrecta= mglobl*mlocal, &
530 mglocs= mglobl*mcs, msymcs= (mcs*mcs+mcs)/2 )
531 DOUBLE PRECISION :: cgmat,clmat,clcmat,bgvec,blvec, &
532 corrm,corrv,summ,diag,scdiag,pparm,dparm,adercs, arhs
534 common/lsqred/cgmat(msym),clmat(msymlc),clcmat(mrecta), &
535 diag(mgl),bgvec(mgl),blvec(mlocal), &
536 corrm(msymgb),corrv(mglobl),psigm(mglobl), &
537 pparm(mglobl),adercs(mglocs),arhs(mcs), dparm(mglobl), &
538 scdiag(mglobl),summ,scflag(mglobl), &
539 indgb(mglobl),indlc(mlocal),loctot,locrej, &
540 nagb,nalc,nsum,nhist,mhist(51),khist(51),lhist(51), &
541 nst,nfl,indst(nstore),arest(nstore),itert,lunit,ncs, &
542 nlnpa(mglobl),nstdev,cfactr,icnpr,icnlim, indnz(mglobl),indbk(mglobl)
544 REAL :: dergb(*),derlc(*)
558 parameter(mglobl=1400,mlocal=10,nstore=10000,mcs=10)
559 parameter(mgl=mglobl+mcs)
561 parameter(msymgb =(mglobl*mglobl+mglobl)/2, msym =(mgl*mgl+mgl)/2, &
562 msymlc=(mlocal*mlocal+mlocal)/2, mrecta= mglobl*mlocal, &
563 mglocs= mglobl*mcs, msymcs= (mcs*mcs+mcs)/2 )
564 DOUBLE PRECISION :: cgmat,clmat,clcmat,bgvec,blvec, &
565 corrm,corrv,summ,diag,scdiag,pparm,dparm,adercs, arhs
567 common/lsqred/cgmat(msym),clmat(msymlc),clcmat(mrecta), &
568 diag(mgl),bgvec(mgl),blvec(mlocal), &
569 corrm(msymgb),corrv(mglobl),psigm(mglobl), &
570 pparm(mglobl),adercs(mglocs),arhs(mcs), dparm(mglobl), &
571 scdiag(mglobl),summ,scflag(mglobl), &
572 indgb(mglobl),indlc(mlocal),loctot,locrej, &
573 nagb,nalc,nsum,nhist,mhist(51),khist(51),lhist(51), &
574 nst,nfl,indst(nstore),arest(nstore),itert,lunit,ncs, &
575 nlnpa(mglobl),nstdev,cfactr,icnpr,icnlim, indnz(mglobl),indbk(mglobl)
581 WRITE(lunit) nst,(indst(i),i=1,nst),(arest(i),i=1,nst)
590 DO i=1,(nalc*nalc+nalc)/2
599 IF(nst <= 1)
GO TO 100
604 IF(ist > nst.OR.indst(ist) == 0)
THEN
607 ELSE IF(jb == 0)
THEN
615 IF(nlnpa(ij) == 0)
THEN
616 rmeas=rmeas-arest(jb+j)*real(pparm(ij)+dparm(ij))
618 rmeas=rmeas-arest(jb+j)*real(dparm(ij))
625 blvec(ij)=blvec(ij)+wght*rmeas*arest(ja+j)
629 clmat(jk)=clmat(jk)+wght*arest(ja+j)*arest(ja+k)
633 IF(ist == nst)
GO TO 21
637 IF(ist <= nst)
GO TO 20
63921
CALL spminv(clmat,blvec,nalc,nrank,scdiag,scflag)
641 IF(icnpr <= icnlim)
THEN
643 WRITE(*,*)
'__________________________________________________'
644 WRITE(*,*)
'Printout of local fit (FITLOC) with rank=',nrank
645 WRITE(*,*)
' Result of local fit: (Index/Parameter/error)'
646 WRITE(*,103) (j,blvec(j),sqrt(clmat((j*j+j)/2)),j=1,jb-ja-1)
647103
FORMAT(2(i6,2g12.4))
657 IF(ist > nst.OR.indst(ist) == 0)
THEN
660 ELSE IF(jb == 0)
THEN
664 IF(icnpr <= icnlim.AND.incrp <= 11)
THEN
669 WRITE(*,*) incrp,
'. equation: ', &
670 'measured value ',arest(ja),
' +-',1.0/sqrt(arest(jb))
672 WRITE(*,*)
' number of derivates (global, local):',ndergl,
',',nderlc
673 WRITE(*,*)
' Global derivatives are: (index/derivative/parvalue)'
674 WRITE(*,101) (indst(jb+j),arest(jb+j), pparm(indst(jb+j)),j=1,ist-jb)
675101
FORMAT(2(i6,2g12.4))
676 WRITE(*,*)
' Local derivatives are: (index/derivative)'
677 WRITE(*,102) (indst(ja+j),arest(ja+j),j=1,jb-ja-1)
678102
FORMAT(3(i6,g14.6))
681 WRITE(*,*)
'... (+ further equations)'
688 IF(nlnpa(ij) == 0)
THEN
689 rmeas=rmeas-arest(jb+j)*real(pparm(ij)+dparm(ij))
691 rmeas=rmeas-arest(jb+j)*real(dparm(ij))
698 rmeas=rmeas-arest(ja+j)*real(blvec(ij))
700 IF(icnpr <= icnlim)
THEN
701 WRITE(*,104) wght*rmeas**2,rmeas
702104
FORMAT(
' Chi square contribution=',f8.2, &
703 5x,g12.4,
'= residuum')
706 ihbin=int(1.0+5.0*(rmeas*sqrt(wght)+5.0))
707 IF(ihbin < 1) ihbin=51
708 IF(ihbin > 50) ihbin=51
709 lhist(ihbin)=lhist(ihbin)+1
710 summ=summ+wght*rmeas**2
712 IF(ist == nst)
GO TO 41
716 IF(ist <= nst)
GO TO 40
718 IF(icnpr <= icnlim)
THEN
719 WRITE(*,*)
'Entry number',icnpr
720 WRITE(*,*)
'Final chi square, degrees of freedom',summ,ndf
724 rms=real(summ)/real(ndf)
727 IF(ihbin < 1) ihbin= 1
728 IF(ihbin > 50) ihbin=51
729 mhist(ihbin)=mhist(ihbin)+1
733 IF(nstdev /= 0.AND.ndf > 0)
THEN
734 cutval=
chindl(nstdev,ndf)*cfactr
735 IF(icnpr <= icnlim)
THEN
736 WRITE(*,*)
'Reject if Chisq/Ndf=',rms,
' > ',cutval
738 IF(rms > cutval)
THEN
748 IF(ist > nst.OR.indst(ist) == 0)
THEN
751 ELSE IF(jb == 0)
THEN
759 IF(nlnpa(ij) == 0)
THEN
760 rmeas=rmeas-arest(jb+j)*real(pparm(ij)+dparm(ij))
762 rmeas=rmeas-arest(jb+j)*real(dparm(ij))
770 bgvec(ij)=bgvec(ij)+wght*rmeas*arest(jb+j)
774 cgmat(jk)=cgmat(jk)+wght*arest(jb+j)*arest(jb+k)
785 clcmat(nagbn*nalc+k)=0.0
797 clcmat(jk)=clcmat(jk)+wght*arest(jb+j)*arest(ja+k)
800 IF(ist == nst)
GO TO 70
804 IF(ist <= nst)
GO TO 60
80770
CALL spavat(clmat,clcmat,corrm,nalc,nagbn)
808 CALL spax(clcmat,blvec,corrv,nagbn,nalc)
812 bgvec(i)=bgvec(i)-corrv(in)
821 cgmat(ij)=cgmat(ij)-corrm(ijn)
825100
IF(itert <= 1)
THEN
828 ibin=int(1.0+50.0*float(nst)/float(nstore))
830 khist(ibin)=khist(ibin)+1
832 khist(51)=khist(51)+1
842 CHARACTER (LEN=2) :: patext
845 parameter(mglobl=1400,mlocal=10,nstore=10000,mcs=10)
846 parameter(mgl=mglobl+mcs)
848 parameter(msymgb =(mglobl*mglobl+mglobl)/2, msym =(mgl*mgl+mgl)/2, &
849 msymlc=(mlocal*mlocal+mlocal)/2, mrecta= mglobl*mlocal, &
850 mglocs= mglobl*mcs, msymcs= (mcs*mcs+mcs)/2 )
851 DOUBLE PRECISION :: cgmat,clmat,clcmat,bgvec,blvec, &
852 corrm,corrv,summ,diag,scdiag,pparm,dparm,adercs, arhs
854 common/lsqred/cgmat(msym),clmat(msymlc),clcmat(mrecta), &
855 diag(mgl),bgvec(mgl),blvec(mlocal), &
856 corrm(msymgb),corrv(mglobl),psigm(mglobl), &
857 pparm(mglobl),adercs(mglocs),arhs(mcs), dparm(mglobl), &
858 scdiag(mglobl),summ,scflag(mglobl), &
859 indgb(mglobl),indlc(mlocal),loctot,locrej, &
860 nagb,nalc,nsum,nhist,mhist(51),khist(51),lhist(51), &
861 nst,nfl,indst(nstore),arest(nstore),itert,lunit,ncs, &
862 nlnpa(mglobl),nstdev,cfactr,icnpr,icnlim, indnz(mglobl),indbk(mglobl)
864 DOUBLE PRECISION :: dsum
865 IF(itert <= 1) itelim=10
869 lthist=lthist+lhist(i)
872 WRITE(*,*)
' Initial residual histogram:', &
873 ' Total',lthist,
' entries with',lhist(51),
' overflows'
874 CALL pxhist(lhist,50,-5.0,+5.0)
883 WRITE(*,*)
'Histogram of used local fit storage:', &
884 ' total',khtot,
' local fits with',khist(51),
' overflows'
886 IF(khist(51) /= 0.AND.icnlim >= 0)
THEN
887 WRITE(*,*)
'Parameter NSTORE to small! Change and rerun!'
890 CALL pxhist(khist,50,0.0,float(nstore))
89210
IF(icnlim >= 0)
THEN
894 WRITE(*,*)
'... making global fit ...'
901 IF(psigm(i) == 0.0)
THEN
908 ELSE IF(psigm(i) > 0.0)
THEN
909 cgmat(ii)=cgmat(ii)+1.0/psigm(i)**2
918 WRITE(*,*)
'Number of constraints ',ncs
920 ii=(nagb*nagb+nagb)/2
924 cgmat(ii+j)=adercs(nagb*(i-1)+j)
925 dsum=dsum-adercs(nagb*(i-1)+j)*(pparm(j)+dparm(j))
936 CALL spminv(cgmat,bgvec,nvar,nrank,scdiag,scflag)
940 dparm(i)=dparm(i)+bgvec(i)
944 WRITE(*,*)
'The rank defect of the symmetric',nvar,
'-by-',nvar, &
945 ' matrix is ',ndefec,
' (should be zero).'
947 IF(itert == 0.OR.nstdev == 0.OR.itert >= itelim)
GO TO 90
951 WRITE(*,*)
' Total',loctot,
' local fits,',locrej,
' rejected.'
952 WRITE(*,*)
' Histogram of Chisq/Ndf:', &
953 ' Total',nhist,
' entries with',mhist(51),
' overflows'
954 CALL pxhist(mhist,50,0.0,10.0)
965 IF(cfactr /= 1.0)
THEN
967 IF(cfactr < 1.2)
THEN
972 IF(icnlim >= 0)
WRITE(*,107) itert,cfactr
973107
FORMAT(
' Iteration',i3,
' with cut factor=',f6.2)
978 DO i=1,(nagb*nagb+nagb)/2
98220
READ(lunit,
END=10) nst,(indst(i),i=1,nst),(arest(i),i=1,nst)
98690
IF(icnlim >= 0)
THEN
988 WRITE(*,*)
' Result of fit for global parameters'
989 WRITE(*,*)
' ==================================='
995 err=real(sqrt(abs(cgmat(ii))))
996 IF(cgmat((i*i+i)/2) < 0.0) err=-err
998 IF(cgmat(ii)*diag(i) > 0.0)
THEN
1000 gcor=real(sqrt(abs(1.0-1.0/(cgmat(ii)*diag(i)))))
1002 IF(i <= 25.OR.nagb-i <= 25)
THEN
1004 IF(nlnpa(i) /= 0) patext=
'nl'
1005 IF(icnlim >= 0)
WRITE(*,102) i,patext, &
1006 pparm(i),pparm(i)+dparm(i),dparm(i),bgvec(i),err,gcor
1008 par(i)=real(pparm(i)+dparm(i))
1011 IF(i == 1.AND.icnlim >= 0)
WRITE(*,*)
' '
1014 dsum=dsum+adercs(nagb*(i-1)+j)*(pparm(j)+dparm(j))
1016 IF(icnlim >= 0)
WRITE(*,106) i,dsum,arhs(i),dsum-arhs(i)
1018 IF(icnlim >= 0)
THEN
1020 WRITE(*,*)
' Total',loctot,
' local fits,',locrej,
' rejected.'
1021 WRITE(*,*)
' Histogram of RMS:', &
1022 ' Total',nhist,
' entries with',mhist(51),
' overflows'
1023 CALL pxhist(mhist,50,0.0,10.0)
1027 lthist=lthist+lhist(i)
1029 IF(icnlim >= 0)
THEN
1030 WRITE(*,*)
' Residual histogram:', &
1031 ' Total',lthist,
' entries with',lhist(51),
' overflows'
1032 CALL pxhist(lhist,50,-5.0,+5.0)
1038 ' o ooooo o o o oo ooo oo ooo oo '/ &
1039 ' o o o o o o o o o o o o o o o o '/ &
1040 ' o o o o o o oooo o o oooo o o oooo '/ &
1041 ' o o o o o o o ooo o o o o '/ &
1042 ' o o o o oo oo oo o oo ooo oo ending.'/ &
1044101
FORMAT(1x,
' I initial final differ', &
1045 ' lastcor Error glcor'/ &
1046 1x,
' --- ----------- ----------- -----------', &
1047 ' ----------- -------- -----')
1048102
FORMAT(1x,i4,1x,a2,1x,4f12.5,f9.5,f6.3)
1049106
FORMAT(
' Constraint',i2,
' Sum - RHS =',g12.5,
' -',g12.5,
' = ',g12.5)
1056 parameter(mglobl=1400,mlocal=10,nstore=10000,mcs=10)
1057 parameter(mgl=mglobl+mcs)
1059 parameter(msymgb =(mglobl*mglobl+mglobl)/2, msym =(mgl*mgl+mgl)/2, &
1060 msymlc=(mlocal*mlocal+mlocal)/2, mrecta= mglobl*mlocal, &
1061 mglocs= mglobl*mcs, msymcs= (mcs*mcs+mcs)/2 )
1062 DOUBLE PRECISION :: cgmat,clmat,clcmat,bgvec,blvec, &
1063 corrm,corrv,summ,diag,scdiag,pparm,dparm,adercs, arhs
1065 common/lsqred/cgmat(msym),clmat(msymlc),clcmat(mrecta), &
1066 diag(mgl),bgvec(mgl),blvec(mlocal), &
1067 corrm(msymgb),corrv(mglobl),psigm(mglobl), &
1068 pparm(mglobl),adercs(mglocs),arhs(mcs), dparm(mglobl), &
1069 scdiag(mglobl),summ,scflag(mglobl), &
1070 indgb(mglobl),indlc(mlocal),loctot,locrej, &
1071 nagb,nalc,nsum,nhist,mhist(51),khist(51),lhist(51), &
1072 nst,nfl,indst(nstore),arest(nstore),itert,lunit,ncs, &
1073 nlnpa(mglobl),nstdev,cfactr,icnpr,icnlim, indnz(mglobl),indbk(mglobl)
1076 IF(i <= 0.OR.i > nagb)
RETURN
1078 errpar=real(sqrt(abs(cgmat(ii))))
1086 parameter(mglobl=1400,mlocal=10,nstore=10000,mcs=10)
1087 parameter(mgl=mglobl+mcs)
1089 parameter(msymgb =(mglobl*mglobl+mglobl)/2, msym =(mgl*mgl+mgl)/2, &
1090 msymlc=(mlocal*mlocal+mlocal)/2, mrecta= mglobl*mlocal, &
1091 mglocs= mglobl*mcs, msymcs= (mcs*mcs+mcs)/2 )
1092 DOUBLE PRECISION :: cgmat,clmat,clcmat,bgvec,blvec, &
1093 corrm,corrv,summ,diag,scdiag,pparm,dparm,adercs, arhs
1095 common/lsqred/cgmat(msym),clmat(msymlc),clcmat(mrecta), &
1096 diag(mgl),bgvec(mgl),blvec(mlocal), &
1097 corrm(msymgb),corrv(mglobl),psigm(mglobl), &
1098 pparm(mglobl),adercs(mglocs),arhs(mcs), dparm(mglobl), &
1099 scdiag(mglobl),summ,scflag(mglobl), &
1100 indgb(mglobl),indlc(mlocal),loctot,locrej, &
1101 nagb,nalc,nsum,nhist,mhist(51),khist(51),lhist(51), &
1102 nst,nfl,indst(nstore),arest(nstore),itert,lunit,ncs, &
1103 nlnpa(mglobl),nstdev,cfactr,icnpr,icnlim, indnz(mglobl),indbk(mglobl)
1106 IF(i <= 0.OR.i > nagb)
RETURN
1107 IF(j <= 0.OR.j > nagb)
RETURN
1112 ij=(k*k-k)/2+min(i,j)
1113 err=real(sqrt(abs(cgmat(ii)*cgmat(jj))))
1114 IF(err /= 0.0)
corpar=real(cgmat(ij))/err
1121 parameter(mglobl=1400,mlocal=10,nstore=10000,mcs=10)
1122 parameter(mgl=mglobl+mcs)
1124 parameter(msymgb =(mglobl*mglobl+mglobl)/2, msym =(mgl*mgl+mgl)/2, &
1125 msymlc=(mlocal*mlocal+mlocal)/2, mrecta= mglobl*mlocal, &
1126 mglocs= mglobl*mcs, msymcs= (mcs*mcs+mcs)/2 )
1127 DOUBLE PRECISION :: cgmat,clmat,clcmat,bgvec,blvec, &
1128 corrm,corrv,summ,diag,scdiag,pparm,dparm,adercs, arhs
1130 common/lsqred/cgmat(msym),clmat(msymlc),clcmat(mrecta), &
1131 diag(mgl),bgvec(mgl),blvec(mlocal), &
1132 corrm(msymgb),corrv(mglobl),psigm(mglobl), &
1133 pparm(mglobl),adercs(mglocs),arhs(mcs), dparm(mglobl), &
1134 scdiag(mglobl),summ,scflag(mglobl), &
1135 indgb(mglobl),indlc(mlocal),loctot,locrej, &
1136 nagb,nalc,nsum,nhist,mhist(51),khist(51),lhist(51), &
1137 nst,nfl,indst(nstore),arest(nstore),itert,lunit,ncs, &
1138 nlnpa(mglobl),nstdev,cfactr,icnpr,icnlim, indnz(mglobl),indbk(mglobl)
1140 CHARACTER (LEN=2) :: patext
1144 WRITE(lup,*)
' Result of fit for global parameters'
1145 WRITE(lup,*)
' ==================================='
1150 err=real(sqrt(abs(cgmat(ii))))
1151 IF(cgmat(ii) < 0.0) err=-err
1153 IF(cgmat(ii)*diag(i) > 0.0)
THEN
1155 gcor=real(sqrt(abs(1.0-1.0/(cgmat(ii)*diag(i)))))
1158 IF(nlnpa(i) /= 0) patext=
'nl'
1159 WRITE(lup,102) i,patext, &
1160 pparm(i),pparm(i)+dparm(i),dparm(i),bgvec(i),err,gcor
1162101
FORMAT(1x,
' I initial final differ', &
1163 ' lastcor Error glcor'/ &
1164 1x,
' --- ----------- ----------- -----------', &
1165 ' ----------- -------- -----')
1166102
FORMAT(1x,i4,1x,a2,1x,4f12.5,f9.5,f6.3)
1190 DOUBLE PRECISION :: v(*),b(n),diag(n),vkk,vjk,eps
1192 parameter(eps=1.0d-10)
1196 diag(i)=abs(v((i*i+i)/2))
1207 IF(abs(v(jj)) > max(abs(vkk),eps*diag(j)))
THEN
1246 v(jl)=v(jl)-v(lk)*vjk
1256 IF(flag(j)) v((k*k-k)/2+j)=0.0d0
1263 10
DO ij=1,(n*n+n)/2
1284 DOUBLE PRECISION :: v,a,w,cik
1285 dimension v(*),a(*),w(*)
1302 cik=cik+a(il+l)*v(lk)
1306 cik=cik+a(il+l)*v(lk)
1312 w(ij)=w(ij)+cik*a(jk)
1330 DOUBLE PRECISION :: a(*),x(*),y(*)
1337 y(i)=y(i)+a(ij)*x(j)
1345 INTEGER :: inc(n),num(maxpl)
1346 parameter(np=maxpl/10+1)
1348 equivalence(nval,fval)
1349 CHARACTER (LEN=1) :: text(10)*130
1350 CHARACTER (LEN=4) :: echar
1351 CHARACTER (LEN=8) :: xchar(maxpl)
1352 CHARACTER (LEN=1) :: chn(0:10)*1
1353 DATA chn/
'0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
'0'/
1358 IF(inc(i) /= 0)
THEN
1360 IF(abs(fval) < 1.0e-30)
THEN
1369 IF(nred > maxpl)
THEN
1392 num(nk)=int(sum+0.5)
1397 IF(num(i) > num(inmax)) inmax=i
1412 IF(num(k) /= 0) text(1)(i:i)=
'.'
1416 WRITE(*,103) text(l)(1:nred)
1422 text(1)(10*i-9:iup)=
'----+----+'
1423 IF(iup == 10*i) text(1)(iup:iup)=chn(i)
1425 WRITE(*,103) text(1)(1:nred)
1427 IF(nap*10-10 > nred) nap=nap-1
1429 p(l)=xa+float(10*l-10)*(xb-xa)/float(nred)
1431 CALL chfmt(p,nap,xchar,echar)
1432 WRITE(*,104) (xchar(l),l=1,nap)
1433 IF(echar /=
' ')
WRITE(*,105) (echar,l=1,nap)
1439 IF(num(i) /= 0)
THEN
1448 WRITE(*,103) text(l)(1:nred)
1452104
FORMAT(12(a8,2x)/)
1453105
FORMAT(3x,12(a4,6x))
1475 CHARACTER (LEN=1) :: ch(10)
1476 CHARACTER (LEN=4) :: echar
1477 CHARACTER (LEN=8) :: xchar(n),fxf,sxf,null
1478 DATA null/
'00000000'/,ch/
'0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9'/
1484 xm=amax1(xm,abs(x(i)))
1487 jp=104-ifix(alog10(abs(xm))+100.04)
1497 ij=int(fc*abs(x(i))+0.5)
1503 IF(jn /= 0.AND.jm == 6) jm=j
151734
IF(jp > jm+4.OR.jp >= 8)
THEN
1530 IF(fxf(j:j) /= ch(1))
GO TO 70
1531 IF(j > jp+1)
GO TO 50
1532 IF(fxf /= null.OR.j >= jp)
GO TO 70
1536 IF(fxf(k:k) /= ch(1))
GO TO 70
1549 IF(x(i) < 0.0) sxf(ib-1:ib-1)=
'-'
1572 REAL :: pn(3),sn(3),table(30,3)
1573 DATA pn/0.31731,0.0455002785,2.69985e-3/
1574 DATA sn/0.47523,1.690140,2.782170/
1575 DATA table/ 1.0000, 1.1479, 1.1753, 1.1798, 1.1775, 1.1730, 1.1680, 1.1630, &
1576 1.1581, 1.1536, 1.1493, 1.1454, 1.1417, 1.1383, 1.1351, 1.1321, &
1577 1.1293, 1.1266, 1.1242, 1.1218, 1.1196, 1.1175, 1.1155, 1.1136, &
1578 1.1119, 1.1101, 1.1085, 1.1070, 1.1055, 1.1040, &
1579 4.0000, 3.0900, 2.6750, 2.4290, 2.2628, 2.1415, 2.0481, 1.9736, &
1580 1.9124, 1.8610, 1.8171, 1.7791, 1.7457, 1.7161, 1.6897, 1.6658, &
1581 1.6442, 1.6246, 1.6065, 1.5899, 1.5745, 1.5603, 1.5470, 1.5346, &
1582 1.5230, 1.5120, 1.5017, 1.4920, 1.4829, 1.4742, &
1583 9.0000, 5.9146, 4.7184, 4.0628, 3.6410, 3.3436, 3.1209, 2.9468, &
1584 2.8063, 2.6902, 2.5922, 2.5082, 2.4352, 2.3711, 2.3143, 2.2635, &
1585 2.2178, 2.1764, 2.1386, 2.1040, 2.0722, 2.0428, 2.0155, 1.9901, &
1586 1.9665, 1.9443, 1.9235, 1.9040, 1.8855, 1.8681/
1595 chindl=(sn(m)+sqrt(float(nd+nd-1)))**2/float(nd+nd)
1604 parameter(mglobl=1400,mlocal=10,nstore=10000,mcs=10)
1605 parameter(mgl=mglobl+mcs)
1607 parameter(msymgb =(mglobl*mglobl+mglobl)/2, msym =(mgl*mgl+mgl)/2, &
1608 msymlc=(mlocal*mlocal+mlocal)/2, mrecta= mglobl*mlocal, &
1609 mglocs= mglobl*mcs, msymcs= (mcs*mcs+mcs)/2 )
1610 DOUBLE PRECISION :: cgmat,clmat,clcmat,bgvec,blvec, &
1611 corrm,corrv,summ,diag,scdiag,pparm,dparm,adercs, arhs
1613 common/lsqred/cgmat(msym),clmat(msymlc),clcmat(mrecta), &
1614 diag(mgl),bgvec(mgl),blvec(mlocal), &
1615 corrm(msymgb),corrv(mglobl),psigm(mglobl), &
1616 pparm(mglobl),adercs(mglocs),arhs(mcs), dparm(mglobl), &
1617 scdiag(mglobl),summ,scflag(mglobl), &
1618 indgb(mglobl),indlc(mlocal),loctot,locrej, &
1619 nagb,nalc,nsum,nhist,mhist(51),khist(51),lhist(51), &
1620 nst,nfl,indst(nstore),arest(nstore),itert,lunit,ncs, &
1621 nlnpa(mglobl),nstdev,cfactr,icnpr,icnlim, indnz(mglobl),indbk(mglobl)
1625 nvec=(nagb*nagb+nagb)/2+nagb
1627 vec(i)=real(cgmat(i))
1630 vec(nvec-nagb+i)=real(bgvec(i))
1632 WRITE(*,*)
'FITMUT ',nvec,(vec(i),i=1,nvec)
1634 entry fitmin(nvec,vec)
1636 IF(nvec /= (nagb*nagb+nagb)/2+nagb)
THEN
1637 WRITE(*,*)
' Wrong dimensions in FITMUT/FITMIN'
1638 WRITE(*,*)
' Argument NVEC =',nvec
1639 WRITE(*,*)
' Expected NVEC =',(nagb*nagb+nagb)/2+nagb
1646 bgvec(i)=vec(nvec-nagb+i)
function znorm()
Return random number N(0,1).
subroutine initgl(nagbar, nalcar, nstd, iprlim)
Initialization of package.
function errpar(i)
Return error for parameter I.
subroutine initun(lun, cutfac)
Define unit for iterations (optional).
subroutine equloc(dergb, derlc, rrmeas, sigma)
Add single equation with its derivatives.
subroutine fitmut(nvec, vec)
Get matrix information out.
subroutine fitglo(par)
Final global fit.
subroutine pxhist(inc, n, xa, xb)
Print X histogram.
subroutine constf(dercs, rhs)
Add constraint (optional).
subroutine chfmt(x, n, xchar, echar)
Prepare printout of array of real numbers as character strings.
subroutine testmp(iarg)
Test of millepede.
subroutine gener(y, a, b, x, sigma, bias, heff)
Generate Y values.
subroutine spavat(v, a, w, n, m)
Similarity operation A*V*A^t.
function corpar(i, j)
Return correlation between parameters I and J.
subroutine spax(a, x, y, m, n)
Multiply general M-by-N matrix A and N-vector X.
function zrand()
Return random number U(0,1).
subroutine fitloc
Fit after end of local block.
subroutine zerloc(dergb, derlc)
Reset derivatives.
subroutine nonlin(INDEX)
Set nonlinear flag for single parameter (optional).
subroutine parglo(par)
Initialize global parameters.
subroutine parsig(INDEX, sigma)
Define sigma for single parameter (optional).
subroutine spminv(v, b, n, nrank, diag, flag)
Obtain solution of a system of linear equations with symmetric matrix and the inverse.
real(mps) function chindl(n, nd)
Chi2/ndf cuts.
subroutine prtglo
Print final log file.