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'
10 external func,gradient,fdum
14 include 'COMMON.SETUP'
15 dimension muster(mpi_status_size)
18 include 'COMMON.FFIELD'
19 include 'COMMON.SBRIDGE'
20 include 'COMMON.DISTFIT'
21 include 'COMMON.CHAIN'
22 dimension var(maxvar),erg(mxch*(mxch+1)/2+1)
23 dimension var2(maxvar)
24 integer iffr(maxres),ihpbt(maxdim),jhpbt(maxdim)
25 double precision d(maxvar),v(1:lv+1),garbage(maxvar)
26 double precision energia(0:n_ene),time0s,time1s
27 dimension indx(9),info(12)
29 dimension idum(1),rdum(1)
30 dimension icont(2,maxcont)
31 logical check_var,fail
33 common /przechowalnia/ v
34 data rad /1.745329252d-2/
36 ! print *,'Processor',me,' calling MINIM_JLEE maxfun',maxfun,
37 ! & ' maxmin',maxmin,' tolf',tolf,' rtolf',rtolf
41 c print *, 'MINIM_JLEE: ',me,' is waiting'
42 call mpi_recv(info,12,mpi_integer,king,idint,CG_COMM,
45 write (iout,'(a12,f10.4,a4)')'Waiting for ',time1s-time0s,' sec'
48 c print *, 'MINIM_JLEE: ',me,' received: ',n
50 crc if (ierr.ne.0) go to 100
53 write (iout,*) 'Finishing minim_jlee - signal',n,' from master'
60 call mpi_recv(var,nvar,mpi_double_precision,
61 * king,idreal,CG_COMM,muster,ierr)
62 call mpi_recv(iffr,nres,mpi_integer,
63 * king,idint,CG_COMM,muster,ierr)
64 call mpi_recv(var2,nvar,mpi_double_precision,
65 * king,idreal,CG_COMM,muster,ierr)
67 c receive initial values of variables
68 call mpi_recv(var,nvar,mpi_double_precision,
69 * king,idreal,CG_COMM,muster,ierr)
70 crc if (ierr.ne.0) go to 100
73 if(vdisulf.and.info(2).ne.-1) then
75 call mpi_recv(ihpbt,info(4),mpi_integer,
76 * king,idint,CG_COMM,muster,ierr)
77 call mpi_recv(jhpbt,info(4),mpi_integer,
78 * king,idint,CG_COMM,muster,ierr)
88 call contact_cp(var,var2,iffr,nfun,n)
91 if(vdisulf.and.info(2).ne.-1) then
94 cd write(iout,*) 'SS=',info(4),'N=',info(1),'IT=',info(2)
95 call var_to_geom(nvar,var)
98 if (dist(ihpbt(i),jhpbt(i)).lt.7.0) then
102 cd write(iout,*) 'SS mv=',info(3),
103 cd & ihpb(nss)-nres,jhpb(nss)-nres,
104 cd & dist(ihpb(nss),jhpb(nss))
108 cd write(iout,*) 'rm SS mv=',info(3),
109 cd & ihpbt(i)-nres,jhpbt(i)-nres,dist(ihpbt(i),jhpbt(i))
119 if (info(3).eq.14) then
120 write(iout,*) 'calling local_move',info(7),info(8)
121 call local_move_init(.false.)
122 call var_to_geom(nvar,var)
123 call local_move(info(7),info(8),20d0,50d0)
124 call geom_to_var(nvar,var)
128 if (info(3).eq.16) then
129 write(iout,*) 'calling beta_slide',info(7),info(8),
130 & info(10), info(11), info(12)
131 call var_to_geom(nvar,var)
132 call beta_slide(info(7),info(8),info(10),info(11),info(12)
134 call geom_to_var(nvar,var)
138 if (info(3).eq.17) then
139 write(iout,*) 'calling beta_zip',info(7),info(8)
140 call var_to_geom(nvar,var)
141 call beta_zip(info(7),info(8),nfun,n)
142 call geom_to_var(nvar,var)
150 call var_to_geom(nvar,var)
152 call etotal(energia(0))
154 if (energia(1).eq.1.0d20) then
156 write (iout,'(a,1pe14.5)')'#OVERLAP evdw=1d20',energia(1)
157 call overlap_sc(fail)
159 call geom_to_var(nvar,var)
160 call etotal(energia(0))
162 write (iout,'(a,1pe14.5)')'#OVERLAP evdw after',energia(1)
172 call var_to_geom(nvar,var)
173 call sc_move(2,nres-1,1,10d0,nft_sc,etot)
174 call geom_to_var(nvar,var)
175 cd write(iout,*) 'sc_move',nft_sc,etot
178 if (check_var(var,info)) then
187 ! write (iout,*) 'MINIM_JLEE: Processor',me,' nvar',nvar
188 ! write (iout,'(8f10.4)') (var(i),i=1,nvar)
189 ! write (*,*) 'MINIM_JLEE: Processor',me,' received nvar',nvar
190 ! write (*,'(8f10.4)') (var(i),i=1,nvar)
196 call deflt(2,iv,liv,lv,v)
197 * 12 means fresh start, dont call deflt
199 * max num of fun calls
200 if (maxfun.eq.0) maxfun=500
202 * max num of iterations
203 if (maxmin.eq.0) maxmin=1000
207 * selects output unit
210 * 1 means to print out result
213 * 1 means to print out summary stats
215 * 1 means to print initial x and d
218 c if(me.eq.3.and.n.eq.255) then
219 c print *,' CHUJ: stoi'
226 * min val for v(radfac) default is 0.1
228 * max val for v(radfac) default is 4.0
231 * check false conv if (act fnctn decrease) .lt. v(26)*(exp decrease)
232 * the sumsl default is 0.1
234 * false conv if (act fnctn decrease) .lt. v(34)
235 * the sumsl default is 100*machep
237 * absolute convergence
238 if (tolf.eq.0.0D0) tolf=1.0D-4
240 * relative convergence
241 if (rtolf.eq.0.0D0) rtolf=1.0D-4
243 * controls initial step size
245 * large vals of d correspond to small components of step
253 ! write (iout,*) 'Processor',me,' nvar',nvar
254 ! write (iout,*) 'Variables BEFORE minimization:'
255 ! write (iout,'(8f10.4)') (rad2deg*var(i),i=1,nvar)
257 c print *, 'MINIM_JLEE: ',me,' before SUMSL '
259 call func(nvar,var,nf,eee,idum,rdum,fdum)
261 if(eee.ge.1.0d20) then
262 c print *,'MINIM_JLEE: ',me,' CHUJ NASTAPIL'
263 c print *,' energy before SUMSL =',eee
264 c print *,' aborting local minimization'
270 ct time0s=MPI_WTIME()
271 call sumsl(nvar,d,var,func,gradient,iv,liv,lv,v,idum,rdum,fdum)
272 ct write(iout,*) 'sumsl time=',MPI_WTIME()-time0s,iv(7),v(10)
273 c print *, 'MINIM_JLEE: ',me,' after SUMSL '
275 c find which conformation was returned from sumsl
277 ! print *,'Processor',me,' iv(17)',iv(17),' iv(18)',iv(18),' nf',nf,
278 ! & ' retcode',iv(1),' energy',v(10),' tolf',v(31),' rtolf',v(32)
279 c if (iv(1).ne.4 .or. nf.le.1) then
280 c write (*,*) 'Processor',me,' something bad in SUMSL',iv(1),nf
281 c write (*,*) 'Initial Variables'
282 c write (*,'(8f10.4)') (rad2deg*garbage(i),i=1,nvar)
283 c write (*,*) 'Variables'
284 c write (*,'(8f10.4)') (rad2deg*var(i),i=1,nvar)
285 c write (*,*) 'Vector d'
286 c write (*,'(8f10.4)') (d(i),i=1,nvar)
287 c write (iout,*) 'Processor',me,' something bad in SUMSL',
289 c write (iout,*) 'Initial Variables'
290 c write (iout,'(8f10.4)') (rad2deg*garbage(i),i=1,nvar)
291 c write (iout,*) 'Variables'
292 c write (iout,'(8f10.4)') (rad2deg*var(i),i=1,nvar)
293 c write (iout,*) 'Vector d'
294 c write (iout,'(8f10.4)') (d(i),i=1,nvar)
296 c if (nf.lt.iv(6)-1) then
297 c recalculate intra- and interchain energies
298 c call func(nvar,var,nf,v(10),iv,v,fdum)
299 c else if (nf.eq.iv(6)-1) then
300 c regenerate conformation
301 c call var_to_geom(nvar,var)
304 c change origin and axes to standard ECEPP format
305 c call var_to_geom(nvar,var)
306 ! write (iout,*) 'MINIM_JLEE after minim: Processor',me,' nvar',nvar
307 ! write (iout,'(8f10.4)') (var(i),i=1,nvar)
308 ! write (iout,*) 'Energy:',v(10)
310 c print *, 'MINIM_JLEE: ',me,' minimized: ',n
313 c return code: 6-gradient 9-number of ftn evaluation, etc
315 c total # of ftn evaluations (for iwf=0, it includes all minimizations).
323 call mpi_send(indx,9,mpi_integer,king,idint,CG_COMM,
327 c calculate contact order
329 call contact(.false.,ncont,icont,co)
330 erg(1)=v(10)-1.0d2*co
335 call mpi_send(erg,j,mpi_double_precision,king,idreal,
338 call mpi_send(co,j,mpi_double_precision,king,idreal,
341 c send back values of variables
342 call mpi_send(var,nvar,mpi_double_precision,
343 * king,idreal,CG_COMM,ierr)
344 ! print * , 'MINIM_JLEE: Processor',me,' send erg and var '
346 if(vdisulf.and.info(2).ne.-1.and.nss.ne.0) then
349 cd call etotal(energia(0))
351 cd call enerprint(energia(0))
352 call mpi_send(ihpb,nss,mpi_integer,
353 * king,idint,CG_COMM,ierr)
354 call mpi_send(jhpb,nss,mpi_integer,
355 * king,idint,CG_COMM,ierr)
359 100 print *, ' error in receiving message from emperor', me
360 call mpi_abort(mpi_comm_world,ierror,ierrcode)
362 200 print *, ' error in sending message to emperor'
363 call mpi_abort(mpi_comm_world,ierror,ierrcode)
365 300 print *, ' error in communicating with emperor'
366 call mpi_abort(mpi_comm_world,ierror,ierrcode)
368 956 format (' initial energy could not be calculated',41x)
370 965 format (' convergence code ',i2,' # of function calls ',
371 * i4,' # of gradient calls ',i4,10x)
372 975 format (' energy ',1p,e12.4,' scaled gradient ',e11.3,32x)
375 logical function check_var(var,info)
376 implicit real*8 (a-h,o-z)
379 include 'COMMON.IOUNITS'
381 include 'COMMON.SETUP'
382 dimension var(maxvar)
386 do i=nphi+ntheta+1,nphi+ntheta+nside
387 ! Check the side chain "valence" angles alpha
388 if (var(i).lt.1.0d-7) then
389 write (iout,*) 'CHUJ NASTAPIL ABSOLUTNY!!!!!!!!!!!!'
390 write (iout,*) 'Processor',me,'received bad variables!!!!'
391 write (iout,*) 'Variables'
392 write (iout,'(8f10.4)') (rad2deg*var(j),j=1,nvar)
393 write (iout,*) 'Continuing calculations at this point',
394 & ' could destroy the results obtained so far... ABORTING!!!!!!'
395 write (iout,'(a19,i5,f10.4,a4,2i4,a3,i3)')
396 & 'valence angle alpha',i-nphi-ntheta,var(i),
397 & 'n it',info(1),info(2),'mv ',info(3)
398 write (*,*) 'CHUJ NASTAPIL ABSOLUTNY!!!!!!!!!!!!'
399 write (*,*) 'Processor',me,'received bad variables!!!!'
400 write (*,*) 'Variables'
401 write (*,'(8f10.4)') (rad2deg*var(j),j=1,nvar)
402 write (*,*) 'Continuing calculations at this point',
403 & ' could destroy the results obtained so far... ABORTING!!!!!!'
404 write (*,'(a19,i5,f10.4,a4,2i4,a3,i3)')
405 & 'valence angle alpha',i-nphi-ntheta,var(i),
406 & 'n it',info(1),info(2),'mv ',info(3)
411 ! Check the backbone "valence" angles theta
412 do i=nphi+1,nphi+ntheta
413 if (var(i).lt.1.0d-7) then
414 write (iout,*) 'CHUJ NASTAPIL ABSOLUTNY!!!!!!!!!!!!'
415 write (iout,*) 'Processor',me,'received bad variables!!!!'
416 write (iout,*) 'Variables'
417 write (iout,'(8f10.4)') (rad2deg*var(j),j=1,nvar)
418 write (iout,*) 'Continuing calculations at this point',
419 & ' could destroy the results obtained so far... ABORTING!!!!!!'
420 write (iout,'(a19,i5,f10.4,a4,2i4,a3,i3)')
421 & 'valence angle theta',i-nphi,var(i),
422 & 'n it',info(1),info(2),'mv ',info(3)
423 write (*,*) 'CHUJ NASTAPIL ABSOLUTNY!!!!!!!!!!!!'
424 write (*,*) 'Processor',me,'received bad variables!!!!'
425 write (*,*) 'Variables'
426 write (*,'(8f10.4)') (rad2deg*var(j),j=1,nvar)
427 write (*,*) 'Continuing calculations at this point',
428 & ' could destroy the results obtained so far... ABORTING!!!!!!'
429 write (*,'(a19,i5,f10.4,a4,2i4,a3,i3)')
430 & 'valence angle theta',i-nphi,var(i),
431 & 'n it',info(1),info(2),'mv ',info(3)