COSMOS v7.655  COSMOSv7655
(AirShowerMC)
mnderi.f
Go to the documentation of this file.
1 *
2 * $Id: mnderi.F,v 1.2 1996/03/15 18:02:43 james Exp $
3 *
4 * $Log: mnderi.F,v $
5 * Revision 1.2 1996/03/15 18:02:43 james
6 * Modified Files:
7 * mnderi.F eliminate possible division by zero
8 * mnexcm.F suppress print on STOP when print flag=-1
9 * set FVAL3 to flag if FCN already called with IFLAG=3
10 * mninit.F set version 96.03
11 * mnlims.F remove arguments, not needed
12 * mnmigr.F VLEN -> LENV in debug print statement
13 * mnparm.F move call to MNRSET to after NPAR redefined, to zero all
14 * mnpsdf.F eliminate possible division by zero
15 * mnscan.F suppress printout when print flag =-1
16 * mnset.F remove arguments in call to MNLIMS
17 * mnsimp.F fix CSTATU so status is PROGRESS only if new minimum
18 * mnvert.F eliminate possible division by zero
19 *
20 * Revision 1.1.1.1 1996/03/07 14:31:29 mclareni
21 * Minuit
22 *
23 *
24  SUBROUTINE mnderi(FCN,FUTIL)
25 *
26 * $Id: d506dp.inc,v 1.1.1.1 1996/03/07 14:31:32 mclareni Exp $
27 *
28 * $Log: d506dp.inc,v $
29 * Revision 1.1.1.1 1996/03/07 14:31:32 mclareni
30 * Minuit
31 *
32 *
33 *
34 *
35 * d506dp.inc
36 *
37 C ************ DOUBLE PRECISION VERSION *************
38  IMPLICIT DOUBLE PRECISION (a-h,o-z)
39 CC Calculates the first derivatives of FCN (GRD),
40 CC either by finite differences or by transforming the user-
41 CC supplied derivatives to internal coordinates,
42 CC according to whether ISW(3) is zero or one.
43 CC
44 *
45 * $Id: d506cm.inc,v 1.1.1.1 1996/03/07 14:31:32 mclareni Exp $
46 *
47 * $Log: d506cm.inc,v $
48 * Revision 1.1.1.1 1996/03/07 14:31:32 mclareni
49 * Minuit
50 *
51 *
52 *
53 *
54 * d506cm.inc
55 *
56  parameter(mne=100 , mni=50)
57  parameter(mnihl=mni*(mni+1)/2)
58  CHARACTER*10 CPNAM
59  COMMON
60  1/mn7nam/ cpnam(mne)
61  2/mn7ext/ u(mne) ,alim(mne) ,blim(mne)
62  3/mn7err/ erp(mni) ,ern(mni) ,werr(mni) ,globcc(mni)
63  4/mn7inx/ nvarl(mne) ,niofex(mne),nexofi(mni)
64  5/mn7int/ x(mni) ,xt(mni) ,dirin(mni)
65  6/mn7fx2/ xs(mni) ,xts(mni) ,dirins(mni)
66  7/mn7der/ grd(mni) ,g2(mni) ,gstep(mni) ,gin(mne) ,dgrd(mni)
67  8/mn7fx3/ grds(mni) ,g2s(mni) ,gsteps(mni)
68  9/mn7fx1/ ipfix(mni) ,npfix
69  a/mn7var/ vhmat(mnihl)
70  b/mn7vat/ vthmat(mnihl)
71  c/mn7sim/ p(mni,mni+1),pstar(mni),pstst(mni) ,pbar(mni),prho(mni)
72 C
73  parameter(maxdbg=10, maxstk=10, maxcwd=20, maxp=30, maxcpt=101)
74  parameter(zero=0.0, one=1.0, half=0.5)
75  COMMON
76  d/mn7npr/ maxint ,npar ,maxext ,nu
77  e/mn7iou/ isysrd ,isyswr ,isyssa ,npagwd ,npagln ,newpag
78  e/mn7io2/ istkrd(maxstk) ,nstkrd ,istkwr(maxstk) ,nstkwr
79  f/mn7tit/ cfrom ,cstatu ,ctitl ,cword ,cundef ,cvrsn ,covmes
80  g/mn7flg/ isw(7) ,idbg(0:maxdbg) ,nblock ,icomnd
81  h/mn7min/ amin ,up ,edm ,fval3 ,epsi ,apsi ,dcovar
82  i/mn7cnv/ nfcn ,nfcnmx ,nfcnlc ,nfcnfr ,itaur,istrat,nwrmes(2)
83  j/mn7arg/ word7(maxp)
84  k/mn7log/ lwarn ,lrepor ,limset ,lnolim ,lnewmn ,lphead
85  l/mn7cns/ epsmac ,epsma2 ,vlimlo ,vlimhi ,undefi ,bigedm,updflt
86  m/mn7rpt/ xpt(maxcpt) ,ypt(maxcpt)
87  n/mn7cpt/ chpt(maxcpt)
88  o/mn7xcr/ xmidcr ,ymidcr ,xdircr ,ydircr ,ke1cr ,ke2cr
89  CHARACTER CTITL*50, CWORD*(maxcwd), CUNDEF*10, CFROM*8,
90  + cvrsn*6, covmes(0:3)*22, cstatu*10, chpt*1
91  LOGICAL LWARN, LREPOR, LIMSET, LNOLIM, LNEWMN, LPHEAD
92  EXTERNAL fcn,futil
93  LOGICAL LDEBUG
94  CHARACTER CBF1*22
95  nparx = npar
96  ldebug = (idbg(2) .GE. 1)
97  IF (amin .EQ. undefi) CALL mnamin(fcn,futil)
98  IF (isw(3) .EQ. 1) GO TO 100
99  IF (ldebug) THEN
100 C make sure starting at the right place
101  CALL mninex(x)
102  nparx = npar
103  CALL fcn(nparx,gin,fs1,u,4,futil)
104  nfcn = nfcn + 1
105  IF (fs1 .NE. amin) THEN
106  df = amin - fs1
107  WRITE (cbf1(1:12),'(G12.3)') df
108  CALL mnwarn('D','MNDERI',
109  + 'function value differs from AMIN by '//cbf1(1:12) )
110  amin = fs1
111  ENDIF
112  WRITE
113  + (isyswr,'(/'' FIRST DERIVATIVE DEBUG PRINTOUT. MNDERI''/
114  + '' PAR DERIV STEP MINSTEP OPTSTEP '',
115  + '' D1-D2 2ND DRV'')')
116  ENDIF
117  dfmin = 8. * epsma2*(abs(amin)+up)
118  vrysml = 8.* epsmac**2
119  IF (istrat .LE. 0) THEN
120  ncyc = 2
121  tlrstp = 0.5
122  tlrgrd = 0.1
123  ELSE IF (istrat .EQ. 1) THEN
124  ncyc = 3
125  tlrstp = 0.3
126  tlrgrd = 0.05
127  ELSE
128  ncyc = 5
129  tlrstp = 0.1
130  tlrgrd = 0.02
131  ENDIF
132 C loop over variable parameters
133  DO 60 i=1,npar
134  epspri = epsma2 + abs(grd(i)*epsma2)
135 C two-point derivatives always assumed necessary
136 C maximum number of cycles over step size depends on strategy
137  xtf = x(i)
138  stepb4 = 0.
139 C loop as little as possible here!
140  DO 45 icyc= 1, ncyc
141 C ........ theoretically best step
142  optstp = sqrt(dfmin/(abs(g2(i))+epspri))
143 C step cannot decrease by more than a factor of ten
144  step = max(optstp, abs(0.1*gstep(i)))
145 C but if parameter has limits, max step size = 0.5
146  IF (gstep(i).LT.zero .AND. step.GT.0.5) step=0.5
147 C and not more than ten times the previous step
148  stpmax = 10.*abs(gstep(i))
149  IF (step .GT. stpmax) step = stpmax
150 C minimum step size allowed by machine precision
151  stpmin = max(vrysml, 8.*abs(epsma2*x(i)))
152  IF (step .LT. stpmin) step = stpmin
153 C end of iterations if step change less than factor 2
154  IF (abs((step-stepb4)/step) .LT. tlrstp) GO TO 50
155 C take step positive
156  gstep(i) = sign(step, gstep(i))
157  stepb4 = step
158  x(i) = xtf + step
159  CALL mninex(x)
160  CALL fcn(nparx,gin,fs1,u,4,futil)
161  nfcn=nfcn+1
162 C take step negative
163  x(i) = xtf - step
164  CALL mninex(x)
165  CALL fcn(nparx,gin,fs2,u,4,futil)
166  nfcn=nfcn+1
167  grbfor = grd(i)
168  grd(i) = (fs1-fs2)/(2.0*step)
169  g2(i) = (fs1+fs2-2.0*amin)/(step**2)
170  x(i) = xtf
171  IF (ldebug) THEN
172  d1d2 = (fs1+fs2-2.0*amin)/step
173  WRITE (isyswr,41) i,grd(i),step,stpmin,optstp,d1d2,g2(i)
174  41 FORMAT (i4,2g11.3,5g10.2)
175  ENDIF
176 C see if another iteration is necessary
177  IF (abs(grbfor-grd(i))/(abs(grd(i))+dfmin/step) .LT. tlrgrd)
178  + GO TO 50
179  45 CONTINUE
180 C end of ICYC loop. too many iterations
181  IF (ncyc .EQ. 1) GO TO 50
182  WRITE (cbf1,'(2E11.3)') grd(i),grbfor
183  CALL mnwarn('D','MNDERI',
184  + 'First derivative not converged. '//cbf1)
185  50 CONTINUE
186 C
187  60 CONTINUE
188  CALL mninex(x)
189  RETURN
190 C . derivatives calc by fcn
191  100 DO 150 iint= 1, npar
192  iext = nexofi(iint)
193  IF (nvarl(iext) .GT. 1) GO TO 120
194  grd(iint) = gin(iext)
195  GO TO 150
196  120 dd = (blim(iext)-alim(iext))*0.5 *cos(x(iint))
197  grd(iint) = gin(iext)*dd
198  150 CONTINUE
199  200 RETURN
200  END
integer npitbl real *nx parameter(n=101, npitbl=46, nx=n-1) real *8 uconst
nodes z
block data include Zlatfit h c fitting region data data data data data d0 data data d0 data data h g *is for param c g data up(2, 1)/7.0d0/
dE dx *! Nuc Int sampling table e
Definition: cblkMuInt.h:130
nodes i
! for length to thickness conversion or v v ! integer maxnodes real Hinf ! This is used when making table for dim simulation ! The slant length for vertical height to km is ! divided by LenStep m steps ! It can cover the slant length of about km for cos
Definition: Zatmos.h:8
! constants thru Cosmos real ! if multiplied to deg radian Torad ! light velocity m sec ! infinty ! kg m2 *Togpcm2 g cm2 ! g cm2 *Tokgpm2 kg m2 ! cm *Tom m ! m *Tocm cm ! g cm3 *Tokgpm3 kg m3 ! kg m3 *Togpcm3 g cm3 ! sec *Tonsec nsec ! Tesla m ! Avogadro *A2deninv ! mfp *n * xs
Definition: Zglobalc.h:18
subroutine mnamin(FCN, FUTIL)
Definition: mnamin.f:10
********************block data cblkHeavy ********************integer j data *HeavyG2symbol p
Definition: cblkHeavy.h:7
********************block data cblkHeavy ********************integer j data *HeavyG2symbol *data *HeavyG2code kiron data j
Definition: cblkHeavy.h:36
struct ob o[NpMax]
Definition: Zprivate.h:34
subroutine mninex(PINT)
Definition: mninex.f:10
dE dx *! Nuc Int sampling table d
Definition: cblkMuInt.h:130
nodes a
dE dx *! Nuc Int sampling table b
Definition: cblkMuInt.h:130
block data include Zlatfit h c fitting region data data data data data d0 data data d0 data data m
Definition: ZlatfitBD.h:35
dE dx *! Nuc Int sampling table h
Definition: cblkMuInt.h:130
dE dx *! Nuc Int sampling table g
Definition: cblkMuInt.h:130
!onst int maxp
Definition: Zprivate.h:3
subroutine mnderi(FCN, FUTIL)
Definition: mnderi.f:25
subroutine mnwarn(COPT, CORG, CMES)
Definition: mnwarn.f:10
integer n
Definition: Zcinippxc.h:1
integer, parameter half
Definition: csoftenPiK.f:108
! structure defining a particle at production ! Basic idea of what is to be contained in ! the particle structue is that dynamical ones should be included those derivable from the particle code ! is not included ******************************************************type fmom momentum sequence union map real e endmap map real * x
Definition: Zptcl.h:21
dE dx *! Nuc Int sampling table f
Definition: cblkMuInt.h:130
dE dx *! Nuc Int sampling table c
Definition: cblkMuInt.h:130