353 USE mptest1, ONLY: nplan,del,dvd
354 USE mptest2, ONLY: nlyr,nmx,nmy,sdevx,sdevy
371 REAL,
DIMENSION(2) :: ta
388 CHARACTER (LEN=24) :: chdate
389 CHARACTER (LEN=24) :: chost
391 INTEGER(KIND=large) :: rows
392 INTEGER(KIND=large) :: cols
394 DOUBLE PRECISION :: sums(9)
407 CALL
mvopen(lunlog,
'millepede.log')
408 CALL getenv(
'HOSTNAME',chost)
409 IF (chost(1:1) ==
' ') CALL getenv(
'HOST',chost)
410 WRITE(*,*)
'($Rev: 92 $)'
417 WRITE(*,*)
' < Millepede II-P starting ... ',chdate
422 WRITE(8,*)
'Log-file Millepede II-P ', chdate
423 WRITE(8,*)
' ', chost
431 IF (memdbg > 0) printflagalloc=1
445 ncache=25000000*mthrd
448 CALL
mpalloc(readbufferinfo,rows,cols,
'read buffer header')
451 CALL
mvopen(lun,
'millepede.his')
456 IF(nrecpr /= 0.OR.nrecp2 /= 0)
THEN
457 CALL
mvopen(1,
'mpdebug.txt')
460 CALL etime(ta,rstext)
466 CALL etime(ta,rloop1)
467 times(1)=rloop1-rstext
470 IF(chicut /= 0.0)
THEN
471 WRITE(8,*)
'Chi square cut equiv 3 st.dev applied ...'
472 WRITE(8,*)
' in first iteration with factor',chicut
473 WRITE(8,*)
' in second iteration with factor',chirem
474 WRITE(8,*)
' (reduced by sqrt in next iterations)'
477 WRITE(8,*)
'Down-weighting of outliers in', lhuber,
' iterations'
478 WRITE(8,*)
'Cut on downweight fraction',dwcut
481 CALL etime(ta,rloop2)
482 times(2)=rloop2-rloop1
501 IF(nloopn > 2.AND.nhistp /= 0)
THEN
511 IF (nloopn <= lfitnp)
THEN
525 CALL
gmpdef(6,1,
'log10(#records) vs file number')
526 CALL
gmpdef(7,1,
'final rejection fraction vs file number')
528 'final <Chi^2/Ndf> from accepted local fits vs file number')
529 CALL
gmpdef(9,1,
'<Ndf> from accepted local fits vs file number')
535 rej=float(nrc-jfd(kfl))/float(nrc)
536 CALL gmpxy(6,float(kfl),alog10(float(nrc)))
537 CALL gmpxy(7,float(kfl),rej)
539 IF (jfd(kfl) > 0)
THEN
540 c2ndf=cfd(kfl)/float(jfd(kfl))
541 CALL gmpxy(8,float(kfl),c2ndf)
542 andf=float(dfd(kfl))/float(jfd(kfl))
543 CALL gmpxy(9,float(kfl),andf)
560 WRITE(*,*)
'Misalignment test wire chamber'
563 CALL
hmpdef( 9,-0.0015,+0.0015,
'True - fitted displacement')
564 CALL
hmpdef(10,-0.0015,+0.0015,
'True - fitted Vdrift')
569 diff=sngl(-del(i)-globalparameter(i))
571 sums(2)=sums(2)+diff*diff
572 diff=sngl(-dvd(i)-globalparameter(100+i))
574 sums(4)=sums(4)+diff*diff
576 sums(1)=0.01d0*sums(1)
577 sums(2)=sqrt(0.01d0*sums(2))
578 sums(3)=0.01d0*sums(3)
579 sums(4)=sqrt(0.01d0*sums(4))
580 WRITE(*,143)
'Parameters 1 - 100: mean =',sums(1),
'rms =',sums(2)
581 WRITE(*,143)
'Parameters 101 - 200: mean =',sums(3),
'rms =',sums(4)
582 143 format(6x,a28,f9.6,3x,a5,f9.6)
588 WRITE(*,102) i,-del(i),globalparameter(i),-del(i)-globalparameter(i), &
589 -dvd(i),globalparameter(100+i),-dvd(i)-globalparameter(100+i)
590 diff=sngl(-del(i)-globalparameter(i))
592 diff=sngl(-dvd(i)-globalparameter(100+i))
604 WRITE(*,*)
'Misalignment test Si tracker'
607 CALL
hmpdef( 9,-0.0025,+0.0025,
'True - fitted displacement X')
608 CALL
hmpdef(10,-0.025,+0.025,
'True - fitted displacement Y')
618 diff=sngl(-sdevx((i-1)*nmxy+k)-globalparameter(ix))
619 sums(1)=sums(1)+1.0d0
621 sums(3)=sums(3)+diff*diff
622 ixv=globalparlabelindex(2,ix)
623 IF (ixv > 0.AND.metsol == 1.OR.metsol == 2)
THEN
625 gmati=sngl(globalmatd(ii))
628 sums(7)=sums(7)+1.0d0
630 sums(9)=sums(9)+diff*diff
633 IF (mod(i,3) == 1)
THEN
636 diff=-sngl(sdevy((i-1)*nmxy+k)-globalparameter(iy))
637 sums(4)=sums(4)+1.0d0
639 sums(6)=sums(6)+diff*diff
640 ixv=globalparlabelindex(2,iy)
641 IF (ixv > 0.AND.metsol == 1.OR.metsol == 2)
THEN
643 gmati=sngl(globalmatd(ii))
646 sums(7)=sums(7)+1.0d0
648 sums(9)=sums(9)+diff*diff
653 sums(2)=sums(2)/sums(1)
654 sums(3)=sqrt(sums(3)/sums(1))
655 sums(5)=sums(5)/sums(4)
656 sums(6)=sqrt(sums(6)/sums(4))
657 WRITE(*,143)
'Parameters 1 - 500: mean =',sums(2),
'rms =',sums(3)
658 WRITE(*,143)
'Parameters 501 - 700: mean =',sums(5),
'rms =',sums(6)
659 IF (sums(7) > 0.5d0)
THEN
660 sums(8)=sums(8)/sums(7)
661 sums(9)=sqrt(sums(9)/sums(7))
662 WRITE(*,143)
'Parameter pulls, all: mean =',sums(8),
'rms =',sums(9)
673 diff=sngl(-sdevx((i-1)*nmxy+k)-globalparameter(ix))
675 WRITE(*,102) ix,-sdevx((i-1)*nmxy+k),globalparameter(ix),-diff
679 IF (mod(i,3) == 1)
THEN
682 diff=sngl(-sdevy((i-1)*nmxy+k)-globalparameter(iy))
684 WRITE(*,102) iy,-sdevy((i-1)*nmxy+k),globalparameter(iy),-diff
696 IF(nrec1+nrec2 > 0)
THEN
699 WRITE(8,*)
'Record',nrec1,
' has largest residual:',value1
702 WRITE(8,*)
'Record',nrec2,
' has largest Chi^2/Ndf:',value2
705 IF(nrec3 < maxi4)
THEN
706 WRITE(8,*)
'Record',nrec3,
' is first with error (rank deficit/NaN)'
709 WRITE(8,*)
'In total 2 +',nloopn,
' loops through the data files'
712 WRITE(8,*)
'In total ',mnrsit,
' internal MINRES iterations'
715 WRITE(8,103) times(0),times(1),times(2),times(4),times(7), &
716 times(5),times(8),times(3),times(6)
720 CALL
sechms(deltat,nhour,minut,secnd)
722 WRITE(8,*)
'Total time =',ntsec,
' seconds =',nhour,
' h',minut, &
723 ' m',nsecnd,
' seconds'
725 WRITE(8,*)
'end ', chdate
726 gbu=4.02e-9*float(maxwordsalloc)
732 IF(nrejec(0)+nrejec(1)+nrejec(2)+nrejec(3) /= 0)
THEN
734 WRITE(8,*)
'Data rejected in last iteration: '
736 nrejec(0),
' (rank deficit/NaN) ',nrejec(1),
' (Ndf=0) ', &
737 nrejec(2),
' (huge) ',nrejec(3),
' (large)'
743 WRITE(*,*)
' < Millepede II-P ending ... ', chdate
745 gbu=4.0e-9*float(maxwordsalloc)
749 102 format(2x,i4,2x,3f10.5,2x,3f10.5)
750 103 format(
' Times [in sec] for text processing',f12.3/ &
753 ' func. value ',f12.3,
' *',f4.0/ &
754 ' func. value, global matrix, solution',f12.3,
' *',f4.0/ &
755 ' new solution',f12.3,
' *',f4.0/)
756 105 format(
' Peak dynamic memory allocation: ',f11.6,
' GB')
783 INTEGER,
INTENT(IN) :: ivgbi
785 DOUBLE PRECISION :: shift
786 DOUBLE PRECISION :: rtol
787 DOUBLE PRECISION :: anorm
788 DOUBLE PRECISION :: acond
789 DOUBLE PRECISION :: rnorm
790 DOUBLE PRECISION :: ynorm
791 DOUBLE PRECISION :: gmati
792 DOUBLE PRECISION :: diag
793 INTEGER(KIND=large) ::
ijadd
794 INTEGER(KIND=large) :: jk
795 INTEGER(KIND=large) :: ii
805 itgbi=globalparvartototal(ivgbi)
806 itgbl=globalparlabelindex(1,itgbi)
809 globalvector(ivgbi)=1.0d0
819 CALL
minres(nagb,globalvector, &
820 workspaced(1), workspaced(1+nagb), workspaced(1+2*nagb), &
821 workspaced(1+3*nagb),workspaced(1+4*nagb),workspaced(1+5*nagb), &
822 globalcorrections,workspaceminres,
avprod,
mcsolv, checka ,.true. , shift, &
823 nout , itnlim, rtol, istop, itn, anorm, acond, rnorm, ynorm)
824 ELSE IF(mbandw > 0)
THEN
825 CALL
minres(nagb,globalvector, &
826 workspaced(1), workspaced(1+nagb), workspaced(1+2*nagb), &
827 workspaced(1+3*nagb),workspaced(1+4*nagb),workspaced(1+5*nagb), &
828 globalcorrections,workspaceminres,
avprod,
mvsolv, checka ,.true. , shift, &
829 nout, itnlim, rtol, istop, itn, anorm, acond, rnorm, ynorm)
831 CALL
minres(nagb,globalvector, &
832 workspaced(1), workspaced(1+nagb), workspaced(1+2*nagb), &
833 workspaced(1+3*nagb),workspaced(1+4*nagb),workspaced(1+5*nagb), &
834 globalcorrections,workspaceminres,
avprod,
mvsolv, checka ,.false., shift, &
835 nout, itnlim, rtol, istop, itn, anorm, acond, rnorm, ynorm)
843 par=sngl(globalparameter(itgbi))
844 dpa=par-globalparstart(itgbi)
845 gmati=globalcorrections(ivgbi)
846 err=sqrt(abs(sngl(gmati)))
847 IF(gmati < 0.0d0) err=-err
851 ELSE IF(matsto == 2)
THEN
852 jk=
ijadd(ivgbi,ivgbi)
857 diag=dble(globalmatf(-jk))
859 gcor2=sngl(1.0d0-1.0d0/(gmati*diag))
860 WRITE(*,102) itgbl,par,globalparpresigma(itgbi),dpa,err,gcor2,itn
861 101 format(1x,
' label parameter presigma differ', &
862 ' Error gcor^2 iit'/ 1x,
'---------',2x,5(
'-----------'),2x,
'----')
863 102 format(i10,2x,4g12.4,f7.4,i6,i4)
886 DOUBLE PRECISION :: rhs
887 DOUBLE PRECISION :: drhs(4)
893 IF(lenconstraints == 0) return
899 rhs=listconstraints(i )%value
900 sgm=listconstraints(i+1)%value
903 label=listconstraints(i)%label
904 factr=listconstraints(i)%value
906 ivgb =globalparlabelindex(2,itgbi)
908 IF(icalcm == 1.AND.ivgb > 0)
THEN
909 CALL
mupdat(nvgb+icgb,ivgb,dble(hugeval*factr))
912 rhs=rhs-factr*globalparameter(itgbi)
914 IF(i > lenconstraints) exit
915 IF(listconstraints(i)%label == 0) exit
917 IF(abs(rhs) > climit)
THEN
923 WRITE(*,101) (idrh(l),drhs(l),l=1,irhs)
927 IF(rhs == 0.0) rhs=1.0e-9
928 globalvector(nvgb+icgb)=rhs*hugeval
932 WRITE(*,101) (idrh(l),drhs(l),l=1,irhs)
935 WRITE(*,102)
' Constraints: only equation values >', climit,
' are printed'
936 101 format(
' ',4(i4,g11.3))
937 102 format(a,g11.2,a)
962 DOUBLE PRECISION:: rhs
963 INTEGER(KIND=large):: length
964 DOUBLE PRECISION,
DIMENSION(:),
ALLOCATABLE :: vecconstraints
965 DOUBLE PRECISION,
DIMENSION(:),
ALLOCATABLE :: matconstraintst
966 DOUBLE PRECISION,
DIMENSION(:),
ALLOCATABLE :: auxvectord
967 INTEGER,
DIMENSION(:),
ALLOCATABLE :: auxvectori
970 IF(lenconstraints == 0) return
972 length=(ncgb*ncgb+ncgb)/2
973 CALL
mpalloc(matconsproduct, length,
'product matrix of constraints')
976 CALL
mpalloc(vecconsresiduals, length,
'residuals of constraints')
977 CALL
mpalloc(vecconstraints,length,
'rhs vector')
978 CALL
mpalloc(auxvectori,length,
'auxiliary array (I)')
979 CALL
mpalloc(auxvectord,length,
'auxiliary array (D)')
982 CALL
mpalloc(matconstraintst,length,
'transposed matrix of constraints')
983 matconstraintst=0.0d0
987 rhs=listconstraints(i )%value
988 sgm=listconstraints(i+1)%value
991 label=listconstraints(i)%label
992 factr=listconstraints(i)%value
994 ivgb =globalparlabelindex(2,itgbi)
995 IF(ivgb > 0) matconstraintst(icgb+(ivgb-1)*ncgb)=factr
996 rhs=rhs-factr*globalparameter(itgbi)
998 IF(i > lenconstraints) exit
999 IF(listconstraints(i)%label == 0) exit
1001 vecconstraints(icgb)=rhs
1009 matconsproduct(ij)=matconsproduct(ij)+matconstraintst((l-1)*ncgb+i)*matconstraintst((l-1)*ncgb+j)
1015 CALL
sqminv(matconsproduct,vecconstraints,ncgb,nrank, auxvectord, auxvectori)
1020 WRITE(*,*)
'Rank of product matrix of constraints is',nrank, &
1021 ' for',ncgb,
' constraint equations'
1022 WRITE(8,*)
'Rank of product matrix of constraints is',nrank, &
1023 ' for',ncgb,
' constraint equations'
1024 IF(nrank < ncgb)
THEN
1025 WRITE(*,*)
'Warning: insufficient constraint equations!'
1026 WRITE(8,*)
'Warning: insufficient constraint equations!'
1027 IF (iforce == 0)
THEN
1029 WRITE(*,*)
' --> enforcing SUBITO mode'
1030 WRITE(8,*)
' --> enforcing SUBITO mode'
1064 REAL,
INTENT(IN) :: concut
1065 INTEGER,
INTENT(OUT) :: iact
1067 DOUBLE PRECISION :: rhs
1068 DOUBLE PRECISION ::sum1
1069 DOUBLE PRECISION ::sum2
1070 DOUBLE PRECISION ::sum3
1071 INTEGER(KIND=large) :: length
1074 DOUBLE PRECISION,
DIMENSION(:),
ALLOCATABLE :: auxvectord
1075 DOUBLE PRECISION,
DIMENSION(:),
ALLOCATABLE :: veccorrections
1079 IF(lenconstraints == 0) return
1082 vecconsresiduals=0.0d0
1087 rhs=listconstraints(i )%value
1088 sgm=listconstraints(i+1)%value
1091 label=listconstraints(i)%label
1092 factr=listconstraints(i)%value
1094 rhs=rhs-factr*globalparameter(itgbi)
1096 IF(i > lenconstraints) exit
1097 IF(listconstraints(i)%label == 0) exit
1099 vecconsresiduals(icgb)=rhs
1108 sum1=sum1+vecconsresiduals(icgb)**2
1109 sum2=sum2+abs(vecconsresiduals(icgb))
1110 sum3=max(sum3,abs(vecconsresiduals(icgb)))
1112 sum1=sqrt(sum1/dfloat(ncgb))
1113 sum2=sum2/dfloat(ncgb)
1115 IF(iter == 1.AND.sum1 < concut) return
1117 IF(iter == 1.AND.ncgb <= 12)
THEN
1119 WRITE(*,*)
'Constraint equation discrepancies:'
1120 WRITE(*,101) (icgb,vecconsresiduals(icgb),icgb=1,ncgb)
1121 101 format(4x,4(i5,g12.4))
1123 103 format(10x,
' Cut on rms value is',g8.1)
1128 WRITE(*,*)
'Improve constraints'
1132 WRITE(*,102) iter,sum1,sum2,sum3
1133 102 format(i6,
' rms',g12.4,
' avrg_abs',g12.4,
' max_abs',g12.4)
1136 CALL
mpalloc(auxvectord,length,
'auxiliary vector (D)')
1138 CALL
mpalloc(veccorrections,length,
'constraint corrections')
1139 veccorrections=0.0d0
1142 CALL
dbsvx(matconsproduct,vecconsresiduals,auxvectord,ncgb)
1146 rhs=listconstraints(i )%value
1147 sgm=listconstraints(i+1)%value
1150 label=listconstraints(i)%label
1151 factr=listconstraints(i)%value
1153 ivgb =globalparlabelindex(2,itgbi)
1155 veccorrections(ivgb)=veccorrections(ivgb)+auxvectord(icgb)*factr
1158 IF(i > lenconstraints) exit
1159 IF(listconstraints(i)%label == 0) exit
1164 itgbi=globalparvartototal(i)
1165 globalparameter(itgbi)=globalparameter(itgbi)+veccorrections(i)
1238 INTEGER :: maxrecordsize
1239 INTEGER :: maxrecordfile
1241 INTEGER,
INTENT(OUT) :: more
1246 DOUBLE PRECISION :: ds0
1247 DOUBLE PRECISION :: ds1
1248 DOUBLE PRECISION :: ds2
1249 DOUBLE PRECISION :: dw
1253 inder(i)=readbufferdatai(i)
1257 DATA npri / 0 /, mpri / 1000 /
1265 minrecordsinblock=
size(readbufferdatai)
1272 IF (ifile < nfilb)
THEN
1274 readbufferinfo(1,k)=ifile
1275 readbufferinfo(2,k)=nact
1280 npointer=
size(readbufferpointer)/nact
1281 ndata=
size(readbufferdatai)/nact
1284 iact=readbufferinfo(2,k)
1285 readbufferinfo(4,k)=0
1286 readbufferinfo(5,k)=iact*ndata
1288 numblocks=numblocks+1
1299 jfile=readbufferinfo(1,ithr)
1300 iact =readbufferinfo(2,ithr)
1301 jrec =readbufferinfo(3,ithr)
1304 files:
DO WHILE (jfile > 0)
1307 nbuf=readbufferinfo(4,ithr)+1
1308 noff=readbufferinfo(5,ithr)+2
1310 IF(kfile <= nfilf)
THEN
1312 READ(lun,iostat=ierrf) n,(readbufferdataf(noff+i),i=1,min(n/2,nr)),&
1313 (readbufferdatai(noff+i),i=1,min(n/2,nr))
1315 IF (ierrf < 0) rewind lun
1320 CALL readc(readbufferdataf(noff+1),readbufferdatai(noff+1),nr,lun,ierrc)
1325 eof=(ierrc <= 0.AND.ierrc /= -4)
1327 IF(eof) exit records
1330 readbufferinfo(3,ithr)=jrec
1332 xfd(jfile)=max(xfd(jfile),n)
1335 IF(inder(noff+1) /= 0) CALL hmpent(8,float(inder(noff+1)))
1339 IF (nr <= ndimbuf)
THEN
1340 readbufferinfo(4,ithr)=nbuf
1341 readbufferinfo(5,ithr)=noff+nr
1343 readbufferpointer(ioffp+nbuf)=noff
1344 readbufferdatai(noff )=noff+nr
1345 readbufferdatai(noff-1)=ifd(kfile)+jrec
1346 readbufferdataf(noff )=
real(kfile)
1347 readbufferdataf(noff-1)=wfd(kfile)
1349 IF ((noff+nr+2+ndimbuf >= ndata*(iact+1)).OR.(nbuf >= npointer)) exit
files
1352 skippedrecords=skippedrecords+1
1358 readbufferinfo(1,ithr)=-jfile
1359 IF (kfd(1,jfile) == 0)
THEN
1360 print *,
'PEREAD: file ', kfile,
'read the first time, found',jrec,
' records'
1365 IF (ifile < nfilb)
THEN
1368 readbufferinfo(1,ithr)=ifile
1369 readbufferinfo(3,ithr)=jrec
1372 jfile=readbufferinfo(1,ithr)
1377 nrd=readbufferinfo(4,1)
1379 iact =readbufferinfo(2,k)
1381 nbuf=readbufferinfo(4,k)
1383 readbufferpointer(nrd+l)=readbufferpointer(ioffp+l)
1390 jfile=readbufferinfo(1,k)
1392 readbufferinfo(2,k)=more
1396 readbufferinfo(1,k)=0
1397 readbufferinfo(2,k)=-1
1398 readbufferinfo(3,k)=0
1402 IF (mxrec > 0.AND.(ntot+nrd) >= mxrec)
THEN
1406 jfile=readbufferinfo(1,k)
1408 nrc=readbufferinfo(3,k)
1409 IF (kfd(1,jfile) == 0) kfd(1,jfile)=-nrc
1410 IF (kfile <= nfilf)
THEN
1427 sumrecords=sumrecords+nrd
1428 minrecordsinblock=min(minrecordsinblock,nrd)
1429 maxrecordsinblock=max(maxrecordsinblock,nrd)
1431 DO WHILE (nloopn == 0.AND.ntot >= nrpr)
1432 WRITE(*,*)
' Record ',nrpr
1433 IF (nrpr < 100000)
THEN
1440 IF (ncache > 0.AND.nloopn <= 1.AND. npri < mpri.AND.mprint > 1)
THEN
1442 IF (npri == 1)
WRITE(*,100)
1443 WRITE(*,101) nrec, nrd, more ,ifile
1444 100 format(/
' PeRead records active file' &
1445 /
' total block threads number')
1446 101 format(
' PeRead',4i10)
1459 IF (xfd(k) > maxrecordsize)
THEN
1460 maxrecordsize=xfd(k)
1463 dw=dfloat(-kfd(1,k))
1464 IF (wfd(k) /= 1.0) nfilw=nfilw+1
1466 ds1=ds1+dw*dble(wfd(k))
1467 ds2=ds2+dw*dble(wfd(k)**2)
1469 print *,
'PEREAD: file ', maxrecordfile,
'with max record size ', maxrecordsize
1470 IF (nfilw > 0.AND.ds0 > 0.0d0)
THEN
1474 WRITE(lun,177) nfilw,sngl(ds1),sngl(ds2)
1475 177 format(/
' !!!!!',i4,
' weighted binary files', &
1476 /
' !!!!! mean, variance of weights =',2g12.4)
1481 ifd(k)=ifd(k-1)-kfd(1,k-1)
1484 IF (nthr > 1) CALL
sort2k(kfd,nfilb)
1485 IF (skippedrecords > 0)
THEN
1486 print *,
'PEREAD skipped records: ', skippedrecords
1487 ndimbuf=maxrecordsize/2
1492 IF (ncache > 0.AND.nloopn <= 1.AND.mprint > 0) &
1493 WRITE(*,179) numblocks, sumrecords, minrecordsinblock, maxrecordsinblock
1494 179 format(/
' Read cache usage (#blocks, #records, ', &
1495 'min,max records/block'/17x,4i10)
1513 INTEGER,
INTENT(IN) :: mode
1530 isfrst(ibuf)=readbufferpointer(ibuf)+1
1531 islast(ibuf)=readbufferdatai(readbufferpointer(ibuf))
1534 ichunk=min((numreadbuffer+mthrd-1)/mthrd/32+1,256)
1540 DO ibuf=1,numreadbuffer
1546 CALL
isjajb(nst,ist,ja,jb,jsp)
1549 readbufferdatai(jb+j)=
inone( readbufferdatai(jb+j) )
1558 DO ibuf=1,numreadbuffer
1562 CALL
isjajb(nst,ist,ja,jb,jsp)
1565 readbufferdatai(jb+j)=
inone( readbufferdatai(jb+j) )
1604 INTEGER,
INTENT(IN) :: nst
1605 INTEGER,
INTENT(IN OUT) :: is
1606 INTEGER,
INTENT(OUT) :: ja
1607 INTEGER,
INTENT(OUT) :: jb
1608 INTEGER,
INTENT(OUT) :: jsp
1611 inder(i)=readbufferdatai(i)
1612 glder(i)=readbufferdataf(i)
1618 IF(is >= nst) return
1621 IF(inder(is) == 0) exit
1626 IF(inder(is) == 0) exit
1629 DO WHILE(inder(is+1) /= 0.AND.is < nst)
1632 IF(ja+1 /= jb.OR.glder(jb) >= 0.0) exit
1635 is=is+ifix(-glder(jb)+0.5)
1694 DOUBLE PRECISION:: adder
1695 DOUBLE PRECISION::funref
1696 DOUBLE PRECISION::dchi2s
1697 DOUBLE PRECISION::sndf
1698 INTEGER(KIND=large):: ii
1701 isfrst(ibuf)=readbufferpointer(ibuf)+1
1702 islast(ibuf)=readbufferdatai(readbufferpointer(ibuf))
1703 inder(i)=readbufferdatai(i)
1704 glder(i)=readbufferdataf(i)
1706 IF(nloopn == 0)
THEN
1716 IF(nloopn == 1)
THEN
1717 CALL
gmpdef(1,4,
'Function value in iterations')
1718 IF (metsol == 3)
THEN
1719 CALL
gmpdef(2,3,
'Number of MINRES steps vs iteration nr')
1721 CALL
hmpdef( 5,0.0,0.0,
'Number of degrees of freedom')
1722 CALL
hmpdef(11,0.0,0.0,
'Number of local parameters')
1723 CALL
hmpdef(23,0.0,0.0,
'SQRT of diagonal elements without presigma')
1724 CALL
hmpdef(24,0.0,0.0,
'Log10 of off-diagonal elements')
1725 CALL
hmpdef(25,0.0,0.0,
'Relative individual pre-sigma')
1726 CALL
hmpdef(26,0.0,0.0,
'Relative global pre-sigma')
1730 CALL
hmpdef(3,-prange,prange, &
1731 'Normalized residuals of single (global) measurement')
1732 CALL
hmpdef(12,-prange,prange, &
1733 'Normalized residuals of single (local) measurement')
1734 CALL
hmpdef(13,-prange,prange, &
1735 'Pulls of single (global) measurement')
1736 CALL
hmpdef(14,-prange,prange, &
1737 'Pulls of single (local) measurement')
1738 CALL
hmpdef(4,0.0,0.0,
'Chi^2/Ndf after local fit')
1739 CALL
gmpdef(4,5,
'location, dispersion (res.) vs record nr')
1740 CALL
gmpdef(5,5,
'location, dispersion (pull) vs record nr')
1747 IF(icalcm == 1)
THEN
1750 IF (metsol >= 3) matprecond=0.0d0
1753 IF(nloopn == 2) CALL
hmpdef(6,0.0,0.0,
'Down-weight fraction')
1756 IF(iterat /= lastit)
THEN
1760 nrej=nrejec(0)+nrejec(1)+nrejec(2)+nrejec(3)
1762 IF(iterat == 1)
THEN
1764 ELSE IF(iterat >= 1)
THEN
1766 IF(chicut /= 0.0.AND.chicut < 1.5) chicut=1.0
1767 IF(chicut /= 0.0.AND.nrej == 0) chicut=1.0
1777 writebufferheader(k)=0
1778 writebufferheader(-k)=0
1793 CALL
loopbf(nrejec,ndfs,sndf,dchi2s,nfiles,jfd,cfd,dfd)
1802 ioffb=ioffb+lenglobalvec
1804 globalvector(k)=globalvector(k)+globalvector(ioffb+k)
1808 IF (icalcm == 1)
THEN
1810 nparl=writebufferheader(3)
1811 ncrit=writebufferheader(4)
1812 used=float(writebufferheader(-5))/float(writebufferheader(-3))*0.1
1813 usei=float(writebufferheader(5))/float(writebufferheader(3))*0.1
1814 peakd=float(writebufferheader(-6))*0.1
1815 peaki=float(writebufferheader(6))*0.1
1816 WRITE(*,111) nparl,ncrit,usei,used,peaki,peakd
1817 111 format(
' Write cache usage (#flush,#overrun,<levels>,', &
1818 'peak(levels))'/2i7,
',',4(f6.1,
'%'))
1823 IF(nloopn == 1)
THEN
1828 IF(matsto == 1)
THEN
1832 IF(matsto == 2) ii=i
1833 IF(matsto == 3) ii=i
1835 elmt=sngl(globalmatd(ii))
1836 IF(elmt > 0.0) CALL hmpent(23,1.0/sqrt(elmt))
1847 IF(icalcm == 1)
THEN
1850 IF(globalparpreweight(ivgb) /= 0.0)
THEN
1851 IF(ivgb > 0) CALL
mupdat(ivgb,ivgb,dble(globalparpreweight(ivgb)))
1866 IF(nregul /= 0)
THEN
1868 itgbi=globalparvartototal(ivgb)
1869 globalvector(ivgb)=globalvector(ivgb) -globalparameter(itgbi)*globalparpreweight(ivgb)
1870 adder=globalparpreweight(ivgb)*globalparameter(itgbi)**2
1880 DO WHILE (i <= lenmeasurements)
1881 rhs=listmeasurements(i )%value
1882 sgm=listmeasurements(i+1)%value
1885 IF(sgm > 0.0) weight=1.0/sgm**2
1893 IF(i > lenmeasurements) exit
1894 IF(listmeasurements(i)%label == 0) exit
1899 factrj=listmeasurements(j)%value
1900 itgbij=
inone(listmeasurements(j)%label)
1901 IF(itgbij /= 0)
THEN
1902 dsum=dsum+factrj*sngl(globalparameter(itgbij))
1906 IF(itgbij /= 0) ivgbij=globalparlabelindex(2,itgbij)
1908 globalvector(ivgbij)=globalvector(ivgbij) -weight*dsum*factrj
1911 IF(icalcm == 1.AND.ivgbij > 0)
THEN
1913 factrk=listmeasurements(k)%value
1914 itgbik=
inone(listmeasurements(k)%label)
1917 IF(itgbik /= 0) ivgbik=globalparlabelindex(2,itgbik)
1918 IF(ivgbij > 0.AND.ivgbik > 0)
THEN
1919 CALL
mupdat(ivgbij,ivgbik,dble(weight*factrj*factrk))
1925 adder=weight*dsum**2
1935 rloop=iterat+0.01*nloopn
1936 actfun=sngl(funref-fvalue)
1937 IF(nloopn == 1) actfun=0.0
1940 IF(delfun /= 0.0)
THEN
1941 ratae=min(99.9,actfun/delfun)
1942 ratae=max(-99.9,ratae)
1947 nrej =nrejec(0)+nrejec(1)+nrejec(2)+nrejec(3)
1948 IF(nloopn == 1)
THEN
1951 WRITE(*,*)
'Data rejected in initial loop:'
1953 nrejec(0),
' (rank deficit/NaN) ',nrejec(1),
' (Ndf=0) ', &
1954 nrejec(2),
' (huge) ',nrejec(3),
' (large)'
1963 IF(newite.AND.iterat == 2)
THEN
1964 IF(nrecpr /= 0.OR.nrecp2 /= 0) nrecer=nrec3
1973 IF(nloopn <= 2)
THEN
1974 IF(nhistp /= 0)
THEN
1983 IF (nloopn <= lfitnp)
THEN
1990 IF(nloopn == 2) CALL hmpwrt(6)
1991 IF(nloopn <= 1)
THEN
1999 IF (nloopn == 1.AND.nbndr > 0)
THEN
2002 WRITE(lun,*)
' === local fits have bordered band matrix structure ==='
2003 WRITE(lun,101)
' NBNDR',nbndr,
'number of records'
2004 WRITE(lun,101)
' NBDRX',nbdrx,
'max border size'
2005 WRITE(lun,101)
' NBNDX',nbndx,
'max band width'
2011 101 format(1x,a6,
' =',i10,
' = ',a)
2015 END SUBROUTINE loopn
2026 INTEGER,
INTENT(IN) :: lunp
2031 101 format(
' it fc',
' fcn_value dfcn_exp slpr costh iit st', &
2032 ' ls step cutf',1x,
'rejects hmmsec FMS')
2033 102 format(
' -- --',
' ----------- -------- ---- ----- --- --', &
2034 ' -- ---- ----',1x,
'------- ------ ---')
2057 REAL,
DIMENSION(2) :: ta
2059 INTEGER,
INTENT(IN) :: lunp
2061 CHARACTER (LEN=4):: ccalcm(4)
2062 DATA ccalcm /
' end',
' S',
' F ',
' FMS' /
2065 nrej=nrejec(0)+nrejec(1)+nrejec(2)+nrejec(3)
2066 IF(nrej > 9999999) nrej=9999999
2069 CALL
sechms(deltim,nhour,minut,secnd)
2071 IF(iterat == 0)
THEN
2072 WRITE(lunp,103) iterat,nloopn,fvalue, &
2073 chicut,nrej,nhour,minut,nsecnd,ccalcm(lcalcm)
2075 CALL
ptlopt(nfa,ma,slopes,steps)
2076 ratae=abs(slopes(2)/slopes(1))
2078 WRITE(lunp,104) iterat,nloopn,fvalue,delfun,ratae,angras, &
2079 iitera,istopa,lsinfo,stepl, chicut,nrej,nhour,minut,nsecnd,ccalcm(lcalcm)
2081 103 format(i3,i3,e12.5,38x,f5.1, 1x,i7, i2,i2,i3,a4)
2082 104 format(i3,i3,e12.5,1x,e8.2,f6.3,f6.3,i5,2i3,f6.2,f5.1, &
2106 REAL,
DIMENSION(2) :: ta
2108 INTEGER,
INTENT(IN) :: lunp
2109 CHARACTER (LEN=4):: ccalcm(4)
2110 DATA ccalcm /
' end',
' S',
' F ',
' FMS' /
2113 nrej=nrejec(0)+nrejec(1)+nrejec(2)+nrejec(3)
2114 IF(nrej > 9999999) nrej=9999999
2117 CALL
sechms(deltim,nhour,minut,secnd)
2119 CALL
ptlopt(nfa,ma,slopes,steps)
2120 ratae=abs(slopes(2)/slopes(1))
2122 WRITE(lunp,105) nloopn,fvalue, ratae,lsinfo, &
2123 stepl,nrej,nhour,minut,nsecnd,ccalcm(lcalcm)
2124 105 format(3x,i3,e12.5,9x, f6.3,14x,i3,f6.2,6x, i7, i2,i2,i3,a4)
2141 REAL,
DIMENSION(2) :: ta
2143 INTEGER,
INTENT(IN) :: lunp
2144 CHARACTER (LEN=4):: ccalcm(4)
2145 DATA ccalcm /
' end',
' S',
' F ',
' FMS' /
2149 CALL
sechms(deltim,nhour,minut,secnd)
2150 nsecnd=ifix(secnd+0.5)
2152 WRITE(lunp,106) nhour,minut,nsecnd,ccalcm(lcalcm)
2153 106 format(69x,i2,i2,i3,a4)
2162 WRITE(lunit,102)
'Explanation of iteration table'
2163 WRITE(lunit,102)
'=============================='
2164 WRITE(lunit,101)
'it', &
2165 'iteration number. Global parameters are improved for it > 0.'
2166 WRITE(lunit,102)
'First function evaluation is called iteraton 0.'
2167 WRITE(lunit,101)
'fc',
'number of function evaluations.'
2168 WRITE(lunit,101)
'fcn_value',
'value of 2 x Likelihood function (LF).'
2169 WRITE(lunit,102)
'The final value is the chi^2 value of the fit and should'
2170 WRITE(lunit,102)
'be about equal to the NDF (see below).'
2171 WRITE(lunit,101)
'dfcn_exp', &
2172 'expected reduction of the value of the Likelihood function (LF)'
2173 WRITE(lunit,101)
'slpr',
'ratio of the actual slope to inital slope.'
2174 WRITE(lunit,101)
'costh', &
2175 'cosine of angle between search direction and -gradient'
2176 WRITE(lunit,101)
'iit', &
2177 'number of internal iterations in GMRES/MINRES algorithmus'
2178 WRITE(lunit,101)
'st',
'stop code of GMRES/MINRES algorithmus'
2179 WRITE(lunit,102)
'< 0: rhs is very special, with beta2 = 0'
2180 WRITE(lunit,102)
'= 0: rhs b = 0, i.e. the exact solution is x = 0'
2181 WRITE(lunit,102)
'= 1 requested accuracy achieved, as determined by rtol'
2182 WRITE(lunit,102)
'= 2 reasonable accuracy achieved, given eps'
2183 WRITE(lunit,102)
'= 3 x has converged to an eigenvector'
2184 WRITE(lunit,102)
'= 4 matrix ill-conditioned (Acond has exceeded 0.1/eps)'
2185 WRITE(lunit,102)
'= 5 the iteration limit was reached'
2186 WRITE(lunit,102)
'= 6 Matrix x vector does not define a symmetric matrix'
2187 WRITE(lunit,102)
'= 7 Preconditioner does not define a symmetric matrix'
2188 WRITE(lunit,101)
'ls',
'line search info'
2189 WRITE(lunit,102)
'< 0 recalculate function'
2190 WRITE(lunit,102)
'= 0: N or STP lt 0 or step not descending'
2191 WRITE(lunit,102)
'= 1: Linesearch convergence conditions reached'
2192 WRITE(lunit,102)
'= 2: interval of uncertainty at lower limit'
2193 WRITE(lunit,102)
'= 3: max nr of line search calls reached'
2194 WRITE(lunit,102)
'= 4: step at the lower bound'
2195 WRITE(lunit,102)
'= 5: step at the upper bound'
2196 WRITE(lunit,102)
'= 6: rounding error limitation'
2197 WRITE(lunit,101)
'step', &
2198 'the factor for the Newton step during the line search. Usually'
2200 'a value of 1 gives a sufficient reduction of the LF. Oherwise'
2201 WRITE(lunit,102)
'other step values are tried.'
2202 WRITE(lunit,101)
'cutf', &
2203 'cut factor. Local fits are rejected, if their chi^2 value'
2205 'is larger than the 3-sigma chi^2 value times the cut factor.'
2206 WRITE(lunit,102)
'A cut factor of 1 is used finally, but initially a larger'
2207 WRITE(lunit,102)
'factor may be used. A value of 0.0 means no cut.'
2208 WRITE(lunit,101)
'rejects',
'total number of rejected local fits.'
2209 WRITE(lunit,101)
'hmmsec',
'the time in hours (h), minutes (mm) and seconds.'
2210 WRITE(lunit,101)
'FMS',
'calculation of Function value, Matrix, Solution.'
2213 101 format(a9,
' = ',a)
2230 INTEGER,
INTENT(IN) :: i
2231 INTEGER,
INTENT(IN) :: j
2232 DOUBLE PRECISION,
INTENT(IN) :: add
2234 INTEGER(KIND=large)::
ijadd
2235 INTEGER(KIND=large):: ia
2236 INTEGER(KIND=large):: ja
2237 INTEGER(KIND=large):: ij
2239 IF(i <= 0.OR.j <= 0) return
2243 IF(matsto == 1)
THEN
2245 globalmatd(ij)=globalmatd(ij)+add
2246 ELSE IF(matsto == 2)
THEN
2250 globalmatd(ij)=globalmatd(ij)+add
2252 globalmatf(-ij)=globalmatf(-ij)+sngl(add)
2255 IF(metsol >= 3)
THEN
2258 ij=indprecond(ia)-ia+ja
2259 IF(ia > 1.AND.ij <= indprecond(ia-1)) ij=0
2260 IF(ij /= 0) matprecond(ij)=matprecond(ij)+add
2261 IF(ij < 0.OR.ij >
size(matprecond)) stop
'mupdat: bad index'
2263 ij=indprecond(nvgb)+(ia-nvgb-1)*nvgb+ja
2264 IF(ij /= 0) matprecond(ij)=matprecond(ij)+add
2266 ELSE IF(mbandw == 0)
THEN
2268 IF(ja == ia) matprecond(ia)=matprecond(ia)+add
2270 ij=nvgb+(ia-nvgb-1)*nvgb+ja
2271 IF(ij /= 0) matprecond(ij)=matprecond(ij)+add
2308 SUBROUTINE loopbf(nrej,ndfs,sndf,dchi2s, numfil,naccf,chi2f,ndff)
2405 INTEGER,
INTENT(IN OUT) :: nrej(0:3)
2406 INTEGER,
INTENT(IN OUT) :: ndfs
2407 DOUBLE PRECISION,
INTENT(IN OUT) :: sndf
2408 DOUBLE PRECISION,
INTENT(IN OUT) :: dchi2s
2409 INTEGER,
INTENT(IN) :: numfil
2410 INTEGER,
INTENT(IN OUT) :: naccf(numfil)
2411 REAL,
INTENT(IN OUT) :: chi2f(numfil)
2412 INTEGER,
INTENT(IN OUT) :: ndff(numfil)
2414 DOUBLE PRECISION::dch2sd
2415 DOUBLE PRECISION:: dchi2
2416 DOUBLE PRECISION::dvar
2417 DOUBLE PRECISION:: dw1
2418 DOUBLE PRECISION::dw2
2419 DOUBLE PRECISION::summ
2425 CHARACTER (LEN=3):: chast
2430 ijsym(i,j)=min(i,j)+(max(i,j)*max(i,j)-max(i,j))/2
2431 isfrst(ibuf)=readbufferpointer(ibuf)+1
2432 islast(ibuf)=readbufferdatai(readbufferpointer(ibuf))
2433 inder(i)=readbufferdatai(i)
2434 glder(i)=readbufferdataf(i)
2436 ichunk=min((numreadbuffer+mthrd-1)/mthrd/32+1,256)
2460 DO ibuf=1,numreadbuffer
2461 nrc=readbufferdatai(isfrst(ibuf)-2)
2462 kfl=nint(readbufferdataf(isfrst(ibuf)-1))
2463 wrc=readbufferdataf(isfrst(ibuf)-2)
2472 ioffd=writebufferheader(-1)*iproc+writebufferinfo(2,iproc+1)
2473 ioffi=writebufferheader(1)*iproc+writebufferinfo(3,iproc+1)+2
2478 IF(nloopn == 1.AND.mod(nrc,100000) == 0)
THEN
2479 WRITE(*,*)
'Record',nrc,
' ... still reading'
2488 IF(newite.AND.(iterat == 1.OR.iterat == 3))
THEN
2489 IF(nrc == nrecpr) lprnt=.true.
2490 IF(nrc == nrecp2) lprnt=.true.
2491 IF(nrc == nrecer) lprnt=.true.
2496 IF (nprdbg == 1) iprdbg=iproc
2497 IF (iproc /= iprdbg) lprnt=.false.
2502 WRITE(1,*)
'------------------ Loop',nloopn, &
2503 ': Printout for record',nrc,iproc
2514 CALL
isjajb(nst,ist,ja,jb,jsp)
2516 IF(imeas == 0)
WRITE(1,1121)
2518 WRITE(1,1122) imeas,glder(ja),glder(jb), &
2519 (inder(ja+j),glder(ja+j),j=1,jb-ja-1)
2521 1121 format(/
'Measured value and local derivatives'/ &
2522 ' i measured std_dev index...derivative ...')
2523 1122 format(i3,2g12.4,3(i3,g12.4)/(27x,3(i3,g12.4)))
2529 CALL
isjajb(nst,ist,ja,jb,jsp)
2531 IF(imeas == 0)
WRITE(1,1123)
2535 WRITE(1,1124) imeas,(globalparlabelindex(1,inder(jb+j)),inder(jb+j), &
2536 globalparlabelindex(2,inder(jb+j)),glder(jb+j),j=1,ist-jb)
2538 WRITE(1,1125) imeas,(globalparlabelindex(1,inder(jb+j)),inder(jb+j), &
2539 globalparlabelindex(2,inder(jb+j)),glder(jb+j),j=1,ist-jb)
2543 1123 format(/
'Global derivatives'/ &
2544 ' i label gindex vindex derivative ...')
2545 1124 format(i3,2(i9,i7,i7,g12.4)/(3x,2(i9,i7,i7,g12.4)))
2546 1125 format(i3,2(i9,i7,i7,g12.4))
2556 WRITE(1,*)
'Data corrections using values of global parameters'
2557 WRITE(1,*)
'=================================================='
2566 CALL
isjajb(nst,ist,ja,jb,jsp)
2572 rmeas=rmeas-glder(jb+j)*sngl(globalparameter(itgbi))
2573 IF (icalcm == 1)
THEN
2574 ij=globalparlabelindex(2,itgbi)
2576 ijn=backindexusage(ioffe+ij)
2579 globalindexusage(ioffc+nalg)=ij
2580 backindexusage(ioffe+ij)=nalg
2587 IF (jb < ist)
WRITE(1,102) imeas,glder(ja),rmeas,glder(jb)
2589 readbufferdataf(ja)=rmeas
2595 101 format(
' index measvalue corrvalue sigma')
2596 102 format(i6,2x,2g12.4,
' +-',g12.4)
2598 IF(nalc <= 0) go to 90
2600 ngg=(nalg*nalg+nalg)/2
2601 IF (icalcm == 1)
THEN
2603 localglobalmatrix(k)=0.0d0
2605 writebufferindices(ioffi-1)=nrc
2606 writebufferindices(ioffi )=nalg
2607 CALL
sort1k(globalindexusage(ioffc+1),nalg)
2609 iext=globalindexusage(ioffc+k)
2610 writebufferindices(ioffi+k)=iext
2611 backindexusage(ioffe+iext)=k
2614 writebufferupdates(ioffd+k)=0.0d0
2620 IF(nloopn /= 1.AND.lhuber /= 0) nter=lhuber
2634 DO WHILE(iter < nter)
2639 WRITE(1,*)
'Outlier-suppression iteration',iter,
' of',nter
2640 WRITE(1,*)
'=========================================='
2650 DO i=1,(nalc*nalc+nalc)/2
2659 CALL
isjajb(nst,ist,ja,jb,jsp)
2666 resid=rmeas-localcorrections(neq)
2667 IF(nloopn /= 1.AND.iter /= 1.AND.lhuber /= 0)
THEN
2669 IF(abs(resid) > chuber*rerr)
THEN
2670 wght=wght*chuber*rerr/abs(resid)
2674 wght=wght/(1.0+(resid/rerr/cauchy)**2)
2678 IF(lprnt.AND.iter /= 1.AND.nter /= 1)
THEN
2680 IF(abs(resid) > chuber*rerr) chast=
'* '
2681 IF(abs(resid) > 3.0*rerr) chast=
'** '
2682 IF(abs(resid) > 6.0*rerr) chast=
'***'
2683 IF(imeas == 0)
WRITE(1,*)
'Second loop: accumulate'
2684 IF(imeas == 0)
WRITE(1,103)
2689 WRITE(1,104) imeas,rmeas,resid,rerr,r1,chast,r2
2691 103 format(
' index corrvalue residuum sigma', &
2693 104 format(i6,2x,2g12.4,
' +-',g12.4,f7.2,1x,a3,f8.2)
2697 blvec(ij)=blvec(ij)+dble(wght)*dble(rmeas)*dble(glder(ja+j))
2701 clmat(jk)=clmat(jk) &
2702 +dble(wght)*dble(glder(ja+j))*dble(glder(ja+k))
2707 ibandh(id)=max(ibandh(id),im)
2713 IF (iter == 1.AND.nalc > 5.AND.lfitbb > 0)
THEN
2720 kbdr=max(kbdr,ibandh(k))
2721 icost=6*(nalc-kbdr)*(kbnd+kbdr+1)**2+2*kbdr**3
2722 IF (icost < icmn)
THEN
2736 IF (nloopn == 1)
THEN
2738 nbdrx=max(nbdrx,mbdr)
2739 nbndx=max(nbndx,mbnd)
2743 IF (nloopn <= lfitnp.AND.iter == 1) inv=1
2744 IF (icalcm == 1.OR.lprnt) inv=2
2745 CALL
sqmibb(clmat,blvec,nalc,mbdr,mbnd,inv,nrank, &
2746 vbnd,vbdr,aux,vbk,vzru,scdiag,scflag)
2750 CALL
sqminv(clmat,blvec,nalc,nrank,scdiag,scflag)
2755 IF ((.NOT.(blvec(k) <= 0.0d0)).AND. (.NOT.(blvec(k) > 0.0d0))) nan=nan+1
2760 WRITE(1,*)
'Parameter determination:',nalc,
' parameters,',
' rank=',nrank
2761 WRITE(1,*)
'-----------------------'
2762 IF(ndown /= 0)
WRITE(1,*)
' ',ndown,
' data down-weighted'
2776 CALL
isjajb(nst,ist,ja,jb,jsp)
2785 rmloc=rmloc+glder(ja+j)*sngl(blvec(ij))
2787 localcorrections(neq)=rmloc
2791 IF(iter == 1.AND.inv > 0.AND.nloopn <= lfitnp)
THEN
2798 dvar=dvar+clmat(jk)*dble(glder(ja+j))*dble(glder(ja+k))
2802 IF (0.999999d0/dble(wght) > dvar)
THEN
2803 pull=rmeas/sngl(dsqrt(1.0d0/dble(wght)-dvar))
2806 CALL hmpent(13,pull)
2807 CALL gmpms(5,rec,pull)
2809 CALL hmpent(14,pull)
2815 IF(iter == 1.AND.jb < ist.AND.lhist) &
2816 CALL gmpms(4,rec,rmeas/rerr)
2818 dchi2=wght*rmeas*rmeas
2821 IF(nloopn /= 1.AND.iter /= 1.AND.lhuber /= 0)
THEN
2823 IF(abs(resid) > chuber*rerr)
THEN
2824 wght=wght*chuber*rerr/abs(resid)
2825 dchi2=2.0*chuber*(abs(resid)/rerr-0.5*chuber)
2828 wght=wght/(1.0+(resid/rerr/cauchy)**2)
2829 dchi2=log(1.0+(resid/rerr/cauchy)**2)*cauchy**2
2839 IF(abs(resid) > chuber*rerr) chast=
'* '
2840 IF(abs(resid) > 3.0*rerr) chast=
'** '
2841 IF(abs(resid) > 6.0*rerr) chast=
'***'
2842 IF(imeas == 0)
WRITE(1,*)
'Third loop: single residuals'
2843 IF(imeas == 0)
WRITE(1,105)
2847 IF(resid < 0.0) r1=-r1
2848 IF(resid < 0.0) r2=-r2
2849 WRITE(1,106) imeas,glder(ja),rmeas,rerr,r1,chast,r2
2851 105 format(
' index corrvalue residuum sigma', &
2853 106 format(i6,2x,2g12.4,
' +-',g12.4,f7.2,1x,a3,f8.2)
2855 IF(iter == nter)
THEN
2856 readbufferdataf(ja)=rmeas
2857 resmax=max(resmax,abs(rmeas)/rerr)
2860 IF(iter == 1.AND.lhist)
THEN
2862 CALL hmpent( 3,rmeas/rerr)
2864 CALL hmpent(12,rmeas/rerr)
2872 resing=(float(nweig)-suwt)/float(nweig)
2874 IF(iter == 1) CALL hmpent( 5,float(ndf))
2875 IF(iter == 1) CALL hmpent(11,float(nalc))
2876 IF(nloopn == 2.AND.iter == nter) CALL hmpent(6,resing)
2880 WRITE(1,*)
'Chi^2=',summ,
' at',ndf,
' degrees of freedom: ', &
2881 '3-sigma limit is',
chindl(3,ndf)*float(ndf)
2882 WRITE(1,*) suwt,
' is sum of factors, compared to',nweig, &
2883 ' Downweight fraction:',resing
2885 IF(nrank /= nalc.OR.nan > 0)
THEN
2887 IF (nrec3 == maxi4) nrec3=nrc
2889 WRITE(1,*)
' rank deficit/NaN ', nalc, nrank, nan
2890 WRITE(1,*)
' ---> rejected!'
2897 WRITE(1,*)
' ---> rejected!'
2902 chndf=sngl(summ/dfloat(ndf))
2904 IF(iter == 1.AND.lhist) CALL hmpent(4,chndf)
2908 sndf=sndf+dfloat(ndf)*dw1
2912 IF(newite.AND.iterat == 2)
THEN
2913 IF(nrecp2 < 0.AND.chndf > writebufferdata(2,iproc+1))
THEN
2914 writebufferdata(2,iproc+1)=chndf
2915 writebufferinfo(7,iproc+1)=nrc
2919 chichi=
chindl(3,ndf)*float(ndf)
2922 IF(chicut >= 0.0)
THEN
2923 IF(summ > chhuge*chichi)
THEN
2926 WRITE(1,*)
' ---> rejected!'
2931 IF(chicut > 0.0)
THEN
2932 chlimt=chicut*chichi
2934 IF(summ > chlimt)
THEN
2936 WRITE(1,*)
' ---> rejected!'
2940 dchi2s=dchi2s+dchi2*dw1
2947 IF(lhuber > 1.AND.dwcut /= 0.0.AND.resing > dwcut)
THEN
2950 dchi2s=dchi2s+dchi2*dw1
2954 WRITE(1,*)
' ---> rejected!'
2959 IF(newite.AND.iterat == 2)
THEN
2960 IF(nrecpr < 0.AND.resmax > writebufferdata(1,iproc+1))
THEN
2961 writebufferdata(1,iproc+1)=resmax
2962 writebufferinfo(6,iproc+1)=nrc
2966 naccf(kfl)=naccf(kfl)+1
2967 ndff(kfl) =ndff(kfl) +ndf
2968 chi2f(kfl)=chi2f(kfl)+chndf
2974 dchi2s=dchi2s+dch2sd
2979 CALL
isjajb(nst,ist,ja,jb,jsp)
2985 dchi2=wght*rmeas*rmeas
2987 IF(nloopn /= 1.AND.lhuber /= 0)
THEN
2989 IF(resid > chuber*rerr)
THEN
2990 wght=wght*chuber*rerr/resid
2991 dchi2=2.0*chuber*(resid/rerr-0.5*chuber)
2994 dchi2s=dchi2s+dchi2*dw1
2999 ivgbj=globalparlabelindex(2,inder(jb+j))
3001 globalvector(ioffb+ivgbj)=globalvector(ioffb+ivgbj) &
3002 +dw1*wght*rmeas*glder(jb+j)
3003 IF(icalcm == 1)
THEN
3004 ije=backindexusage(ioffe+ivgbj)
3006 ivgbk=globalparlabelindex(2,inder(jb+k))
3008 ike=backindexusage(ioffe+ivgbk)
3012 writebufferupdates(ioffd+ij)=writebufferupdates(ioffd+ij) &
3013 -dw1*wght*glder(jb+j)*glder(jb+k)
3022 IF (icalcm /= 1) cycle
3024 ivgbj=globalparlabelindex(2,inder(jb+j))
3026 ije=backindexusage(ioffe+ivgbj)
3030 localglobalmatrix(jk)=localglobalmatrix(jk)+dw2*wght*glder(jb+j)*glder(ja+k)
3039 IF(icalcm /= 1) go to 90
3044 CALL
dbavat(clmat,localglobalmatrix,writebufferupdates(ioffd+1),nalc,-nalg)
3052 writebufferinfo(1,iproc+1)=writebufferinfo(1,iproc+1)+1
3053 writebufferinfo(2,iproc+1)=writebufferinfo(2,iproc+1)+ngg
3054 writebufferinfo(3,iproc+1)=writebufferinfo(3,iproc+1)+nalg+2
3056 nfred=writebufferheader(-1)-writebufferinfo(2,iproc+1)-writebufferheader(-2)
3057 nfrei=writebufferheader(1)-writebufferinfo(3,iproc+1)-writebufferheader(2)
3058 IF (nfred < 0.OR.nfrei < 0)
THEN
3059 nb=writebufferinfo(1,iproc+1)
3060 joffd=writebufferheader(-1)*iproc
3061 joffi=writebufferheader(1)*iproc+2
3062 used=float(writebufferinfo(2,iproc+1))/float(writebufferheader(-1))
3063 writebufferinfo(4,iproc+1)=writebufferinfo(4,iproc+1) +ifix(1000.0*used+0.5)
3064 used=float(writebufferinfo(3,iproc+1))/float(writebufferheader(1))
3065 writebufferinfo(5,iproc+1)=writebufferinfo(5,iproc+1) +ifix(1000.0*used+0.5)
3067 writebufferheader(-4)=writebufferheader(-4)+1
3068 writebufferheader(4)=writebufferheader(4)+1
3072 DO in=1,writebufferindices(joffi)
3073 i=writebufferindices(joffi+in)
3077 j=writebufferindices(joffi+jn)
3078 CALL
mupdat(i,j,-writebufferupdates(joffd+ijn))
3082 joffi=joffi+writebufferindices(joffi)+2
3087 writebufferinfo(k,iproc+1)=0
3093 WRITE(1,*)
'------------------ End of printout for record',nrc
3098 iext=globalindexusage(ioffc+i)
3099 backindexusage(ioffe+iext)=0
3105 IF (icalcm == 1)
THEN
3108 writebufferheader(-3)=writebufferheader(-3)+1
3109 used=float(writebufferinfo(2,k))/float(writebufferheader(-1))
3110 writebufferinfo(4,k)=writebufferinfo(4,k)+ifix(1000.0*used+0.5)
3111 writebufferheader(-5)=writebufferheader(-5)+writebufferinfo(4,k)
3112 writebufferheader(-6)=max(writebufferheader(-6),writebufferinfo(4,k))
3113 writebufferinfo(4,k)=0
3114 writebufferheader(3)=writebufferheader(3)+1
3115 used=float(writebufferinfo(3,k))/float(writebufferheader(1))
3116 writebufferinfo(5,k)=writebufferinfo(5,k)+ifix(1000.0*used+0.5)
3117 writebufferheader(5)=writebufferheader(5)+writebufferinfo(5,k)
3118 writebufferheader(6)=max(writebufferheader(6),writebufferinfo(5,k))
3119 writebufferinfo(5,k)=0
3128 nb=writebufferinfo(1,jproc+1)
3130 joffd=writebufferheader(-1)*jproc
3131 joffi=writebufferheader(1)*jproc+2
3135 DO in=1,writebufferindices(joffi)
3136 i=writebufferindices(joffi+in)
3140 j=writebufferindices(joffi+jn)
3141 CALL
mupdat(i,j,-writebufferupdates(joffd+ijn))
3148 joffi=joffi+writebufferindices(joffi)+2
3154 IF(newite.AND.iterat == 2)
THEN
3155 IF (nrecpr < 0)
THEN
3157 IF (writebufferdata(1,k) > value1)
THEN
3158 value1=writebufferdata(1,k)
3159 nrec1 =writebufferinfo(6,k)
3163 IF (nrecp2 < 0)
THEN
3165 IF (writebufferdata(2,k) > value2)
THEN
3166 value2=writebufferdata(2,k)
3167 nrec2 =writebufferinfo(7,k)
3213 DOUBLE PRECISION:: diag
3214 DOUBLE PRECISION::gmati
3215 DOUBLE PRECISION::gcor2
3217 INTEGER(KIND=large):: ii
3223 CALL
mvopen(lup,
'millepede.res')
3226 WRITE(*,*)
' Result of fit for global parameters'
3227 WRITE(*,*)
' ==================================='
3232 WRITE(lup,*)
'Parameter ! first 3 elements per line are', &
3233 ' significant (if used as input)'
3236 itgbl=globalparlabelindex(1,itgbi)
3237 ivgbi=globalparlabelindex(2,itgbi)
3238 par=sngl(globalparameter(itgbi))
3240 dpa=par-globalparstart(itgbi)
3241 IF(metsol == 1.OR.metsol == 2)
THEN
3244 gmati=globalmatd(ii)
3245 err=sqrt(abs(sngl(gmati)))
3246 IF(gmati < 0.0d0) err=-err
3247 diag=workspaced(ivgbi)
3249 IF(gmati*diag > 0.0d0)
THEN
3250 gcor2=1.0d0-1.0d0/(gmati*diag)
3251 IF(gcor2 >= 0.0d0.AND.gcor2 <= 1.0d0) gcor=sngl(dsqrt(gcor2))
3255 IF(itgbi <= iprlim)
THEN
3257 WRITE(* ,102) itgbl,par,globalparpresigma(itgbi)
3259 IF(metsol == 1.OR.metsol == 2)
THEN
3260 IF (igcorr == 0)
THEN
3261 WRITE(*,102) itgbl,par,globalparpresigma(itgbi),dpa,err
3263 WRITE(*,102) itgbl,par,globalparpresigma(itgbi),dpa,err,gcor
3266 WRITE(*,102) itgbl,par,globalparpresigma(itgbi),dpa
3269 ELSE IF(itgbi == iprlim+1)
THEN
3270 WRITE(* ,*)
'... (further printout suppressed, but see log file)'
3275 WRITE(lup,102) itgbl,par,globalparpresigma(itgbi)
3277 IF(metsol == 1.OR.metsol == 2)
THEN
3278 IF (igcorr == 0)
THEN
3279 WRITE(lup,102) itgbl,par,globalparpresigma(itgbi),dpa,err
3281 WRITE(lup,102) itgbl,par,globalparpresigma(itgbi),dpa,err,gcor
3284 WRITE(lup,102) itgbl,par,globalparpresigma(itgbi),dpa
3291 IF(metsol == 2)
THEN
3292 CALL
mvopen(lup,
'millepede.eve')
3295 IF(workspaceeigenvalues(i) > 0.0d0)
THEN
3302 DO isub=0,min(15,imin-1)
3310 WRITE(*,*)
'Eigenvector ',i,
' with eigenvalue',workspaceeigenvalues(i)
3311 WRITE(lup,*)
'Eigenvector ',i,
' with eigenvalue',workspaceeigenvalues(i)
3315 itgbi=globalparvartototal(j)
3316 label=globalparlabelindex(1,itgbi)
3322 compnt(iev)=sngl(workspaceeigenvectors(ij))
3324 WRITE(lup,103) (labele(ie),compnt(ie),ie=1,iev)
3328 IF(iev /= 0)
WRITE(lup,103) (labele(ie),compnt(ie),ie=1,iev)
3335 101 format(1x,
' label parameter presigma differ', &
3336 ' error'/ 1x,
'-----------',4x,4(
'-------------'))
3337 102 format(i10,2x,4g14.5,f8.3)
3338 103 format(3(i11,f11.7,2x))
3365 INTEGER,
INTENT(IN) :: n
3366 DOUBLE PRECISION,
INTENT(IN) :: x(n)
3367 DOUBLE PRECISION,
INTENT(OUT) :: b(n)
3368 INTEGER(KIND=large) :: k
3369 INTEGER(KIND=large) :: kk
3370 INTEGER(KIND=large) :: kl
3371 INTEGER(KIND=large) :: ku
3372 INTEGER(KIND=large) :: ll
3373 INTEGER(KIND=large) :: lj
3374 INTEGER(KIND=large) :: indij
3375 INTEGER(KIND=large) :: indid
3376 INTEGER(KIND=large) :: ij
3384 ichunk=min((n+mthrd-1)/mthrd/8+1,1024)
3385 IF(matsto == 1)
THEN
3397 b(i)=globalmatd(ij+i)*x(i)
3399 b(j)=b(j)+globalmatd(ij+j)*x(i)
3400 b(i)=b(i)+globalmatd(ij+j)*x(j)
3406 IF(sparsematrixoffsets(2,1) /= n+1) stop
'AVPROD: mismatched vector and matrix'
3408 iencdm=ishft(1,iencdb)-1
3418 b(i)=globalmatd(i)*x(i)
3421 kk=sparsematrixoffsets(1,ir)
3422 ll=sparsematrixoffsets(2,ir)
3424 ku=sparsematrixoffsets(1,ir+1)-1-kk
3427 IF (sparsematrixcolumns(indid) /= 0)
THEN
3429 j=sparsematrixcolumns(indid+k)
3430 b(j)=b(j)+globalmatd(indij+k)*x(i)
3431 b(i)=b(i)+globalmatd(indij+k)*x(j)
3438 jc=sparsematrixcolumns(indid+kl)
3442 b(j)=b(j)+globalmatd(indij+lj)*x(i)
3443 b(i)=b(i)+globalmatd(indij+lj)*x(j)
3452 kk=sparsematrixoffsets(1,ir)
3453 ll=sparsematrixoffsets(2,ir)
3455 ku=sparsematrixoffsets(1,ir+1)-1-kk
3458 IF (sparsematrixcolumns(indid) /= 0)
THEN
3460 j=sparsematrixcolumns(indid+k)
3461 b(j)=b(j)+dble(globalmatf(indij+k))*x(i)
3462 b(i)=b(i)+dble(globalmatf(indij+k))*x(j)
3469 jc=sparsematrixcolumns(indid+kl)
3473 b(j)=b(j)+dble(globalmatf(indij+lj))*x(i)
3474 b(i)=b(i)+dble(globalmatf(indij+lj))*x(j)
3495 FUNCTION ijadd(itema,itemb) ! index using "d" and "z"
3508 INTEGER,
INTENT(IN) :: itema
3509 INTEGER,
INTENT(IN) :: itemb
3511 INTEGER(KIND=large) ::
ijadd
3512 INTEGER(KIND=large) :: k
3513 INTEGER(KIND=large) :: kk
3514 INTEGER(KIND=large) :: kl
3515 INTEGER(KIND=large) :: ku
3516 INTEGER(KIND=large) :: indid
3517 INTEGER(KIND=large) :: nd
3518 INTEGER(KIND=large) :: ll
3519 INTEGER(KIND=large) :: k8
3520 INTEGER(KIND=large) :: item1
3523 nd=sparsematrixoffsets(2,1)-1
3524 item1=max(itema,itemb)
3525 item2=min(itema,itemb)
3526 IF(item2 <= 0.OR.item1 > nd) return
3527 IF(item1 == item2)
THEN
3533 iencdm=ishft(1,iencdb)-1
3535 outer:
DO ispc=1,nspc
3536 kk=sparsematrixoffsets(1,item1)
3537 ll=sparsematrixoffsets(2,item1)
3539 ku=sparsematrixoffsets(1,item1+1)-1-kk
3543 IF (sparsematrixcolumns(indid) == 0)
THEN
3548 IF(ku < kl) cycle outer
3551 jtemc=sparsematrixcolumns(indid+k)
3552 jtem =ishft(jtemc,-iencdb)
3553 jtemn=jtem+iand(jtemc,iencdm)
3554 IF(item2 >= jtem.AND.item2 < jtemn) exit
3555 IF(item2 < jtem)
THEN
3557 ELSE IF(item2 >= jtemn)
THEN
3564 ll=ll+sparsematrixcolumns(kk+k8)
3566 ll=ll+iand(sparsematrixcolumns(indid+kl),iencdm)
3572 IF(ku < kl) cycle outer
3575 jtem=sparsematrixcolumns(indid+k)
3577 IF(item2 == jtem) exit
3578 IF(item2 < jtem)
THEN
3580 ELSE IF(item2 > jtem)
THEN
3606 REAL,
INTENT(IN) :: deltat
3607 INTEGER,
INTENT(OUT) :: minut
3608 INTEGER,
INTENT(OUT):: nhour
3609 REAL,
INTENT(OUT):: secnd
3615 minut=nsecd/60-60*nhour
3616 secnd=deltat-60*(minut+60*nhour)
3647 INTEGER FUNCTION inone(item) ! translate 1-D identifier to nrs
3652 INTEGER,
INTENT(IN) :: item
3656 INTEGER(KIND=large) :: length
3657 INTEGER(KIND=large),
PARAMETER :: two = 2
3660 IF(item <= 0) return
3661 IF(globalparheader(-1) == 0)
THEN
3663 CALL
mpalloc(globalparlabelindex,two,length,
'INONE: label & index')
3664 CALL
mpalloc(globalparhashtable,2*length,
'INONE: hash pointer')
3665 globalparhashtable = 0
3666 globalparheader(-0)=int(length)
3667 globalparheader(-1)=0
3668 globalparheader(-2)=0
3669 globalparheader(-3)=int(length)
3670 globalparheader(-4)=
iprime(globalparheader(-0))
3671 globalparheader(-5)=0
3672 globalparheader(-6)=0
3675 j=1+mod(item,globalparheader(-4))+globalparheader(-0)
3678 j=globalparhashtable(k)
3679 IF(j == 0) exit inner
3680 IF(item == globalparlabelindex(1,j)) exit outer
3683 IF(globalparheader(-1) == globalparheader(-0).OR.globalparheader(-2) /= 0)
THEN
3684 globalparheader(-5)=globalparheader(-5)+1
3688 globalparheader(-1)=globalparheader(-1)+1
3689 globalparheader(-3)=globalparheader(-1)
3690 j=globalparheader(-1)
3691 globalparhashtable(k)=j
3692 globalparlabelindex(1,j)=item
3693 globalparlabelindex(2,j)=0
3694 IF(globalparheader(-1) /= globalparheader(-0)) exit outer
3696 globalparheader(-3)=globalparheader(-3)*2
3698 IF (lvllog > 1)
WRITE(lunlog,*)
'INONE: array increased to', &
3699 globalparheader(-3),
' words'
3702 IF(globalparheader(-2) == 0)
THEN
3703 globalparlabelindex(2,j)=globalparlabelindex(2,j)+1
3704 globalparheader(-7)=globalparheader(-7)+1
3720 LOGICAL :: finalupdate
3721 INTEGER(KIND=large) :: oldlength
3722 INTEGER(KIND=large) :: newlength
3723 INTEGER(KIND=large),
PARAMETER :: two = 2
3724 INTEGER,
DIMENSION(:,:),
ALLOCATABLE :: temparr
3727 finalupdate=(globalparheader(-3) == globalparheader(-1))
3728 IF(finalupdate)
THEN
3729 CALL
sort2k(globalparlabelindex,globalparheader(-1))
3732 nused = globalparheader(-1)
3733 oldlength = globalparheader(-0)
3734 CALL
mpalloc(temparr,two,oldlength,
'INONE: temp array')
3735 temparr(:,1:nused)=globalparlabelindex(:,1:nused)
3739 newlength = globalparheader(-3)
3740 CALL
mpalloc(globalparlabelindex,two,newlength,
'INONE: label & index')
3741 CALL
mpalloc(globalparhashtable,2*newlength,
'INONE: hash pointer')
3742 globalparhashtable = 0
3743 globalparlabelindex(:,1:nused) = temparr(:,1:nused)
3745 globalparheader(-0)=int(newlength)
3746 globalparheader(-3)=globalparheader(-1)
3747 globalparheader(-4)=
iprime(globalparheader(-0))
3749 outer:
DO i=1,globalparheader(-1)
3750 j=1+mod(globalparlabelindex(1,i),globalparheader(-4))+globalparheader(-0)
3753 j=globalparhashtable(k)
3754 IF(j == 0) exit inner
3755 IF(j == i) cycle outer
3757 globalparhashtable(k)=i
3759 IF(.NOT.finalupdate) return
3761 globalparheader(-2)=1
3762 IF (lvllog > 1)
THEN
3764 WRITE(lunlog,*)
'INONE: array reduced to',newlength,
' words'
3765 WRITE(lunlog,*)
'INONE:',globalparheader(-1),
' items stored.'
3767 END SUBROUTINE upone
3776 INTEGER,
INTENT(IN) :: n
3783 IF(mod(nprime,2) == 0) nprime=nprime+1
3786 nsqrt=ifix(sqrt(float(nprime)))
3788 IF(i*(nprime/i) == nprime) cycle outer
3828 equivalence(plvs(1),lpvs(1))
3829 INTEGER (KIND=large) :: length
3833 WRITE(lunlog,*)
'LOOP1: starting'
3836 DO i=1, lenparameters
3837 idum=
inone(listparameters(i)%label)
3839 DO i=1, lenpresigmas
3840 idum=
inone(listpresigmas(i)%label)
3842 DO i=1, lenconstraints
3843 idum=
inone(listconstraints(i)%label)
3845 DO i=1, lenmeasurements
3846 idum=
inone(listmeasurements(i)%label)
3849 IF(globalparheader(-1) /= 0)
THEN
3850 WRITE(lunlog,*)
'LOOP1:',globalparheader(-1),
' labels from txt data stored'
3852 WRITE(lunlog,*)
'LOOP1: reading data files'
3855 DO j=1,globalparheader(-1)
3856 globalparlabelindex(2,j)=0
3861 IF(mprint /= 0)
THEN
3862 WRITE(*,*)
'Read all binary data files:'
3864 CALL hmpldf(1,
'Number of words/record in binary file')
3865 CALL
hmpdef(8,0.0,60.0,
'not_stored data per record')
3867 nc21=ncache/(21*mthrdr)
3870 CALL
mpalloc(readbufferpointer,length,
'read buffer, pointer')
3871 nwrd=nc21*10+2+ndimbuf
3873 CALL
mpalloc(readbufferdatai,length,
'read buffer, integer')
3874 CALL
mpalloc(readbufferdataf,length,
'read buffer, float')
3878 IF (skippedrecords == 0) CALL
peprep(0)
3885 IF (skippedrecords == 0)
THEN
3888 WRITE(lunlog,*)
'LOOP1: reading data files again'
3892 IF(nhistp /= 0)
THEN
3899 ntgb = globalparheader(-1)
3900 WRITE(lunlog,*)
'LOOP1:',ntgb, &
3901 ' is total number NTGB of labels/parameters'
3903 CALL hmpldf(2,
'Number of entries per label')
3905 CALL hmplnt(2,globalparlabelindex(2,j))
3907 IF(nhistp /= 0) CALL hmprnt(2)
3912 CALL
mpalloc(globalparameter,length,
'global parameters')
3913 globalparameter=0.0d0
3914 CALL
mpalloc(globalparpresigma,length,
'pre-sigmas')
3915 globalparpresigma=0.
3916 CALL
mpalloc(globalparstart,length,
'global parameters at start')
3918 CALL
mpalloc(globalparcopy,length,
'copy of global parameters')
3920 DO i=1,lenparameters
3921 param=listparameters(i)%value
3922 in=
inone(listparameters(i)%label)
3924 globalparameter(in)=param
3925 globalparstart(in)=param
3931 presg=listpresigmas(i)%value
3932 in=
inone(listpresigmas(i)%label)
3934 IF(presg > 0.0) npresg=npresg+1
3935 globalparpresigma(in)=presg
3938 WRITE(lunlog,*)
'LOOP1:',npresg,
' is number of pre-sigmas'
3939 WRITE(*,*)
'LOOP1:',npresg,
' is number of pre-sigmas'
3940 IF(npresg == 0)
WRITE(*,*)
'Warning: no pre-sigmas defined'
3946 IF(globalparlabelindex(2,i) >= mreqen.AND.globalparpresigma(i) >= 0.0)
THEN
3948 globalparlabelindex(2,i)=indab
3950 globalparlabelindex(2,i)=-1
3953 globalparheader(-6)=indab
3955 WRITE(lunlog,*)
'LOOP1:',nvgb,
' is number NVGB of variable parameters'
3959 CALL
mpalloc(globalparvartototal,length,
'translation table var -> total')
3962 IF(globalparlabelindex(2,i) > 0)
THEN
3964 globalparvartototal(indab)=i
3969 CALL
mpalloc(globalparpreweight,length,
'pre-sigmas weights')
3970 WRITE(*,112)
' Default pre-sigma =',regpre, &
3971 ' (if no individual pre-sigma defined)'
3972 WRITE(*,*)
'Pre-sigma factor is',regula
3974 IF(nregul == 0)
THEN
3975 WRITE(*,*)
'No regularization will be done'
3977 WRITE(*,*)
'Regularization will be done, using factor',regula
3979 112 format(a,e9.2,a)
3980 IF (nvgb <= 0) stop
'... no variable global parameters'
3983 itgbi=globalparvartototal(ivgbi)
3984 presg=globalparpresigma(itgbi)
3986 IF(presg > 0.0)
THEN
3988 ELSE IF(presg == 0.0.AND.regpre > 0.0)
THEN
3991 globalparpreweight(ivgbi)=regula*prewt
3996 itgbl=globalparlabelindex(1,i)
3997 ivgbi=globalparlabelindex(2,i)
4005 WRITE(*,101)
'NTGB',ntgb,
'total number of parameters'
4006 WRITE(*,101)
'NVGB',nvgb,
'number of variable parameters'
4011 IF(mprint /= 0)
THEN
4013 WRITE(*,101)
' NREC',nrec,
'number of records'
4014 WRITE(*,101)
'MREQEN',mreqen,
'required number of entries'
4015 IF (mreqpe > 1)
WRITE(*,101) &
4016 'MREQPE',mreqpe,
'required number of pair entries'
4017 IF (msngpe >= 1)
WRITE(*,101) &
4018 'MSNGPE',msngpe,
'max pair entries single prec. storage'
4019 WRITE(*,101)
'NTGB',ntgb,
'total number of parameters'
4020 WRITE(*,101)
'NVGB',nvgb,
'number of variable parameters'
4023 WRITE(*,*)
'Global parameter labels:'
4026 WRITE(*,*) (globalparlabelindex(2,i),i=1,mqi)
4028 WRITE(*,*) (globalparlabelindex(2,i),i=1,30)
4030 mqi=((mqi-20)/20)*20+1
4031 WRITE(*,*) (globalparlabelindex(2,i),i=mqi,ntgb)
4038 WRITE(8,101)
' NREC',nrec,
'number of records'
4039 WRITE(8,101)
'MREQEN',mreqen,
'required number of entries'
4041 WRITE(lunlog,*)
'LOOP1: ending'
4045 101 format(1x,a6,
' =',i10,
' = ',a)
4046 END SUBROUTINE loop1
4132 DOUBLE PRECISION::dstat(3)
4134 INTEGER(KIND=large):: ndimbi
4135 INTEGER(KIND=large):: ndimsa(4)
4136 INTEGER(KIND=large):: ndgn
4137 INTEGER(KIND=large):: matsiz(2)
4138 INTEGER(KIND=large):: matwords
4139 INTEGER(KIND=large):: length
4140 INTEGER(KIND=large):: rows
4141 INTEGER(KIND=large):: cols
4142 INTEGER(KIND=large),
PARAMETER :: two=2
4143 INTEGER:: maxglobalpar = 0
4144 INTEGER:: maxlocalpar = 0
4145 INTEGER:: maxequations = 0
4148 SUBROUTINE ndbits(ndims,ncmprs,nsparr,mnpair,ihst,jcmprs)
4150 INTEGER(KIND=large),
DIMENSION(4),
INTENT(OUT) :: ndims
4151 INTEGER,
DIMENSION(:),
INTENT(OUT) :: ncmprs
4152 INTEGER(KIND=large),
DIMENSION(:,:),
INTENT(OUT) :: nsparr
4153 INTEGER,
INTENT(IN) :: mnpair
4154 INTEGER,
INTENT(IN) :: ihst
4155 INTEGER,
INTENT(IN) :: jcmprs
4157 SUBROUTINE spbits(nsparr,nsparc,ncmprs)
4159 INTEGER(KIND=large),
DIMENSION(:,:),
INTENT(IN) :: nsparr
4160 INTEGER,
DIMENSION(:),
INTENT(OUT) :: nsparc
4161 INTEGER,
DIMENSION(:),
INTENT(IN) :: ncmprs
4169 isfrst(ibuf)=readbufferpointer(ibuf)+1
4170 islast(ibuf)=readbufferdatai(readbufferpointer(ibuf))
4171 inder(i)=readbufferdatai(i)
4172 glder(i)=readbufferdataf(i)
4175 WRITE(lunlog,*)
'LOOP2: starting'
4180 CALL
mpalloc(globalindexusage,length,
'global index')
4181 CALL
mpalloc(backindexusage,length,
'back index')
4189 DO WHILE(i < lenconstraints)
4191 label=listconstraints(i)%label
4192 IF(last == 0.AND.label == (-1)) ncgb=ncgb+1
4195 WRITE(*,*)
'LOOP2:',ncgb,
' constraints'
4198 noff8=int8(nagb)*int8(nagb-1)/2
4202 IF(matsto == 2)
THEN
4203 IF (mcmprs /= 0) numbit=max(numbit,2)
4204 CALL
clbits(nagb,ndimbi,nencdb,numbit)
4212 WRITE(lunlog,*)
'LOOP2: start event reading'
4215 IF (matsto == 2.AND.matmon /= 0)
THEN
4217 IF (matmon > 0)
THEN
4227 nc21=ncache/(21*mthrdr)
4230 CALL
mpalloc(readbufferpointer,length,
'read buffer, pointer')
4231 nwrd=nc21*10+2+ndimbuf
4233 CALL
mpalloc(readbufferdatai,length,
'read buffer, integer')
4234 CALL
mpalloc(readbufferdataf,length,
'read buffer, float')
4240 DO ibuf=1,numreadbuffer
4241 nrec=readbufferdatai(isfrst(ibuf)-2)
4243 IF(nrec <= mdebug)
THEN
4245 kfile=nint(readbufferdataf(isfrst(ibuf)-1))
4246 wrec =readbufferdataf(isfrst(ibuf)-2)
4248 WRITE(*,*)
'Record number ',nrec,
' from file ',kfile
4249 IF (wgh /= 1.0)
WRITE(*,*)
' weight ',wrec
4253 CALL
isjajb(nst,ist,ja,jb,jsp)
4256 IF(nda > mdebg2)
THEN
4257 IF(nda == mdebg2+1)
WRITE(*,*)
'... and more data'
4261 WRITE(*,*) nda,
' Measured value =',glder(ja),
' +- ',glder(jb)
4262 WRITE(*,*)
'Local derivatives:'
4263 WRITE(*,107) (inder(ja+j),glder(ja+j),j=1,jb-ja-1)
4264 107 format(6(i3,g12.4))
4266 WRITE(*,*)
'Global derivatives:'
4267 WRITE(*,108) (globalparlabelindex(1,inder(jb+j)),inder(jb+j), &
4268 globalparlabelindex(2,inder(jb+j)),glder(jb+j),j=1,ist-jb)
4269 108 format(3i11,g12.4)
4272 WRITE(*,*)
'total_par_label __label__ var_par_index derivative'
4286 CALL
isjajb(nst,ist,ja,jb,jsp)
4287 IF(ja == 0.AND.jb == 0) exit
4291 IF (ist > jb) naeqng=naeqng+1
4295 ij=globalparlabelindex(2,ij)
4297 ijn=backindexusage(ij)
4300 globalindexusage(nagbn)=ij
4301 backindexusage(ij)=nagbn
4307 IF (nfixed > 0) naeqnf=naeqnf+1
4310 IF(ja /= 0.AND.jb /= 0)
THEN
4319 IF (naeqnf > maeqnf) nrecf=nrecf+1
4323 maxglobalpar=max(nagbn,maxglobalpar)
4324 maxlocalpar=max(nalcn,maxlocalpar)
4325 maxequations=max(naeqn,maxequations)
4328 dstat(1)=dstat(1)+dfloat((nwrd+2)*2)
4329 dstat(2)=dstat(2)+dfloat(nagbn+2)
4330 dstat(3)=dstat(3)+dfloat(nagbn*nagbn+nagbn)
4332 CALL
sort1k(globalindexusage,nagbn)
4335 readbufferpointer(ibuf)=ioff
4336 readbufferdatai(ioff)=ioff+nagbn
4338 iext=globalindexusage(i)
4339 backindexusage(iext)=0
4340 readbufferdatai(ioff+i)=iext
4347 IF (matsto == 2)
THEN
4353 DO ibuf=1,numreadbuffer
4357 iext=readbufferdatai(i)
4360 jext=readbufferdatai(l)
4368 IF (matmon /= 0.AND. &
4369 (irecmm >= nrecmm.OR.irecmm == mxrec))
THEN
4370 IF (nmatmo == 0)
THEN
4372 WRITE(*,*)
'Monitoring of sparse matrix construction'
4373 WRITE(*,*)
' records ........ off-diagonal elements ', &
4374 '....... compression memory'
4375 WRITE(*,*)
' non-zero used(double) used', &
4379 jcmprs=max(mcmprs,msngpe)
4380 CALL
ckbits(ndimsa,mreqpe,jcmprs)
4381 gbc=4.0e-9*float(ndimsa(2)+2*ndimsa(3)+ndimsa(4))
4382 gbu=1.2e-8*float(ndimsa(3)+ndimsa(4))
4384 WRITE(*,1177) irecmm,ndimsa(1),ndimsa(3),ndimsa(4),cpr,gbc
4385 1177 format(i9,3i13,f10.2,f11.6)
4386 DO WHILE(irecmm >= nrecmm)
4387 IF (matmon > 0)
THEN
4388 nrecmm=nrecmm+matmon
4404 WRITE(lunlog,*)
'LOOP2: event reading ended - end of data'
4406 dstat(k)=dstat(k)/dfloat(nrec)
4410 IF(matsto == 2)
THEN
4423 DO WHILE(i < lenconstraints)
4425 label=listconstraints(i)%label
4426 IF(last == 0.AND.label == (-1)) icgb=icgb+1
4429 ij=globalparlabelindex(2,itgbi)
4431 CALL
inbits(nvgb+icgb,ij,mreqpe)
4441 DO WHILE (i <= lenmeasurements)
4447 IF(i > lenmeasurements) exit
4448 IF(listmeasurements(i)%label == 0) exit
4453 itgbij=
inone(listmeasurements(j)%label)
4456 IF(itgbij /= 0) ivgbij=globalparlabelindex(2,itgbij)
4458 itgbik=
inone(listmeasurements(k)%label)
4461 IF(itgbik /= 0) ivgbik=globalparlabelindex(2,itgbik)
4462 IF(ivgbij > 0.AND.ivgbik > 0)
THEN
4463 CALL
inbits(ivgbij,ivgbik,mreqpe)
4464 IF (mprint > 1)
WRITE(*,*)
'add index pair ',ivgbij,ivgbik
4474 IF (nagb >= 65536)
THEN
4475 noff=int(noff8/1000)
4482 IF(matsto == 2)
THEN
4484 IF (mhispe > 0)
THEN
4486 CALL
hmpdef(ihis,0.0,float(mhispe),
'NDBITS: #off-diagonal elements')
4488 jcmprs=max(mcmprs,msngpe)
4489 IF (jcmprs > 0.AND.numbit > 1) nspc=2
4491 CALL
mpalloc(sparsematrixcompression,length,
'INBITS: row compression')
4492 sparsematrixcompression=0
4493 length=(nagb+1)*nspc
4494 CALL
mpalloc(sparsematrixoffsets,two,length,
'sparse matrix row offsets')
4495 CALL
ndbits(ndimsa,sparsematrixcompression,sparsematrixoffsets, &
4497 ndgn=ndimsa(3)+ndimsa(4)
4498 matwords=ndimsa(2)+length
4500 IF (mhispe > 0)
THEN
4501 IF (nhistp /= 0) CALL hmprnt(ihis)
4513 IF (fcache(2) == 0.0)
THEN
4514 fcache(1)=sngl(dstat(1))*fcache(1)
4515 fcache(2)=sngl(dstat(2))
4516 fcache(3)=sngl(dstat(3))
4518 fsum=fcache(1)+fcache(2)+fcache(3)
4520 fcache(k)=fcache(k)/fsum
4522 ncachr=ifix(float(ncache)*fcache(1)+0.5)
4524 nc21=ncachr/(21*mthrdr)
4527 CALL
mpalloc(readbufferpointer,length,
'read buffer, pointer')
4528 nwrd=nc21*10+2+ndimbuf
4530 CALL
mpalloc(readbufferdatai,length,
'read buffer, integer')
4531 CALL
mpalloc(readbufferdataf,length,
'read buffer, float')
4533 ncachi=ifix(float(ncache)*fcache(2)+0.5)
4534 ncachd=ncache-ncachr-ncachi
4535 nggd=(nagbn*nagbn+nagbn)/2+ncachd/(2*mthrd)
4536 nggi=2+nagbn+ncachi/mthrd
4538 CALL
mpalloc(globalindexusage,length,
'global parameters (dim =max/event)')
4540 CALL
mpalloc(backindexusage,length,
'global variable-index array')
4543 CALL
mpalloc(localglobalmatrix,length,
'local/global matrix')
4545 CALL
mpalloc(writebufferupdates,length,
'symmetric update matrices')
4546 writebufferheader(-1)=nggd
4547 writebufferheader(-2)=(nagbn*nagbn+nagbn)/2
4549 CALL
mpalloc(writebufferindices,length,
'symmetric update matrix indices')
4551 CALL
mpalloc(writebufferinfo,rows,cols,
'write buffer status (I)')
4553 CALL
mpalloc(writebufferdata,rows,cols,
'write buffer status (F)')
4554 writebufferheader(1)=nggi
4555 writebufferheader(2)=nagbn+2
4562 WRITE(lu,101)
'NTGB',ntgb,
'total number of parameters'
4563 WRITE(lu,102)
'(all parameters, appearing in binary files)'
4564 WRITE(lu,101)
'NVGB',nvgb,
'number of variable parameters'
4565 WRITE(lu,102)
'(appearing in fit matrix/vectors)'
4566 WRITE(lu,101)
'NAGB',nagb,
'number of fit parameters'
4567 WRITE(lu,102)
'(including Lagrange multiplier or reduced)'
4568 WRITE(lu,101)
'MBANDW',mbandw,
'band width of band matrix'
4569 WRITE(lu,102)
'(if =0, no band matrix)'
4570 IF (nagb >= 65536)
THEN
4571 WRITE(lu,101)
'NOFF/K',noff,
'max number of off-diagonal elements'
4573 WRITE(lu,101)
'NOFF',noff,
'max number of off-diagonal elements'
4576 WRITE(lu,101)
'NDGN',ndgn,
'actual number of off-diagonal elements'
4577 WRITE(lu,101)
'NCGB',ncgb,
'number of constraints'
4578 WRITE(lu,101)
'NAGBN',nagbn,
'max number of global parameters in an event'
4579 WRITE(lu,101)
'NALCN',nalcn,
'max number of local parameters in an event'
4580 WRITE(lu,101)
'NAEQN',naeqn,
'max number of equations in an event'
4581 IF (mprint > 1)
THEN
4582 WRITE(lu,101)
'NAEQNA',naeqna,
'number of equations'
4583 WRITE(lu,101)
'NAEQNG',naeqng, &
4584 'number of equations with global derivatives'
4585 WRITE(lu,101)
'NAEQNF',naeqnf, &
4586 'number of equations with fixed global derivatives'
4587 WRITE(lu,101)
'NRECF',nrecf, &
4588 'number of records with fixed global derivatives'
4590 IF (ncache > 0)
THEN
4591 WRITE(lu,101)
'NCACHE',ncache,
'number of words for caching'
4592 WRITE(lu,111) (fcache(k)*100.0,k=1,3)
4593 111 format(22x,
'cache splitting ',3(f6.1,
' %'))
4596 IF(matsto == 2)
THEN
4606 WRITE(lu,*)
'Solution method and matrix-storage mode:'
4607 IF(metsol == 1)
THEN
4608 WRITE(lu,*)
' METSOL = 1: matrix inversion'
4609 ELSE IF(metsol == 2)
THEN
4610 WRITE(lu,*)
' METSOL = 2: diagonalization'
4611 ELSE IF(metsol == 3)
THEN
4613 WRITE(lu,*)
' METSOL = 3: MINRES (rtol', mrestl,
')'
4614 ELSE IF(metsol == 4)
THEN
4615 WRITE(lu,*)
' METSOL = 4: GMRES'
4617 WRITE(lu,*)
' with',mitera,
' iterations'
4618 IF(matsto == 1)
THEN
4619 WRITE(lu,*)
' MATSTO = 1: symmetric matrix, ',
'(n*n+n)/2 elements'
4620 ELSE IF(matsto == 2)
THEN
4621 WRITE(lu,*)
' MATSTO = 2: sparse matrix'
4624 IF(dflim /= 0.0)
THEN
4625 WRITE(lu,103)
'Convergence assumed, if expected dF <',dflim
4632 IF(0.0 < wolfc1.AND.wolfc1 < wolfc2.AND.wolfc2 < 1.0) go to 32
4633 IF(wolfc1 == 0.0) wolfc1=1.0e-4
4634 IF(wolfc2 == 0.0) wolfc2=0.9
4635 IF(0.0 < wolfc1.AND.wolfc1 < wolfc2.AND.wolfc2 < 1.0) go to 32
4636 IF(wolfc1 <= 0.0) wolfc1=1.0e-4
4637 IF(wolfc2 >= 1.0) wolfc2=0.9
4638 IF(wolfc1 > wolfc2)
THEN
4646 WRITE(*,105) wolfc1,wolfc2
4647 WRITE(lun,105) wolfc1,wolfc2
4648 105 format(
' Constants C1, C2 for Wolfe conditions:',g12.4,
', ',g12.4)
4652 32 matsiz(1)=int8(nagb)*int8(nagb+1)/2
4654 IF(matsto == 2)
THEN
4655 matsiz(1)=ndimsa(3)+nagb
4657 CALL
mpalloc(sparsematrixcolumns,ndimsa(2),
'sparse matrix column list')
4658 CALL
spbits(sparsematrixoffsets,sparsematrixcolumns,sparsematrixcompression)
4660 matwords=matwords+matsiz(1)*2+matsiz(2)
4666 IF (matwords < 250000)
THEN
4667 WRITE(*,*)
'Size of global matrix: < 1 MB'
4669 WRITE(*,*)
'Size of global matrix:',int(float(matwords)*4.0e-6),
' MB'
4675 WRITE(lunlog,*)
' Cut values of Chi^2/Ndf and Chi2,'
4676 WRITE(lunlog,*)
' corresponding to 2 and 3 standard deviations'
4677 WRITE(lunlog,*)
' Ndf Chi^2/Ndf(2) Chi^2(2) ', &
4678 ' Chi^2/Ndf(3) Chi^2(3)'
4681 IF(ndf > naeqn) exit
4684 ELSE IF(ndf < 20)
THEN
4686 ELSE IF(ndf < 100)
THEN
4688 ELSE IF(ndf < 200)
THEN
4695 WRITE(lunlog,106) ndf,chin2,chin2*float(ndf),chin3, chin3*float(ndf)
4698 WRITE(lunlog,*)
'LOOP2: ending'
4701 101 format(1x,a6,
' =',i10,
' = ',a)
4703 103 format(1x,a,g12.4)
4704 106 format(i6,2(3x,f9.3,f12.1,3x))
4705 END SUBROUTINE loop2
4719 INTEGER(KIND=large),
INTENT(IN) :: msize(2)
4721 INTEGER(KIND=large) :: length
4726 CALL
mpalloc(globalvector,length,
'rhs vector')
4729 CALL
mpalloc(localcorrections,length,
'residual vector of one record')
4731 CALL
mpalloc(aux,length,
' local fit scratch array: aux')
4732 CALL
mpalloc(vbnd,length,
' local fit scratch array: vbnd')
4733 CALL
mpalloc(vbdr,length,
' local fit scratch array: vbdr')
4734 length=((nalcn+1)*nalcn)/2
4735 CALL
mpalloc(clmat,length,
' local fit matrix: clmat')
4736 CALL
mpalloc(vbk,length,
' local fit scratch array: vbk')
4738 CALL
mpalloc(blvec,length,
' local fit vector: blvec')
4739 CALL
mpalloc(vzru,length,
' local fit scratch array: vzru')
4740 CALL
mpalloc(scdiag,length,
' local fit scratch array: scdiag')
4741 CALL
mpalloc(scflag,length,
' local fit scratch array: scflag')
4742 CALL
mpalloc(ibandh,length,
' local fit band width hist.: ibandh')
4744 CALL
mpalloc(globalmatd,msize(1),
'global matrix (D)' )
4745 CALL
mpalloc(globalmatf,msize(2),
'global matrix (F)')
4747 IF(metsol >= 3)
THEN
4754 CALL
mpalloc(indprecond,length,
'pointer-array variable-band matrix')
4755 DO i=1,min(mbandw,nvgb)
4756 indprecond(i)=(i*i+i)/2
4758 DO i=min(mbandw,nvgb)+1,nvgb
4759 indprecond(i)=indprecond(i-1)+mbandw
4764 length=indprecond(nvgb)+ncgb*nvgb+(ncgb*ncgb+ncgb)/2
4765 CALL
mpalloc(matprecond,length,
'variable-band matrix')
4767 length=nvgb+ncgb*nvgb+(ncgb*ncgb+ncgb)/2
4768 CALL
mpalloc(matprecond,length,
'default preconditioner matrix')
4774 CALL
mpalloc(globalcorrections,length,
'corrections')
4776 CALL
mpalloc(workspacelinesearch,length,
'auxiliary array (D2)')
4777 CALL
mpalloc(workspacei, length,
'auxiliary array (I)')
4778 CALL
mpalloc(workspaceminres,length,
'auxiliary array (D7)')
4780 IF(metsol == 1)
THEN
4781 CALL
mpalloc(workspaced,length,
'auxiliary array (D1)')
4785 IF(metsol == 2)
THEN
4786 CALL
mpalloc(workspaced,length,
'auxiliary array (D1)')
4787 CALL
mpalloc(workspacediagonalization,length,
'auxiliary array (D3)')
4788 CALL
mpalloc(workspaceeigenvalues,length,
'auxiliary array (D6)')
4790 CALL
mpalloc(workspaceeigenvectors,length,
'(rotation) matrix U')
4793 IF(metsol >= 3)
THEN
4796 CALL
mpalloc(workspaced,length,
'auxiliary array (D1)')
4816 IF(lunlog == 0) lunlog=6
4819 IF(icalcm == 1)
THEN
4820 CALL
sqminl(globalmatd, globalcorrections,nagb,nrank, &
4821 workspaced,workspacei)
4823 IF(ndefec /= 0)
THEN
4824 WRITE(*,*)
'The rank defect of the symmetric',nagb, &
4825 '-by-',nagb,
' matrix is ',ndefec,
' (should be zero).'
4826 WRITE(lun,*)
'The rank defect of the symmetric',nagb, &
4827 '-by-',nagb,
' matrix is ',ndefec,
' (should be zero).'
4828 IF (iforce == 0)
THEN
4830 WRITE(*,*)
' --> enforcing SUBITO mode'
4831 WRITE(lun,*)
' --> enforcing SUBITO mode'
4834 WRITE(lun,*)
'No rank defect of the symmetric matrix'
4838 CALL
dbsvxl(globalmatd,globalvector,globalcorrections,nagb)
4858 INTEGER(KIND=large) :: ii
4863 IF(lunlog == 0) lun=6
4865 IF(icalcm == 1)
THEN
4869 workspaced(i)=globalmatd((ii*ii+ii)/2)
4873 CALL
devrot(nvar,workspaceeigenvalues,workspaceeigenvectors,globalmatd, &
4874 workspacediagonalization,workspacei)
4878 nmax=int(1.0+log10(sngl(workspaceeigenvalues(1))))
4881 IF(workspaceeigenvalues(i) > 0.0d0)
THEN
4886 nmin=int(log10(sngl(workspaceeigenvalues(imin))))
4888 DO WHILE(ntop < nmax)
4892 CALL
hmpdef(7,float(nmin),float(ntop),
'log10 of positive eigenvalues')
4894 IF(workspaceeigenvalues(idia) > 0.0d0)
THEN
4895 evalue=log10(sngl(workspaceeigenvalues(idia)))
4896 CALL hmpent(7,evalue)
4899 IF(nhistp /= 0) CALL hmprnt(7)
4903 CALL
gmpdef(3,2,
'low-value end of eigenvalues')
4905 evalue=sngl(workspaceeigenvalues(i))
4906 CALL gmpxy(3,float(i),evalue)
4908 IF(nhistp /= 0) CALL gmprnt(3)
4912 workspacediagonalization(i)=0.0d0
4913 IF(workspaceeigenvalues(i) /= 0.0d0)
THEN
4914 workspacediagonalization(i)=max(0.0d0,log10(abs(workspaceeigenvalues(i)))+3.0d0)
4915 IF(workspaceeigenvalues(i) < 0.0d0) workspacediagonalization(i)=-workspacediagonalization(i)
4919 WRITE(lun,*)
'The first (largest) eigenvalues ...'
4920 WRITE(lun,102) (workspaceeigenvalues(i),i=1,min(20,nagb))
4922 WRITE(lun,*)
'The last eigenvalues ... up to',nvgb
4923 WRITE(lun,102) (workspaceeigenvalues(i),i=max(1,nvgb-19),nvgb)
4925 WRITE(lun,*)
'The eigenvalues from',nvgb+1,
' to',nagb
4926 WRITE(lun,102) (workspaceeigenvalues(i),i=nvgb+1,nagb)
4928 WRITE(lun,*)
'Log10 + 3 of ',nagb,
' eigenvalues in decreasing',
' order'
4929 WRITE(lun,*)
'(for Eigenvalue < 0.001 the value 0.0 is shown)'
4930 WRITE(lun,101) (workspacediagonalization(i),i=1,nagb)
4931 IF(workspacediagonalization(nvar) < 0)
WRITE(lun,*)
'Negative values are ', &
4932 'printed for negative eigenvalues'
4933 CALL
devsig(nagb,workspaceeigenvalues,workspaceeigenvectors,globalvector,workspacediagonalization)
4935 WRITE(lun,*) nvgb,
' significances: insignificant if ', &
4936 'compatible with N(0,1)'
4937 WRITE(lun,101) (workspacediagonalization(i),i=1,nvgb)
4948 CALL
devsol(nvar,workspaceeigenvalues,workspaceeigenvectors,globalvector,globalcorrections,workspacediagonalization)
4958 CALL
devinv(nagb,workspaceeigenvalues,workspaceeigenvectors,globalmatd)
4980 DOUBLE PRECISION :: shift
4981 DOUBLE PRECISION :: rtol
4982 DOUBLE PRECISION :: anorm
4983 DOUBLE PRECISION :: acond
4984 DOUBLE PRECISION :: rnorm
4985 DOUBLE PRECISION :: ynorm
4991 IF(lunlog == 0) lun=6
5004 IF(mbandw == 0)
THEN
5005 IF(icalcm == 1)
THEN
5007 CALL
precon(ncgb,nvgb,matprecond,matprecond, matprecond(1+nvgb), &
5008 matprecond(1+nvgb+ncgb*nvgb))
5015 CALL
minres(nagb,globalvector, &
5016 workspaced(1), workspaced(1+nagb), workspaced(1+2*nagb), &
5017 workspaced(1+3*nagb),workspaced(1+4*nagb),workspaced(1+5*nagb), &
5018 globalcorrections,workspaceminres,
avprod,
mcsolv, checka ,.true. , shift, &
5019 nout , itnlim, rtol, istop, itn, anorm, acond, rnorm, ynorm)
5023 ELSE IF(mbandw > 0)
THEN
5024 IF(icalcm == 1)
THEN
5025 WRITE(lun,*)
'MMINRS: EQUDEC started'
5026 CALL
equdec(nvgb,ncgb,matprecond,indprecond,nrkd,nrkd2)
5027 WRITE(lun,*)
'MMINRS: EQUDEC ended'
5029 CALL
minres(nagb,globalvector, &
5030 workspaced(1), workspaced(1+nagb), workspaced(1+2*nagb), &
5031 workspaced(1+3*nagb),workspaced(1+4*nagb),workspaced(1+5*nagb), &
5032 globalcorrections,workspaceminres,
avprod,
mvsolv, checka ,.true. , shift, &
5033 nout, itnlim, rtol, istop, itn, anorm, acond, rnorm, ynorm)
5036 CALL
minres(nagb,globalvector, &
5037 workspaced(1), workspaced(1+nagb), workspaced(1+2*nagb), &
5038 workspaced(1+3*nagb),workspaced(1+4*nagb),workspaced(1+5*nagb), &
5039 globalcorrections,workspaceminres,
avprod,
mvsolv, checka ,.false., shift, &
5040 nout, itnlim, rtol, istop, itn, anorm, acond, rnorm, ynorm)
5046 IF (istopa == 0) print *,
'MINRES: istop=0, exact solution x=0.'
5064 INTEGER,
INTENT(IN) :: n
5065 DOUBLE PRECISION,
INTENT(IN) :: x(n)
5066 DOUBLE PRECISION,
INTENT(OUT) :: y(n)
5069 CALL
presol(ncgb,nvgb,matprecond,matprecond(1+nvgb),matprecond(1+nvgb+ncgb*nvgb),y,x)
5093 INTEGER,
INTENT(IN) :: n
5094 DOUBLE PRECISION,
INTENT(IN) :: x(n)
5095 DOUBLE PRECISION,
INTENT(OUT) :: y(n)
5109 DO WHILE(i < lenconstraints)
5111 label=listconstraints(i)%label
5112 IF(last == 0.AND.label == (-1)) icgb=icgb+1
5114 factr=listconstraints(i)%value
5116 ivgb =globalparlabelindex(2,itgbi)
5128 CALL
equslv(nvgb,ncgb,matprecond,indprecond,y)
5155 REAL,
DIMENSION(2) :: ta
5180 DOUBLE PRECISION :: stp
5181 DOUBLE PRECISION :: dratio
5182 DOUBLE PRECISION :: dfacin
5183 DOUBLE PRECISION :: djrat
5184 DOUBLE PRECISION :: dwmean
5185 DOUBLE PRECISION :: db
5186 DOUBLE PRECISION :: db1
5187 DOUBLE PRECISION :: db2
5188 DOUBLE PRECISION ::
dbdot
5196 IF(lunlog == 0) lunlog=6
5198 DO lunp=6,lunlog,lunlog-6
5200 WRITE(lunp,*)
'Solution algorithm: '
5201 WRITE(lunp,121)
'=================================================== '
5203 IF(metsol == 1)
THEN
5204 WRITE(lunp,121)
'solution method:',
'matrix inversion'
5205 ELSE IF(metsol == 2)
THEN
5206 WRITE(lunp,121)
'solution method:',
'diagonalization'
5208 IF(metsol == 3)
THEN
5209 WRITE(lunp,121)
'solution method:',
'minres (Paige/Saunders)'
5210 ELSE IF(metsol == 4)
THEN
5211 WRITE(lunp,121)
'solution method:', &
5212 'gmres (generalized minimzation of residuals)'
5215 WRITE(lunp,123)
'convergence limit at Delta F=',dflim
5216 WRITE(lunp,122)
'maximum number of iterations=',mitera
5217 matrit=min(matrit,mitera)
5219 WRITE(lunp,122)
'matrix recalculation up to ',matrit,
'. iteration'
5221 IF(metsol >= 3)
THEN
5222 IF(matsto == 1)
THEN
5223 WRITE(lunp,121)
'matrix storage:',
'full'
5224 ELSE IF(matsto == 2)
THEN
5225 WRITE(lunp,121)
'matrix storage:',
'sparse'
5227 WRITE(lunp,122)
'pre-con band-width parameter=',mbandw
5228 IF(mbandw == 0)
THEN
5229 WRITE(lunp,121)
'pre-conditioning:',
'default'
5230 ELSE IF(mbandw < 0)
THEN
5231 WRITE(lunp,121)
'pre-conditioning:',
'none!'
5232 ELSE IF(mbandw > 0)
THEN
5233 WRITE(lunp,121)
'pre-conditioning=',
'band-matrix'
5236 IF(regpre == 0.0d0.AND.npresg == 0)
THEN
5237 WRITE(lunp,121)
'using pre-sigmas:',
'no'
5240 WRITE(lunp,124)
'pre-sigmas defined for', &
5241 float(100*npresg)/float(nvgb),
' % of variable parameters'
5242 WRITE(lunp,123)
'default pre-sigma=',regpre
5244 IF(nregul == 0)
THEN
5245 WRITE(lunp,121)
'regularization:',
'no'
5247 WRITE(lunp,121)
'regularization:',
'yes'
5248 WRITE(lunp,123)
'regularization factor=',regula
5251 IF(chicut /= 0.0)
THEN
5252 WRITE(lunp,121)
'Chi square cut equiv 3 st.dev applied'
5253 WRITE(lunp,123)
'... in first iteration with factor',chicut
5254 WRITE(lunp,123)
'... in second iteration with factor',chirem
5255 WRITE(lunp,121)
' (reduced by sqrt in next iterations)'
5258 IF(lhuber /= 0)
THEN
5259 WRITE(lunp,122)
'Down-weighting of outliers in', lhuber,
' iterations'
5260 WRITE(lunp,123)
'Cut on downweight fraction',dwcut
5264 121 format(1x,a40,3x,a)
5265 122 format(1x,a40,2x,i2,a)
5266 123 format(1x,a40,2x,e9.2)
5267 124 format(1x,a40,3x,f5.1,a)
5286 IF(metsol == 1)
THEN
5289 ELSE IF(metsol == 2)
THEN
5292 ELSE IF(metsol == 3)
THEN
5295 ELSE IF(metsol == 4)
THEN
5303 IF(nofeas == 0)
THEN
5304 WRITE(lunlog,*)
'Checking feasibility of parameters:'
5305 WRITE(*,*)
'Checking feasibility of parameters:'
5309 WRITE(*,*)
' parameters are made feasible'
5310 WRITE(lunlog,102) concut
5311 WRITE(lunlog,*)
' parameters are made feasible'
5313 WRITE(*,*)
' parameters are feasible (i.e. satisfy constraints)'
5314 WRITE(lunlog,*)
' parameters are feasible (i.e. satisfy constraints)'
5322 WRITE(*,*)
'Reading files and accumulating vectors/matrices ...'
5325 CALL etime(ta,rstart)
5336 IF(iterat >= 0)
THEN
5338 IF(jcalcm+1 /= 0)
THEN
5339 IF(iterat == 0)
THEN
5345 CALL gmpxyd(1,float(nloopn),
REAL(fvalue),0.5,0.)
5347 IF(iterat /= litera)
THEN
5352 CALL gmpxyd(1,float(nloopn),
REAL(fvalue),0.5,delfun)
5353 IF(metsol == 3)
THEN
5354 CALL gmpxy(2,float(iterat),float(iitera))
5359 CALL gmpxyd(1,float(nloopn),
REAL(fvalue),0.5,0.)
5366 CALL etime(ta,rstart)
5368 IF (iabs(jcalcm) <= 1)
THEN
5370 times(idx )=(times(idx )*times(idx+3)+deltim) /(times(idx+3)+1.0)
5371 times(idx+3)= times(idx+3)+1.0
5376 IF(icalcm >= 0)
THEN
5380 nrej=nrejec(0)+nrejec(1)+nrejec(2)+nrejec(3)
5381 IF(3*nrej > nrecal)
THEN
5383 WRITE(*,*)
'Data rejected in previous loop: '
5385 nrejec(0),
' (rank deficit/NaN) ',nrejec(1),
' (Ndf=0) ', &
5386 nrejec(2),
' (huge) ',nrejec(3),
' (large)'
5387 WRITE(*,*)
'Too many rejects (>33.3%) - stop'
5393 IF(abs(icalcm) == 1)
THEN
5395 globalcorrections(i)=globalvector(i)
5398 itgbi=globalparvartototal(i)
5399 workspacelinesearch(i)=globalparameter(itgbi)
5402 IF(metsol == 1)
THEN
5404 ELSE IF(metsol == 2)
THEN
5406 ELSE IF(metsol == 3)
THEN
5408 ELSE IF(metsol == 4)
THEN
5409 WRITE(*,*)
'... reserved for GMRES (not yet!)'
5416 itgbi=globalparvartototal(i)
5417 globalparcopy(itgbi)=globalparameter(itgbi)
5418 globalparameter(itgbi)=globalparameter(itgbi)+globalcorrections(i)
5423 itgbi=globalparvartototal(i)
5424 globalcorrections(i)=globalparameter(itgbi)-globalparcopy(itgbi)
5425 globalparameter(itgbi)=globalparcopy(itgbi)
5430 CALL
ptldef(wolfc2, 10.0, minf,10)
5431 IF(metsol == 1)
THEN
5434 ELSE IF(metsol == 2)
THEN
5437 ELSE IF(metsol == 3)
THEN
5440 ELSE IF(metsol == 4)
THEN
5444 db=
dbdot(nvgb,globalcorrections,globalvector)
5445 db1=
dbdot(nvgb,globalcorrections,globalcorrections)
5446 db2=
dbdot(nvgb,globalvector,globalvector)
5448 angras=sngl(db/dsqrt(db1*db2))
5450 IF(db <= 0.0d0)
THEN
5451 WRITE(*,*)
'Function not decreasing:',db
5452 IF(db <= -1.0d-3)
THEN
5454 IF (iagain <= 1)
THEN
5455 WRITE(*,*)
'... again matrix calculation'
5459 WRITE(*,*)
'... aborting iterations'
5463 WRITE(*,*)
'... stopping iterations'
5474 IF(icalcm+2 == 0) exit
5475 CALL
ptline(nagb,workspacelinesearch, &
5478 globalcorrections, &
5487 itgbi=globalparvartototal(i)
5488 IF ((.NOT.(workspacelinesearch(i) <= 0.0d0)).AND. &
5489 (.NOT.(workspacelinesearch(i) > 0.0d0))) nan=nan+1
5490 globalparameter(itgbi)=workspacelinesearch(i)
5494 WRITE(*,*)
'Result vector containes ', nan,
' NaNs - stop'
5500 IF(isubit /= 0)
THEN
5501 WRITE(*,*)
'Subito! Exit after first step.'
5506 WRITE(*,*)
'INFO=0 should not happen (line search input err)'
5507 IF (iagain <= 0)
THEN
5517 IF(iact /= 0.OR.chicut > 1.0)
THEN
5519 IF(iterat < matrit) icalcm=+1
5522 IF(delfun <= dflim) go to 90
5523 IF(iterat >= mitera) go to 90
5525 IF(iterat < matrit) icalcm=+1
5532 IF(nrejec(0)+nrejec(1)+nrejec(2)+nrejec(3) /= 0)
THEN
5534 WRITE(*,*)
'Data rejected in last loop: '
5536 nrejec(0),
' (rank deficit/NaN) ',nrejec(1),
' (Ndf=0) ', &
5537 nrejec(2),
' (huge) ',nrejec(3),
' (large)'
5540 dwmean=sumndf/dfloat(ndfsum)
5541 dratio=fvalue/dwmean/dfloat(ndfsum-nagb)
5543 IF(lhuber /= 0)
THEN
5544 IF (lhuber <= 3)
THEN
5550 mrati=nint(100.0*catio)
5552 DO lunp=6,lunlog,lunlog-6
5554 IF (nfilw <= 0)
THEN
5555 WRITE(lunp,*)
'Sum(Chi^2)/Sum(Ndf) =',fvalue
5556 WRITE(lunp,*)
' / (',ndfsum,
'-',nagb,
')'
5557 WRITE(lunp,*)
' =',dratio
5559 WRITE(lunp,*)
'Sum(W*Chi^2)/Sum(Ndf)/<W> =',fvalue
5560 WRITE(lunp,*)
' / (',ndfsum,
'-', nagb,
')'
5561 WRITE(lunp,*)
' /',dwmean
5562 WRITE(lunp,*)
' =',dratio
5565 IF(lhuber /= 0)
WRITE(lunp,*) &
5566 ' with correction for down-weighting ',catio
5568 nrej=nrejec(0)+nrejec(1)+nrejec(2)+nrejec(3)
5587 nrati=nint(10000.0*float(nrej)/float(nrecal))
5588 djrat=0.01d0*dfloat(nrati)
5589 nfaci=nint(100.0*sqrt(catio))
5591 dratio=0.01d0*dfloat(mrati)
5592 dfacin=0.01d0*dfloat(nfaci)
5595 IF(mrati < 90.OR.mrati > 110) warner=.true.
5596 IF(nrati > 1) warner=.true.
5597 IF(nmiss1 /= 0) warner=.true.
5598 IF(iagain /= 0) warner=.true.
5603 WRITE(*,199)
'WarningWarningWarningWarningWarningWarningWarningWarningWar'
5604 WRITE(*,199)
'arningWarningWarningWarningWarningWarningWarningWarningWarn'
5605 WRITE(*,199)
'rningWarningWarningWarningWarningWarningWarningWarningWarni'
5606 WRITE(*,199)
'ningWarningWarningWarningWarningWarningWarningWarningWarnin'
5607 WRITE(*,199)
'ingWarningWarningWarningWarningWarningWarningWarningWarning'
5608 WRITE(*,199)
'ngWarningWarningWarningWarningWarningWarningWarningWarningW'
5609 WRITE(*,199)
'gWarningWarningWarningWarningWarningWarningWarningWarningWa'
5611 IF(mrati < 90.OR.mrati > 110)
THEN
5613 WRITE(*,*)
' Chi^2/Ndf = ',dratio,
' (should be close to 1)'
5614 WRITE(*,*)
' => multiply all input standard ', &
5615 'deviations by factor',dfacin
5620 WRITE(*,*)
' Fraction of rejects =',djrat,
' %', &
5621 ' (should be far below 1 %)'
5622 WRITE(*,*)
' => please provide correct mille data'
5625 IF(iagain /= 0)
THEN
5627 WRITE(*,*)
' Matrix not positiv definite '// &
5628 '(function not decreasing)'
5629 WRITE(*,*)
' => please provide correct mille data'
5632 IF(nmiss1 /= 0)
THEN
5634 WRITE(*,*)
' Rank defect =',nmiss1, &
5635 ' for constraint equations, should be 0'
5636 WRITE(*,*)
' => please correct constraint definition'
5640 WRITE(*,199)
'WarningWarningWarningWarningWarningWarningWarningWarningWar'
5641 WRITE(*,199)
'arningWarningWarningWarningWarningWarningWarningWarningWarn'
5642 WRITE(*,199)
'rningWarningWarningWarningWarningWarningWarningWarningWarni'
5643 WRITE(*,199)
'ningWarningWarningWarningWarningWarningWarningWarningWarnin'
5644 WRITE(*,199)
'ingWarningWarningWarningWarningWarningWarningWarningWarning'
5645 WRITE(*,199)
'ngWarningWarningWarningWarningWarningWarningWarningWarningW'
5646 WRITE(*,199)
'gWarningWarningWarningWarningWarningWarningWarningWarningWa'
5655 IF(metsol == 1)
THEN
5657 ELSE IF(metsol == 2)
THEN
5659 ELSE IF(metsol == 3)
THEN
5663 IF(labelg == 0) cycle
5666 IF(itgbi /= 0) ivgbi=globalparlabelindex(2,itgbi)
5667 IF(ivgbi < 0) ivgbi=0
5668 IF(ivgbi == 0) cycle
5673 ELSE IF(metsol == 4)
THEN
5679 102 format(
' Call FEASIB with cut=',g10.3)
5725 INTEGER :: lenfileinfo
5726 INTEGER :: lenfilenames
5728 INTEGER,
DIMENSION(:,:),
ALLOCATABLE :: vecfileinfo
5729 INTEGER,
DIMENSION(:,:),
ALLOCATABLE :: temparray
5730 INTEGER(KIND=large) :: rows
5731 INTEGER(KIND=large) :: cols
5732 INTEGER(KIND=large) :: newcols
5733 INTEGER(KIND=large) :: length
5735 CHARACTER (LEN=1024) :: text
5736 CHARACTER (LEN=1024) :: fname
5737 CHARACTER (LEN=14) :: bite(3)
5738 CHARACTER (LEN=32) :: keystx
5739 DOUBLE PRECISION :: dnum(100)
5741 DATA bite/
'C_binary',
'text ',
'Fortran_binary'/
5756 WRITE(*,*)
'Command line options: '
5757 WRITE(*,*)
'--------------------- '
5760 CALL
rltext(text,ia,ib,nab)
5761 WRITE(*,101) i,text(1:nab)
5762 IF(text(ia:ia) /=
'-')
THEN
5765 IF(filnam /=
' ')
THEN
5766 WRITE(*,*)
'Second text file in command line - stop'
5772 WRITE(*,*)
'Open error for file:',text(ia:ib),
' - stop'
5776 IF(index(text(ia:ib),
'b') /= 0)
THEN
5778 WRITE(*,*)
'Debugging requested'
5780 it=index(text(ia:ib),
't')
5783 ieq=index(text(ia+it:ib),
'=')+it
5785 IF (index(text(ia+ieq:ib),
'SL0' ) /= 0) ictest=2
5786 IF (index(text(ia+ieq:ib),
'SLE' ) /= 0) ictest=3
5787 IF (index(text(ia+ieq:ib),
'BP' ) /= 0) ictest=4
5788 IF (index(text(ia+ieq:ib),
'BRLF') /= 0) ictest=5
5789 IF (index(text(ia+ieq:ib),
'BRLC') /= 0) ictest=6
5792 IF(index(text(ia:ib),
's') /= 0) isubit=1
5793 IF(index(text(ia:ib),
'f') /= 0) iforce=1
5795 IF(i == iargc())
WRITE(*,*)
'--------------------- '
5801 IF(ictest >= 1)
THEN
5803 IF (ictest == 1)
THEN
5808 IF(filnam ==
' ') filnam=
'mp2str.txt'
5814 IF(filnam ==
' ')
THEN
5816 CALL
rltext(text,ia,ib,nab)
5821 stop
'in FILETC: no steering file. .'
5832 CALL
rltext(filnam,ia,ib,nfnam)
5834 WRITE(*,*)
'Listing of steering file: ',filnam(1:nfnam)
5835 WRITE(*,*)
'-------------------------'
5836 OPEN(10,file=filnam(1:nfnam),iostat=ios)
5838 WRITE(*,*)
'Open error for steering file - stop'
5846 rows=6; cols=lenfileinfo
5847 CALL
mpalloc(vecfileinfo,rows,cols,
'file info from steering')
5850 READ(10,102,iostat=ierrf) text
5852 CALL
rltext(text,ia,ib,nab)
5854 IF(nline <= 50)
THEN
5855 WRITE(*,101) nline,text(1:nab)
5856 IF(nline == 50)
WRITE(*,*)
' ...'
5859 CALL
rltext(text,ia,ib,nab)
5861 mat=
matint(text(ia:ib),
'end',npat,ntext)
5865 WRITE(*,*)
' end-statement after',nline,
' text lines'
5870 keystx=
'fortranfiles'
5873 IF (text(ia:ib) == keystx)
THEN
5882 IF (text(ia:ib) == keystx)
THEN
5891 iopt=index(text(ia:ib),
' -- ')
5892 IF (iopt > 0) ie=iopt-1
5897 IF (nfiles == lenfileinfo)
THEN
5898 CALL
mpalloc(temparray,rows,cols,
'temp file info from steering')
5899 temparray=vecfileinfo
5901 lenfileinfo=lenfileinfo*2
5903 CALL
mpalloc(vecfileinfo,rows,newcols,
'file info from steering')
5904 vecfileinfo(:,1:cols)=temparray(:,1:cols)
5910 lenfilenames=lenfilenames+ie-ia+1
5911 vecfileinfo(1,nfiles)=nline
5912 vecfileinfo(2,nfiles)=nu
5913 vecfileinfo(3,nfiles)=ia
5914 vecfileinfo(4,nfiles)=ie
5915 vecfileinfo(5,nfiles)=iopt
5916 vecfileinfo(6,nfiles)=ib
5925 CALL
mpalloc(mfd,length,
'file type')
5926 CALL
mpalloc(nfd,length,
'file line (in steering)')
5927 CALL
mpalloc(lfd,length,
'file name length')
5928 CALL
mpalloc(ofd,length,
'file option')
5930 CALL
mpalloc(tfd,length,
'file name')
5935 READ(10,102,iostat=ierrf) text
5938 IF (nline == vecfileinfo(1,i))
THEN
5939 nfd(i)=vecfileinfo(1,i)
5940 mfd(i)=vecfileinfo(2,i)
5941 ia=vecfileinfo(3,i)-1
5942 lfd(i)=vecfileinfo(4,i)-ia
5943 forall(k=1:lfd(i)) tfd(ioff+k)=text(ia+k:ia+k)
5947 IF (vecfileinfo(5,i) > 0)
THEN
5948 CALL
ratext(text(vecfileinfo(5,i)+4:vecfileinfo(6,i)),nums,dnum)
5949 IF (nums > 0) ofd(i)=sngl(dnum(1))
5952 IF (i > nfiles) exit
5958 length=nfiles; rows=2
5959 CALL
mpalloc(ifd,length,
'integrated record numbers (=offset)')
5960 CALL
mpalloc(jfd,length,
'number of accepted records')
5961 CALL
mpalloc(kfd,rows,length,
'number of records in file, file order')
5962 CALL
mpalloc(dfd,length,
'ndf sum')
5963 CALL
mpalloc(xfd,length,
'max. record size')
5964 CALL
mpalloc(wfd,length,
'file weight')
5965 CALL
mpalloc(cfd,length,
'chi2 sum')
5967 WRITE(*,*)
'-------------------------'
5972 IF (mprint > 1)
THEN
5973 WRITE(*,*)
'Table of files:'
5974 WRITE(*,*)
'---------------'
5977 WRITE(8,*)
'Text and data files:'
5980 forall(k=1:lfd(i)) fname(k:k)=tfd(ioff+k)
5982 IF (mprint > -1)
WRITE(*,103) i,bite(mfd(i)),fname(1:lfd(i))
5983 WRITE(8,103) i,bite(mfd(i)),fname(1:lfd(i))
5986 IF (mprint > 1)
THEN
5987 WRITE(*,*)
'---------------'
5999 IF(mfd(i) == 3)
THEN
6000 forall(k=1:lfd(i)) fname(k:k)=tfd(ioff+k)
6002 WRITE(*,*)
'Opening Fortran file ',10+nfilf+1,
' ',fname(1:lfd(i))
6003 OPEN(10+nfilf+1,file=fname(1:lfd(i)),iostat=ios, form=
'UNFORMATTED')
6005 WRITE(*,*)
'Open error for file ',fname(1:lfd(i))
6021 IF(mfd(i) == 1)
THEN
6023 IF(nfilc < 0) CALL initc(nfiles)
6024 IF(nfilc < 0) nfilc=0
6025 forall(k=1:lfd(i)) fname(k:k)=tfd(ioff+k)
6027 WRITE(*,*)
'Opening C file ',nfilc+1,
': ',fname(1:lfd(i))
6028 CALL openc(fname(1:lfd(i)),ios)
6030 WRITE(*,*)
'Open error ',ios,
' for file ',fname(1:lfd(i))
6038 WRITE(*,*)
'Opening of C-files not supported.'
6055 stop
'FILETC: open error '
6058 stop
'FILETC: no binary files '
6060 WRITE(*,*) nfilb,
' binary files opened'
6063 103 format(i3,2x,a14,3x,a)
6142 CHARACTER (LEN=1024) :: text
6143 CHARACTER (LEN=1024) :: fname
6146 WRITE(*,*)
'Processing text files ...'
6153 WRITE(*,*)
'File ',filnam(1:nfnam)
6159 IF(mfd(i) /= 2) cycle
6160 forall(k=1:lfd(i)) fname(k:k)=tfd(ia+k)
6161 WRITE(*,*)
'File ',fname(1:lfd(i))
6162 IF (mprint > 1)
WRITE(*,*)
' '
6163 OPEN(10,file=fname(1:lfd(i)),iostat=ios,form=
'FORMATTED')
6165 WRITE(*,*)
'Open error for file ',fname(1:lfd(i))
6175 READ(10,102,iostat=ierrf) text
6179 WRITE(*,*)
' end-of-file after',nline,
' text lines'
6183 IF(nline <= nlinmx.AND.mprint > 1)
THEN
6184 CALL
rltext(text,ia,ib,nab)
6186 WRITE(*,101) nline,text(1:nab)
6187 IF(nline == nlinmx)
WRITE(*,*)
' ...'
6190 CALL
rltext(text,ia,ib,nab)
6192 mat=
matint(text(ia:ib),
'end',npat,ntext)
6196 WRITE(*,*)
' end-statement after',nline,
' text lines'
6202 IF(nfiln <= nfiles.AND.nline == nfd(nfiln))
THEN
6217 stop
'FILETX: open error(s) in text files '
6220 WRITE(*,*)
'... end of text file processing.'
6223 IF(lunkno /= 0)
THEN
6225 WRITE(*,*) lunkno,
' unknown keywords in steering files, ', &
6226 'or file non-existing,'
6227 WRITE(*,*)
' see above!'
6228 WRITE(*,*)
'------------> stop'
6235 IF(metsol == 0)
THEN
6236 IF(matsto == 0)
THEN
6239 ELSE IF(matsto == 1)
THEN
6241 ELSE IF(matsto == 2)
THEN
6244 ELSE IF(metsol == 1)
THEN
6246 ELSE IF(metsol == 2)
THEN
6248 ELSE IF(metsol == 3)
THEN
6250 ELSE IF(metsol == 4)
THEN
6253 WRITE(*,*)
'MINRES forced with sparse matrix!'
6255 WRITE(*,*)
'MINRES forced with sparse matrix!'
6257 WRITE(*,*)
'MINRES forced with sparse matrix!'
6262 WRITE(*,*)
'MINRES forced with sparse matrix!'
6264 WRITE(*,*)
'MINRES forced with sparse matrix!'
6266 WRITE(*,*)
'MINRES forced with sparse matrix!'
6274 WRITE(*,*)
'Solution method and matrix-storage mode:'
6275 IF(metsol == 1)
THEN
6276 WRITE(*,*)
' METSOL = 1: matrix inversion'
6277 ELSE IF(metsol == 2)
THEN
6278 WRITE(*,*)
' METSOL = 2: diagonalization'
6279 ELSE IF(metsol == 3)
THEN
6280 WRITE(*,*)
' METSOL = 3: MINRES'
6281 ELSE IF(metsol == 4)
THEN
6282 WRITE(*,*)
' METSOL = 4: GMRES (-> MINRES)'
6286 WRITE(*,*)
' with',mitera,
' iterations'
6288 IF(matsto == 1)
THEN
6289 WRITE(*,*)
' MATSTO = 1: symmetric matrix, ',
'(n*n+n)/2 elements'
6290 ELSE IF(matsto == 2)
THEN
6291 WRITE(*,*)
' MATSTO = 2: sparse matrix'
6293 IF(mbandw /= 0)
THEN
6294 WRITE(*,*)
' and band matrix, width',mbandw
6299 IF(chicut /= 0.0)
THEN
6300 WRITE(*,*)
'Chi square cut equiv 3 st.dev applied ...'
6301 WRITE(*,*)
' in first iteration with factor',chicut
6302 WRITE(*,*)
' in second iteration with factor',chirem
6303 WRITE(*,*)
' (reduced by sqrt in next iterations)'
6306 IF(lhuber /= 0)
THEN
6307 WRITE(*,*)
' Down-weighting of outliers in', lhuber,
' iterations'
6308 WRITE(*,*)
' Cut on downweight fraction',dwcut
6339 CHARACTER (LEN=*),
INTENT(INOUT) :: fname
6344 IF(fname(1:5) ==
'rfio:') nuprae=1
6345 IF(fname(1:5) ==
'dcap:') nuprae=2
6346 IF(fname(1:5) ==
'root:') nuprae=3
6347 IF(nuprae == 0)
THEN
6348 INQUIRE(file=fname,iostat=ios,exist=ex)
6349 IF(ios /= 0)
nufile=-abs(ios)
6351 ELSE IF(nuprae == 1)
THEN
6364 nm=
matint(
'xt',fname(l1:ll),npat,ntext)
6367 nm=
matint(
'tx',fname(l1:ll),npat,ntext)
6408 CHARACTER (LEN=*),
INTENT(IN) :: text
6409 INTEGER,
INTENT(IN) :: nline
6411 parameter(nkeys=9,nmeth=4)
6412 CHARACTER (LEN=16) :: methxt(nmeth)
6413 CHARACTER (LEN=16) :: keylst(nkeys)
6414 CHARACTER (LEN=32) :: keywrd
6415 CHARACTER (LEN=32) :: keystx
6416 DOUBLE PRECISION :: dnum(100)
6419 equivalence(plvs(1),lpvs(1))
6422 SUBROUTINE additem(length,list,label,value)
6424 INTEGER,
INTENT(IN OUT) :: length
6425 TYPE(listitem
),
DIMENSION(:),
INTENT(IN OUT),
ALLOCATABLE :: list
6426 INTEGER,
INTENT(IN) :: label
6427 REAL,
INTENT(IN) :: value
6431 DATA keylst/
'unknown',
'parameter',
'constraint',
'wconstraint', &
6432 'measurement',
'method', &
6433 'mestimate',
'atleast',
'option'/
6440 DATA methxt/
'diagonalization',
'inversion',
'fullMINRES',
'sparseMINRES'/
6445 CALL
rltext(text,ia,ib,nab)
6446 IF(nab == 0) goto 10
6447 CALL
ratext(text(1:nab),nums,dnum)
6449 IF(nums /= 0) nkey=0
6451 keywrd=text(keya:keyb)
6458 mat=
matint(text(keya:keyb),keystx,npat,ntext)
6459 IF(mat >= ntext-ntext/5) go to 10
6465 mat=
matint(text(keya:keyb),keystx,npat,ntext)
6468 IF(mat >= (npat-npat/5))
THEN
6471 IF(nums > 0) mprint=idnint(dnum(1))
6476 mat=
matint(text(keya:keyb),keystx,npat,ntext)
6477 IF(mat >= (npat-npat/5))
THEN
6481 IF(nums > 0) mdebug=idnint(dnum(1))
6482 IF(nums > 1) mdebg2=idnint(dnum(2))
6487 mat=
matint(text(keya:keyb),keystx,npat,ntext)
6488 IF(mat >= (npat-npat/5))
THEN
6491 IF(nums > 0) mreqen=idnint(dnum(1))
6492 IF (mreqen <= 0) mreqen=1
6496 keystx=
'printrecord'
6497 mat=
matint(text(keya:keyb),keystx,npat,ntext)
6498 IF(mat >= (npat-npat/5))
THEN
6499 IF(nums > 0) nrecpr=idnint(dnum(1))
6500 IF(nums > 1) nrecp2=idnint(dnum(2))
6505 mat=
matint(text(keya:keyb),keystx,npat,ntext)
6506 IF(mat >= (npat-npat/5))
THEN
6507 IF (nums > 0.AND.dnum(1) > 0.) mxrec=idnint(dnum(1))
6512 mat=
matint(text(keya:keyb),keystx,npat,ntext)
6513 IF(mat >= (npat-npat/5))
THEN
6514 IF (nums > 0.AND.dnum(1) >= 0.) ncache=idnint(dnum(1))
6515 IF (nums == 2.AND.dnum(2) > 0..AND.dnum(2) <= 1.0) &
6516 fcache(1)=sngl(dnum(2))
6519 fcache(k)=sngl(dnum(k+1))
6526 mat=
matint(text(keya:keyb),keystx,npat,ntext)
6527 IF(mat >= (npat-npat/5))
THEN
6532 chicut=sngl(dnum(1))
6533 IF(chicut < 1.0) chicut=-1.0
6537 chirem=sngl(dnum(2))
6538 IF(chirem < 1.0) chirem=1.0
6539 IF(chicut >= 1.0) chirem=min(chirem,chicut)
6547 mat=
matint(text(keya:keyb),keystx,npat,ntext)
6548 IF(mat >= (npat-npat/5))
THEN
6549 IF(nums > 0) chhuge=sngl(dnum(1))
6550 IF(chhuge < 1.0) chhuge=1.0
6556 mat=
matint(text(keya:keyb),keystx,npat,ntext)
6557 IF(mat >= (npat-npat/5))
THEN
6558 IF(nums > 0) lfitnp=idnint(dnum(1))
6559 IF(nums > 1) lfitbb=idnint(dnum(2))
6563 keystx=
'regularization'
6564 mat=
matint(text(keya:keyb),keystx,npat,ntext)
6565 IF(mat >= (npat-npat/5))
THEN
6567 regula=sngl(dnum(1))
6568 IF(nums >= 2) regpre=sngl(dnum(2))
6572 keystx=
'regularisation'
6573 mat=
matint(text(keya:keyb),keystx,npat,ntext)
6574 IF(mat >= (npat-npat/5))
THEN
6576 regula=sngl(dnum(1))
6577 IF(nums >= 2) regpre=sngl(dnum(2))
6582 mat=
matint(text(keya:keyb),keystx,npat,ntext)
6583 IF(mat >= (npat-npat/5))
THEN
6584 regpre=sngl(dnum(1))
6589 mat=
matint(text(keya:keyb),keystx,npat,ntext)
6590 IF(mat >= (npat-npat/5))
THEN
6591 matrit=idnint(dnum(1))
6596 mat=
matint(text(keya:keyb),keystx,npat,ntext)
6597 IF(mat >= (npat-npat/5))
THEN
6599 IF (nums > 0.AND.dnum(1) > 0.) matmon=idnint(dnum(1))
6604 mat=
matint(text(keya:keyb),keystx,npat,ntext)
6606 IF(mat >= (npat-npat/5))
THEN
6607 IF(nums > 0) mbandw=idnint(dnum(1))
6608 IF(mbandw < 0) mbandw=-1
6632 keystx=
'outlierdownweighting'
6633 mat=
matint(text(keya:keyb),keystx,npat,ntext)
6636 IF(mat >= (npat-npat/5))
THEN
6637 lhuber=idnint(dnum(1))
6638 IF(lhuber > 0.AND.lhuber <= 2) lhuber=2
6642 keystx=
'dwfractioncut'
6643 mat=
matint(text(keya:keyb),keystx,npat,ntext)
6644 IF(mat >= (npat-npat/5))
THEN
6646 IF(dwcut > 0.5) dwcut=0.5
6651 mat=
matint(text(keya:keyb),keystx,npat,ntext)
6652 IF(mat >= (npat-npat/5))
THEN
6653 prange=abs(sngl(dnum(1)))
6658 mat=
matint(text(keya:keyb),keystx,npat,ntext)
6659 IF(mat >= (npat-npat/5))
THEN
6665 mat=
matint(text(keya:keyb),keystx,npat,ntext)
6666 IF(mat >= (npat-npat/5))
THEN
6671 keystx=
'memorydebug'
6672 mat=
matint(text(keya:keyb),keystx,npat,ntext)
6673 IF(mat >= (npat-npat/5))
THEN
6675 IF (nums > 0.AND.dnum(1) > 0.0) memdbg=idnint(dnum(1))
6680 mat=
matint(text(keya:keyb),keystx,npat,ntext)
6681 IF(mat >= (npat-npat/5))
THEN
6687 mat=
matint(text(keya:keyb),keystx,npat,ntext)
6688 IF(mat >= (npat-npat/5))
THEN
6698 WRITE(*,*)
'WARNING: multithreading not available'
6704 mat=
matint(text(keya:keyb),keystx,npat,ntext)
6705 IF(mat >= (npat-npat/5))
THEN
6711 mat=
matint(text(keya:keyb),keystx,npat,ntext)
6712 IF(mat >= (npat-npat/5).AND.mnrsel < 100)
THEN
6713 nl=min(nums,100-mnrsel)
6715 lbmnrs(mnrsel+k)=idnint(dnum(k))
6721 keystx=
'pairentries'
6722 mat=
matint(text(keya:keyb),keystx,npat,ntext)
6723 IF(mat >= (npat-npat/5))
THEN
6726 IF (nums > 0.AND.dnum(1) > 0.0)
THEN
6727 mreqpe=idnint(dnum(1))
6728 IF (nums >= 2.AND.dnum(2) >= dnum(1)) mhispe=idnint(dnum(2))
6729 IF (nums >= 3.AND.dnum(3) > 0.0) msngpe=idnint(dnum(3))
6730 icount=max(msngpe+1,mhispe)
6731 icount=max(mreqpe,icount)
6735 IF (icount >= mxcnt)
THEN
6745 mat=
matint(text(keya:keyb),keystx,npat,ntext)
6746 IF(mat >= (npat-npat/5))
THEN
6747 wolfc1=sngl(dnum(1))
6748 wolfc2=sngl(dnum(2))
6755 mat=
matint(text(keya:keyb),keystx,npat,ntext)
6756 IF(mat >= (npat-npat/5))
THEN
6758 IF (dnum(1) < 1.0d-10.OR.dnum(1) > 1.0d-04)
THEN
6759 WRITE(*,*)
'ERROR: need 1.0D-10 <= MRESTL ', &
6760 '<= 1.0D-04, but get ', dnum(1)
6762 mrestl=idnint(dnum(1))
6769 keystx=
'nofeasiblestart'
6770 mat=
matint(text(keya:keyb),keystx,npat,ntext)
6771 IF(mat >= (npat-npat/5))
THEN
6777 mat=
matint(text(keya:keyb),keystx,npat,ntext)
6778 IF(mat >= ntext-ntext/10)
THEN
6784 keystx=
'fortranfiles'
6785 mat=
matint(text(ia:ib),keystx,npat,ntext)
6786 IF(mat >= ntext-ntext/10) return
6789 mat=
matint(text(ia:ib),keystx,npat,ntext)
6790 IF(mat >= ntext-ntext/10) return
6794 IF(nums /= 0) nkey=0
6797 WRITE(*,*)
'**************************************************'
6799 WRITE(*,*)
'Unknown keyword(s): ',text(1:min(nab,50))
6801 WRITE(*,*)
'**************************************************'
6824 10
IF(nkey > 0)
THEN
6828 lpvs(1)=idnint(dnum(1))
6829 plvs(2)=sngl(dnum(2))
6830 plvs(3)=sngl(dnum(3))
6831 IF(lpvs(1) /= 0)
THEN
6833 CALL
additem(lenparameters,listparameters,lpvs(1),plvs(2))
6834 CALL
additem(lenpresigmas,listpresigmas,lpvs(1),plvs(3))
6836 WRITE(*,*)
'Line',nline,
' error, label=',lpvs(1)
6838 ELSE IF(nums /= 0)
THEN
6840 WRITE(*,*)
'Wrong text in line',nline
6841 WRITE(*,*)
'Status: new parameter'
6842 WRITE(*,*)
'> ',text(1:nab)
6844 ELSE IF(lkey == 3.OR.lkey == 4)
THEN
6846 IF(nums >= 1.AND.nums <= 2)
THEN
6849 plvs(2)=sngl(dnum(1))
6851 CALL
additem(lenconstraints,listconstraints,lpvs(1),plvs(2))
6854 IF(lkey == 4) lpvs(1)=-2
6857 IF(nums == 2) plvs(2)=sngl(dnum(2))
6859 CALL
additem(lenconstraints,listconstraints,lpvs(1),plvs(2))
6863 WRITE(*,*)
'Wrong text in line',nline
6864 WRITE(*,*)
'Status: new keyword (w)constraint'
6865 WRITE(*,*)
'> ',text(1:nab)
6867 ELSE IF(lkey == 5)
THEN
6870 plvs(2)=sngl(dnum(1))
6872 CALL
additem(lenmeasurements,listmeasurements,lpvs(1),plvs(2))
6874 plvs(2)=sngl(dnum(2))
6876 CALL
additem(lenmeasurements,listmeasurements,lpvs(1),plvs(2))
6879 WRITE(*,*)
'Wrong text in line',nline
6880 WRITE(*,*)
'Status: new keyword measurement'
6881 WRITE(*,*)
'> ',text(1:nab)
6884 ELSE IF(lkey == 6)
THEN
6886 IF(nums >= 1) miter=idnint(dnum(1))
6887 IF(miter >= 1) mitera=miter
6892 mat=
matint(text(keya:keyb),keystx,npat,ntext)
6893 IF(mat >= ntext-ntext/5)
THEN
6897 ELSE IF(i == 2)
THEN
6900 ELSE IF(i == 3)
THEN
6904 ELSE IF(i == 4)
THEN
6913 ELSE IF(nkey == 0)
THEN
6916 lpvs(1)=idnint(dnum(1))
6917 plvs(2)=sngl(dnum(2))
6918 plvs(3)=sngl(dnum(3))
6919 IF(lpvs(1) /= 0)
THEN
6921 CALL
additem(lenparameters,listparameters,lpvs(1),plvs(2))
6922 CALL
additem(lenpresigmas,listpresigmas,lpvs(1),plvs(3))
6924 WRITE(*,*)
'Line',nline,
' error, label=',lpvs(1)
6926 ELSE IF(nums > 1.AND.nums < 3)
THEN
6928 WRITE(*,*)
'Wrong text in line',nline
6929 WRITE(*,*)
'Status continuation parameter'
6930 WRITE(*,*)
'> ',text(1:nab)
6933 ELSE IF(lkey == 3.OR.lkey == 4)
THEN
6936 label=idnint(dnum(i))
6937 IF(label <= 0) ier=1
6939 IF(mod(nums,2) /= 0) ier=1
6942 lpvs(1)=idnint(dnum(i))
6943 plvs(2)=sngl(dnum(i+1))
6945 CALL
additem(lenconstraints,listconstraints,lpvs(1),plvs(2))
6949 WRITE(*,*)
'Wrong text in line',nline
6950 WRITE(*,*)
'Status continuation (w)constraint'
6951 WRITE(*,*)
'> ',text(1:nab)
6954 ELSE IF(lkey == 5)
THEN
6958 label=idnint(dnum(i))
6959 IF(label <= 0) ier=1
6961 IF(mod(nums,2) /= 0) ier=1
6965 lpvs(1)=idnint(dnum(i))
6966 plvs(2)=sngl(dnum(i+1))
6968 CALL
additem(lenmeasurements,listmeasurements,lpvs(1),plvs(2))
6972 WRITE(*,*)
'Wrong text in line',nline
6973 WRITE(*,*)
'Status continuation measurement'
6974 WRITE(*,*)
'> ',text(1:nab)
6991 INTEGER,
INTENT(IN OUT) :: length
6992 TYPE(listitem
),
DIMENSION(:),
INTENT(IN OUT),
ALLOCATABLE :: list
6993 INTEGER,
INTENT(IN) :: label
6994 REAL,
INTENT(IN) :: value
6996 INTEGER(kind=large) :: newsize
6997 INTEGER(kind=large) :: oldsize
6998 TYPE(listitem
),
DIMENSION(:),
ALLOCATABLE :: templist
7000 IF (label > 0.AND.value == 0.) return
7001 IF (length == 0 )
THEN
7003 CALL
mpalloc(list,newsize,
' list ')
7005 oldsize=
size(list,kind=large)
7006 IF (length >= oldsize)
THEN
7007 newsize = oldsize + oldsize/5 + 100
7008 CALL
mpalloc(templist,oldsize,
' temp. list ')
7011 CALL
mpalloc(list,newsize,
' list ')
7012 list(1:oldsize)=templist(1:oldsize)
7017 list(length)%label=label
7018 list(length)%value=value
7024 USE mpmod, ONLY: textl
7031 CHARACTER (LEN=*),
INTENT(IN) :: text
7032 CHARACTER (LEN=16) :: textc
7041 textl(ka:kb)=text(1:l)
7045 textc=text(1:l)//
'-end'
7053 textl(ka:kb)=textc(1:l)
7059 USE mpmod, ONLY: textl
7078 INTEGER,
INTENT(IN) :: lun
7079 CHARACTER (LEN=*),
INTENT(IN) :: fname
7080 CHARACTER (LEN=33) :: nafile
7081 CHARACTER (LEN=33) :: nbfile
7086 IF(l > 32) stop
'File name too long '
7090 INQUIRE(file=nafile(1:l),exist=ex)
7092 INQUIRE(file=nafile(1:l+1),exist=ex)
7094 CALL system(
'rm '//nafile)
7098 CALL system(
'mv '//nafile//nbfile)
7100 OPEN(unit=lun,file=fname)
7132 minut1=nsecd1/60-60*nhour1
7133 secnd1=delta-60*(minut1+60*nhour1)
7137 minut2=nsecd2/60-60*nhour2
7138 secnd2=delta-60*(minut2+60*nhour2)
7139 WRITE(*,101) nhour1,minut1,secnd1, nhour2,minut2,secnd2
7144 101 format(i4,
' h',i3,
' min',f5.1,
' sec total',18x,
'elapsed', &
7145 i4,
' h',i3,
' min',f5.1,
' sec')
7158 DOUBLE PRECISION:: add
7162 accuratensum=accuratensum+nadd
7163 accuratedsum=accuratedsum+(add-dfloat(nadd))
7164 IF(accuratedsum > 16.0d0)
THEN
7165 accuratedsum=accuratedsum-16.0d0
7166 accuratensum=accuratensum+16
7168 IF(accuratensum > nexp20)
THEN
7169 accuratenexp=accuratenexp+1
7170 accuratensum=accuratensum-nexp20
7183 DOUBLE PRECISION,
INTENT(OUT) ::asum
7184 asum=(accuratedsum+dfloat(accuratensum))+dfloat(accuratenexp)*dfloat(nexp20)