9 implicit real*8 (a-h,o-z)
12 parameter (liv=60,lv=(77+maxvar*(maxvar+17)/2))
15 include 'COMMON.IOUNITS'
16 include 'COMMON.MINIM'
19 double precision grdmin
23 double precision v(1:lv+1)
24 common /przechowalnia/ v
25 external func,gradient,fdum
30 include 'COMMON.SETUP'
32 include 'COMMON.CHAIN'
33 include 'COMMON.FFIELD'
34 dimension muster(mpi_status_size)
35 dimension var(maxvar),erg(mxch*(mxch+1)/2+1)
36 double precision d(maxvar),garbage(maxvar)
38 dimension idum(1),rdum(1)
39 double precision przes(3),obrot(3,3)
41 data rad /1.745329252d-2/
46 call mpi_recv(indx,6,mpi_integer,king,idint,CG_COMM,
48 if (indx(1).eq.0) return
49 c print *, 'worker ',me,' received order ',n,ichuj
50 call mpi_recv(var,nvar,mpi_double_precision,
51 * king,idreal,CG_COMM,muster,ierr)
52 call mpi_recv(ene0,1,mpi_double_precision,
53 * king,idreal,CG_COMM,muster,ierr)
54 c print *, 'worker ',me,' var read '
63 if (.not. allocated(scale)) allocate (scale(nvar))
65 c set scaling parameter for function and derivative values;
66 c use square root of median eigenvalue of typical Hessian
79 if(eee.gt.1.0d18) then
80 c print *,'MINIM_JLEE: ',me,' CHUJ NASTAPIL'
81 c print *,' energy before SUMSL =',eee
82 c print *,' aborting local minimization'
86 c write (iout,*) "Calling lbfgs"
87 call lbfgs (nvar,x,eee,grdmin,funcgrad,optsave)
91 call deflt(2,iv,liv,lv,v)
92 * 12 means fresh start, dont call deflt
94 * max num of fun calls
95 if (maxfun.eq.0) maxfun=500
97 * max num of iterations
98 if (maxmin.eq.0) maxmin=1000
102 * selects output unit
105 * 1 means to print out result
107 * 1 means to print out summary stats
109 * 1 means to print initial x and d
111 * min val for v(radfac) default is 0.1
113 * max val for v(radfac) default is 4.0
115 * check false conv if (act fnctn decrease) .lt. v(26)*(exp decrease)
116 * the sumsl default is 0.1
118 * false conv if (act fnctn decrease) .lt. v(34)
119 * the sumsl default is 100*machep
121 * absolute convergence
122 if (tolf.eq.0.0D0) tolf=1.0D-4
124 * relative convergence
125 if (rtolf.eq.0.0D0) rtolf=1.0D-4
127 * controls initial step size
129 * large vals of d correspond to small components of step
138 call func(nvar,var,nf,eee,idum,rdum,fdum)
139 if(eee.gt.1.0d18) then
140 c print *,'MINIM_JLEE: ',me,' CHUJ NASTAPIL'
141 c print *,' energy before SUMSL =',eee
142 c print *,' aborting local minimization'
149 call sumsl(nvar,d,var,func,gradient,iv,liv,lv,v,idum,rdum,fdum)
150 c find which conformation was returned from sumsl
154 c total # of ftn evaluations (for iwf=0, it includes all minimizations).
163 call mpi_send(indx,6,mpi_integer,king,idint,CG_COMM,
165 c print '(a5,i3,15f10.5)', 'ENEX0',indx(1),v(10)
166 call mpi_send(var,nvar,mpi_double_precision,
167 * king,idreal,CG_COMM,ierr)
168 call mpi_send(eee,1,mpi_double_precision,king,idreal,
170 call mpi_send(ene0,1,mpi_double_precision,king,idreal,