SND@LHC Software
|
Millepede II program, subroutines. More...
Go to the source code of this file.
Functions/Subroutines | |
program | mptwo |
Millepede II main program Pede. | |
subroutine | solglo (ivgbi) |
Error for single global parameter from MINRES. | |
subroutine | solgloqlp (ivgbi) |
Error for single global parameter from MINRES-QLP. | |
subroutine | addcst |
Add constraint information to matrix and vector. | |
subroutine | prpcon |
Prepare constraints. | |
subroutine | feasma |
Matrix for feasible solution. | |
subroutine | feasib (concut, iact) |
Make parameters feasible. | |
subroutine | peread (more) |
Read (block of) records from binary files. | |
subroutine | peprep (mode) |
Prepare records. | |
subroutine | pechk (ibuf, nerr) |
Check Millepede record. | |
subroutine | isjajb (nst, is, ja, jb, jsp) |
Decode Millepede record. | |
subroutine | loopn |
Loop with fits and sums. | |
subroutine | ploopa (lunp) |
Print title for iteration. | |
subroutine | ploopb (lunp) |
Print iteration line. | |
subroutine | ploopc (lunp) |
Print sub-iteration line. | |
subroutine | ploopd (lunp) |
Print solution line. | |
subroutine | explfc (lunit) |
Print explanation of iteration table. | |
subroutine | mupdat (i, j, add) |
Update element of global matrix. | |
subroutine | loopbf (nrej, ndfs, sndf, dchi2s, numfil, naccf, chi2f, ndff) |
Loop over records in read buffer (block), fits and sums. | |
subroutine | prtglo |
Print final log file. | |
subroutine | prtstat |
Print input statistic. | |
subroutine | avprd0 (n, x, b) |
Product symmetric matrix times vector. | |
subroutine | avprod (n, x, b) |
Product symmetric matrix times vector. | |
integer(mpl) function | ijadd (itema, itemb) |
Index for sparse storage. | |
subroutine | mhalf2 |
Fill 2nd half of matrix for extended storage. | |
subroutine | sechms (deltat, nhour, minut, secnd) |
Time conversion. | |
integer(mpi) function | inone (item) |
Translate labels to indices (for global parameters). | |
subroutine | upone |
Update, redefine hash indices. | |
integer(mpi) function | iprime (n) |
largest prime number < N. | |
subroutine | loop1 |
First data loop (get global labels). | |
subroutine | loop1i |
Iteration of first data loop. | |
subroutine | loop2 |
Second data loop (number of derivatives, global label pairs). | |
subroutine | monres |
Monitor input residuals. | |
subroutine | vmprep (msize) |
Prepare storage for vectors and matrices. | |
subroutine | minver |
Solution by matrix inversion. | |
subroutine | mdiags |
Solution by diagonalization. | |
subroutine | zdiags |
Covariance matrix for diagonalization (,correction of eigenvectors). | |
subroutine | mminrs |
Solution with MINRES. | |
subroutine | mminrsqlp |
Solution with MINRES-QLP. | |
subroutine | mcsolv (n, x, y) |
Solution for zero band width preconditioner. | |
subroutine | mvsolv (n, x, y) |
Solution for finite band width preconditioner. | |
subroutine | xloopn |
Standard solution algorithm. | |
subroutine | filetc |
Interprete command line option, steering file. | |
subroutine | filetx |
Interprete text files. | |
integer(mpi) function | nufile (fname) |
Inquire on file. | |
subroutine | intext (text, nline) |
Interprete text. | |
subroutine | additem (length, list, label, value) |
add item to list | |
subroutine | mstart (text) |
Start of 'module' printout. | |
subroutine | mend |
End of 'module' printout. | |
subroutine | mvopen (lun, fname) |
Open file. | |
subroutine | petime |
Print times. | |
subroutine | peend (icode, cmessage) |
Print exit code. | |
subroutine | binopn (kfile, ithr, ierr) |
Open binary file. | |
subroutine | bincls (kfile, ithr) |
Close binary file. | |
subroutine | binrwd (kfile) |
Rewind binary file. | |
subroutine | addsum (add) |
Accurate summation. | |
subroutine | getsum (asum) |
Get accurate sum. | |
Millepede II program, subroutines.
Definition in file pede.f90.
subroutine addcst |
Add constraint information to matrix and vector.
Definition at line 1169 of file pede.f90.
subroutine additem | ( | integer(mpi), intent(inout) | length, |
type(listitem), dimension(:), intent(inout), allocatable | list, | ||
integer(mpi), intent(in) | label, | ||
real(mpd), intent(in) | value | ||
) |
add item to list
[in,out] | length | length of list |
[in,out] | list | list of items |
[in] | label | item label |
[in] | value | item value |
Definition at line 8713 of file pede.f90.
subroutine addsum | ( | real(mpd) | add | ) |
subroutine avprd0 | ( | integer(mpi), intent(in) | n, |
real(mpd), dimension(n), intent(in) | x, | ||
real(mpd), dimension(n), intent(out) | b | ||
) |
Product symmetric matrix times vector.
A(sym) * X => B. Used by MINRES method (Is most CPU intensive part). The matrix A is the global matrix in full symmetric or (compressed) sparse storage.
[in] | n | size of matrix |
[in] | x | vector X |
[in] | b | result vector B |
Definition at line 4226 of file pede.f90.
subroutine avprod | ( | integer(mpi), intent(in) | n, |
real(mpd), dimension(n), intent(in) | x, | ||
real(mpd), dimension(n), intent(out) | b | ||
) |
Product symmetric matrix times vector.
A(sym) * X => B. Used by MINRES method (Is most CPU intensive part). The matrix A is the global matrix in full symmetric or (compressed) sparse storage. Allows for size of X and smaller than size of matrix in case of solution with constriants by elimination.
[in] | n | size of matrix ( <= size of global matrix) |
[in] | x | vector X |
[in] | b | result vector B |
Definition at line 4394 of file pede.f90.
subroutine bincls | ( | integer(mpi), intent(in) | kfile, |
integer(mpi), intent(in) | ithr | ||
) |
Close binary file.
[in] | kfile | file number |
[in] | ithr | thread number ([1..nthrd] - close and reopen) for C files |
Definition at line 8987 of file pede.f90.
subroutine binopn | ( | integer(mpi), intent(in) | kfile, |
integer(mpi), intent(in) | ithr, | ||
integer(mpi), intent(out) | ierr | ||
) |
Open binary file.
[in] | kfile | file number |
[in] | ithr | thread number ([1..nthrd] - close and reopen) or 0 (next file - keep open) for C files |
[out] | ierr | error flag |
Definition at line 8909 of file pede.f90.
subroutine binrwd | ( | integer(mpi), intent(in) | kfile | ) |
Rewind binary file.
[in] | kfile | file number |
Definition at line 9013 of file pede.f90.
subroutine explfc | ( | integer(mpi) | lunit | ) |
Print explanation of iteration table.
Definition at line 2886 of file pede.f90.
subroutine feasib | ( | real(mps), intent(in) | concut, |
integer(mpi), intent(out) | iact | ||
) |
Make parameters feasible.
Correct for constraint equation discrepancies.
[in] | concut | cut for discrepancies |
[out] | iact | =1 if correction needed, else =0 |
Definition at line 1576 of file pede.f90.
subroutine feasma |
Matrix for feasible solution.
Check rank of product matrix of constraints.
Definition at line 1427 of file pede.f90.
subroutine filetc |
Interprete command line option, steering file.
Fetch and interprete command line options, if steering file specified, check file existence (calling NUFILE)
If no steering file specified, check default steering file.
Create test files for command line option '-t'.
Read steering file, print some lines, detect names of text and binary files, check file existence, store all file names.
Open all binary files.
Definition at line 7283 of file pede.f90.
subroutine filetx |
Interprete text files.
Reset flags and read steering and all other text files. Print some lines from each file.
Store parameter values, constraints and measurements.
Check flags METSOL (method of solution) and MATSTO (matrix storage mode). Set default values for flags, which are undefined.
Parameter values, format:
1 label 2 (initial) parameter value 3 pre-sigma 4 label 5 (initial) parameter value 6 pre-sigma 7 label ... ... (number of words is multiple of 3)
Constraint data, format:
1 0 ! constraint header of four words: 2 right-hand-side ! 0 and -1 ... 3 -1; -2 ! ... indicate (weighting) ... 4 sigma ! ... header 5 label 6 factor 7 label 8 factor 9 ... ... ... (number of words is multiple of 2, at least 6)
Measured data, format:
1 0 ! constraint header of four words: 2 right-hand-side ! 0 and -1 ... 3 -1 ! ... indicate ... 4 sigma ! ... header 5 label 6 factor 7 label 8 factor 9 ... ... ... (number of words is multiple of 2, at least 6)
Definition at line 7733 of file pede.f90.
subroutine getsum | ( | real(mpd), intent(out) | asum | ) |
Get accurate sum.
[out] | asum | accurate sum |
Definition at line 9066 of file pede.f90.
integer(mpl) function ijadd | ( | integer(mpi), intent(in) | itema, |
integer(mpi), intent(in) | itemb | ||
) |
Index for sparse storage.
In case of (compressed) sparse storage calculate index for off-diagonal matrix element.
[in] | itema | row number |
[in] | itemb | column number |
Definition at line 4432 of file pede.f90.
integer(mpi) function inone | ( | integer(mpi), intent(in) | item | ) |
Translate labels to indices (for global parameters).
Functions INONE and subroutine UPONE are used to collect items, i.e. labels, and to order and translate them.
In the first phase items are collected and stored by calling IRES=INONE(ITEM)
.
At the first entry the two sub-arrays "a" (globalParLabelIndex) and "b" (globalParHashTable) of length 2N are generated with a start length for N=128 entries. In array "a" two words are reserved for each item: (ITEM, count). The function INONE(ITEM) returns the number of the item. At each entry the argument is compared with the already stored items, new items are stored. Search for entries is done using hash-indices, stored in sub-array "b". The initial hash-index is
j = 1 + mod(ITEM, n_prime) + N
where n_prime is the largest prime number less than N. At each entry the count is increased by one. If N items are stored, the size of the sub-arrays is increased by calling CALL UPONE
.
[in] | item | label |
Definition at line 4662 of file pede.f90.
subroutine intext | ( | character (len=*), intent(in) | text, |
integer(mpi), intent(in) | nline | ||
) |
Interprete text.
Look for keywords and argument in text line.
[in] | text | text |
[in] | nline | line number |
Definition at line 8019 of file pede.f90.
integer(mpi) function iprime | ( | integer(mpi), intent(in) | n | ) |
largest prime number < N.
[in] | n | N |
Definition at line 4789 of file pede.f90.
subroutine isjajb | ( | integer(mpi), intent(in) | nst, |
integer(mpi), intent(inout) | is, | ||
integer(mpi), intent(out) | ja, | ||
integer(mpi), intent(out) | jb, | ||
integer(mpi), intent(out) | jsp | ||
) |
Decode Millepede record.
Get indices JA, JB, IS for next measurement within record:
GLDER(JA)
(INDER(JA+J),GLDER(JA+J),J=1,JB-JA-1)
i.e. JB-JA-1 derivativesGLDER(JB)
(INDER(JB+J),GLDER(JB+J),J=1,IS-JB)
i.e. IST-JB derivativesEnd_of_data is indicated by returned values JA=0 and JB=0 Special data are ignored. At end_of_data the info to the special data is returned: IS = pointer to special data; number of words is NSP=-GLDER(IS)
.
[in] | nst | index of last word of record |
[in,out] | is | index of last global derivative (index of first word of record at the first call) |
[out] | ja | index of measured value (=0 at end), = pointer to local derivatives |
[out] | jb | index of standard deviation (=0 at end), = pointer to global derivatives |
[out] | jsp | index to special data |
Definition at line 2259 of file pede.f90.
subroutine loop1 |
First data loop (get global labels).
Read all data files and add all labels to global labels table, add labels from parameters, constraints and measurements (from text files).
Define variable and fixed global parameters (depending on entries and pre-sigma).
Iterate if records had been skipped due to too small read buffer size.
Definition at line 4821 of file pede.f90.
subroutine loop1i |
Iteration of first data loop.
Read all data files again skipping measurements with any parameter below the entries cut to update the number of entries.
Redefine variable and fixed global parameters (depending on updated entries).
Definition at line 5095 of file pede.f90.
subroutine loop2 |
Second data loop (number of derivatives, global label pairs).
Calculate maximum number of local, global derivatives and equations per record.
For sparse storage count index pairs with bit (field) counters to construct sparsity structure (row offsets, (compressed) column lists).
Determine read/write cache splitting from average record values (length, global par. vector/matrix).
Check constraints for rank deficit.
Definition at line 5215 of file pede.f90.
subroutine loopbf | ( | integer(mpi), dimension(0:3), intent(inout) | nrej, |
integer(mpi), intent(inout) | ndfs, | ||
real(mpd), intent(inout) | sndf, | ||
real(mpd), intent(inout) | dchi2s, | ||
integer(mpi), intent(in) | numfil, | ||
integer(mpi), dimension(numfil), intent(inout) | naccf, | ||
real(mps), dimension(numfil), intent(inout) | chi2f, | ||
integer(mpi), dimension(numfil), intent(inout) | ndff | ||
) |
Loop over records in read buffer (block), fits and sums.
Loop over records in current read buffer block (with multiple threads). Perform local fits (optionally with outlier downweigthing) to calculate Chi2, ndf and r.h.s. 'b' of linear equation system A*x=b. In first iteration(s) fill global matrix A.
For the filling of the global matrix each thread creates from his share of local fits (small) udpdate matrices (
The matrices of the local fits are checked for bordered band structure. For border size b and band width m all elements (i,j) are zero for min(i,j)>b and abs(i-j)>m. For sufficient small (b,m) a solution by root free Cholesky decomposition and forward/backward substitution of the band part is much faster compared to inversion (see broken lines in references). Based on the expected computing cost the faster solution method is selected.
[in,out] | nrej | number of rejected records |
[in,out] | ndfs | sum(ndf) |
[in,out] | sndf | sum(weighted ndf) |
[in,out] | dchi2s | sum(weighted chi2) |
[in] | numfil | number of binary files |
[in,out] | naccf | number of accepted records per binary file |
[in,out] | chi2f | sum(chi2/ndf) per binary file |
[in,out] | ndff | sum(ndf) per binary file |
Definition at line 3063 of file pede.f90.
subroutine loopn |
Loop with fits and sums.
Loop over all binary files. Perform local fits to calculate Chi2, ndf and r.h.s. 'b' of linear equation system A*x=b. In first iteration(s) fill matrix A.
Definition at line 2315 of file pede.f90.
subroutine mcsolv | ( | integer(mpi), intent(in) | n, |
real(mpd), dimension(n), intent(in) | x, | ||
real(mpd), dimension(n), intent(out) | y | ||
) |
Solution for zero band width preconditioner.
Used by MINRES.
[in] | n | size of vectors |
[in] | x | rhs vector |
[out] | y | result vector |
Definition at line 6579 of file pede.f90.
subroutine mdiags |
Solution by diagonalization.
Definition at line 6206 of file pede.f90.
subroutine mend |
subroutine mhalf2 |
Fill 2nd half of matrix for extended storage.
Definition at line 4535 of file pede.f90.
subroutine minver |
Solution by matrix inversion.
Parallelized (SQMINL), solve A*x=b.
Definition at line 6129 of file pede.f90.
subroutine mminrs |
Solution with MINRES.
Solve A*x=b by minimizing |A*x-b| iteratively. Parallelized (AVPROD).
Use preconditioner with zero (precon) or finite (equdec) band width.
Definition at line 6385 of file pede.f90.
subroutine mminrsqlp |
Solution with MINRES-QLP.
Solve A*x=b by minimizing |A*x-b| iteratively. Parallelized (AVPROD).
Use preconditioner with zero (precon) or finite (equdec) band width.
Definition at line 6478 of file pede.f90.
subroutine monres |
Monitor input residuals.
Read all data files again to monitor input residuals
Definition at line 5940 of file pede.f90.
subroutine mstart | ( | character (len=*), intent(in) | text | ) |
Start of 'module' printout.
Definition at line 8749 of file pede.f90.
subroutine mupdat | ( | integer(mpi), intent(in) | i, |
integer(mpi), intent(in) | j, | ||
real(mpd), intent(in) | add | ||
) |
Update element of global matrix.
Add value ADD to matrix element (I,J).
[in] | i | first index |
[in] | j | second index |
[in] | add | summand |
Definition at line 2977 of file pede.f90.
subroutine mvopen | ( | integer(mpi), intent(in) | lun, |
character (len=*), intent(in) | fname | ||
) |
Open file.
Evtl. move existing file to ~ version.
[in] | lun | unit number |
[in] | fname | file name |
Definition at line 8802 of file pede.f90.
subroutine mvsolv | ( | integer(mpi), intent(in) | n, |
real(mpd), dimension(n), intent(in) | x, | ||
real(mpd), dimension(n), intent(out) | y | ||
) |
Solution for finite band width preconditioner.
Used by MINRES.
[in] | n | size of vectors |
[in] | x | rhs vector |
[out] | y | result vector |
Definition at line 6599 of file pede.f90.
integer(mpi) function nufile | ( | character (len=*), intent(inout) | fname | ) |
Inquire on file.
Result = 1 for existing binary file, =2 for existing text file, else =0, < 0 open error.
Text file names are recognized by the filename extension, which should contain 'xt' or 'tx'.
[in,out] | fname | file name, optionaly strip prefix. |
Definition at line 7965 of file pede.f90.
subroutine pechk | ( | integer(mpi), intent(in) | ibuf, |
integer(mpi), intent(out) | nerr | ||
) |
Check Millepede record.
Check integer structure of labels and markers (zeros). Check floats for NaNs.
[in] | ibuf | buffer number |
[out] | nerr | error flags |
Definition at line 2161 of file pede.f90.
subroutine peend | ( | integer(mpi), intent(in) | icode, |
character (len=*), intent(in) | cmessage | ||
) |
Print exit code.
Print exit code and message.
[in] | icode | exit code |
[in] | cmessage | exit massage |
subroutine peprep | ( | integer(mpi), intent(in) | mode | ) |
Prepare records.
For global parameters replace label by index (INONE
).
[in] | mode | <=0: build index table (INONE) for global variables; >0: use index table, can be parallelized, optional scale errors |
Definition at line 2066 of file pede.f90.
subroutine peread | ( | integer(mpi), intent(out) | more | ) |
Read (block of) records from binary files.
Optionally using several threads (each file read by single thread). Records larger than the read buffer (ndimbuf
) are skipped. In case of skipped events in the first loop over all binary files the buffer size is adapted to the maximum record size (and the initial loop (LOOP1
) is repeated). C binary files are handled by readc.c and may be gzipped.
[out] | more | more records to come |
The records consist of parallel integer and real arrays:
real array integer array 1 0.0 error count (this record) 2 RMEAS, measured value 0 JA 3 local derivative index of local derivative 4 local derivative index of local derivative 5 ... 6 SIGMA, error (>0) 0 JB global derivative label of global derivative global derivative label of global derivative IST RMEAS, measured value 0 local derivative index of local derivative local derivative index of local derivative ... SIGMA, error 0 global derivative label of global derivative global derivative label of global derivative ... NR global derivative label of global derivative
Definition at line 1737 of file pede.f90.
subroutine petime |
Print times.
Print the elapsed and total time.
Definition at line 8839 of file pede.f90.
subroutine ploopa | ( | integer(mpi), intent(in) | lunp | ) |
Print title for iteration.
[in] | lunp | unit number |
Definition at line 2736 of file pede.f90.
subroutine ploopb | ( | integer(mpi), intent(in) | lunp | ) |
Print iteration line.
[in] | lunp | unit number |
Definition at line 2757 of file pede.f90.
subroutine ploopc | ( | integer(mpi), intent(in) | lunp | ) |
Print sub-iteration line.
[in] | lunp | unit number |
Definition at line 2813 of file pede.f90.
subroutine ploopd | ( | integer(mpi), intent(in) | lunp | ) |
Print solution line.
[in] | lunp | unit number |
Definition at line 2860 of file pede.f90.
subroutine prpcon |
Prepare constraints.
Count, sort constraints and split into disjoint blocks.
Definition at line 1243 of file pede.f90.
subroutine prtglo |
Print final log file.
For each global parameter:
Definition at line 3982 of file pede.f90.
subroutine prtstat |
Print input statistic.
For each global parameter:
Definition at line 4162 of file pede.f90.
subroutine sechms | ( | real(mps), intent(in) | deltat, |
integer(mpi), intent(out) | nhour, | ||
integer(mpi), intent(out) | minut, | ||
real(mps), intent(out) | secnd | ||
) |
Time conversion.
Convert from seconds to hours, minues, seconds
[in] | deltat | time in seconds |
[out] | nhour | hours |
[out] | minut | minutes |
[out] | secnd | seconds |
Definition at line 4617 of file pede.f90.
subroutine solglo | ( | integer(mpi), intent(in) | ivgbi | ) |
Error for single global parameter from MINRES.
Calculate single row 'x_i' from inverse matrix by solving A*x_i=b with b=0 except b_i=1.
[in] | ivgbi | index of variable parameter |
Definition at line 978 of file pede.f90.
subroutine solgloqlp | ( | integer(mpi), intent(in) | ivgbi | ) |
Error for single global parameter from MINRES-QLP.
Calculate single row 'x_i' from inverse matrix by solving A*x_i=b with b=0 except b_i=1.
[in] | ivgbi | index of variable parameter |
Definition at line 1074 of file pede.f90.
subroutine upone |
Update, redefine hash indices.
Definition at line 4725 of file pede.f90.
subroutine vmprep | ( | integer(mpl), dimension(2), intent(in) | msize | ) |
Prepare storage for vectors and matrices.
[in] | msize | number of words for storage of global matrix (double, single prec.) |
Definition at line 6034 of file pede.f90.
subroutine xloopn |
Standard solution algorithm.
Iterative solution. In current iteration calculate:
ICALCM = +1 Matrix, gradient, Function value & solution ICALCM = 0 gradient, Function value ICALCM = -1 solution ICALCM = -2 end
Solution is obtained by selected method and improved by line search.
Definition at line 6632 of file pede.f90.
subroutine zdiags |
Covariance matrix for diagonalization (,correction of eigenvectors).
Definition at line 6348 of file pede.f90.