2 c controls minimization and sorting routines
3 implicit real*8 (a-h,o-z)
5 parameter (liv=60,lv=(77+maxvar*(maxvar+17)/2))
7 include 'COMMON.IOUNITS'
9 include 'COMMON.CONTROL'
11 external func,gradient,fdum
13 include 'COMMON.SETUP'
15 include 'COMMON.FFIELD'
16 include 'COMMON.SBRIDGE'
17 include 'COMMON.DISTFIT'
18 include 'COMMON.CHAIN'
19 dimension muster(mpi_status_size)
20 dimension var(maxvar),erg(mxch*(mxch+1)/2+1)
21 dimension var2(maxvar)
22 integer iffr(maxres),ihpbt(maxdim),jhpbt(maxdim)
23 double precision d(maxvar),v(1:lv+1),garbage(maxvar)
24 double precision energia(0:n_ene),time0s,time1s
25 dimension indx(9),info(12)
27 dimension idum(1),rdum(1)
28 dimension icont(2,maxcont)
29 logical check_var,fail
31 common /przechowalnia/ v
32 data rad /1.745329252d-2/
34 ! print *,'Processor',me,' calling MINIM_JLEE maxfun',maxfun,
35 ! & ' maxmin',maxmin,' tolf',tolf,' rtolf',rtolf
39 c print *, 'MINIM_JLEE: ',me,' is waiting'
40 call mpi_recv(info,12,mpi_integer,king,idint,CG_COMM,
43 write (iout,'(a12,f10.4,a4)')'Waiting for ',time1s-time0s,' sec'
45 if (info(1).eq.0.and.info(2).eq.-2) then
46 cd write (iout,*) 'Parallel tmscore for refresh bank'
48 call refresh_bank_worker_tmscore(var)
52 c print *, 'MINIM_JLEE: ',me,' received: ',n
54 crc if (ierr.ne.0) go to 100
57 write (iout,*) 'Finishing minim_jlee - signal',n,' from master'
64 call mpi_recv(var,nvar,mpi_double_precision,
65 * king,idreal,CG_COMM,muster,ierr)
66 call mpi_recv(iffr,nres,mpi_integer,
67 * king,idint,CG_COMM,muster,ierr)
68 call mpi_recv(var2,nvar,mpi_double_precision,
69 * king,idreal,CG_COMM,muster,ierr)
71 c receive initial values of variables
72 call mpi_recv(var,nvar,mpi_double_precision,
73 * king,idreal,CG_COMM,muster,ierr)
74 crc if (ierr.ne.0) go to 100
77 if(vdisulf.and.info(2).ne.-1) then
79 call mpi_recv(ihpbt,info(4),mpi_integer,
80 * king,idint,CG_COMM,muster,ierr)
81 call mpi_recv(jhpbt,info(4),mpi_integer,
82 * king,idint,CG_COMM,muster,ierr)
92 call contact_cp(var,var2,iffr,nfun,n)
95 if(vdisulf.and.info(2).ne.-1) then
98 cd write(iout,*) 'SS=',info(4),'N=',info(1),'IT=',info(2)
99 call var_to_geom(nvar,var)
102 if (dist(ihpbt(i),jhpbt(i)).lt.7.0) then
106 cd write(iout,*) 'SS mv=',info(3),
107 cd & ihpb(nss)-nres,jhpb(nss)-nres,
108 cd & dist(ihpb(nss),jhpb(nss))
112 cd write(iout,*) 'rm SS mv=',info(3),
113 cd & ihpbt(i)-nres,jhpbt(i)-nres,dist(ihpbt(i),jhpbt(i))
123 if (info(3).eq.14) then
124 write(iout,*) 'calling local_move',info(7),info(8)
125 call local_move_init(.false.)
126 call var_to_geom(nvar,var)
127 call local_move(info(7),info(8),20d0,50d0)
128 call geom_to_var(nvar,var)
132 if (info(3).eq.16) then
133 write(iout,*) 'calling beta_slide',info(7),info(8),
134 & info(10), info(11), info(12)
135 call var_to_geom(nvar,var)
136 call beta_slide(info(7),info(8),info(10),info(11),info(12)
138 call geom_to_var(nvar,var)
142 if (info(3).eq.17) then
143 write(iout,*) 'calling beta_zip',info(7),info(8)
144 call var_to_geom(nvar,var)
145 call beta_zip(info(7),info(8),nfun,n)
146 call geom_to_var(nvar,var)
154 call var_to_geom(nvar,var)
156 call etotal(energia(0))
158 if (energia(1).eq.1.0d20) then
160 write (iout,'(a,1pe14.5)')'#OVERLAP evdw=1d20',energia(1)
161 call overlap_sc(fail)
163 call geom_to_var(nvar,var)
164 call etotal(energia(0))
166 write (iout,'(a,1pe14.5)')'#OVERLAP evdw after',energia(1)
176 call var_to_geom(nvar,var)
177 call sc_move(2,nres-1,1,10d0,nft_sc,etot)
178 call geom_to_var(nvar,var)
179 cd write(iout,*) 'sc_move',nft_sc,etot
182 if (check_var(var,info)) then
191 ! write (iout,*) 'MINIM_JLEE: Processor',me,' nvar',nvar
192 ! write (iout,'(8f10.4)') (var(i),i=1,nvar)
193 ! write (*,*) 'MINIM_JLEE: Processor',me,' received nvar',nvar
194 ! write (*,'(8f10.4)') (var(i),i=1,nvar)
200 call deflt(2,iv,liv,lv,v)
201 * 12 means fresh start, dont call deflt
203 * max num of fun calls
204 if (maxfun.eq.0) maxfun=500
206 * max num of iterations
207 if (maxmin.eq.0) maxmin=1000
211 * selects output unit
214 * 1 means to print out result
217 * 1 means to print out summary stats
219 * 1 means to print initial x and d
222 c if(me.eq.3.and.n.eq.255) then
223 c print *,' CHUJ: stoi'
230 * min val for v(radfac) default is 0.1
232 * max val for v(radfac) default is 4.0
235 * check false conv if (act fnctn decrease) .lt. v(26)*(exp decrease)
236 * the sumsl default is 0.1
238 * false conv if (act fnctn decrease) .lt. v(34)
239 * the sumsl default is 100*machep
241 * absolute convergence
242 if (tolf.eq.0.0D0) tolf=1.0D-4
244 * relative convergence
245 if (rtolf.eq.0.0D0) rtolf=1.0D-4
247 * controls initial step size
249 * large vals of d correspond to small components of step
257 ! write (iout,*) 'Processor',me,' nvar',nvar
258 ! write (iout,*) 'Variables BEFORE minimization:'
259 ! write (iout,'(8f10.4)') (rad2deg*var(i),i=1,nvar)
261 c print *, 'MINIM_JLEE: ',me,' before SUMSL '
263 call func(nvar,var,nf,eee,idum,rdum,fdum)
265 if(eee.ge.1.0d20) then
266 c print *,'MINIM_JLEE: ',me,' CHUJ NASTAPIL'
267 c print *,' energy before SUMSL =',eee
268 c print *,' aborting local minimization'
274 ct time0s=MPI_WTIME()
275 call sumsl(nvar,d,var,func,gradient,iv,liv,lv,v,idum,rdum,fdum)
276 ct write(iout,*) 'sumsl time=',MPI_WTIME()-time0s,iv(7),v(10)
277 c print *, 'MINIM_JLEE: ',me,' after SUMSL '
279 c find which conformation was returned from sumsl
281 ! print *,'Processor',me,' iv(17)',iv(17),' iv(18)',iv(18),' nf',nf,
282 ! & ' retcode',iv(1),' energy',v(10),' tolf',v(31),' rtolf',v(32)
283 c if (iv(1).ne.4 .or. nf.le.1) then
284 c write (*,*) 'Processor',me,' something bad in SUMSL',iv(1),nf
285 c write (*,*) 'Initial Variables'
286 c write (*,'(8f10.4)') (rad2deg*garbage(i),i=1,nvar)
287 c write (*,*) 'Variables'
288 c write (*,'(8f10.4)') (rad2deg*var(i),i=1,nvar)
289 c write (*,*) 'Vector d'
290 c write (*,'(8f10.4)') (d(i),i=1,nvar)
291 c write (iout,*) 'Processor',me,' something bad in SUMSL',
293 c write (iout,*) 'Initial Variables'
294 c write (iout,'(8f10.4)') (rad2deg*garbage(i),i=1,nvar)
295 c write (iout,*) 'Variables'
296 c write (iout,'(8f10.4)') (rad2deg*var(i),i=1,nvar)
297 c write (iout,*) 'Vector d'
298 c write (iout,'(8f10.4)') (d(i),i=1,nvar)
300 c if (nf.lt.iv(6)-1) then
301 c recalculate intra- and interchain energies
302 c call func(nvar,var,nf,v(10),iv,v,fdum)
303 c else if (nf.eq.iv(6)-1) then
304 c regenerate conformation
305 c call var_to_geom(nvar,var)
308 c change origin and axes to standard ECEPP format
309 c call var_to_geom(nvar,var)
310 ! write (iout,*) 'MINIM_JLEE after minim: Processor',me,' nvar',nvar
311 ! write (iout,'(8f10.4)') (var(i),i=1,nvar)
312 ! write (iout,*) 'Energy:',v(10)
314 c print *, 'MINIM_JLEE: ',me,' minimized: ',n
317 c return code: 6-gradient 9-number of ftn evaluation, etc
319 c total # of ftn evaluations (for iwf=0, it includes all minimizations).
327 call mpi_send(indx,9,mpi_integer,king,idint,CG_COMM,
331 c calculate contact order
333 call contact(.false.,ncont,icont,co)
334 erg(1)=v(10)-1.0d2*co
339 call mpi_send(erg,j,mpi_double_precision,king,idreal,
342 call mpi_send(co,j,mpi_double_precision,king,idreal,
345 c send back values of variables
346 call mpi_send(var,nvar,mpi_double_precision,
347 * king,idreal,CG_COMM,ierr)
348 ! print * , 'MINIM_JLEE: Processor',me,' send erg and var '
350 if(vdisulf.and.info(2).ne.-1.and.nss.ne.0) then
353 cd call etotal(energia(0))
355 cd call enerprint(energia(0))
356 call mpi_send(ihpb,nss,mpi_integer,
357 * king,idint,CG_COMM,ierr)
358 call mpi_send(jhpb,nss,mpi_integer,
359 * king,idint,CG_COMM,ierr)
363 100 print *, ' error in receiving message from emperor', me
364 call mpi_abort(mpi_comm_world,ierror,ierrcode)
366 200 print *, ' error in sending message to emperor'
367 call mpi_abort(mpi_comm_world,ierror,ierrcode)
369 300 print *, ' error in communicating with emperor'
370 call mpi_abort(mpi_comm_world,ierror,ierrcode)
372 956 format (' initial energy could not be calculated',41x)
374 965 format (' convergence code ',i2,' # of function calls ',
375 * i4,' # of gradient calls ',i4,10x)
376 975 format (' energy ',1p,e12.4,' scaled gradient ',e11.3,32x)
379 logical function check_var(var,info)
380 implicit real*8 (a-h,o-z)
383 include 'COMMON.IOUNITS'
385 include 'COMMON.SETUP'
386 dimension var(maxvar)
390 do i=nphi+ntheta+1,nphi+ntheta+nside
391 ! Check the side chain "valence" angles alpha
392 if (var(i).lt.1.0d-7) then
393 write (iout,*) 'CHUJ NASTAPIL ABSOLUTNY!!!!!!!!!!!!'
394 write (iout,*) 'Processor',me,'received bad variables!!!!'
395 write (iout,*) 'Variables'
396 write (iout,'(8f10.4)') (rad2deg*var(j),j=1,nvar)
397 write (iout,*) 'Continuing calculations at this point',
398 & ' could destroy the results obtained so far... ABORTING!!!!!!'
399 write (iout,'(a19,i5,f10.4,a4,2i4,a3,i3)')
400 & 'valence angle alpha',i-nphi-ntheta,var(i),
401 & 'n it',info(1),info(2),'mv ',info(3)
402 write (*,*) 'CHUJ NASTAPIL ABSOLUTNY!!!!!!!!!!!!'
403 write (*,*) 'Processor',me,'received bad variables!!!!'
404 write (*,*) 'Variables'
405 write (*,'(8f10.4)') (rad2deg*var(j),j=1,nvar)
406 write (*,*) 'Continuing calculations at this point',
407 & ' could destroy the results obtained so far... ABORTING!!!!!!'
408 write (*,'(a19,i5,f10.4,a4,2i4,a3,i3)')
409 & 'valence angle alpha',i-nphi-ntheta,var(i),
410 & 'n it',info(1),info(2),'mv ',info(3)
415 ! Check the backbone "valence" angles theta
416 do i=nphi+1,nphi+ntheta
417 if (var(i).lt.1.0d-7) then
418 write (iout,*) 'CHUJ NASTAPIL ABSOLUTNY!!!!!!!!!!!!'
419 write (iout,*) 'Processor',me,'received bad variables!!!!'
420 write (iout,*) 'Variables'
421 write (iout,'(8f10.4)') (rad2deg*var(j),j=1,nvar)
422 write (iout,*) 'Continuing calculations at this point',
423 & ' could destroy the results obtained so far... ABORTING!!!!!!'
424 write (iout,'(a19,i5,f10.4,a4,2i4,a3,i3)')
425 & 'valence angle theta',i-nphi,var(i),
426 & 'n it',info(1),info(2),'mv ',info(3)
427 write (*,*) 'CHUJ NASTAPIL ABSOLUTNY!!!!!!!!!!!!'
428 write (*,*) 'Processor',me,'received bad variables!!!!'
429 write (*,*) 'Variables'
430 write (*,'(8f10.4)') (rad2deg*var(j),j=1,nvar)
431 write (*,*) 'Continuing calculations at this point',
432 & ' could destroy the results obtained so far... ABORTING!!!!!!'
433 write (*,'(a19,i5,f10.4,a4,2i4,a3,i3)')
434 & 'valence angle theta',i-nphi,var(i),
435 & 'n it',info(1),info(2),'mv ',info(3)