2 < subroutine etotal(energia,fact)
4 > subroutine etotal(energia)
6 < include 'DIMENSIONS.ZSCOPT'
12 < include 'COMMON.IOUNITS'
13 < double precision energia(0:max_ene),energia1(0:max_ene+1)
15 < include 'COMMON.INFO'
21 > double precision weights_(n_ene)
23 > include 'COMMON.SETUP'
24 > include 'COMMON.IOUNITS'
25 > double precision energia(0:n_ene)
26 > include 'COMMON.LOCAL'
28 < double precision fact(6)
29 < cd write(iout, '(a,i2)')'Calling etotal ipot=',ipot
30 < cd print *,'nnt=',nnt,' nct=',nct
33 > include 'COMMON.VAR'
35 > include 'COMMON.CONTROL'
36 > include 'COMMON.TIME1'
38 > c print*,"ETOTAL Processor",fg_rank," absolute rank",myrank,
39 > c & " nfgtasks",nfgtasks
40 > if (nfgtasks.gt.1) then
42 > C FG slaves call the following matching MPI_Bcast in ERGASTULUM
43 > if (fg_rank.eq.0) then
44 > call MPI_Bcast(0,1,MPI_INTEGER,king,FG_COMM,IERROR)
45 > c print *,"Processor",myrank," BROADCAST iorder"
46 > C FG master sets up the WEIGHTS_ array which will be broadcast to the
47 > C FG slaves as WEIGHTS array.
62 > weights_(15)=wstrain
67 > C FG Master broadcasts the WEIGHTS_ array
68 > call MPI_Bcast(weights_(1),n_ene,
69 > & MPI_DOUBLE_PRECISION,king,FG_COMM,IERROR)
71 > C FG slaves receive the WEIGHTS array
72 > call MPI_Bcast(weights(1),n_ene,
73 > & MPI_DOUBLE_PRECISION,king,FG_COMM,IERROR)
94 > time_Bcast=time_Bcast+MPI_Wtime()-time00
95 > time_Bcastw=time_Bcastw+MPI_Wtime()-time00
96 > c call chainbuild_cart
98 > c print *,'Processor',myrank,' calling etotal ipot=',ipot
99 > c print *,'Processor',myrank,' nnt=',nnt,' nct=',nct
101 > c if (modecalc.eq.12.or.modecalc.eq.14) then
102 > c call int_from_cart1(.false.)
110 < goto (101,102,103,104,105) ipot
112 > goto (101,102,103,104,105,106) ipot
114 < 101 call elj(evdw,evdw_t)
122 < 102 call eljk(evdw,evdw_t)
125 > 102 call eljk(evdw)
128 < 103 call ebp(evdw,evdw_t)
134 < 104 call egb(evdw,evdw_t)
140 < 105 call egbv(evdw,evdw_t)
142 > 105 call egbv(evdw)
144 > C Soft-sphere potential
145 > 106 call e_softsphere(evdw)
147 < 106 call eelec(ees,evdw1,eel_loc,eello_turn3,eello_turn4)
150 > c print *,"Processor",myrank," computed USCSC"
156 > time_vec=time_vec+MPI_Wtime()-time01
158 > c print *,"Processor",myrank," left VEC_AND_DERIV"
159 > if (ipot.lt.6) then
161 > if (welec.gt.0d0.or.wvdwpp.gt.0d0.or.wel_loc.gt.0d0.or.
162 > & wturn3.gt.0d0.or.wturn4.gt.0d0 .or. wcorr.gt.0.0d0
163 > & .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.d0
164 > & .or. wcorr6.gt.0.0d0 .or. wturn6.gt.0.0d0 ) then
166 > if (welec.gt.0d0.or.wel_loc.gt.0d0.or.
167 > & wturn3.gt.0d0.or.wturn4.gt.0d0 .or. wcorr.gt.0.0d0
168 > & .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.d0
169 > & .or. wcorr6.gt.0.0d0 .or. wturn6.gt.0.0d0 ) then
171 > call eelec(ees,evdw1,eel_loc,eello_turn3,eello_turn4)
180 > c write (iout,*) "Soft-spheer ELEC potential"
181 > call eelec_soft_sphere(ees,evdw1,eel_loc,eello_turn3,
184 > c print *,"Processor",myrank," computed UELEC"
186 < call escp(evdw2,evdw2_14)
188 > if (ipot.lt.6) then
189 > if(wscp.gt.0d0) then
190 > call escp(evdw2,evdw2_14)
196 > c write (iout,*) "Soft-sphere SCP potential"
197 > call escp_soft_sphere(evdw2,evdw2_14)
200 < c write (iout,*) "estr",estr
203 < cd print *,'Bend energy finished.'
205 > if (wang.gt.0d0) then
210 > c print *,"Processor",myrank," computed UB"
212 < cd print *,'SCLOC energy finished.'
214 > c print *,"Processor",myrank," computed USC"
216 < call etor(etors,edihcnstr,fact(1))
218 > if (wtor.gt.0) then
219 > call etor(etors,edihcnstr)
224 > c print *,"Processor",myrank," computed Utor"
226 < call etor_d(etors_d,fact(2))
228 > if (wtor_d.gt.0) then
229 > call etor_d(etors_d)
233 > c print *,"Processor",myrank," computed Utord"
235 < call eback_sc_corr(esccor)
237 > if (wsccor.gt.0.0d0) then
238 > call eback_sc_corr(esccor)
242 > c print *,"Processor",myrank," computed Usccorr"
244 < if (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0
245 < & .or. wturn6.gt.0.0d0) then
246 < c print *,"calling multibody_eello"
248 > if ((wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0
249 > & .or. wturn6.gt.0.0d0) .and. ipot.lt.6) then
251 < c write (*,*) 'n_corr=',n_corr,' n_corr1=',n_corr1
252 < c print *,ecorr,ecorr5,ecorr6,eturn6
254 > cd write(2,*)'multibody_eello n_corr=',n_corr,' n_corr1=',n_corr1,
255 > cd &" ecorr",ecorr," ecorr5",ecorr5," ecorr6",ecorr6," eturn6",eturn6
262 < if (wcorr4.eq.0.0d0 .and. wcorr.gt.0.0d0) then
264 > if ((wcorr4.eq.0.0d0 .and. wcorr.gt.0.0d0) .and. ipot.lt.6) then
266 > cd write (iout,*) "multibody_hb ecorr",ecorr
268 < c write (iout,*) "ft(6)",fact(6)," evdw",evdw," evdw_t",evdw_t
270 < etot=wsc*(evdw+fact(6)*evdw_t)+wscp*evdw2+welec*fact(1)*ees
272 < & +wang*ebe+wtor*fact(1)*etors+wscloc*escloc
273 < & +wstrain*ehpb+nss*ebr+wcorr*fact(3)*ecorr+wcorr5*fact(4)*ecorr5
274 < & +wcorr6*fact(5)*ecorr6+wturn4*fact(3)*eello_turn4
275 < & +wturn3*fact(2)*eello_turn3+wturn6*fact(5)*eturn6
276 < & +wel_loc*fact(2)*eel_loc+edihcnstr+wtor_d*fact(2)*etors_d
277 < & +wbond*estr+wsccor*fact(1)*esccor
279 < etot=wsc*(evdw+fact(6)*evdw_t)+wscp*evdw2
280 < & +welec*fact(1)*(ees+evdw1)
281 < & +wang*ebe+wtor*fact(1)*etors+wscloc*escloc
282 < & +wstrain*ehpb+nss*ebr+wcorr*fact(3)*ecorr+wcorr5*fact(4)*ecorr5
283 < & +wcorr6*fact(5)*ecorr6+wturn4*fact(3)*eello_turn4
284 < & +wturn3*fact(2)*eello_turn3+wturn6*fact(5)*eturn6
285 < & +wel_loc*fact(2)*eel_loc+edihcnstr+wtor_d*fact(2)*etors_d
286 < & +wbond*estr+wsccor*fact(1)*esccor
288 > c print *,"Processor",myrank," computed Ucorr"
290 > C If performing constraint dynamics, call the constraint energy
291 > C after the equilibration time
292 > if(usampl.and.totT.gt.eq_time) then
300 > time_enecalc=time_enecalc+MPI_Wtime()-time00
304 > c print *,"Processor",myrank," computed Uconstr"
312 < energia(17)=evdw2_14
314 > energia(18)=evdw2_14
322 < energia(20)=edihcnstr
325 > energia(19)=edihcnstr
327 > energia(20)=Uconst+Uconst_back
329 > c print *," Processor",myrank," calls SUM_ENERGY"
330 > call sum_energy(energia,.true.)
331 > c print *," Processor",myrank," left SUM_ENERGY"
333 > time_sumene=time_sumene+MPI_Wtime()-time00
337 > c-------------------------------------------------------------------------------
338 > subroutine sum_energy(energia,reduce)
339 > implicit real*8 (a-h,o-z)
340 > include 'DIMENSIONS'
344 > cMS$ATTRIBUTES C :: proc_proc
350 > include 'COMMON.SETUP'
351 > include 'COMMON.IOUNITS'
352 > double precision energia(0:n_ene),enebuff(0:n_ene+1)
353 > include 'COMMON.FFIELD'
354 > include 'COMMON.DERIV'
355 > include 'COMMON.INTERACT'
356 > include 'COMMON.SBRIDGE'
357 > include 'COMMON.CHAIN'
358 > include 'COMMON.VAR'
359 > include 'COMMON.CONTROL'
360 > include 'COMMON.TIME1'
363 > if (nfgtasks.gt.1 .and. reduce) then
365 > write (iout,*) "energies before REDUCE"
366 > call enerprint(energia)
370 > enebuff(i)=energia(i)
373 > call MPI_Barrier(FG_COMM,IERR)
374 > time_barrier_e=time_barrier_e+MPI_Wtime()-time00
376 > call MPI_Reduce(enebuff(0),energia(0),n_ene+1,
377 > & MPI_DOUBLE_PRECISION,MPI_SUM,king,FG_COMM,IERR)
379 > write (iout,*) "energies after REDUCE"
380 > call enerprint(energia)
383 > time_Reduce=time_Reduce+MPI_Wtime()-time00
385 > if (fg_rank.eq.0) then
389 > evdw2=energia(2)+energia(18)
390 > evdw2_14=energia(18)
405 > eello_turn3=energia(8)
406 > eello_turn4=energia(9)
411 > etors_d=energia(14)
413 > edihcnstr=energia(19)
418 > etot=wsc*evdw+wscp*evdw2+welec*ees+wvdwpp*evdw1
419 > & +wang*ebe+wtor*etors+wscloc*escloc
420 > & +wstrain*ehpb+nss*ebr+wcorr*ecorr+wcorr5*ecorr5
421 > & +wcorr6*ecorr6+wturn4*eello_turn4+wturn3*eello_turn3
422 > & +wturn6*eturn6+wel_loc*eel_loc+edihcnstr+wtor_d*etors_d
423 > & +wbond*estr+Uconst+wsccor*esccor
425 > etot=wsc*evdw+wscp*evdw2+welec*(ees+evdw1)
426 > & +wang*ebe+wtor*etors+wscloc*escloc
427 > & +wstrain*ehpb+nss*ebr+wcorr*ecorr+wcorr5*ecorr5
428 > & +wcorr6*ecorr6+wturn4*eello_turn4+wturn3*eello_turn3
429 > & +wturn6*eturn6+wel_loc*eel_loc+edihcnstr+wtor_d*etors_d
430 > & +wbond*estr+Uconst+wsccor*esccor
442 > c-------------------------------------------------------------------------------
443 > subroutine sum_gradient
444 > implicit real*8 (a-h,o-z)
445 > include 'DIMENSIONS'
449 > cMS$ATTRIBUTES C :: proc_proc
454 > double precision gradbufc(3,maxres),gradbufx(3,maxres),
455 > & glocbuf(4*maxres),gradbufc_sum(3,maxres)
457 > include 'COMMON.SETUP'
458 > include 'COMMON.IOUNITS'
459 > include 'COMMON.FFIELD'
460 > include 'COMMON.DERIV'
461 > include 'COMMON.INTERACT'
462 > include 'COMMON.SBRIDGE'
463 > include 'COMMON.CHAIN'
464 > include 'COMMON.VAR'
465 > include 'COMMON.CONTROL'
466 > include 'COMMON.TIME1'
467 > include 'COMMON.MAXGRAD'
472 > write (iout,*) "sum_gradient gvdwc, gvdwx"
474 > write (iout,'(i3,3f10.5,5x,3f10.5,5x,f10.5)')
475 > & i,(gvdwx(j,i),j=1,3),(gvdwc(j,i),j=1,3)
480 > C FG slaves call the following matching MPI_Bcast in ERGASTULUM
481 > if (nfgtasks.gt.1 .and. fg_rank.eq.0)
482 > & call MPI_Bcast(1,1,MPI_INTEGER,king,FG_COMM,IERROR)
484 < if (calc_grad) then
486 < C Sum up the components of the Cartesian gradient.
488 > C 9/29/08 AL Transform parts of gradients in site coordinates to the gradient
489 > C in virtual-bond-vector coordinates
492 > c write (iout,*) "gel_loc gel_loc_long and gel_loc_loc"
494 > c write (iout,'(i5,3f10.5,2x,3f10.5,2x,f10.5)')
495 > c & i,(gel_loc(j,i),j=1,3),(gel_loc_long(j,i),j=1,3),gel_loc_loc(i)
497 > c write (iout,*) "gel_loc_tur3 gel_loc_turn4"
499 > c write (iout,'(i5,3f10.5,2x,f10.5)')
500 > c & i,(gcorr4_turn(j,i),j=1,3),gel_loc_turn4(i)
502 > write (iout,*) "gradcorr5 gradcorr5_long gradcorr5_loc"
504 > write (iout,'(i3,3f10.5,5x,3f10.5,5x,f10.5)')
505 > & i,(gradcorr5(j,i),j=1,3),(gradcorr5_long(j,i),j=1,3),
511 < gradc(j,i,icg)=wsc*gvdwc(j,i)+wscp*gvdwc_scp(j,i)+
512 < & welec*fact(1)*gelc(j,i)+wvdwpp*gvdwpp(j,i)+
513 < & wbond*gradb(j,i)+
514 < & wstrain*ghpbc(j,i)+
515 < & wcorr*fact(3)*gradcorr(j,i)+
516 < & wel_loc*fact(2)*gel_loc(j,i)+
517 < & wturn3*fact(2)*gcorr3_turn(j,i)+
518 < & wturn4*fact(3)*gcorr4_turn(j,i)+
519 < & wcorr5*fact(4)*gradcorr5(j,i)+
520 < & wcorr6*fact(5)*gradcorr6(j,i)+
521 < & wturn6*fact(5)*gcorr6_turn(j,i)+
522 < & wsccor*fact(2)*gsccorc(j,i)
523 < gradx(j,i,icg)=wsc*gvdwx(j,i)+wscp*gradx_scp(j,i)+
524 < & wbond*gradbx(j,i)+
525 < & wstrain*ghpbx(j,i)+wcorr*gradxorr(j,i)+
526 < & wsccor*fact(2)*gsccorx(j,i)
528 > gradbufc(j,i)=wsc*gvdwc(j,i)+
529 > & wscp*(gvdwc_scp(j,i)+gvdwc_scpp(j,i))+
530 > & welec*gelc_long(j,i)+wvdwpp*gvdwpp(j,i)+
531 > & wel_loc*gel_loc_long(j,i)+
532 > & wcorr*gradcorr_long(j,i)+
533 > & wcorr5*gradcorr5_long(j,i)+
534 > & wcorr6*gradcorr6_long(j,i)+
535 > & wturn6*gcorr6_turn_long(j,i)+
536 > & wstrain*ghpbc(j,i)
540 < gradc(j,i,icg)=wsc*gvdwc(j,i)+wscp*gvdwc_scp(j,i)+
541 < & welec*fact(1)*gelc(j,i)+wstrain*ghpbc(j,i)+
543 > gradbufc(j,i)=wsc*gvdwc(j,i)+
544 > & wscp*(gvdwc_scp(j,i)+gvdwc_scpp(j,i))+
545 > & welec*gelc_long(j,i)+
547 < & wcorr*fact(3)*gradcorr(j,i)+
548 < & wel_loc*fact(2)*gel_loc(j,i)+
549 < & wturn3*fact(2)*gcorr3_turn(j,i)+
550 < & wturn4*fact(3)*gcorr4_turn(j,i)+
551 < & wcorr5*fact(4)*gradcorr5(j,i)+
552 < & wcorr6*fact(5)*gradcorr6(j,i)+
553 < & wturn6*fact(5)*gcorr6_turn(j,i)+
554 < & wsccor*fact(2)*gsccorc(j,i)
556 > & wel_loc*gel_loc_long(j,i)+
557 > & wcorr*gradcorr_long(j,i)+
558 > & wcorr5*gradcorr5_long(j,i)+
559 > & wcorr6*gradcorr6_long(j,i)+
560 > & wturn6*gcorr6_turn_long(j,i)+
561 > & wstrain*ghpbc(j,i)
566 > if (nfgtasks.gt.1) then
569 > write (iout,*) "gradbufc before allreduce"
571 > write (iout,'(i3,3f10.5)') i,(gradbufc(j,i),j=1,3)
577 > gradbufc_sum(j,i)=gradbufc(j,i)
580 > c call MPI_AllReduce(gradbufc(1,1),gradbufc_sum(1,1),3*nres,
581 > c & MPI_DOUBLE_PRECISION,MPI_SUM,FG_COMM,IERR)
582 > c time_reduce=time_reduce+MPI_Wtime()-time00
584 > c write (iout,*) "gradbufc_sum after allreduce"
586 > c write (iout,'(i3,3f10.5)') i,(gradbufc_sum(j,i),j=1,3)
591 > c time_allreduce=time_allreduce+MPI_Wtime()-time00
595 > gradbufc(k,i)=0.0d0
599 > write (iout,*) "igrad_start",igrad_start," igrad_end",igrad_end
600 > write (iout,*) (i," jgrad_start",jgrad_start(i),
601 > & " jgrad_end ",jgrad_end(i),
602 > & i=igrad_start,igrad_end)
605 > c Obsolete and inefficient code; we can make the effort O(n) and, therefore,
606 > c do not parallelize this part.
608 > c do i=igrad_start,igrad_end
609 > c do j=jgrad_start(i),jgrad_end(i)
611 > c gradbufc(k,i)=gradbufc(k,i)+gradbufc_sum(k,j)
616 > gradbufc(j,nres-1)=gradbufc_sum(j,nres)
620 > gradbufc(j,i)=gradbufc(j,i+1)+gradbufc_sum(j,i+1)
624 > write (iout,*) "gradbufc after summing"
626 > write (iout,'(i3,3f10.5)') i,(gradbufc(j,i),j=1,3)
633 > write (iout,*) "gradbufc"
635 > write (iout,'(i3,3f10.5)') i,(gradbufc(j,i),j=1,3)
641 > gradbufc_sum(j,i)=gradbufc(j,i)
642 > gradbufc(j,i)=0.0d0
646 > gradbufc(j,nres-1)=gradbufc_sum(j,nres)
650 > gradbufc(j,i)=gradbufc(j,i+1)+gradbufc_sum(j,i+1)
655 > c gradbufc(k,i)=0.0d0
659 > c gradbufc(k,i)=gradbufc(k,i)+gradbufc(k,j)
664 > write (iout,*) "gradbufc after summing"
666 > write (iout,'(i3,3f10.5)') i,(gradbufc(j,i),j=1,3)
674 > gradbufc(k,nres)=0.0d0
679 > gradc(j,i,icg)=gradbufc(j,i)+welec*gelc(j,i)+
680 > & wel_loc*gel_loc(j,i)+
681 > & 0.5d0*(wscp*gvdwc_scpp(j,i)+
682 > & welec*gelc_long(j,i)+wvdwpp*gvdwpp(j,i)+
683 > & wel_loc*gel_loc_long(j,i)+
684 > & wcorr*gradcorr_long(j,i)+
685 > & wcorr5*gradcorr5_long(j,i)+
686 > & wcorr6*gradcorr6_long(j,i)+
687 > & wturn6*gcorr6_turn_long(j,i))+
688 > & wbond*gradb(j,i)+
689 > & wcorr*gradcorr(j,i)+
690 > & wturn3*gcorr3_turn(j,i)+
691 > & wturn4*gcorr4_turn(j,i)+
692 > & wcorr5*gradcorr5(j,i)+
693 > & wcorr6*gradcorr6(j,i)+
694 > & wturn6*gcorr6_turn(j,i)+
695 > & wsccor*gsccorc(j,i)
696 > & +wscloc*gscloc(j,i)
698 > gradc(j,i,icg)=gradbufc(j,i)+welec*gelc(j,i)+
699 > & wel_loc*gel_loc(j,i)+
700 > & 0.5d0*(wscp*gvdwc_scpp(j,i)+
701 > & welec*gelc_long(j,i)
702 > & wel_loc*gel_loc_long(j,i)+
703 > & wcorr*gcorr_long(j,i)+
704 > & wcorr5*gradcorr5_long(j,i)+
705 > & wcorr6*gradcorr6_long(j,i)+
706 > & wturn6*gcorr6_turn_long(j,i))+
707 > & wbond*gradb(j,i)+
708 > & wcorr*gradcorr(j,i)+
709 > & wturn3*gcorr3_turn(j,i)+
710 > & wturn4*gcorr4_turn(j,i)+
711 > & wcorr5*gradcorr5(j,i)+
712 > & wcorr6*gradcorr6(j,i)+
713 > & wturn6*gcorr6_turn(j,i)+
714 > & wsccor*gsccorc(j,i)
715 > & +wscloc*gscloc(j,i)
718 < & wsccor*fact(1)*gsccorx(j,i)
720 > & wsccor*gsccorx(j,i)
721 > & +wscloc*gsclocx(j,i)
727 > write (iout,*) "gloc before adding corr"
729 > write (iout,*) i,gloc(i,icg)
736 < gloc(i,icg)=gloc(i,icg)+wcorr*fact(3)*gcorr_loc(i)
737 < & +wcorr5*fact(4)*g_corr5_loc(i)
738 < & +wcorr6*fact(5)*g_corr6_loc(i)
739 < & +wturn4*fact(3)*gel_loc_turn4(i)
740 < & +wturn3*fact(2)*gel_loc_turn3(i)
741 < & +wturn6*fact(5)*gel_loc_turn6(i)
742 < & +wel_loc*fact(2)*gel_loc_loc(i)
743 < & +wsccor*fact(1)*gsccor_loc(i)
745 > gloc(i,icg)=gloc(i,icg)+wcorr*gcorr_loc(i)
746 > & +wcorr5*g_corr5_loc(i)
747 > & +wcorr6*g_corr6_loc(i)
748 > & +wturn4*gel_loc_turn4(i)
749 > & +wturn3*gel_loc_turn3(i)
750 > & +wturn6*gel_loc_turn6(i)
751 > & +wel_loc*gel_loc_loc(i)
752 > & +wsccor*gsccor_loc(i)
755 > write (iout,*) "gloc after adding corr"
757 > write (iout,*) i,gloc(i,icg)
761 > if (nfgtasks.gt.1) then
764 > gradbufc(j,i)=gradc(j,i,icg)
765 > gradbufx(j,i)=gradx(j,i,icg)
769 > glocbuf(i)=gloc(i,icg)
772 > call MPI_Barrier(FG_COMM,IERR)
773 > time_barrier_g=time_barrier_g+MPI_Wtime()-time00
775 > call MPI_Reduce(gradbufc(1,1),gradc(1,1,icg),3*nres,
776 > & MPI_DOUBLE_PRECISION,MPI_SUM,king,FG_COMM,IERR)
777 > call MPI_Reduce(gradbufx(1,1),gradx(1,1,icg),3*nres,
778 > & MPI_DOUBLE_PRECISION,MPI_SUM,king,FG_COMM,IERR)
779 > call MPI_Reduce(glocbuf(1),gloc(1,icg),4*nres,
780 > & MPI_DOUBLE_PRECISION,MPI_SUM,king,FG_COMM,IERR)
781 > time_reduce=time_reduce+MPI_Wtime()-time00
783 > write (iout,*) "gloc after reduce"
785 > write (iout,*) i,gloc(i,icg)
790 > if (gnorm_check) then
792 > c Compute the maximum elements of the gradient
795 > gvdwc_scp_max=0.0d0
802 > gcorr3_turn_max=0.0d0
803 > gcorr4_turn_max=0.0d0
804 > gradcorr5_max=0.0d0
805 > gradcorr6_max=0.0d0
806 > gcorr6_turn_max=0.0d0
810 > gradx_scp_max=0.0d0
816 > gvdwc_norm=dsqrt(scalar(gvdwc(1,i),gvdwc(1,i)))
817 > if (gvdwc_norm.gt.gvdwc_max) gvdwc_max=gvdwc_norm
818 > gvdwc_scp_norm=dsqrt(scalar(gvdwc_scp(1,i),gvdwc_scp(1,i)))
819 > if (gvdwc_scp_norm.gt.gvdwc_scp_max)
820 > & gvdwc_scp_max=gvdwc_scp_norm
821 > gelc_norm=dsqrt(scalar(gelc(1,i),gelc(1,i)))
822 > if (gelc_norm.gt.gelc_max) gelc_max=gelc_norm
823 > gvdwpp_norm=dsqrt(scalar(gvdwpp(1,i),gvdwpp(1,i)))
824 > if (gvdwpp_norm.gt.gvdwpp_max) gvdwpp_max=gvdwpp_norm
825 > gradb_norm=dsqrt(scalar(gradb(1,i),gradb(1,i)))
826 > if (gradb_norm.gt.gradb_max) gradb_max=gradb_norm
827 > ghpbc_norm=dsqrt(scalar(ghpbc(1,i),ghpbc(1,i)))
828 > if (ghpbc_norm.gt.ghpbc_max) ghpbc_max=ghpbc_norm
829 > gradcorr_norm=dsqrt(scalar(gradcorr(1,i),gradcorr(1,i)))
830 > if (gradcorr_norm.gt.gradcorr_max) gradcorr_max=gradcorr_norm
831 > gel_loc_norm=dsqrt(scalar(gel_loc(1,i),gel_loc(1,i)))
832 > if (gel_loc_norm.gt.gel_loc_max) gel_loc_max=gel_loc_norm
833 > gcorr3_turn_norm=dsqrt(scalar(gcorr3_turn(1,i),
834 > & gcorr3_turn(1,i)))
835 > if (gcorr3_turn_norm.gt.gcorr3_turn_max)
836 > & gcorr3_turn_max=gcorr3_turn_norm
837 > gcorr4_turn_norm=dsqrt(scalar(gcorr4_turn(1,i),
838 > & gcorr4_turn(1,i)))
839 > if (gcorr4_turn_norm.gt.gcorr4_turn_max)
840 > & gcorr4_turn_max=gcorr4_turn_norm
841 > gradcorr5_norm=dsqrt(scalar(gradcorr5(1,i),gradcorr5(1,i)))
842 > if (gradcorr5_norm.gt.gradcorr5_max)
843 > & gradcorr5_max=gradcorr5_norm
844 > gradcorr6_norm=dsqrt(scalar(gradcorr6(1,i),gradcorr6(1,i)))
845 > if (gradcorr6_norm.gt.gradcorr6_max) gcorr6_max=gradcorr6_norm
846 > gcorr6_turn_norm=dsqrt(scalar(gcorr6_turn(1,i),
847 > & gcorr6_turn(1,i)))
848 > if (gcorr6_turn_norm.gt.gcorr6_turn_max)
849 > & gcorr6_turn_max=gcorr6_turn_norm
850 > gsccorr_norm=dsqrt(scalar(gsccorc(1,i),gsccorc(1,i)))
851 > if (gsccorr_norm.gt.gsccorr_max) gsccorr_max=gsccorr_norm
852 > gscloc_norm=dsqrt(scalar(gscloc(1,i),gscloc(1,i)))
853 > if (gscloc_norm.gt.gscloc_max) gscloc_max=gscloc_norm
854 > gvdwx_norm=dsqrt(scalar(gvdwx(1,i),gvdwx(1,i)))
855 > if (gvdwx_norm.gt.gvdwx_max) gvdwx_max=gvdwx_norm
856 > gradx_scp_norm=dsqrt(scalar(gradx_scp(1,i),gradx_scp(1,i)))
857 > if (gradx_scp_norm.gt.gradx_scp_max)
858 > & gradx_scp_max=gradx_scp_norm
859 > ghpbx_norm=dsqrt(scalar(ghpbx(1,i),ghpbx(1,i)))
860 > if (ghpbx_norm.gt.ghpbx_max) ghpbx_max=ghpbx_norm
861 > gradxorr_norm=dsqrt(scalar(gradxorr(1,i),gradxorr(1,i)))
862 > if (gradxorr_norm.gt.gradxorr_max) gradxorr_max=gradxorr_norm
863 > gsccorrx_norm=dsqrt(scalar(gsccorx(1,i),gsccorx(1,i)))
864 > if (gsccorrx_norm.gt.gsccorrx_max) gsccorrx_max=gsccorrx_norm
865 > gsclocx_norm=dsqrt(scalar(gsclocx(1,i),gsclocx(1,i)))
866 > if (gsclocx_norm.gt.gsclocx_max) gsclocx_max=gsclocx_norm
870 > open(istat,file=statname,position="append")
872 > open(istat,file=statname,access="append")
874 > write (istat,'(1h#,21f10.2)') gvdwc_max,gvdwc_scp_max,
875 > & gelc_max,gvdwpp_max,gradb_max,ghpbc_max,
876 > & gradcorr_max,gel_loc_max,gcorr3_turn_max,gcorr4_turn_max,
877 > & gradcorr5_max,gradcorr6_max,gcorr6_turn_max,gsccorc_max,
878 > & gscloc_max,gvdwx_max,gradx_scp_max,ghpbx_max,gradxorr_max,
879 > & gsccorx_max,gsclocx_max
881 > if (gvdwc_max.gt.1.0d4) then
882 > write (iout,*) "gvdwc gvdwx gradb gradbx"
884 > write(iout,'(i5,4(3f10.2,5x))') i,(gvdwc(j,i),gvdwx(j,i),
885 > & gradb(j,i),gradbx(j,i),j=1,3)
887 > call pdbout(0.0d0,'cipiszcze',iout)
893 > write (iout,*) "gradc gradx gloc"
895 > write (iout,'(i5,3f10.5,5x,3f10.5,5x,f10.5)')
896 > & i,(gradc(j,i,icg),j=1,3),(gradx(j,i,icg),j=1,3),gloc(i,icg)
900 > time_sumgradient=time_sumgradient+MPI_Wtime()-time01
904 > c-------------------------------------------------------------------------------
905 > subroutine rescale_weights(t_bath)
906 > implicit real*8 (a-h,o-z)
907 > include 'DIMENSIONS'
908 > include 'COMMON.IOUNITS'
909 > include 'COMMON.FFIELD'
910 > include 'COMMON.SBRIDGE'
911 > double precision kfac /2.4d0/
912 > double precision x,x2,x3,x4,x5,licznik /1.12692801104297249644/
913 > c facT=temp0/t_bath
914 > c facT=2*temp0/(t_bath+temp0)
915 > if (rescale_mode.eq.0) then
921 > else if (rescale_mode.eq.1) then
922 > facT=kfac/(kfac-1.0d0+t_bath/temp0)
923 > facT2=kfac**2/(kfac**2-1.0d0+(t_bath/temp0)**2)
924 > facT3=kfac**3/(kfac**3-1.0d0+(t_bath/temp0)**3)
925 > facT4=kfac**4/(kfac**4-1.0d0+(t_bath/temp0)**4)
926 > facT5=kfac**5/(kfac**5-1.0d0+(t_bath/temp0)**5)
927 > else if (rescale_mode.eq.2) then
933 > facT=licznik/dlog(dexp(x)+dexp(-x))
934 > facT2=licznik/dlog(dexp(x2)+dexp(-x2))
935 > facT3=licznik/dlog(dexp(x3)+dexp(-x3))
936 > facT4=licznik/dlog(dexp(x4)+dexp(-x4))
937 > facT5=licznik/dlog(dexp(x5)+dexp(-x5))
939 > write (iout,*) "Wrong RESCALE_MODE",rescale_mode
940 > write (*,*) "Wrong RESCALE_MODE",rescale_mode
942 > call MPI_Finalize(MPI_COMM_WORLD,IERROR)
946 > welec=weights(3)*fact
947 > wcorr=weights(4)*fact3
948 > wcorr5=weights(5)*fact4
949 > wcorr6=weights(6)*fact5
950 > wel_loc=weights(7)*fact2
951 > wturn3=weights(8)*fact2
952 > wturn4=weights(9)*fact3
953 > wturn6=weights(10)*fact5
954 > wtor=weights(13)*fact
955 > wtor_d=weights(14)*fact2
956 > wsccor=weights(21)*fact
959 < subroutine enerprint(energia,fact)
961 > subroutine enerprint(energia)
963 < include 'DIMENSIONS.ZSCOPT'
965 < double precision energia(0:max_ene),fact(6)
967 > include 'COMMON.MD'
968 > double precision energia(0:n_ene)
970 < evdw=energia(1)+fact(6)*energia(21)
975 < evdw2=energia(2)+energia(17)
977 > evdw2=energia(2)+energia(18)
980 < edihcnstr=energia(20)
983 > edihcnstr=energia(19)
988 < write (iout,10) evdw,wsc,evdw2,wscp,ees,welec*fact(1),evdw1,
990 < & estr,wbond,ebe,wang,escloc,wscloc,etors,wtor*fact(1),
991 < & etors_d,wtor_d*fact(2),ehpb,wstrain,
992 < & ecorr,wcorr*fact(3),ecorr5,wcorr5*fact(4),ecorr6,wcorr6*fact(5),
993 < & eel_loc,wel_loc*fact(2),eello_turn3,wturn3*fact(2),
994 < & eello_turn4,wturn4*fact(3),eello_turn6,wturn6*fact(5),
995 < & esccor,wsccor*fact(1),edihcnstr,ebr*nss,etot
997 > write (iout,10) evdw,wsc,evdw2,wscp,ees,welec,evdw1,wvdwpp,
998 > & estr,wbond,ebe,wang,
999 > & escloc,wscloc,etors,wtor,etors_d,wtor_d,ehpb,wstrain,
1001 > & ecorr5,wcorr5,ecorr6,wcorr6,eel_loc,wel_loc,eello_turn3,wturn3,
1002 > & eello_turn4,wturn4,eello_turn6,wturn6,esccor,wsccor,
1003 > & edihcnstr,ebr*nss,
1006 < & 'EES= ',1pE16.6,' WEIGHT=',1pD16.6,' (p-p elec)'/
1008 > & 'EES= ',1pE16.6,' WEIGHT=',1pD16.6,' (p-p)'/
1010 < & 'ESS= ',1pE16.6,' (disulfide-bridge intrinsic energy)'/
1012 > & 'ESS= ',1pE16.6,' (disulfide-bridge intrinsic energy)'/
1013 > & 'UCONST= ',1pE16.6,' (Constraint energy)'/
1015 < write (iout,10) evdw,wsc,evdw2,wscp,ees,welec*fact(1),estr,wbond,
1016 < & ebe,wang,escloc,wscloc,etors,wtor*fact(1),etors_d,wtor_d*fact2,
1017 < & ehpb,wstrain,ecorr,wcorr*fact(3),ecorr5,wcorr5*fact(4),
1018 < & ecorr6,wcorr6*fact(5),eel_loc,wel_loc*fact(2),
1019 < & eello_turn3,wturn3*fact(2),eello_turn4,wturn4*fact(3),
1020 < & eello_turn6,wturn6*fact(5),esccor*fact(1),wsccor,
1021 < & edihcnstr,ebr*nss,etot
1023 > write (iout,10) evdw,wsc,evdw2,wscp,ees,welec,
1024 > & estr,wbond,ebe,wang,
1025 > & escloc,wscloc,etors,wtor,etors_d,wtor_d,ehpb,wstrain,
1027 > & ecorr5,wcorr5,ecorr6,wcorr6,eel_loc,wel_loc,eello_turn3,wturn3,
1028 > & eello_turn4,wturn4,eello_turn6,wturn6,esccor,wsccro,edihcnstr,
1029 > & ebr*nss,Uconst,etot
1031 < & 'ESS= ',1pE16.6,' (disulfide-bridge intrinsic energy)'/
1033 > & 'ESS= ',1pE16.6,' (disulfide-bridge intrinsic energy)'/
1034 > & 'UCONST=',1pE16.6,' (Constraint energy)'/
1036 < subroutine elj(evdw,evdw_t)
1038 > subroutine elj(evdw)
1040 < include 'DIMENSIONS.ZSCOPT'
1041 < include "DIMENSIONS.COMPAR"
1043 < include 'COMMON.ENEPS'
1047 < cd print *,'Entering ELJ nnt=',nnt,' nct=',nct,' expon=',expon
1050 < eneps_temp(j,i)=0.0d0
1054 > c write(iout,*)'Entering ELJ nnt=',nnt,' nct=',nct,' expon=',expon
1058 < ij=icant(itypi,itypj)
1059 < eneps_temp(1,ij)=eneps_temp(1,ij)+e1/dabs(eps0ij)
1060 < eneps_temp(2,ij)=eneps_temp(2,ij)+e2/eps0ij
1062 < if (bb(itypi,itypj).gt.0.0d0) then
1065 < evdw_t=evdw_t+evdwij
1067 < if (calc_grad) then
1071 > gvdwc(k,i)=gvdwc(k,i)-gg(k)
1072 > gvdwc(k,j)=gvdwc(k,j)+gg(k)
1076 < gvdwc(l,k)=gvdwc(l,k)+gg(l)
1083 > cgrad gvdwc(l,k)=gvdwc(l,k)+gg(l)
1087 < if (calc_grad) then
1091 < subroutine eljk(evdw,evdw_t)
1093 > subroutine eljk(evdw)
1095 < include 'DIMENSIONS.ZSCOPT'
1096 < include "DIMENSIONS.COMPAR"
1098 < include 'COMMON.ENEPS'
1105 < eneps_temp(j,i)=0.0d0
1111 < ij=icant(itypi,itypj)
1112 < eneps_temp(1,ij)=eneps_temp(1,ij)+(e1+a_augm)
1113 < & /dabs(eps(itypi,itypj))
1114 < eneps_temp(2,ij)=eneps_temp(2,ij)+e2/eps(itypi,itypj)
1116 < if (bb(itypi,itypj).gt.0.0d0) then
1119 < evdw_t=evdw_t+evdwij
1121 < if (calc_grad) then
1125 > gvdwc(k,i)=gvdwc(k,i)-gg(k)
1126 > gvdwc(k,j)=gvdwc(k,j)+gg(k)
1130 < gvdwc(l,k)=gvdwc(l,k)+gg(l)
1137 > cgrad gvdwc(l,k)=gvdwc(l,k)+gg(l)
1141 < if (calc_grad) then
1145 < subroutine ebp(evdw,evdw_t)
1147 > subroutine ebp(evdw)
1149 < include 'DIMENSIONS.ZSCOPT'
1150 < include "DIMENSIONS.COMPAR"
1152 < include 'COMMON.ENEPS'
1158 < eneps_temp(j,i)=0.0d0
1166 > c dsci_inv=dsc_inv(itypi)
1168 > c dscj_inv=dsc_inv(itypj)
1170 < ij=icant(itypi,itypj)
1171 < aux=eps1*eps2rt**2*eps3rt**2
1172 < eneps_temp(1,ij)=eneps_temp(1,ij)+e1*aux
1173 < & /dabs(eps(itypi,itypj))
1174 < eneps_temp(2,ij)=eneps_temp(2,ij)+e2*aux/eps(itypi,itypj)
1175 < if (bb(itypi,itypj).gt.0.0d0) then
1178 < evdw_t=evdw_t+evdwij
1180 < if (calc_grad) then
1186 < subroutine egb(evdw,evdw_t)
1188 > subroutine egb(evdw)
1190 < include 'DIMENSIONS.ZSCOPT'
1191 < include "DIMENSIONS.COMPAR"
1193 < include 'COMMON.ENEPS'
1195 > include 'COMMON.CONTROL'
1197 < common /srutu/icall
1202 < eneps_temp(j,i)=0.0d0
1207 > ccccc energy_dec=.false.
1211 < c if (icall.gt.0) lprn=.true.
1213 > c if (icall.eq.0) lprn=.false.
1215 > c dsci_inv=dsc_inv(itypi)
1217 > c write (iout,*) "i",i,dsc_inv(itypi),dsci_inv,1.0d0/vbld(i+nres)
1218 > c write (iout,*) "dcnori",dxi*dxi+dyi*dyi+dzi*dzi
1220 > c dscj_inv=dsc_inv(itypj)
1222 > c write (iout,*) "j",j,dsc_inv(itypj),dscj_inv,
1223 > c & 1.0d0/vbld(j+nres)
1224 > c write (iout,*) "i",i," j", j," itype",itype(i),itype(j)
1226 < c write (iout,*) i,j,xj,yj,zj
1228 > c write (iout,*) "dcnorj",dxi*dxi+dyi*dyi+dzi*dzi
1229 > c write (iout,*) "j",j," dc_norm",
1230 > c & dc_norm(1,nres+j),dc_norm(2,nres+j),dc_norm(3,nres+j)
1232 > c for diagnostics; uncomment
1233 > c rij_shift=1.2*sig0ij
1235 > cd write (iout,'(2(a3,i3,2x),17(0pf7.3))')
1236 > cd & restyp(itypi),i,restyp(itypj),j,
1237 > cd & rij_shift,1.0D0/rij,sig,sig0ij,sigsq,1-dsqrt(sigsq)
1239 > c write (iout,*) "sigsq",sigsq," sig",sig," eps2rt",eps2rt,
1240 > c & " eps3rt",eps3rt," eps1",eps1," e1",e1," e2",e2
1242 < if (bb(itypi,itypj).gt.0) then
1245 < evdw_t=evdw_t+evdwij
1247 < ij=icant(itypi,itypj)
1248 < aux=eps1*eps2rt**2*eps3rt**2
1249 < eneps_temp(1,ij)=eneps_temp(1,ij)+aux*e1
1250 < & /dabs(eps(itypi,itypj))
1251 < eneps_temp(2,ij)=eneps_temp(2,ij)+aux*e2/eps(itypi,itypj)
1252 < c write (iout,*) "i",i," j",j," itypi",itypi," itypj",itypj,
1253 < c & " ij",ij," eneps",aux*e1/dabs(eps(itypi,itypj)),
1254 < c & aux*e2/eps(itypi,itypj)
1258 < if (calc_grad) then
1261 > if (energy_dec) write (iout,'(a6,2i5,0pf7.3)')
1262 > & 'evdw',i,j,evdwij
1269 > c write (iout,*) "Number of loop steps in EGB:",ind
1270 > cccc energy_dec=.false.
1272 < subroutine egbv(evdw,evdw_t)
1274 > subroutine egbv(evdw)
1276 < include 'DIMENSIONS.ZSCOPT'
1277 < include "DIMENSIONS.COMPAR"
1279 < include 'COMMON.ENEPS'
1285 < eneps_temp(j,i)=0.0d0
1291 < c if (icall.gt.0) lprn=.true.
1293 > c if (icall.eq.0) lprn=.true.
1295 > c dsci_inv=dsc_inv(itypi)
1297 > c dscj_inv=dsc_inv(itypj)
1299 < if (bb(itypi,itypj).gt.0.0d0) then
1300 < evdw=evdw+evdwij+e_augm
1302 < evdw_t=evdw_t+evdwij+e_augm
1304 > evdw=evdw+evdwij+e_augm
1306 > sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
1307 > epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
1308 > write (iout,'(2(a3,i3,2x),17(0pf7.3))')
1309 > & restyp(itypi),i,restyp(itypj),j,
1310 > & epsi,sigm,sig,(augm(itypi,itypj)/epsi)**(1.0D0/12.0D0),
1311 > & chi1,chi2,chip1,chip2,
1312 > & eps1,eps2rt**2,eps3rt**2,
1313 > & om1,om2,om12,1.0D0/rij,1.0D0/rij_shift,
1316 < ij=icant(itypi,itypj)
1317 < aux=eps1*eps2rt**2*eps3rt**2
1318 < eneps_temp(1,ij)=eneps_temp(1,ij)+aux*(e1+e_augm)
1319 < & /dabs(eps(itypi,itypj))
1320 < eneps_temp(2,ij)=eneps_temp(2,ij)+aux*e2/eps(itypi,itypj)
1321 < c eneps_temp(ij)=eneps_temp(ij)
1322 < c & +(evdwij+e_augm)/eps(itypi,itypj)
1324 < c sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
1325 < c epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
1326 < c write (iout,'(2(a3,i3,2x),17(0pf7.3))')
1327 < c & restyp(itypi),i,restyp(itypj),j,
1328 < c & epsi,sigm,sig,(augm(itypi,itypj)/epsi)**(1.0D0/12.0D0),
1329 < c & chi1,chi2,chip1,chip2,
1330 < c & eps1,eps2rt**2,eps3rt**2,
1331 < c & om1,om2,om12,1.0D0/rij,1.0D0/rij_shift,
1334 < if (calc_grad) then
1340 > include 'COMMON.IOUNITS'
1342 > c diagnostics only
1343 > c faceps1_inv=om12
1346 > c write (iout,*) "om12",om12," eps1",eps1
1348 > c diagnostics only
1352 > c sigsq_om12=0.0d0
1353 > c write (iout,*) "chiom1",chiom1," chiom2",chiom2," chiom12",chiom12
1354 > c write (iout,*) "faceps1",faceps1," faceps1_inv",faceps1_inv,
1357 > c write (iout,*) "chipom1",chipom1," chipom2",chipom2,
1358 > c & " chipom12",chipom12," facp",facp," facp_inv",facp_inv
1360 > c write (iout,*) "eps2rt",eps2rt," eps3rt",eps3rt
1361 > c write (iout,*) "eps2rt_om1",eps2rt_om1," eps2rt_om2",eps2rt_om2,
1362 > c & " eps2rt_om12",eps2rt_om12
1364 < include 'DIMENSIONS.ZSCOPT'
1366 > include 'COMMON.IOUNITS'
1368 > c diagnostics only
1371 > c eom12=evdwij*eps1_om12
1373 > c write (iout,*) "eps2der",eps2der," eps3der",eps3der,
1374 > c & " sigder",sigder
1375 > c write (iout,*) "eps1_om12",eps1_om12," eps2rt_om12",eps2rt_om12
1376 > c write (iout,*) "eom1",eom1," eom2",eom2," eom12",eom12
1378 > c write (iout,*) "gg",(gg(k),k=1,3)
1380 > c write (iout,*)(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i))
1381 > c & +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
1382 > c write (iout,*)(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j))
1383 > c & +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
1387 < gvdwc(l,k)=gvdwc(l,k)+gg(l)
1392 > cgrad gvdwc(l,k)=gvdwc(l,k)+gg(l)
1396 > gvdwc(l,i)=gvdwc(l,i)-gg(l)
1397 > gvdwc(l,j)=gvdwc(l,j)+gg(l)
1399 < c------------------------------------------------------------------------------
1400 < subroutine vec_and_deriv
1402 > C-----------------------------------------------------------------------
1403 > subroutine e_softsphere(evdw)
1405 > C This subroutine calculates the interaction energy of nonbonded side chains
1406 > C assuming the LJ potential of interaction.
1409 < include 'DIMENSIONS.ZSCOPT'
1410 < include 'COMMON.IOUNITS'
1412 > parameter (accur=1.0d-10)
1414 < include 'COMMON.VECTORS'
1416 < dimension uyder(3,3,2),uzder(3,3,2),vbld_inv_temp(2)
1417 < C Compute the local reference systems. For reference system (i), the
1418 < C X-axis points from CA(i) to CA(i+1), the Y axis is in the
1419 < C CA(i)-CA(i+1)-CA(i+2) plane, and the Z axis is perpendicular to this plane.
1421 < c if (i.eq.nres-1 .or. itel(i+1).eq.0) then
1422 < if (i.eq.nres-1) then
1423 < C Case of the last full residue
1424 < C Compute the Z-axis
1425 < call vecpr(dc_norm(1,i),dc_norm(1,i-1),uz(1,i))
1426 < costh=dcos(pi-theta(nres))
1427 < fac=1.0d0/dsqrt(1.0d0-costh*costh)
1429 < uz(k,i)=fac*uz(k,i)
1431 < if (calc_grad) then
1432 < C Compute the derivatives of uz
1433 < uzder(1,1,1)= 0.0d0
1434 < uzder(2,1,1)=-dc_norm(3,i-1)
1435 < uzder(3,1,1)= dc_norm(2,i-1)
1436 < uzder(1,2,1)= dc_norm(3,i-1)
1437 < uzder(2,2,1)= 0.0d0
1438 < uzder(3,2,1)=-dc_norm(1,i-1)
1439 < uzder(1,3,1)=-dc_norm(2,i-1)
1440 < uzder(2,3,1)= dc_norm(1,i-1)
1441 < uzder(3,3,1)= 0.0d0
1442 < uzder(1,1,2)= 0.0d0
1443 < uzder(2,1,2)= dc_norm(3,i)
1444 < uzder(3,1,2)=-dc_norm(2,i)
1445 < uzder(1,2,2)=-dc_norm(3,i)
1446 < uzder(2,2,2)= 0.0d0
1447 < uzder(3,2,2)= dc_norm(1,i)
1448 < uzder(1,3,2)= dc_norm(2,i)
1449 < uzder(2,3,2)=-dc_norm(1,i)
1450 < uzder(3,3,2)= 0.0d0
1452 < C Compute the Y-axis
1455 < uy(k,i)=fac*(dc_norm(k,i-1)-costh*dc_norm(k,i))
1457 < if (calc_grad) then
1458 < C Compute the derivatives of uy
1461 < uyder(k,j,1)=2*dc_norm(k,i-1)*dc_norm(j,i)
1462 < & -dc_norm(k,i)*dc_norm(j,i-1)
1463 < uyder(k,j,2)=-dc_norm(j,i)*dc_norm(k,i)
1465 < uyder(j,j,1)=uyder(j,j,1)-costh
1466 < uyder(j,j,2)=1.0d0+uyder(j,j,2)
1471 < uygrad(l,k,j,i)=uyder(l,k,j)
1472 < uzgrad(l,k,j,i)=uzder(l,k,j)
1476 < call unormderiv(uy(1,i),uyder(1,1,1),facy,uygrad(1,1,1,i))
1477 < call unormderiv(uy(1,i),uyder(1,1,2),facy,uygrad(1,1,2,i))
1478 < call unormderiv(uz(1,i),uzder(1,1,1),fac,uzgrad(1,1,1,i))
1479 < call unormderiv(uz(1,i),uzder(1,1,2),fac,uzgrad(1,1,2,i))
1483 < C Compute the Z-axis
1484 < call vecpr(dc_norm(1,i),dc_norm(1,i+1),uz(1,i))
1485 < costh=dcos(pi-theta(i+2))
1486 < fac=1.0d0/dsqrt(1.0d0-costh*costh)
1488 < uz(k,i)=fac*uz(k,i)
1490 < if (calc_grad) then
1491 < C Compute the derivatives of uz
1492 < uzder(1,1,1)= 0.0d0
1493 < uzder(2,1,1)=-dc_norm(3,i+1)
1494 < uzder(3,1,1)= dc_norm(2,i+1)
1495 < uzder(1,2,1)= dc_norm(3,i+1)
1496 < uzder(2,2,1)= 0.0d0
1497 < uzder(3,2,1)=-dc_norm(1,i+1)
1498 < uzder(1,3,1)=-dc_norm(2,i+1)
1499 < uzder(2,3,1)= dc_norm(1,i+1)
1500 < uzder(3,3,1)= 0.0d0
1501 < uzder(1,1,2)= 0.0d0
1502 < uzder(2,1,2)= dc_norm(3,i)
1503 < uzder(3,1,2)=-dc_norm(2,i)
1504 < uzder(1,2,2)=-dc_norm(3,i)
1505 < uzder(2,2,2)= 0.0d0
1506 < uzder(3,2,2)= dc_norm(1,i)
1507 < uzder(1,3,2)= dc_norm(2,i)
1508 < uzder(2,3,2)=-dc_norm(1,i)
1509 < uzder(3,3,2)= 0.0d0
1511 > include 'COMMON.TORSION'
1512 > include 'COMMON.SBRIDGE'
1513 > include 'COMMON.NAMES'
1514 > include 'COMMON.IOUNITS'
1515 > include 'COMMON.CONTACTS'
1517 > cd print *,'Entering Esoft_sphere nnt=',nnt,' nct=',nct
1519 > do i=iatsc_s,iatsc_e
1521 > if (itypi.eq.21) cycle
1527 > C Calculate SC interaction energy.
1529 > do iint=1,nint_gr(i)
1530 > cd write (iout,*) 'i=',i,' iint=',iint,' istart=',istart(i,iint),
1531 > cd & 'iend=',iend(i,iint)
1532 > do j=istart(i,iint),iend(i,iint)
1534 > if (itypj.eq.21) cycle
1538 > rij=xj*xj+yj*yj+zj*zj
1539 > c write (iout,*)'i=',i,' j=',j,' itypi=',itypi,' itypj=',itypj
1540 > r0ij=r0(itypi,itypj)
1542 > c print *,i,j,r0ij,dsqrt(rij)
1543 > if (rij.lt.r0ijsq) then
1544 > evdwij=0.25d0*(rij-r0ijsq)**2
1550 < C Compute the Y-axis
1555 > C Calculate the components of the gradient in DC and X
1561 < uy(k,i)=facy*(dc_norm(k,i+1)-costh*dc_norm(k,i))
1563 < if (calc_grad) then
1564 < C Compute the derivatives of uy
1567 < uyder(k,j,1)=2*dc_norm(k,i+1)*dc_norm(j,i)
1568 < & -dc_norm(k,i)*dc_norm(j,i+1)
1569 < uyder(k,j,2)=-dc_norm(j,i)*dc_norm(k,i)
1571 < uyder(j,j,1)=uyder(j,j,1)-costh
1572 < uyder(j,j,2)=1.0d0+uyder(j,j,2)
1574 > gvdwx(k,i)=gvdwx(k,i)-gg(k)
1575 > gvdwx(k,j)=gvdwx(k,j)+gg(k)
1576 > gvdwc(k,i)=gvdwc(k,i)-gg(k)
1577 > gvdwc(k,j)=gvdwc(k,j)+gg(k)
1582 < uygrad(l,k,j,i)=uyder(l,k,j)
1583 < uzgrad(l,k,j,i)=uzder(l,k,j)
1587 < call unormderiv(uy(1,i),uyder(1,1,1),facy,uygrad(1,1,1,i))
1588 < call unormderiv(uy(1,i),uyder(1,1,2),facy,uygrad(1,1,2,i))
1589 < call unormderiv(uz(1,i),uzder(1,1,1),fac,uzgrad(1,1,1,i))
1590 < call unormderiv(uz(1,i),uzder(1,1,2),fac,uzgrad(1,1,2,i))
1595 > cgrad gvdwc(l,k)=gvdwc(l,k)+gg(l)
1603 > C--------------------------------------------------------------------------
1604 > subroutine eelec_soft_sphere(ees,evdw1,eel_loc,eello_turn3,
1607 > C Soft-sphere potential of p-p interaction
1609 > implicit real*8 (a-h,o-z)
1610 > include 'DIMENSIONS'
1611 > include 'COMMON.CONTROL'
1612 > include 'COMMON.IOUNITS'
1613 > include 'COMMON.GEO'
1614 > include 'COMMON.VAR'
1615 > include 'COMMON.LOCAL'
1616 > include 'COMMON.CHAIN'
1617 > include 'COMMON.DERIV'
1618 > include 'COMMON.INTERACT'
1619 > include 'COMMON.CONTACTS'
1620 > include 'COMMON.TORSION'
1621 > include 'COMMON.VECTORS'
1622 > include 'COMMON.FFIELD'
1624 > cd write(iout,*) 'In EELEC_soft_sphere'
1631 > do i=iatel_s,iatel_e
1632 > if (itype(i).eq.21 .or. itype(i+1).eq.21) cycle
1636 > xmedi=c(1,i)+0.5d0*dxi
1637 > ymedi=c(2,i)+0.5d0*dyi
1638 > zmedi=c(3,i)+0.5d0*dzi
1640 > c write (iout,*) 'i',i,' ielstart',ielstart(i),' ielend',ielend(i)
1641 > do j=ielstart(i),ielend(i)
1642 > if (itype(j).eq.21 .or. itype(j+1).eq.21) cycle
1646 > if (j.eq.i+2 .and. itelj.eq.2) iteli=2
1647 > r0ij=rpp(iteli,itelj)
1652 > xj=c(1,j)+0.5D0*dxj-xmedi
1653 > yj=c(2,j)+0.5D0*dyj-ymedi
1654 > zj=c(3,j)+0.5D0*dzj-zmedi
1655 > rij=xj*xj+yj*yj+zj*zj
1656 > if (rij.lt.r0ijsq) then
1657 > evdw1ij=0.25d0*(rij-r0ijsq)**2
1664 < if (calc_grad) then
1666 < vbld_inv_temp(1)=vbld_inv(i+1)
1667 < if (i.lt.nres-1) then
1668 < vbld_inv_temp(2)=vbld_inv(i+2)
1670 < vbld_inv_temp(2)=vbld_inv(i)
1674 > evdw1=evdw1+evdw1ij
1676 > C Calculate contributions to the Cartesian gradient.
1683 < uygrad(l,k,j,i)=vbld_inv_temp(j)*uygrad(l,k,j,i)
1684 < uzgrad(l,k,j,i)=vbld_inv_temp(j)*uzgrad(l,k,j,i)
1687 > gvdwpp(k,i)=gvdwpp(k,i)-ggg(k)
1688 > gvdwpp(k,j)=gvdwpp(k,j)+ggg(k)
1695 > * Loop over residues i+1 thru j-1.
1697 > cgrad do k=i+1,j-1
1699 > cgrad gelc(l,k)=gelc(l,k)+ggg(l)
1704 > cgrad do i=nnt,nct-1
1706 > cgrad gelc(k,i)=gelc(k,i)+0.5d0*gelc(k,i)
1708 > cgrad do j=i+1,nct-1
1710 > cgrad gelc(k,i)=gelc(k,i)+gelc(k,j)
1715 < C-----------------------------------------------------------------------------
1716 < subroutine vec_and_deriv_test
1718 > c------------------------------------------------------------------------------
1719 > subroutine vec_and_deriv
1721 < include 'DIMENSIONS.ZSCOPT'
1727 < dimension uyder(3,3,2),uzder(3,3,2)
1729 > include 'COMMON.SETUP'
1730 > include 'COMMON.TIME1'
1731 > dimension uyder(3,3,2),uzder(3,3,2),vbld_inv_temp(2)
1734 > do i=ivec_start,ivec_end
1739 < c write (iout,*) 'fac',fac,
1740 < c & 1.0d0/dsqrt(scalar(uz(1,i),uz(1,i)))
1741 < fac=1.0d0/dsqrt(scalar(uz(1,i),uz(1,i)))
1744 < uy(k,i)=fac*(dc_norm(k,i-1)-costh*dc_norm(k,i))
1747 < facy=1.0d0/dsqrt(scalar(dc_norm(1,i),dc_norm(1,i))*
1748 < & (scalar(dc_norm(1,i-1),dc_norm(1,i-1))**2-
1749 < & scalar(dc_norm(1,i),dc_norm(1,i-1))**2))
1751 < c uy(k,i)=facy*(dc_norm(k,i+1)-costh*dc_norm(k,i))
1754 < & dc_norm(k,i-1)*scalar(dc_norm(1,i),dc_norm(1,i))
1755 < & -scalar(dc_norm(1,i),dc_norm(1,i-1))*dc_norm(k,i)
1758 < c write (iout,*) 'facy',facy,
1759 < c & 1.0d0/dsqrt(scalar(uy(1,i),uy(1,i)))
1760 < facy=1.0d0/dsqrt(scalar(uy(1,i),uy(1,i)))
1762 < uy(k,i)=facy*uy(k,i)
1764 > uy(k,i)=fac*(dc_norm(k,i-1)-costh*dc_norm(k,i))
1766 < c uyder(j,j,1)=uyder(j,j,1)-costh
1767 < c uyder(j,j,2)=1.0d0+uyder(j,j,2)
1768 < uyder(j,j,1)=uyder(j,j,1)
1769 < & -scalar(dc_norm(1,i),dc_norm(1,i-1))
1770 < uyder(j,j,2)=scalar(dc_norm(1,i),dc_norm(1,i))
1773 > uyder(j,j,1)=uyder(j,j,1)-costh
1774 > uyder(j,j,2)=1.0d0+uyder(j,j,2)
1776 < fac=1.0d0/dsqrt(scalar(uz(1,i),uz(1,i)))
1778 < facy=1.0d0/dsqrt(scalar(dc_norm(1,i),dc_norm(1,i))*
1779 < & (scalar(dc_norm(1,i+1),dc_norm(1,i+1))**2-
1780 < & scalar(dc_norm(1,i),dc_norm(1,i+1))**2))
1782 < c uy(k,i)=facy*(dc_norm(k,i+1)-costh*dc_norm(k,i))
1785 < & dc_norm(k,i+1)*scalar(dc_norm(1,i),dc_norm(1,i))
1786 < & -scalar(dc_norm(1,i),dc_norm(1,i+1))*dc_norm(k,i)
1789 < c write (iout,*) 'facy',facy,
1790 < c & 1.0d0/dsqrt(scalar(uy(1,i),uy(1,i)))
1791 < facy=1.0d0/dsqrt(scalar(uy(1,i),uy(1,i)))
1793 < uy(k,i)=facy*uy(k,i)
1795 > uy(k,i)=facy*(dc_norm(k,i+1)-costh*dc_norm(k,i))
1797 < c uyder(j,j,1)=uyder(j,j,1)-costh
1798 < c uyder(j,j,2)=1.0d0+uyder(j,j,2)
1799 < uyder(j,j,1)=uyder(j,j,1)
1800 < & -scalar(dc_norm(1,i),dc_norm(1,i+1))
1801 < uyder(j,j,2)=scalar(dc_norm(1,i),dc_norm(1,i))
1804 > uyder(j,j,1)=uyder(j,j,1)-costh
1805 > uyder(j,j,2)=1.0d0+uyder(j,j,2)
1807 > vbld_inv_temp(1)=vbld_inv(i+1)
1808 > if (i.lt.nres-1) then
1809 > vbld_inv_temp(2)=vbld_inv(i+2)
1811 > vbld_inv_temp(2)=vbld_inv(i)
1814 < uygrad(l,k,j,i)=vblinv*uygrad(l,k,j,i)
1815 < uzgrad(l,k,j,i)=vblinv*uzgrad(l,k,j,i)
1817 > uygrad(l,k,j,i)=vbld_inv_temp(j)*uygrad(l,k,j,i)
1818 > uzgrad(l,k,j,i)=vbld_inv_temp(j)*uzgrad(l,k,j,i)
1820 > #if defined(PARVEC) && defined(MPI)
1821 > if (nfgtasks1.gt.1) then
1822 > time00=MPI_Wtime()
1823 > c print *,"Processor",fg_rank1,kolor1," ivec_start",ivec_start,
1824 > c & " ivec_displ",(ivec_displ(i),i=0,nfgtasks1-1),
1825 > c & " ivec_count",(ivec_count(i),i=0,nfgtasks1-1)
1826 > call MPI_Allgatherv(uy(1,ivec_start),ivec_count(fg_rank1),
1827 > & MPI_UYZ,uy(1,1),ivec_count(0),ivec_displ(0),MPI_UYZ,
1829 > call MPI_Allgatherv(uz(1,ivec_start),ivec_count(fg_rank1),
1830 > & MPI_UYZ,uz(1,1),ivec_count(0),ivec_displ(0),MPI_UYZ,
1832 > call MPI_Allgatherv(uygrad(1,1,1,ivec_start),
1833 > & ivec_count(fg_rank1),MPI_UYZGRAD,uygrad(1,1,1,1),ivec_count(0),
1834 > & ivec_displ(0),MPI_UYZGRAD,FG_COMM1,IERR)
1835 > call MPI_Allgatherv(uzgrad(1,1,1,ivec_start),
1836 > & ivec_count(fg_rank1),MPI_UYZGRAD,uzgrad(1,1,1,1),ivec_count(0),
1837 > & ivec_displ(0),MPI_UYZGRAD,FG_COMM1,IERR)
1838 > time_gather=time_gather+MPI_Wtime()-time00
1840 > c if (fg_rank.eq.0) then
1841 > c write (iout,*) "Arrays UY and UZ"
1843 > c write (iout,'(i5,3f10.5,5x,3f10.5)') i,(uy(k,i),k=1,3),
1844 > c & (uz(k,i),k=1,3)
1849 < include 'DIMENSIONS.ZSCOPT'
1851 < include 'DIMENSIONS.ZSCOPT'
1855 > include "COMMON.SETUP"
1857 > integer status(MPI_STATUS_SIZE)
1861 > do i=ivec_start+2,ivec_end+2
1866 > c if (i.gt. iatel_s+2 .and. i.lt.iatel_e+5) then
1868 < if (itype(i-2).le.ntyp) then
1869 < iti = itortyp(itype(i-2))
1874 > iti = itortyp(itype(i-2))
1876 > c if (i.gt. iatel_s+1 .and. i.lt.iatel_e+4) then
1878 < if (itype(i-1).le.ntyp) then
1879 < iti1 = itortyp(itype(i-1))
1884 > iti1 = itortyp(itype(i-1))
1886 < c print *,"itilde1 i iti iti1",i,iti,iti1
1887 < if (i .gt. iatel_s+2) then
1889 > c if (i .gt. iatel_s+2) then
1890 > if (i .gt. nnt+2) then
1892 > if (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0)
1897 < c print *,"itilde2 i iti iti1",i,iti,iti1
1899 < call matmat2(CC(1,1,iti1),Ugder(1,1,i-2),CUgder(1,1,i-2))
1900 < call matmat2(DD(1,1,iti),Ugder(1,1,i-2),DUgder(1,1,i-2))
1901 < call matmat2(Dtilde(1,1,iti),Ug2der(1,1,i-2),DtUg2der(1,1,i-2))
1902 < call matvec2(Ctilde(1,1,iti1),obrot_der(1,i-2),Ctobrder(1,i-2))
1903 < call matvec2(Dtilde(1,1,iti),obrot2_der(1,i-2),Dtobr2der(1,i-2))
1904 < c print *,"itilde3 i iti iti1",i,iti,iti1
1906 > c if (i.gt. iatel_s+1 .and. i.lt.iatel_e+4) then
1908 < if (itype(i-1).le.ntyp) then
1909 < iti1 = itortyp(itype(i-1))
1914 > iti1 = itortyp(itype(i-1))
1916 > cd write (iout,*) 'mu ',mu(:,i-2)
1917 > cd write (iout,*) 'mu1',mu1(:,i-2)
1918 > cd write (iout,*) 'mu2',mu2(:,i-2)
1919 > if (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or.wcorr6.gt.0.0d0)
1921 > call matmat2(CC(1,1,iti1),Ugder(1,1,i-2),CUgder(1,1,i-2))
1922 > call matmat2(DD(1,1,iti),Ugder(1,1,i-2),DUgder(1,1,i-2))
1923 > call matmat2(Dtilde(1,1,iti),Ug2der(1,1,i-2),DtUg2der(1,1,i-2))
1924 > call matvec2(Ctilde(1,1,iti1),obrot_der(1,i-2),Ctobrder(1,i-2))
1925 > call matvec2(Dtilde(1,1,iti),obrot2_der(1,i-2),Dtobr2der(1,i-2))
1927 < cd write (iout,*) 'i',i,' mu ',(mu(k,i-2),k=1,2),
1928 < cd & ' mu1',(b1(k,i-2),k=1,2),' mu2',(Ub2(k,i-2),k=1,2)
1932 > if (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or.wcorr6.gt.0.0d0)
1934 > c do i=max0(ivec_start,2),ivec_end
1937 > #if defined(MPI) && defined(PARMAT)
1939 > c if (fg_rank.eq.0) then
1940 > write (iout,*) "Arrays UG and UGDER before GATHER"
1942 > write (iout,'(i5,4f10.5,5x,4f10.5)') i,
1943 > & ((ug(l,k,i),l=1,2),k=1,2),
1944 > & ((ugder(l,k,i),l=1,2),k=1,2)
1946 > write (iout,*) "Arrays UG2 and UG2DER"
1948 > write (iout,'(i5,4f10.5,5x,4f10.5)') i,
1949 > & ((ug2(l,k,i),l=1,2),k=1,2),
1950 > & ((ug2der(l,k,i),l=1,2),k=1,2)
1952 > write (iout,*) "Arrays OBROT OBROT2 OBROTDER and OBROT2DER"
1954 > write (iout,'(i5,4f10.5,5x,4f10.5)') i,
1955 > & (obrot(k,i),k=1,2),(obrot2(k,i),k=1,2),
1956 > & (obrot_der(k,i),k=1,2),(obrot2_der(k,i),k=1,2)
1958 > write (iout,*) "Arrays COSTAB SINTAB COSTAB2 and SINTAB2"
1960 > write (iout,'(i5,4f10.5,5x,4f10.5)') i,
1961 > & costab(i),sintab(i),costab2(i),sintab2(i)
1963 > write (iout,*) "Array MUDER"
1965 > write (iout,'(i5,2f10.5)') i,muder(1,i),muder(2,i)
1969 > if (nfgtasks.gt.1) then
1970 > time00=MPI_Wtime()
1971 > c write(iout,*)"Processor",fg_rank,kolor," ivec_start",ivec_start,
1972 > c & " ivec_displ",(ivec_displ(i),i=0,nfgtasks-1),
1973 > c & " ivec_count",(ivec_count(i),i=0,nfgtasks-1)
1975 > call MPI_Allgatherv(Ub2(1,ivec_start),ivec_count(fg_rank1),
1976 > & MPI_MU,Ub2(1,1),ivec_count(0),ivec_displ(0),MPI_MU,
1978 > call MPI_Allgatherv(Ub2der(1,ivec_start),ivec_count(fg_rank1),
1979 > & MPI_MU,Ub2der(1,1),ivec_count(0),ivec_displ(0),MPI_MU,
1981 > call MPI_Allgatherv(mu(1,ivec_start),ivec_count(fg_rank1),
1982 > & MPI_MU,mu(1,1),ivec_count(0),ivec_displ(0),MPI_MU,
1984 > call MPI_Allgatherv(muder(1,ivec_start),ivec_count(fg_rank1),
1985 > & MPI_MU,muder(1,1),ivec_count(0),ivec_displ(0),MPI_MU,
1987 > call MPI_Allgatherv(Eug(1,1,ivec_start),ivec_count(fg_rank1),
1988 > & MPI_MAT1,Eug(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,
1990 > call MPI_Allgatherv(Eugder(1,1,ivec_start),ivec_count(fg_rank1),
1991 > & MPI_MAT1,Eugder(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,
1993 > call MPI_Allgatherv(costab(ivec_start),ivec_count(fg_rank1),
1994 > & MPI_DOUBLE_PRECISION,costab(1),ivec_count(0),ivec_displ(0),
1995 > & MPI_DOUBLE_PRECISION,FG_COMM1,IERR)
1996 > call MPI_Allgatherv(sintab(ivec_start),ivec_count(fg_rank1),
1997 > & MPI_DOUBLE_PRECISION,sintab(1),ivec_count(0),ivec_displ(0),
1998 > & MPI_DOUBLE_PRECISION,FG_COMM1,IERR)
1999 > call MPI_Allgatherv(costab2(ivec_start),ivec_count(fg_rank1),
2000 > & MPI_DOUBLE_PRECISION,costab2(1),ivec_count(0),ivec_displ(0),
2001 > & MPI_DOUBLE_PRECISION,FG_COMM1,IERR)
2002 > call MPI_Allgatherv(sintab2(ivec_start),ivec_count(fg_rank1),
2003 > & MPI_DOUBLE_PRECISION,sintab2(1),ivec_count(0),ivec_displ(0),
2004 > & MPI_DOUBLE_PRECISION,FG_COMM1,IERR)
2005 > if (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0)
2007 > call MPI_Allgatherv(Ctobr(1,ivec_start),ivec_count(fg_rank1),
2008 > & MPI_MU,Ctobr(1,1),ivec_count(0),ivec_displ(0),MPI_MU,
2010 > call MPI_Allgatherv(Ctobrder(1,ivec_start),ivec_count(fg_rank1),
2011 > & MPI_MU,Ctobrder(1,1),ivec_count(0),ivec_displ(0),MPI_MU,
2013 > call MPI_Allgatherv(Dtobr2(1,ivec_start),ivec_count(fg_rank1),
2014 > & MPI_MU,Dtobr2(1,1),ivec_count(0),ivec_displ(0),MPI_MU,
2016 > call MPI_Allgatherv(Dtobr2der(1,ivec_start),ivec_count(fg_rank1),
2017 > & MPI_MU,Dtobr2der(1,1),ivec_count(0),ivec_displ(0),MPI_MU,
2019 > call MPI_Allgatherv(Ug2Db1t(1,ivec_start),ivec_count(fg_rank1),
2020 > & MPI_MU,Ug2Db1t(1,1),ivec_count(0),ivec_displ(0),MPI_MU,
2022 > call MPI_Allgatherv(Ug2Db1tder(1,ivec_start),
2023 > & ivec_count(fg_rank1),
2024 > & MPI_MU,Ug2Db1tder(1,1),ivec_count(0),ivec_displ(0),MPI_MU,
2026 > call MPI_Allgatherv(CUgb2(1,ivec_start),ivec_count(fg_rank1),
2027 > & MPI_MU,CUgb2(1,1),ivec_count(0),ivec_displ(0),MPI_MU,
2029 > call MPI_Allgatherv(CUgb2der(1,ivec_start),ivec_count(fg_rank1),
2030 > & MPI_MU,CUgb2der(1,1),ivec_count(0),ivec_displ(0),MPI_MU,
2032 > call MPI_Allgatherv(Cug(1,1,ivec_start),ivec_count(fg_rank1),
2033 > & MPI_MAT1,Cug(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,
2035 > call MPI_Allgatherv(Cugder(1,1,ivec_start),ivec_count(fg_rank1),
2036 > & MPI_MAT1,Cugder(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,
2038 > call MPI_Allgatherv(Dug(1,1,ivec_start),ivec_count(fg_rank1),
2039 > & MPI_MAT1,Dug(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,
2041 > call MPI_Allgatherv(Dugder(1,1,ivec_start),ivec_count(fg_rank1),
2042 > & MPI_MAT1,Dugder(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,
2044 > call MPI_Allgatherv(Dtug2(1,1,ivec_start),ivec_count(fg_rank1),
2045 > & MPI_MAT1,Dtug2(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,
2047 > call MPI_Allgatherv(Dtug2der(1,1,ivec_start),
2048 > & ivec_count(fg_rank1),
2049 > & MPI_MAT1,Dtug2der(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,
2051 > call MPI_Allgatherv(EugC(1,1,ivec_start),ivec_count(fg_rank1),
2052 > & MPI_MAT1,EugC(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,
2054 > call MPI_Allgatherv(EugCder(1,1,ivec_start),ivec_count(fg_rank1),
2055 > & MPI_MAT1,EugCder(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,
2057 > call MPI_Allgatherv(EugD(1,1,ivec_start),ivec_count(fg_rank1),
2058 > & MPI_MAT1,EugD(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,
2060 > call MPI_Allgatherv(EugDder(1,1,ivec_start),ivec_count(fg_rank1),
2061 > & MPI_MAT1,EugDder(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,
2063 > call MPI_Allgatherv(DtUg2EUg(1,1,ivec_start),
2064 > & ivec_count(fg_rank1),
2065 > & MPI_MAT1,DtUg2EUg(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,
2067 > call MPI_Allgatherv(Ug2DtEUg(1,1,ivec_start),
2068 > & ivec_count(fg_rank1),
2069 > & MPI_MAT1,Ug2DtEUg(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,
2071 > call MPI_Allgatherv(DtUg2EUgder(1,1,1,ivec_start),
2072 > & ivec_count(fg_rank1),
2073 > & MPI_MAT2,DtUg2EUgder(1,1,1,1),ivec_count(0),ivec_displ(0),
2074 > & MPI_MAT2,FG_COMM1,IERR)
2075 > call MPI_Allgatherv(Ug2DtEUgder(1,1,1,ivec_start),
2076 > & ivec_count(fg_rank1),
2077 > & MPI_MAT2,Ug2DtEUgder(1,1,1,1),ivec_count(0),ivec_displ(0),
2078 > & MPI_MAT2,FG_COMM1,IERR)
2081 > c Passes matrix info through the ring
2084 > if (irecv.lt.0) irecv=nfgtasks1-1
2087 > if (inext.ge.nfgtasks1) inext=0
2088 > do i=1,nfgtasks1-1
2089 > c write (iout,*) "isend",isend," irecv",irecv
2090 > c call flush(iout)
2091 > lensend=lentyp(isend)
2092 > lenrecv=lentyp(irecv)
2093 > c write (iout,*) "lensend",lensend," lenrecv",lenrecv
2094 > c call MPI_SENDRECV(ug(1,1,ivec_displ(isend)+1),1,
2095 > c & MPI_ROTAT1(lensend),inext,2200+isend,
2096 > c & ug(1,1,ivec_displ(irecv)+1),1,MPI_ROTAT1(lenrecv),
2097 > c & iprev,2200+irecv,FG_COMM,status,IERR)
2098 > c write (iout,*) "Gather ROTAT1"
2099 > c call flush(iout)
2100 > c call MPI_SENDRECV(obrot(1,ivec_displ(isend)+1),1,
2101 > c & MPI_ROTAT2(lensend),inext,3300+isend,
2102 > c & obrot(1,ivec_displ(irecv)+1),1,MPI_ROTAT2(lenrecv),
2103 > c & iprev,3300+irecv,FG_COMM,status,IERR)
2104 > c write (iout,*) "Gather ROTAT2"
2105 > c call flush(iout)
2106 > call MPI_SENDRECV(costab(ivec_displ(isend)+1),1,
2107 > & MPI_ROTAT_OLD(lensend),inext,4400+isend,
2108 > & costab(ivec_displ(irecv)+1),1,MPI_ROTAT_OLD(lenrecv),
2109 > & iprev,4400+irecv,FG_COMM,status,IERR)
2110 > c write (iout,*) "Gather ROTAT_OLD"
2111 > c call flush(iout)
2112 > call MPI_SENDRECV(mu(1,ivec_displ(isend)+1),1,
2113 > & MPI_PRECOMP11(lensend),inext,5500+isend,
2114 > & mu(1,ivec_displ(irecv)+1),1,MPI_PRECOMP11(lenrecv),
2115 > & iprev,5500+irecv,FG_COMM,status,IERR)
2116 > c write (iout,*) "Gather PRECOMP11"
2117 > c call flush(iout)
2118 > call MPI_SENDRECV(Eug(1,1,ivec_displ(isend)+1),1,
2119 > & MPI_PRECOMP12(lensend),inext,6600+isend,
2120 > & Eug(1,1,ivec_displ(irecv)+1),1,MPI_PRECOMP12(lenrecv),
2121 > & iprev,6600+irecv,FG_COMM,status,IERR)
2122 > c write (iout,*) "Gather PRECOMP12"
2123 > c call flush(iout)
2124 > if (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0)
2126 > call MPI_SENDRECV(ug2db1t(1,ivec_displ(isend)+1),1,
2127 > & MPI_ROTAT2(lensend),inext,7700+isend,
2128 > & ug2db1t(1,ivec_displ(irecv)+1),1,MPI_ROTAT2(lenrecv),
2129 > & iprev,7700+irecv,FG_COMM,status,IERR)
2130 > c write (iout,*) "Gather PRECOMP21"
2131 > c call flush(iout)
2132 > call MPI_SENDRECV(EUgC(1,1,ivec_displ(isend)+1),1,
2133 > & MPI_PRECOMP22(lensend),inext,8800+isend,
2134 > & EUgC(1,1,ivec_displ(irecv)+1),1,MPI_PRECOMP22(lenrecv),
2135 > & iprev,8800+irecv,FG_COMM,status,IERR)
2136 > c write (iout,*) "Gather PRECOMP22"
2137 > c call flush(iout)
2138 > call MPI_SENDRECV(Ug2DtEUgder(1,1,1,ivec_displ(isend)+1),1,
2139 > & MPI_PRECOMP23(lensend),inext,9900+isend,
2140 > & Ug2DtEUgder(1,1,1,ivec_displ(irecv)+1),1,
2141 > & MPI_PRECOMP23(lenrecv),
2142 > & iprev,9900+irecv,FG_COMM,status,IERR)
2143 > c write (iout,*) "Gather PRECOMP23"
2144 > c call flush(iout)
2148 > if (irecv.lt.0) irecv=nfgtasks1-1
2151 > time_gather=time_gather+MPI_Wtime()-time00
2154 > c if (fg_rank.eq.0) then
2155 > write (iout,*) "Arrays UG and UGDER"
2157 > write (iout,'(i5,4f10.5,5x,4f10.5)') i,
2158 > & ((ug(l,k,i),l=1,2),k=1,2),
2159 > & ((ugder(l,k,i),l=1,2),k=1,2)
2161 > write (iout,*) "Arrays UG2 and UG2DER"
2163 > write (iout,'(i5,4f10.5,5x,4f10.5)') i,
2164 > & ((ug2(l,k,i),l=1,2),k=1,2),
2165 > & ((ug2der(l,k,i),l=1,2),k=1,2)
2167 > write (iout,*) "Arrays OBROT OBROT2 OBROTDER and OBROT2DER"
2169 > write (iout,'(i5,4f10.5,5x,4f10.5)') i,
2170 > & (obrot(k,i),k=1,2),(obrot2(k,i),k=1,2),
2171 > & (obrot_der(k,i),k=1,2),(obrot2_der(k,i),k=1,2)
2173 > write (iout,*) "Arrays COSTAB SINTAB COSTAB2 and SINTAB2"
2175 > write (iout,'(i5,4f10.5,5x,4f10.5)') i,
2176 > & costab(i),sintab(i),costab2(i),sintab2(i)
2178 > write (iout,*) "Array MUDER"
2180 > write (iout,'(i5,2f10.5)') i,muder(1,i),muder(2,i)
2190 < include 'DIMENSIONS.ZSCOPT'
2192 > include 'COMMON.SETUP'
2194 > include 'COMMON.TIME1'
2196 < common /locel/ a_temp,agg,aggi,aggi1,aggj,aggj1,j1
2198 > common /locel/ a_temp,agg,aggi,aggi1,aggj,aggj1,a22,a23,a32,a33,
2199 > & dxi,dyi,dzi,dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,
2203 > double precision scal_el /1.0d0/
2208 < cd if (wel_loc.gt.0.0d0) then
2209 < if (icheckgrad.eq.1) then
2210 < call vec_and_deriv_test
2212 < call vec_and_deriv
2215 > c call vec_and_deriv
2217 > time01=MPI_Wtime()
2221 > time_mat=time_mat+MPI_Wtime()-time01
2224 < cd write (iout,'(i5,2f10.5)') k,uy(k,i),uz(k,i)
2226 > cd write (iout,'(i5,2f10.5)') k,uy(k,i),uz(k,i)
2234 > c 9/27/08 AL Split the interaction loop to ensure load balancing of turn terms
2236 > C Loop over i,i+2 and i,i+3 pairs of the peptide groups
2238 > do i=iturn3_start,iturn3_end
2239 > if (itype(i).eq.21 .or. itype(i+1).eq.21
2240 > & .or. itype(i+2).eq.21 .or. itype(i+3).eq.21) cycle
2244 > dx_normi=dc_norm(1,i)
2245 > dy_normi=dc_norm(2,i)
2246 > dz_normi=dc_norm(3,i)
2247 > xmedi=c(1,i)+0.5d0*dxi
2248 > ymedi=c(2,i)+0.5d0*dyi
2249 > zmedi=c(3,i)+0.5d0*dzi
2251 > call eelecij(i,i+2,ees,evdw1,eel_loc)
2252 > if (wturn3.gt.0.0d0) call eturn3(i,eello_turn3)
2253 > num_cont_hb(i)=num_conti
2255 > do i=iturn4_start,iturn4_end
2256 > if (itype(i).eq.21 .or. itype(i+1).eq.21
2257 > & .or. itype(i+3).eq.21
2258 > & .or. itype(i+4).eq.21) cycle
2262 > dx_normi=dc_norm(1,i)
2263 > dy_normi=dc_norm(2,i)
2264 > dz_normi=dc_norm(3,i)
2265 > xmedi=c(1,i)+0.5d0*dxi
2266 > ymedi=c(2,i)+0.5d0*dyi
2267 > zmedi=c(3,i)+0.5d0*dzi
2268 > num_conti=num_cont_hb(i)
2269 > call eelecij(i,i+3,ees,evdw1,eel_loc)
2270 > if (wturn4.gt.0.0d0 .and. itype(i+2).ne.21)
2271 > & call eturn4(i,eello_turn4)
2272 > num_cont_hb(i)=num_conti
2275 > c Loop over all pairs of interacting peptide groups except i,i+2 and i,i+3
2278 < if (itel(i).eq.0) goto 1215
2282 > num_conti=num_cont_hb(i)
2284 > c write (iout,*) i,j,itype(i),itype(j)
2286 < if (itel(j).eq.0) goto 1216
2289 > call eelecij(i,j,ees,evdw1,eel_loc)
2291 > num_cont_hb(i)=num_conti
2293 > c write (iout,*) "Number of loop steps in EELEC:",ind
2295 > cd write (iout,'(i3,3f10.5,5x,3f10.5)')
2296 > cd & i,(gel_loc(k,i),k=1,3),gel_loc_loc(i)
2298 > c 12/7/99 Adam eello_turn3 will be considered as a separate energy term
2299 > ccc eel_loc=eel_loc+eello_turn3
2300 > cd print *,"Processor",fg_rank," t_eelecij",t_eelecij
2303 > C-------------------------------------------------------------------------------
2304 > subroutine eelecij(i,j,ees,evdw1,eel_loc)
2305 > implicit real*8 (a-h,o-z)
2306 > include 'DIMENSIONS'
2310 > include 'COMMON.CONTROL'
2311 > include 'COMMON.IOUNITS'
2312 > include 'COMMON.GEO'
2313 > include 'COMMON.VAR'
2314 > include 'COMMON.LOCAL'
2315 > include 'COMMON.CHAIN'
2316 > include 'COMMON.DERIV'
2317 > include 'COMMON.INTERACT'
2318 > include 'COMMON.CONTACTS'
2319 > include 'COMMON.TORSION'
2320 > include 'COMMON.VECTORS'
2321 > include 'COMMON.FFIELD'
2322 > include 'COMMON.TIME1'
2323 > dimension ggg(3),gggp(3),gggm(3),erij(3),dcosb(3),dcosg(3),
2324 > & erder(3,3),uryg(3,3),urzg(3,3),vryg(3,3),vrzg(3,3)
2325 > double precision acipa(2,2),agg(3,4),aggi(3,4),aggi1(3,4),
2326 > & aggj(3,4),aggj1(3,4),a_temp(2,2),muij(4)
2327 > common /locel/ a_temp,agg,aggi,aggi1,aggj,aggj1,a22,a23,a32,a33,
2328 > & dxi,dyi,dzi,dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,
2330 > c 4/26/02 - AL scaling factor for 1,4 repulsive VDW interactions
2332 > double precision scal_el /1.0d0/
2334 > double precision scal_el /0.5d0/
2337 > C 13-go grudnia roku pamietnego...
2338 > double precision unmat(3,3) /1.0d0,0.0d0,0.0d0,
2339 > & 0.0d0,1.0d0,0.0d0,
2340 > & 0.0d0,0.0d0,1.0d0/
2341 > c time00=MPI_Wtime()
2342 > cd write (iout,*) "eelecij",i,j
2345 < C Diagnostics only!!!
2352 < c write (iout,*) "i",i,iteli," j",j,itelj," eesij",eesij
2355 > if (energy_dec) then
2356 > write (iout,'(a6,2i5,0pf7.3)') 'evdw1',i,j,evdwij
2357 > write (iout,'(a6,2i5,0pf7.3)') 'ees',i,j,eesij
2361 < facvdw=-6*rrmij*(ev1+evdwij)
2363 > facvdw=-6*rrmij*(ev1+evdwij)
2365 < if (calc_grad) then
2372 > c ghalf=0.5D0*ggg(k)
2373 > c gelc(k,i)=gelc(k,i)+ghalf
2374 > c gelc(k,j)=gelc(k,j)+ghalf
2376 > c 9/28/08 AL Gradient compotents will be summed only at the end
2378 < ghalf=0.5D0*ggg(k)
2379 < gelc(k,i)=gelc(k,i)+ghalf
2380 < gelc(k,j)=gelc(k,j)+ghalf
2382 > gelc_long(k,j)=gelc_long(k,j)+ggg(k)
2383 > gelc_long(k,i)=gelc_long(k,i)-ggg(k)
2387 < gelc(l,k)=gelc(l,k)+ggg(l)
2391 > cgrad do k=i+1,j-1
2393 > cgrad gelc(l,k)=gelc(l,k)+ggg(l)
2398 > c ghalf=0.5D0*ggg(k)
2399 > c gvdwpp(k,i)=gvdwpp(k,i)+ghalf
2400 > c gvdwpp(k,j)=gvdwpp(k,j)+ghalf
2402 > c 9/28/08 AL Gradient compotents will be summed only at the end
2404 < ghalf=0.5D0*ggg(k)
2405 < gvdwpp(k,i)=gvdwpp(k,i)+ghalf
2406 < gvdwpp(k,j)=gvdwpp(k,j)+ghalf
2408 > gvdwpp(k,j)=gvdwpp(k,j)+ggg(k)
2409 > gvdwpp(k,i)=gvdwpp(k,i)-ggg(k)
2413 < gvdwpp(l,k)=gvdwpp(l,k)+ggg(l)
2417 > cgrad do k=i+1,j-1
2419 > cgrad gvdwpp(l,k)=gvdwpp(l,k)+ggg(l)
2423 < if (calc_grad) then
2426 > c ghalf=0.5D0*ggg(k)
2427 > c gelc(k,i)=gelc(k,i)+ghalf
2428 > c gelc(k,j)=gelc(k,j)+ghalf
2430 > c 9/28/08 AL Gradient compotents will be summed only at the end
2432 < ghalf=0.5D0*ggg(k)
2433 < gelc(k,i)=gelc(k,i)+ghalf
2434 < gelc(k,j)=gelc(k,j)+ghalf
2436 > gelc_long(k,j)=gelc(k,j)+ggg(k)
2437 > gelc_long(k,i)=gelc(k,i)-ggg(k)
2441 < gelc(l,k)=gelc(l,k)+ggg(l)
2444 > cgrad do k=i+1,j-1
2446 > cgrad gelc(l,k)=gelc(l,k)+ggg(l)
2449 > c 9/28/08 AL Gradient compotents will be summed only at the end
2454 > gvdwpp(k,j)=gvdwpp(k,j)+ggg(k)
2455 > gvdwpp(k,i)=gvdwpp(k,i)-ggg(k)
2458 > c ghalf=0.5D0*ggg(k)
2459 > c gelc(k,i)=gelc(k,i)+ghalf
2460 > c & +(ecosa*(dc_norm(k,j)-cosa*dc_norm(k,i))
2461 > c & + ecosb*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1)
2462 > c gelc(k,j)=gelc(k,j)+ghalf
2463 > c & +(ecosa*(dc_norm(k,i)-cosa*dc_norm(k,j))
2464 > c & + ecosg*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)
2466 > cgrad do k=i+1,j-1
2468 > cgrad gelc(l,k)=gelc(l,k)+ggg(l)
2472 < ghalf=0.5D0*ggg(k)
2473 < gelc(k,i)=gelc(k,i)+ghalf
2475 > gelc(k,i)=gelc(k,i)
2477 < gelc(k,j)=gelc(k,j)+ghalf
2479 > gelc(k,j)=gelc(k,j)
2481 > gelc_long(k,j)=gelc_long(k,j)+ggg(k)
2482 > gelc_long(k,i)=gelc_long(k,i)-ggg(k)
2486 < gelc(l,k)=gelc(l,k)+ggg(l)
2492 < C For diagnostics only
2498 < cd write (2,*) 'fac=',fac
2499 < C For diagnostics only
2502 < cd write (iout,'(2(3f10.5,5x)/2(3f10.5,5x))') (uy(k,i),k=1,3),
2503 < cd & (uz(k,i),k=1,3),(uy(k,j),k=1,3),(uz(k,j),k=1,3)
2505 > cd write (iout,'(2(3f10.5,5x)/2(3f10.5,5x))') uy(:,i),uz(:,i),
2506 > cd & uy(:,j),uz(:,j)
2508 < cd write (iout,'(2i3,9f10.5/)') i,j,
2510 > cd write (iout,'(9f10.5/)')
2512 < if (calc_grad) then
2514 < call unormderiv(erij(1),unmat(1,1),rmij,erder(1,1))
2517 < cd erder(k,l)=0.0d0
2521 > call unormderiv(erij(1),unmat(1,1),rmij,erder(1,1))
2525 < cd uryg(k,l)=0.0d0
2526 < cd urzg(k,l)=0.0d0
2527 < cd vryg(k,l)=0.0d0
2528 < cd vrzg(k,l)=0.0d0
2537 < ghalf1=0.5d0*agg(k,1)
2538 < ghalf2=0.5d0*agg(k,2)
2539 < ghalf3=0.5d0*agg(k,3)
2540 < ghalf4=0.5d0*agg(k,4)
2542 > cgrad ghalf1=0.5d0*agg(k,1)
2543 > cgrad ghalf2=0.5d0*agg(k,2)
2544 > cgrad ghalf3=0.5d0*agg(k,3)
2545 > cgrad ghalf4=0.5d0*agg(k,4)
2547 < & -3.0d0*uryg(k,2)*vry)+ghalf1
2549 > & -3.0d0*uryg(k,2)*vry)!+ghalf1
2551 < & -3.0d0*uryg(k,2)*vrz)+ghalf2
2553 > & -3.0d0*uryg(k,2)*vrz)!+ghalf2
2555 < & -3.0d0*urzg(k,2)*vry)+ghalf3
2557 > & -3.0d0*urzg(k,2)*vry)!+ghalf3
2559 < & -3.0d0*urzg(k,2)*vrz)+ghalf4
2561 > & -3.0d0*urzg(k,2)*vrz)!+ghalf4
2563 < & -3.0d0*uryg(k,3)*vry)+agg(k,1)
2565 > & -3.0d0*uryg(k,3)*vry)!+agg(k,1)
2567 < & -3.0d0*uryg(k,3)*vrz)+agg(k,2)
2569 > & -3.0d0*uryg(k,3)*vrz)!+agg(k,2)
2571 < & -3.0d0*urzg(k,3)*vry)+agg(k,3)
2573 > & -3.0d0*urzg(k,3)*vry)!+agg(k,3)
2575 < & -3.0d0*urzg(k,3)*vrz)+agg(k,4)
2577 > & -3.0d0*urzg(k,3)*vrz)!+agg(k,4)
2579 < & -3.0d0*vryg(k,2)*ury)+ghalf1
2581 > & -3.0d0*vryg(k,2)*ury)!+ghalf1
2583 < & -3.0d0*vrzg(k,2)*ury)+ghalf2
2585 > & -3.0d0*vrzg(k,2)*ury)!+ghalf2
2587 < & -3.0d0*vryg(k,2)*urz)+ghalf3
2589 > & -3.0d0*vryg(k,2)*urz)!+ghalf3
2591 < & -3.0d0*vrzg(k,2)*urz)+ghalf4
2593 > & -3.0d0*vrzg(k,2)*urz)!+ghalf4
2595 < cd aggi(k,1)=ghalf1
2596 < cd aggi(k,2)=ghalf2
2597 < cd aggi(k,3)=ghalf3
2598 < cd aggi(k,4)=ghalf4
2599 < C Derivatives in DC(i+1)
2600 < cd aggi1(k,1)=agg(k,1)
2601 < cd aggi1(k,2)=agg(k,2)
2602 < cd aggi1(k,3)=agg(k,3)
2603 < cd aggi1(k,4)=agg(k,4)
2604 < C Derivatives in DC(j)
2605 < cd aggj(k,1)=ghalf1
2606 < cd aggj(k,2)=ghalf2
2607 < cd aggj(k,3)=ghalf3
2608 < cd aggj(k,4)=ghalf4
2609 < C Derivatives in DC(j+1)
2610 < cd aggj1(k,1)=0.0d0
2611 < cd aggj1(k,2)=0.0d0
2612 < cd aggj1(k,3)=0.0d0
2613 < cd aggj1(k,4)=0.0d0
2614 < if (j.eq.nres-1 .and. i.lt.j-2) then
2616 < aggj1(k,l)=aggj1(k,l)+agg(k,l)
2617 < cd aggj1(k,l)=agg(k,l)
2621 > cgrad if (j.eq.nres-1 .and. i.lt.j-2) then
2623 > cgrad aggj1(k,l)=aggj1(k,l)+agg(k,l)
2629 < C Check the loc-el terms by numerical integration
2633 < cd write (iout,*) a22,muij(1),a23,muij(2),a32,muij(3)
2636 > if (energy_dec) write (iout,'(a6,2i5,0pf7.3)')
2637 > & 'eelloc',i,j,eel_loc_ij
2640 < if (calc_grad) then
2642 < cd call checkint3(i,j,mu1,mu2,a22,a23,a32,a33,acipa,eel_loc_ij)
2643 < cd write(iout,*) 'agg ',agg
2644 < cd write(iout,*) 'aggi ',aggi
2645 < cd write(iout,*) 'aggi1',aggi1
2646 < cd write(iout,*) 'aggj ',aggj
2647 < cd write(iout,*) 'aggj1',aggj1
2653 < gel_loc(l,k)=gel_loc(l,k)+ggg(l)
2657 > gel_loc_long(l,j)=gel_loc_long(l,j)+ggg(l)
2658 > gel_loc_long(l,i)=gel_loc_long(l,i)-ggg(l)
2659 > cgrad ghalf=0.5d0*ggg(l)
2660 > cgrad gel_loc(l,i)=gel_loc(l,i)+ghalf
2661 > cgrad gel_loc(l,j)=gel_loc(l,j)+ghalf
2665 > cgrad gel_loc(l,k)=gel_loc(l,k)+ggg(l)
2671 < if (wturn3.gt.0.0d0 .or. wturn4.gt.0.0d0) then
2672 < C Contributions from turns
2677 < call eturn34(i,j,eello_turn3,eello_turn4)
2680 < if (j.gt.i+1 .and. num_conti.le.maxconts) then
2682 > c if (j.gt.i+1 .and. num_conti.le.maxconts) then
2683 > if (wcorr+wcorr4+wcorr5+wcorr6.gt.0.0d0
2684 > & .and. num_conti.le.maxconts) then
2685 > c write (iout,*) i,j," entered corr"
2687 > cd write (iout,*) "i",i," j",j," num_conti",num_conti,
2688 > cd & " jcont_hb",jcont_hb(num_conti,i)
2690 < c if (i.eq.1) then
2691 < c a_chuj(1,1,num_conti,i)=-0.61d0
2692 < c a_chuj(1,2,num_conti,i)= 0.4d0
2693 < c a_chuj(2,1,num_conti,i)= 0.65d0
2694 < c a_chuj(2,2,num_conti,i)= 0.50d0
2695 < c else if (i.eq.2) then
2696 < c a_chuj(1,1,num_conti,i)= 0.0d0
2697 < c a_chuj(1,2,num_conti,i)= 0.0d0
2698 < c a_chuj(2,1,num_conti,i)= 0.0d0
2699 < c a_chuj(2,2,num_conti,i)= 0.0d0
2701 < C --- and its gradients
2702 < cd write (iout,*) 'i',i,' j',j
2704 < cd write (iout,*) 'iii 1 kkk',kkk
2705 < cd write (iout,*) agg(kkk,:)
2708 < cd write (iout,*) 'iii 2 kkk',kkk
2709 < cd write (iout,*) aggi(kkk,:)
2712 < cd write (iout,*) 'iii 3 kkk',kkk
2713 < cd write (iout,*) aggi1(kkk,:)
2716 < cd write (iout,*) 'iii 4 kkk',kkk
2717 < cd write (iout,*) aggj(kkk,:)
2720 < cd write (iout,*) 'iii 5 kkk',kkk
2721 < cd write (iout,*) aggj1(kkk,:)
2725 < c a_chuj_der(k,l,m,mm,num_conti,i)=0.0d0
2728 < ees0pij=dsqrt(4.0D0+cosa4+wij*wij-3.0D0*cosbg1*cosbg1)
2729 < ees0mij=dsqrt(4.0D0-cosa4+wij*wij-3.0D0*cosbg2*cosbg2)
2731 > c ees0pij=dsqrt(4.0D0+cosa4+wij*wij-3.0D0*cosbg1*cosbg1)
2732 > ees0tmp=4.0D0+cosa4+wij*wij-3.0D0*cosbg1*cosbg1
2733 > if (ees0tmp.gt.0) then
2734 > ees0pij=dsqrt(ees0tmp)
2738 > c ees0mij=dsqrt(4.0D0-cosa4+wij*wij-3.0D0*cosbg2*cosbg2)
2739 > ees0tmp=4.0D0-cosa4+wij*wij-3.0D0*cosbg2*cosbg2
2740 > if (ees0tmp.gt.0) then
2741 > ees0mij=dsqrt(ees0tmp)
2746 < c write (iout,*) 'i=',i,' j=',j,' rij=',rij,' r0ij=',r0ij,
2747 < c & ' ees0ij=',ees0p(num_conti,i),ees0m(num_conti,i),' fcont=',fcont
2748 < facont_hb(num_conti,i)=fcont
2749 < if (calc_grad) then
2751 > c write (iout,*) 'i=',i,' j=',j,' rij=',rij,' r0ij=',r0ij,
2752 > c & ' ees0ij=',ees0p(num_conti,i),ees0m(num_conti,i),' fcont=',fcont
2754 > facont_hb(num_conti,i)=fcont
2756 < ghalfp=0.5D0*gggp(k)
2757 < ghalfm=0.5D0*gggm(k)
2758 < gacontp_hb1(k,num_conti,i)=ghalfp
2761 > c 10/24/08 cgrad and ! comments indicate the parts of the code removed
2762 > c following the change of gradient-summation algorithm.
2764 > cgrad ghalfp=0.5D0*gggp(k)
2765 > cgrad ghalfm=0.5D0*gggm(k)
2766 > gacontp_hb1(k,num_conti,i)=!ghalfp
2768 < gacontp_hb2(k,num_conti,i)=ghalfp
2770 > gacontp_hb2(k,num_conti,i)=!ghalfp
2772 < gacontm_hb1(k,num_conti,i)=ghalfm
2774 > gacontm_hb1(k,num_conti,i)=!ghalfm
2776 < gacontm_hb2(k,num_conti,i)=ghalfm
2778 > gacontm_hb2(k,num_conti,i)=!ghalfm
2784 < num_cont_hb(i)=num_conti
2788 < cd write (iout,'(i3,3f10.5,5x,3f10.5)')
2789 < cd & i,(gel_loc(k,i),k=1,3),gel_loc_loc(i)
2791 < c 12/7/99 Adam eello_turn3 will be considered as a separate energy term
2792 < ccc eel_loc=eel_loc+eello_turn3
2794 > if (wturn3.gt.0.0d0 .or. wturn4.gt.0.0d0) then
2797 > ghalf=0.5d0*agg(l,k)
2798 > aggi(l,k)=aggi(l,k)+ghalf
2799 > aggi1(l,k)=aggi1(l,k)+agg(l,k)
2800 > aggj(l,k)=aggj(l,k)+ghalf
2803 > if (j.eq.nres-1 .and. i.lt.j-2) then
2806 > aggj1(l,k)=aggj1(l,k)+agg(l,k)
2811 > c t_eelecij=t_eelecij+MPI_Wtime()-time00
2813 < subroutine eturn34(i,j,eello_turn3,eello_turn4)
2815 > subroutine eturn3(i,eello_turn3)
2817 < include 'DIMENSIONS.ZSCOPT'
2819 > include 'COMMON.CONTROL'
2821 < & aggj(3,4),aggj1(3,4),a_temp(2,2)
2822 < common /locel/ a_temp,agg,aggi,aggi1,aggj,aggj1,j1,j2
2823 < if (j.eq.i+2) then
2825 > & aggj(3,4),aggj1(3,4),a_temp(2,2),auxmat3(2,2)
2826 > common /locel/ a_temp,agg,aggi,aggi1,aggj,aggj1,a22,a23,a32,a33,
2827 > & dxi,dyi,dzi,dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,
2830 > c write (iout,*) "eturn3",i,j,j1,j2
2836 > if (energy_dec) write (iout,'(a6,2i5,0pf7.3)')
2837 > & 'eturn3',i,j,0.5d0*(pizda(1,1)+pizda(2,2))
2839 < if (calc_grad) then
2841 < call transpose2(auxmat2(1,1),pizda(1,1))
2842 < call matmat2(a_temp(1,1),pizda(1,1),pizda(1,1))
2844 > call transpose2(auxmat2(1,1),auxmat3(1,1))
2845 > call matmat2(a_temp(1,1),auxmat3(1,1),pizda(1,1))
2847 < call transpose2(auxmat2(1,1),pizda(1,1))
2848 < call matmat2(a_temp(1,1),pizda(1,1),pizda(1,1))
2850 > call transpose2(auxmat2(1,1),auxmat3(1,1))
2851 > call matmat2(a_temp(1,1),auxmat3(1,1),pizda(1,1))
2853 < a_temp(1,1)=aggi(l,1)
2854 < a_temp(1,2)=aggi(l,2)
2855 < a_temp(2,1)=aggi(l,3)
2856 < a_temp(2,2)=aggi(l,4)
2858 > c ghalf1=0.5d0*agg(l,1)
2859 > c ghalf2=0.5d0*agg(l,2)
2860 > c ghalf3=0.5d0*agg(l,3)
2861 > c ghalf4=0.5d0*agg(l,4)
2862 > a_temp(1,1)=aggi(l,1)!+ghalf1
2863 > a_temp(1,2)=aggi(l,2)!+ghalf2
2864 > a_temp(2,1)=aggi(l,3)!+ghalf3
2865 > a_temp(2,2)=aggi(l,4)!+ghalf4
2867 < a_temp(1,1)=aggi1(l,1)
2868 < a_temp(1,2)=aggi1(l,2)
2869 < a_temp(2,1)=aggi1(l,3)
2870 < a_temp(2,2)=aggi1(l,4)
2872 > a_temp(1,1)=aggi1(l,1)!+agg(l,1)
2873 > a_temp(1,2)=aggi1(l,2)!+agg(l,2)
2874 > a_temp(2,1)=aggi1(l,3)!+agg(l,3)
2875 > a_temp(2,2)=aggi1(l,4)!+agg(l,4)
2877 < a_temp(1,1)=aggj(l,1)
2878 < a_temp(1,2)=aggj(l,2)
2879 < a_temp(2,1)=aggj(l,3)
2880 < a_temp(2,2)=aggj(l,4)
2882 > a_temp(1,1)=aggj(l,1)!+ghalf1
2883 > a_temp(1,2)=aggj(l,2)!+ghalf2
2884 > a_temp(2,1)=aggj(l,3)!+ghalf3
2885 > a_temp(2,2)=aggj(l,4)!+ghalf4
2888 < else if (j.eq.i+3 .and. itype(i+2).ne.21) then
2892 > C-------------------------------------------------------------------------------
2893 > subroutine eturn4(i,eello_turn4)
2894 > C Third- and fourth-order contributions from turns
2895 > implicit real*8 (a-h,o-z)
2896 > include 'DIMENSIONS'
2897 > include 'COMMON.IOUNITS'
2898 > include 'COMMON.GEO'
2899 > include 'COMMON.VAR'
2900 > include 'COMMON.LOCAL'
2901 > include 'COMMON.CHAIN'
2902 > include 'COMMON.DERIV'
2903 > include 'COMMON.INTERACT'
2904 > include 'COMMON.CONTACTS'
2905 > include 'COMMON.TORSION'
2906 > include 'COMMON.VECTORS'
2907 > include 'COMMON.FFIELD'
2908 > include 'COMMON.CONTROL'
2910 > double precision auxmat(2,2),auxmat1(2,2),auxmat2(2,2),pizda(2,2),
2911 > & e1t(2,2),e2t(2,2),e3t(2,2),e1tder(2,2),e2tder(2,2),e3tder(2,2),
2912 > & e1a(2,2),ae3(2,2),ae3e2(2,2),auxvec(2),auxvec1(2)
2913 > double precision agg(3,4),aggi(3,4),aggi1(3,4),
2914 > & aggj(3,4),aggj1(3,4),a_temp(2,2),auxmat3(2,2)
2915 > common /locel/ a_temp,agg,aggi,aggi1,aggj,aggj1,a22,a23,a32,a33,
2916 > & dxi,dyi,dzi,dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,
2920 > c write (iout,*) "eturn4 i",i," j",j," j1",j1," j2",j2
2926 > c write(iout,*) "iti1",iti1," iti2",iti2," iti3",iti3
2928 > if (energy_dec) write (iout,'(a6,2i5,0pf7.3)')
2929 > & 'eturn4',i,j,-(s1+s2+s3)
2931 < if (calc_grad) then
2933 < call matmat2(auxmat(1,1),e2t(1,1),auxmat(1,1))
2934 < call matmat2(auxmat(1,1),e1t(1,1),pizda(1,1))
2936 > call matmat2(auxmat(1,1),e2t(1,1),auxmat3(1,1))
2937 > call matmat2(auxmat3(1,1),e1t(1,1),pizda(1,1))
2939 > c write (iout,*) "s1",s1," s2",s2," s3",s3," s1+s2+s3",s1+s2+s3
2944 > subroutine escp_soft_sphere(evdw2,evdw2_14)
2946 > C This subroutine calculates the excluded-volume interaction energy between
2947 > C peptide-group centers and side chains and its gradient in virtual-bond and
2948 > C side-chain vectors.
2950 > implicit real*8 (a-h,o-z)
2951 > include 'DIMENSIONS'
2952 > include 'COMMON.GEO'
2953 > include 'COMMON.VAR'
2954 > include 'COMMON.LOCAL'
2955 > include 'COMMON.CHAIN'
2956 > include 'COMMON.DERIV'
2957 > include 'COMMON.INTERACT'
2958 > include 'COMMON.FFIELD'
2959 > include 'COMMON.IOUNITS'
2960 > include 'COMMON.CONTROL'
2965 > cd print '(a)','Enter ESCP'
2966 > cd write (iout,*) 'iatscp_s=',iatscp_s,' iatscp_e=',iatscp_e
2967 > do i=iatscp_s,iatscp_e
2968 > if (itype(i).eq.21 .or. itype(i+1).eq.21) cycle
2970 > xi=0.5D0*(c(1,i)+c(1,i+1))
2971 > yi=0.5D0*(c(2,i)+c(2,i+1))
2972 > zi=0.5D0*(c(3,i)+c(3,i+1))
2974 > do iint=1,nscp_gr(i)
2976 > do j=iscpstart(i,iint),iscpend(i,iint)
2977 > if (itype(j).eq.21) cycle
2979 > C Uncomment following three lines for SC-p interactions
2980 > c xj=c(1,nres+j)-xi
2981 > c yj=c(2,nres+j)-yi
2982 > c zj=c(3,nres+j)-zi
2983 > C Uncomment following three lines for Ca-p interactions
2987 > rij=xj*xj+yj*yj+zj*zj
2990 > if (rij.lt.r0ijsq) then
2991 > evdwij=0.25d0*(rij-r0ijsq)**2
2997 > evdw2=evdw2+evdwij
2999 > C Calculate contributions to the gradient in the virtual-bond and SC vectors.
3004 > cgrad if (j.lt.i) then
3005 > cd write (iout,*) 'j<i'
3006 > C Uncomment following three lines for SC-p interactions
3008 > c gradx_scp(k,j)=gradx_scp(k,j)+ggg(k)
3011 > cd write (iout,*) 'j>i'
3013 > cgrad ggg(k)=-ggg(k)
3014 > C Uncomment following line for SC-p interactions
3015 > c gradx_scp(k,j)=gradx_scp(k,j)-ggg(k)
3019 > cgrad gvdwc_scp(k,i)=gvdwc_scp(k,i)-0.5D0*ggg(k)
3021 > cgrad kstart=min0(i+1,j)
3022 > cgrad kend=max0(i-1,j-1)
3023 > cd write (iout,*) 'i=',i,' j=',j,' kstart=',kstart,' kend=',kend
3024 > cd write (iout,*) ggg(1),ggg(2),ggg(3)
3025 > cgrad do k=kstart,kend
3027 > cgrad gvdwc_scp(l,k)=gvdwc_scp(l,k)-ggg(l)
3031 > gvdwc_scpp(k,i)=gvdwc_scpp(k,i)-ggg(k)
3032 > gvdwc_scp(k,j)=gvdwc_scp(k,j)+ggg(k)
3040 > C-----------------------------------------------------------------------------
3042 < include 'DIMENSIONS.ZSCOPT'
3044 > include 'COMMON.CONTROL'
3046 < c write (iout,*) 'iatscp_s=',iatscp_s,' iatscp_e=',iatscp_e,
3047 < c & ' scal14',scal14
3049 > cd write (iout,*) 'iatscp_s=',iatscp_s,' iatscp_e=',iatscp_e
3051 < c write (iout,*) "i",i," iteli",iteli," nscp_gr",nscp_gr(i),
3052 < c & " iscp",(iscpstart(i,j),iscpend(i,j),j=1,nscp_gr(i))
3053 < if (iteli.eq.0) goto 1225
3055 < c write (iout,*) i,j,evdwij
3057 < if (calc_grad) then
3059 > if (energy_dec) write (iout,'(a6,2i5,0pf7.3)')
3060 > & 'evdw2',i,j,evdwij
3064 > cgrad if (j.lt.i) then
3074 > cgrad ggg(k)=-ggg(k)
3076 < c gradx_scp(k,j)=gradx_scp(k,j)-ggg(k)
3080 < gvdwc_scp(k,i)=gvdwc_scp(k,i)-0.5D0*ggg(k)
3082 < kstart=min0(i+1,j)
3083 < kend=max0(i-1,j-1)
3085 > ccgrad gradx_scp(k,j)=gradx_scp(k,j)-ggg(k)
3086 > c gradx_scp(k,j)=gradx_scp(k,j)+ggg(k)
3090 > cgrad gvdwc_scp(k,i)=gvdwc_scp(k,i)-0.5D0*ggg(k)
3092 > cgrad kstart=min0(i+1,j)
3093 > cgrad kend=max0(i-1,j-1)
3097 < gvdwc_scp(l,k)=gvdwc_scp(l,k)-ggg(l)
3100 > cgrad do k=kstart,kend
3102 > cgrad gvdwc_scp(l,k)=gvdwc_scp(l,k)-ggg(l)
3106 > gvdwc_scpp(k,i)=gvdwc_scpp(k,i)-ggg(k)
3107 > gvdwc_scp(k,j)=gvdwc_scp(k,j)+ggg(k)
3115 > gvdwc_scpp(j,i)=expon*gvdwc_scpp(j,i)
3117 < include 'DIMENSIONS.ZSCOPT'
3119 > include 'COMMON.IOUNITS'
3121 < cd print *,'edis: nhpb=',nhpb,' fbr=',fbr
3122 < cd print *,'link_start=',link_start,' link_end=',link_end
3124 > cd write(iout,*)'edis: nhpb=',nhpb,' fbr=',fbr
3125 > cd write(iout,*)'link_start=',link_start,' link_end=',link_end
3127 > cd write (iout,*) "i",i," ii",ii," iii",iii," jj",jj," jjj",jjj
3129 > cd write (iout,*) "eij",eij
3133 < ghpbc(k,j)=ghpbc(k,j)+ggg(k)
3136 > cgrad do j=iii,jjj-1
3138 > cgrad ghpbc(k,j)=ghpbc(k,j)+ggg(k)
3142 > ghpbc(k,jjj)=ghpbc(k,jjj)+ggg(k)
3143 > ghpbc(k,iii)=ghpbc(k,iii)-ggg(k)
3145 < include 'DIMENSIONS.ZSCOPT'
3147 < dsci_inv=dsc_inv(itypi)
3149 > c dsci_inv=dsc_inv(itypi)
3150 > dsci_inv=vbld_inv(nres+i)
3152 < dscj_inv=dsc_inv(itypj)
3154 > c dscj_inv=dsc_inv(itypj)
3155 > dscj_inv=vbld_inv(nres+j)
3157 < gg(k)=ed*erij(k)+eom1*dcosom1(k)+eom2*dcosom2(k)
3160 < ghpbx(k,i)=ghpbx(k,i)-gg(k)
3161 < & +(eom12*dc_norm(k,nres+j)+eom1*erij(k))*dsci_inv
3162 < ghpbx(k,j)=ghpbx(k,j)+gg(k)
3163 < & +(eom12*dc_norm(k,nres+i)+eom2*erij(k))*dscj_inv
3165 > ggk=ed*erij(k)+eom1*dcosom1(k)+eom2*dcosom2(k)
3166 > ghpbx(k,i)=ghpbx(k,i)-ggk
3167 > & +(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i))
3168 > & +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
3169 > ghpbx(k,j)=ghpbx(k,j)+ggk
3170 > & +(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j))
3171 > & +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
3172 > ghpbc(k,i)=ghpbc(k,i)-ggk
3173 > ghpbc(k,j)=ghpbc(k,j)+ggk
3177 < ghpbc(l,k)=ghpbc(l,k)+gg(l)
3183 > cgrad ghpbc(l,k)=ghpbc(l,k)+gg(l)
3187 < include 'DIMENSIONS.ZSCOPT'
3189 < logical energy_dec /.false./
3191 > include 'COMMON.SETUP'
3193 < write (iout,*) "distchainmax",distchainmax
3197 > do i=ibondp_start,ibondp_end
3199 < if (energy_dec) write(iout,*)
3201 > if (energy_dec) write(iout,*)
3203 < diff = vbld(i)-vbldp0
3204 < c write (iout,*) i,vbld(i),vbldp0,diff,AKP*diff*diff
3205 < estr=estr+diff*diff
3207 < gradb(j,i-1)=AKP*diff*dc(j,i-1)/vbld(i)
3210 > diff = vbld(i)-vbldp0
3211 > if (energy_dec) write (iout,*)
3212 > & "estr bb",i,vbld(i),vbldp0,diff,AKP*diff*diff
3213 > estr=estr+diff*diff
3215 > gradb(j,i-1)=AKP*diff*dc(j,i-1)/vbld(i)
3217 > c write (iout,'(i5,3f10.5)') i,(gradb(j,i-1),j=1,3)
3221 < estr=0.5d0*AKP*estr
3223 > estr=0.5d0*AKP*estr+estr1
3227 > do i=ibond_start,ibond_end
3229 < c write (iout,*) i,iti,vbld(i+nres),vbldsc0(1,iti),diff,
3230 < c & AKSC(1,iti),AKSC(1,iti)*diff*diff
3232 > if (energy_dec) write (iout,*)
3233 > & "estr sc",i,iti,vbld(i+nres),vbldsc0(1,iti),diff,
3234 > & AKSC(1,iti),AKSC(1,iti)*diff*diff
3236 < diff=vbld(i+nres)-vbldsc0(j,iti)
3238 > diff=vbld(i+nres)-vbldsc0(j,iti)
3240 < usumsqder=usumsqder+ud(j)*uprod2
3242 > usumsqder=usumsqder+ud(j)*uprod2
3244 < c write (iout,*) i,iti,vbld(i+nres),(vbldsc0(j,iti),
3245 < c & AKSC(j,iti),abond0(j,iti),u(j),j=1,nbi)
3251 < include 'DIMENSIONS.ZSCOPT'
3253 > include 'COMMON.CONTROL'
3255 < time11=dexp(-2*time)
3258 > c time11=dexp(-2*time)
3261 < c write (iout,*) "nres",nres
3263 < c write (iout,*) ithet_start,ithet_end
3267 < call proc_proc(phii,icrc)
3268 < if (icrc.eq.1) phii=150.0
3271 > if (phii.ne.phii) phii=150.0
3279 < call proc_proc(phii1,icrc)
3280 < if (icrc.eq.1) phii1=150.0
3283 > if (phii1.ne.phii1) phii1=150.0
3289 < c write (iout,*) "thet_pred_mean",thet_pred_mean
3291 < c write (iout,*) "thet_pred_mean",thet_pred_mean
3293 < c write (iout,'(2i3,3f8.3,f10.5)') i,it,rad2deg*theta(i),
3294 < c & rad2deg*phii,rad2deg*phii1,ethetai
3296 > if (energy_dec) write (iout,'(a6,i5,0pf7.3)')
3297 > & 'ebend',i,ethetai
3301 < include 'DIMENSIONS.ZSCOPT'
3303 < c write (iout,*) "ithetyp",(ithetyp(i),i=1,ntyp1)
3305 < c write (iout,*) "i",i," ityp1",itype(i-2),ityp1,
3306 < c & " ityp2",itype(i-1),ityp2," ityp3",itype(i),ityp3
3307 < c call flush(iout)
3309 < include 'DIMENSIONS.ZSCOPT'
3311 > include 'COMMON.CONTROL'
3313 < c write (iout,*) "i",i," x",x(1),x(2),x(3)
3315 < c write (iout,*) 'i=',i,' escloci=',escloci,' dersc=',dersc
3317 > if (energy_dec) write (iout,'(a6,i5,0pf7.3)')
3318 > & 'escloc',i,escloci
3319 > c write (iout,*) 'i=',i,' escloci=',escloci,' dersc=',dersc
3322 > adexp=bsc(j,it)-0.5D0*contr(j,iii)+emin
3323 > if(adexp.ne.adexp) adexp=1.0
3324 > expfac=dexp(adexp)
3329 < include 'DIMENSIONS.ZSCOPT'
3331 < c write (2,*) "escloc",escloc
3332 < if (.not. calc_grad) goto 1
3334 > c write (2,*) "i",i," escloc",sumene,escloc
3336 > c------------------------------------------------------------------------------
3337 > double precision function enesc(x,xx,yy,zz,cost2,sint2)
3339 > double precision x(65),xx,yy,zz,cost2,sint2,sumene1,sumene2,
3340 > & sumene3,sumene4,sumene,dsc_i,dp2_i,dscp1,dscp2,s1,s1_6,s2,s2_6
3341 > sumene1= x(1)+ x(2)*xx+ x(3)*yy+ x(4)*zz+ x(5)*xx**2
3342 > & + x(6)*yy**2+ x(7)*zz**2+ x(8)*xx*zz+ x(9)*xx*yy
3344 > sumene2= x(11) + x(12)*xx + x(13)*yy + x(14)*zz + x(15)*xx**2
3345 > & + x(16)*yy**2 + x(17)*zz**2 + x(18)*xx*zz + x(19)*xx*yy
3347 > sumene3= x(21) +x(22)*xx +x(23)*yy +x(24)*zz +x(25)*xx**2
3348 > & +x(26)*yy**2 +x(27)*zz**2 +x(28)*xx*zz +x(29)*xx*yy
3349 > & +x(30)*yy*zz +x(31)*xx**3 +x(32)*yy**3 +x(33)*zz**3
3350 > & +x(34)*(xx**2)*yy +x(35)*(xx**2)*zz +x(36)*(yy**2)*xx
3351 > & +x(37)*(yy**2)*zz +x(38)*(zz**2)*xx +x(39)*(zz**2)*yy
3353 > sumene4= x(41) +x(42)*xx +x(43)*yy +x(44)*zz +x(45)*xx**2
3354 > & +x(46)*yy**2 +x(47)*zz**2 +x(48)*xx*zz +x(49)*xx*yy
3355 > & +x(50)*yy*zz +x(51)*xx**3 +x(52)*yy**3 +x(53)*zz**3
3356 > & +x(54)*(xx**2)*yy +x(55)*(xx**2)*zz +x(56)*(yy**2)*xx
3357 > & +x(57)*(yy**2)*zz +x(58)*(zz**2)*xx +x(59)*(zz**2)*yy
3359 > dsc_i = 0.743d0+x(61)
3360 > dp2_i = 1.9d0+x(62)
3361 > dscp1=dsqrt(dsc_i**2+dp2_i**2-2*dsc_i*dp2_i
3362 > & *(xx*cost2+yy*sint2))
3363 > dscp2=dsqrt(dsc_i**2+dp2_i**2-2*dsc_i*dp2_i
3364 > & *(xx*cost2-yy*sint2))
3365 > s1=(1+x(63))/(0.1d0 + dscp1)
3366 > s1_6=(1+x(64))/(0.1d0 + dscp1**6)
3367 > s2=(1+x(65))/(0.1d0 + dscp2)
3368 > s2_6=(1+x(65))/(0.1d0 + dscp2**6)
3369 > sumene = ( sumene3*sint2 + sumene1)*(s1+s1_6)
3370 > & + (sumene4*cost2 +sumene2)*(s2+s2_6)
3375 < include 'DIMENSIONS.ZSCOPT'
3377 < subroutine etor(etors,edihcnstr,fact)
3379 > subroutine etor(etors,edihcnstr)
3381 < include 'DIMENSIONS.ZSCOPT'
3383 > include 'COMMON.CONTROL'
3385 < if (itype(i-2).eq.21 .or. itype(i-1).eq.21
3388 > if (itype(i-2).eq.21 .or. itype(i-1).eq.21
3390 > if (energy_dec) etors_ii=etors_ii+etorsi-v1(1,3,3)
3392 > if (energy_dec) etors_ii=etors_ii+
3393 > & v2ij*sinphi+dabs(v1ij)+dabs(v2ij)
3395 > if (energy_dec) etors_ii=etors_ii+
3396 > & v1ij*cosphi+v2ij*sinphi+dabs(v1ij)+dabs(v2ij)
3398 > if (energy_dec) write (iout,'(a6,i5,0pf7.3)')
3401 < gloc(i-3,icg)=gloc(i-3,icg)+wtor*fact*gloci
3403 > gloc(i-3,icg)=gloc(i-3,icg)+wtor*gloci
3405 > subroutine etor_d(etors_d)
3409 > c----------------------------------------------------------------------------
3411 < subroutine etor(etors,edihcnstr,fact)
3413 > subroutine etor(etors,edihcnstr)
3415 < include 'DIMENSIONS.ZSCOPT'
3417 > include 'COMMON.CONTROL'
3423 < if (itype(i-2).eq.21 .or. itype(i-1).eq.21
3425 > if (itype(i-2).eq.21 .or. itype(i-1).eq.21
3427 < if (itel(i-2).eq.0 .or. itel(i-1).eq.0) goto 1215
3431 > if (energy_dec) etors_ii=etors_ii+
3432 > & v1ij*cosphi+v2ij*sinphi
3434 > if (energy_dec) etors_ii=etors_ii+
3437 > if (energy_dec) write (iout,'(a6,i5,0pf7.3)')
3438 > & 'etor',i,etors_ii-v0(itori,itori1)
3440 < gloc(i-3,icg)=gloc(i-3,icg)+wtor*fact*gloci
3442 > gloc(i-3,icg)=gloc(i-3,icg)+wtor*gloci
3446 < do i=1,ndih_constr
3448 > c do i=1,ndih_constr
3449 > do i=idihconstr_start,idihconstr_end
3453 < edihi=0.25d0*ftors*difi**4
3455 < edihi=0.25d0*ftors*difi**4
3461 < c write (iout,'(2i5,4f10.5,e15.5)') i,itori,phii,phi0(i),difi,
3462 < c & drange(i),edihi
3463 < ! write (iout,'(2i5,2f8.3,2e14.5)') i,itori,rad2deg*phii,
3464 < ! & rad2deg*difi,0.25d0*ftors*difi**4,gloc(itori-3,icg)
3466 > cd write (iout,'(2i5,4f8.3,2e14.5)') i,itori,rad2deg*phii,
3467 > cd & rad2deg*phi0(i), rad2deg*drange(i),
3468 > cd & rad2deg*difi,0.25d0*ftors*difi**4,gloc(itori-3,icg)
3470 < ! write (iout,*) 'edihcnstr',edihcnstr
3472 > cd write (iout,*) 'edihcnstr',edihcnstr
3474 < subroutine etor_d(etors_d,fact2)
3476 > subroutine etor_d(etors_d)
3478 < include 'DIMENSIONS.ZSCOPT'
3480 < do i=iphi_start,iphi_end-1
3482 > do i=iphid_start,iphid_end
3484 < if (itel(i-2).eq.0 .or. itel(i-1).eq.0 .or. itel(i).eq.0)
3487 < gloc(i-3,icg)=gloc(i-3,icg)+wtor_d*fact2*gloci1
3488 < gloc(i-2,icg)=gloc(i-2,icg)+wtor_d*fact2*gloci2
3491 > gloc(i-3,icg)=gloc(i-3,icg)+wtor_d*gloci1
3492 > gloc(i-2,icg)=gloc(i-2,icg)+wtor_d*gloci2
3494 < c of residues computed from AM1 energy surfaces of terminally-blocked
3496 > c of residues computed from AM1 energy surfaces of terminally-blocked
3498 < include 'DIMENSIONS.ZSCOPT'
3500 < gsccor_loc(i-3)=gloci
3502 > gsccor_loc(i-3)=gsccor_loc(i-3)+gloci
3504 < c------------------------------------------------------------------------------
3506 > c----------------------------------------------------------------------------
3511 < gradcorr(ll,m)=gradcorr(ll,m)+gx(ll)
3516 < gradcorr(ll,m)=gradcorr(ll,m)+gx1(ll)
3522 < c------------------------------------------------------------------------------
3524 < subroutine pack_buffer(dimen1,dimen2,atom,indx,buffer)
3525 < implicit real*8 (a-h,o-z)
3526 < include 'DIMENSIONS'
3527 < integer dimen1,dimen2,atom,indx
3528 < double precision buffer(dimen1,dimen2)
3529 < double precision zapas
3530 < common /contacts_hb/ zapas(3,20,maxres,7),
3531 < & facont_hb(20,maxres),ees0p(20,maxres),ees0m(20,maxres),
3532 < & num_cont_hb(maxres),jcont_hb(20,maxres)
3533 < num_kont=num_cont_hb(atom)
3537 < buffer(i,indx+(k-1)*3+j)=zapas(j,i,atom,k)
3540 < buffer(i,indx+22)=facont_hb(i,atom)
3541 < buffer(i,indx+23)=ees0p(i,atom)
3542 < buffer(i,indx+24)=ees0m(i,atom)
3543 < buffer(i,indx+25)=dfloat(jcont_hb(i,atom))
3545 < buffer(1,indx+26)=dfloat(num_kont)
3548 < c------------------------------------------------------------------------------
3549 < subroutine unpack_buffer(dimen1,dimen2,atom,indx,buffer)
3550 < implicit real*8 (a-h,o-z)
3551 < include 'DIMENSIONS'
3552 < integer dimen1,dimen2,atom,indx
3553 < double precision buffer(dimen1,dimen2)
3554 < double precision zapas
3555 < common /contacts_hb/ zapas(3,20,maxres,7),
3556 < & facont_hb(20,maxres),ees0p(20,maxres),ees0m(20,maxres),
3557 < & num_cont_hb(maxres),jcont_hb(20,maxres)
3558 < num_kont=buffer(1,indx+26)
3559 < num_kont_old=num_cont_hb(atom)
3560 < num_cont_hb(atom)=num_kont+num_kont_old
3565 < zapas(j,ii,atom,k)=buffer(i,indx+(k-1)*3+j)
3568 < facont_hb(ii,atom)=buffer(i,indx+22)
3569 < ees0p(ii,atom)=buffer(i,indx+23)
3570 < ees0m(ii,atom)=buffer(i,indx+24)
3571 < jcont_hb(ii,atom)=buffer(i,indx+25)
3577 > gradcorr(ll,m)=gradcorr(ll,m)+gx(ll)
3582 > gradcorr(ll,m)=gradcorr(ll,m)+gx1(ll)
3589 < include 'DIMENSIONS.ZSCOPT'
3592 < include 'COMMON.INFO'
3596 > parameter (max_cont=maxconts)
3597 > parameter (max_dim=26)
3598 > integer source,CorrelType,CorrelID,CorrelType1,CorrelID1,Error
3599 > double precision zapas(max_dim,maxconts,max_fg_procs),
3600 > & zapas_recv(max_dim,maxconts,max_fg_procs)
3601 > common /przechowalnia/ zapas
3602 > integer status(MPI_STATUS_SIZE),req(maxconts*2),
3603 > & status_array(MPI_STATUS_SIZE,maxconts*2)
3605 > include 'COMMON.SETUP'
3608 < parameter (max_cont=maxconts)
3609 < parameter (max_dim=2*(8*3+2))
3610 < parameter (msglen1=max_cont*max_dim*4)
3611 < parameter (msglen2=2*msglen1)
3612 < integer source,CorrelType,CorrelID,Error
3613 < double precision buffer(max_cont,max_dim)
3615 < double precision gx(3),gx1(3)
3617 > include 'COMMON.CONTROL'
3618 > include 'COMMON.LOCAL'
3619 > double precision gx(3),gx1(3),time00
3625 < if (fgProcs.le.1) goto 30
3627 > if (nfgtasks.le.1) goto 30
3629 < write (iout,'(a)') 'Contact function values:'
3631 > write (iout,'(a)') 'Contact function values before RECEIVE:'
3633 < C Caution! Following code assumes that electrostatic interactions concerning
3634 < C a given atom are split among at most two processors!
3637 > do i=1,ntask_cont_from
3640 > do i=1,ntask_cont_to
3643 > c write (iout,*) "ntask_cont_from",ntask_cont_from," ntask_cont_to",
3645 > C Make the list of contacts to send to send to other procesors
3646 > c write (iout,*) "limits",max0(iturn4_end-1,iatel_s),iturn3_end
3647 > c call flush(iout)
3648 > do i=iturn3_start,iturn3_end
3649 > c write (iout,*) "make contact list turn3",i," num_cont",
3650 > c & num_cont_hb(i)
3651 > call add_hb_contact(i,i+2,iturn3_sent_local(1,i))
3653 > do i=iturn4_start,iturn4_end
3654 > c write (iout,*) "make contact list turn4",i," num_cont",
3655 > c & num_cont_hb(i)
3656 > call add_hb_contact(i,i+3,iturn4_sent_local(1,i))
3660 > c write (iout,*) "make contact list longrange",i,ii," num_cont",
3661 > c & num_cont_hb(i)
3662 > do j=1,num_cont_hb(i)
3665 > iproc=iint_sent_local(k,jjc,ii)
3666 > c write (iout,*) "i",i," j",j," k",k," jjc",jjc," iproc",iproc
3667 > if (iproc.gt.0) then
3668 > ncont_sent(iproc)=ncont_sent(iproc)+1
3669 > nn=ncont_sent(iproc)
3670 > zapas(1,nn,iproc)=i
3671 > zapas(2,nn,iproc)=jjc
3672 > zapas(3,nn,iproc)=facont_hb(j,i)
3673 > zapas(4,nn,iproc)=ees0p(j,i)
3674 > zapas(5,nn,iproc)=ees0m(j,i)
3675 > zapas(6,nn,iproc)=gacont_hbr(1,j,i)
3676 > zapas(7,nn,iproc)=gacont_hbr(2,j,i)
3677 > zapas(8,nn,iproc)=gacont_hbr(3,j,i)
3678 > zapas(9,nn,iproc)=gacontm_hb1(1,j,i)
3679 > zapas(10,nn,iproc)=gacontm_hb1(2,j,i)
3680 > zapas(11,nn,iproc)=gacontm_hb1(3,j,i)
3681 > zapas(12,nn,iproc)=gacontp_hb1(1,j,i)
3682 > zapas(13,nn,iproc)=gacontp_hb1(2,j,i)
3683 > zapas(14,nn,iproc)=gacontp_hb1(3,j,i)
3684 > zapas(15,nn,iproc)=gacontm_hb2(1,j,i)
3685 > zapas(16,nn,iproc)=gacontm_hb2(2,j,i)
3686 > zapas(17,nn,iproc)=gacontm_hb2(3,j,i)
3687 > zapas(18,nn,iproc)=gacontp_hb2(1,j,i)
3688 > zapas(19,nn,iproc)=gacontp_hb2(2,j,i)
3689 > zapas(20,nn,iproc)=gacontp_hb2(3,j,i)
3690 > zapas(21,nn,iproc)=gacontm_hb3(1,j,i)
3691 > zapas(22,nn,iproc)=gacontm_hb3(2,j,i)
3692 > zapas(23,nn,iproc)=gacontm_hb3(3,j,i)
3693 > zapas(24,nn,iproc)=gacontp_hb3(1,j,i)
3694 > zapas(25,nn,iproc)=gacontp_hb3(2,j,i)
3695 > zapas(26,nn,iproc)=gacontp_hb3(3,j,i)
3702 > & "Numbers of contacts to be sent to other processors",
3703 > & (ncont_sent(i),i=1,ntask_cont_to)
3704 > write (iout,*) "Contacts sent"
3705 > do ii=1,ntask_cont_to
3707 > iproc=itask_cont_to(ii)
3708 > write (iout,*) nn," contacts to processor",iproc,
3709 > & " of CONT_TO_COMM group"
3711 > write(iout,'(2f5.0,4f10.5)')(zapas(j,i,ii),j=1,5)
3725 < cd write (iout,*) 'MyRank',MyRank,' mm',mm
3728 < cd write (iout,*) 'Sending: MyRank',MyRank,' mm',mm,' ldone',ldone
3729 < if (MyRank.gt.0) then
3730 < C Send correlation contributions to the preceding processor
3732 < nn=num_cont_hb(iatel_s)
3733 < call pack_buffer(max_cont,max_dim,iatel_s,0,buffer)
3734 < cd write (iout,*) 'The BUFFER array:'
3736 < cd write (iout,'(i2,9(3f8.3,2x))') i,(buffer(i,j),j=1,26)
3738 < if (ielstart(iatel_s).gt.iatel_s+ispp) then
3740 < call pack_buffer(max_cont,max_dim,iatel_s+1,26,buffer)
3741 < C Clear the contacts of the atom passed to the neighboring processor
3742 < nn=num_cont_hb(iatel_s+1)
3744 < cd write (iout,'(i2,9(3f8.3,2x))') i,(buffer(i,j+26),j=1,26)
3746 < num_cont_hb(iatel_s)=0
3748 < cd write (iout,*) 'Processor ',MyID,MyRank,
3749 < cd & ' is sending correlation contribution to processor',MyID-1,
3750 < cd & ' msglen=',msglen
3751 < cd write (*,*) 'Processor ',MyID,MyRank,
3752 < cd & ' is sending correlation contribution to processor',MyID-1,
3753 < cd & ' msglen=',msglen,' CorrelType=',CorrelType
3754 < call mp_bsend(buffer,msglen,MyID-1,CorrelType,CorrelID)
3755 < cd write (iout,*) 'Processor ',MyID,
3756 < cd & ' has sent correlation contribution to processor',MyID-1,
3757 < cd & ' msglen=',msglen,' CorrelID=',CorrelID
3758 < cd write (*,*) 'Processor ',MyID,
3759 < cd & ' has sent correlation contribution to processor',MyID-1,
3760 < cd & ' msglen=',msglen,' CorrelID=',CorrelID
3762 < endif ! (MyRank.gt.0)
3763 < if (ldone) goto 30
3766 < cd write (iout,*) 'Receiving: MyRank',MyRank,' mm',mm,' ldone',ldone
3767 < if (MyRank.lt.fgProcs-1) then
3768 < C Receive correlation contributions from the next processor
3770 < if (ielend(iatel_e).lt.nct-1) msglen=msglen2
3771 < cd write (iout,*) 'Processor',MyID,
3772 < cd & ' is receiving correlation contribution from processor',MyID+1,
3773 < cd & ' msglen=',msglen,' CorrelType=',CorrelType
3774 < cd write (*,*) 'Processor',MyID,
3775 < cd & ' is receiving correlation contribution from processor',MyID+1,
3776 < cd & ' msglen=',msglen,' CorrelType=',CorrelType
3778 < do while (nbytes.le.0)
3779 < call mp_probe(MyID+1,CorrelType,nbytes)
3781 < cd print *,'Processor',MyID,' msglen',msglen,' nbytes',nbytes
3782 < call mp_brecv(buffer,msglen,MyID+1,CorrelType,nbytes)
3783 < cd write (iout,*) 'Processor',MyID,
3784 < cd & ' has received correlation contribution from processor',MyID+1,
3785 < cd & ' msglen=',msglen,' nbytes=',nbytes
3786 < cd write (iout,*) 'The received BUFFER array:'
3787 < cd do i=1,max_cont
3788 < cd write (iout,'(i2,9(3f8.3,2x))') i,(buffer(i,j),j=1,52)
3790 < if (msglen.eq.msglen1) then
3791 < call unpack_buffer(max_cont,max_dim,iatel_e+1,0,buffer)
3792 < else if (msglen.eq.msglen2) then
3793 < call unpack_buffer(max_cont,max_dim,iatel_e,0,buffer)
3794 < call unpack_buffer(max_cont,max_dim,iatel_e+1,26,buffer)
3797 < & 'ERROR!!!! message length changed while processing correlations.'
3799 < & 'ERROR!!!! message length changed while processing correlations.'
3800 < call mp_stopall(Error)
3801 < endif ! msglen.eq.msglen1
3802 < endif ! MyRank.lt.fgProcs-1
3803 < if (ldone) goto 30
3807 > CorrelID=fg_rank+1
3809 > CorrelID1=nfgtasks+fg_rank+1
3811 > C Receive the numbers of needed contacts from other processors
3812 > do ii=1,ntask_cont_from
3813 > iproc=itask_cont_from(ii)
3815 > call MPI_Irecv(ncont_recv(ii),1,MPI_INTEGER,iproc,CorrelType,
3816 > & FG_COMM,req(ireq),IERR)
3818 > c write (iout,*) "IRECV ended"
3819 > c call flush(iout)
3820 > C Send the number of contacts needed by other processors
3821 > do ii=1,ntask_cont_to
3822 > iproc=itask_cont_to(ii)
3824 > call MPI_Isend(ncont_sent(ii),1,MPI_INTEGER,iproc,CorrelType,
3825 > & FG_COMM,req(ireq),IERR)
3827 > c write (iout,*) "ISEND ended"
3828 > c write (iout,*) "number of requests (nn)",ireq
3831 > & call MPI_Waitall(ireq,req,status_array,ierr)
3833 > c & "Numbers of contacts to be received from other processors",
3834 > c & (ncont_recv(i),i=1,ntask_cont_from)
3835 > c call flush(iout)
3836 > C Receive contacts
3838 > do ii=1,ntask_cont_from
3839 > iproc=itask_cont_from(ii)
3841 > c write (iout,*) "Receiving",nn," contacts from processor",iproc,
3842 > c & " of CONT_TO_COMM group"
3846 > call MPI_Irecv(zapas_recv(1,1,ii),nn*max_dim,
3847 > & MPI_DOUBLE_PRECISION,iproc,CorrelType1,FG_COMM,req(ireq),IERR)
3848 > c write (iout,*) "ireq,req",ireq,req(ireq)
3851 > C Send the contacts to processors that need them
3852 > do ii=1,ntask_cont_to
3853 > iproc=itask_cont_to(ii)
3855 > c write (iout,*) nn," contacts to processor",iproc,
3856 > c & " of CONT_TO_COMM group"
3859 > call MPI_Isend(zapas(1,1,ii),nn*max_dim,MPI_DOUBLE_PRECISION,
3860 > & iproc,CorrelType1,FG_COMM,req(ireq),IERR)
3861 > c write (iout,*) "ireq,req",ireq,req(ireq)
3863 > c write(iout,'(2f5.0,4f10.5)')(zapas(j,i,ii),j=1,5)
3867 > c write (iout,*) "number of requests (contacts)",ireq
3868 > c write (iout,*) "req",(req(i),i=1,4)
3869 > c call flush(iout)
3871 > & call MPI_Waitall(ireq,req,status_array,ierr)
3872 > do iii=1,ntask_cont_from
3873 > iproc=itask_cont_from(iii)
3874 > nn=ncont_recv(iii)
3876 > write (iout,*) "Received",nn," contacts from processor",iproc,
3877 > & " of CONT_FROM_COMM group"
3880 > write(iout,'(2f5.0,4f10.5)')(zapas_recv(j,i,iii),j=1,5)
3885 > ii=zapas_recv(1,i,iii)
3886 > c Flag the received contacts to prevent double-counting
3887 > jj=-zapas_recv(2,i,iii)
3888 > c write (iout,*) "iii",iii," i",i," ii",ii," jj",jj
3889 > c call flush(iout)
3890 > nnn=num_cont_hb(ii)+1
3891 > num_cont_hb(ii)=nnn
3892 > jcont_hb(nnn,ii)=jj
3893 > facont_hb(nnn,ii)=zapas_recv(3,i,iii)
3894 > ees0p(nnn,ii)=zapas_recv(4,i,iii)
3895 > ees0m(nnn,ii)=zapas_recv(5,i,iii)
3896 > gacont_hbr(1,nnn,ii)=zapas_recv(6,i,iii)
3897 > gacont_hbr(2,nnn,ii)=zapas_recv(7,i,iii)
3898 > gacont_hbr(3,nnn,ii)=zapas_recv(8,i,iii)
3899 > gacontm_hb1(1,nnn,ii)=zapas_recv(9,i,iii)
3900 > gacontm_hb1(2,nnn,ii)=zapas_recv(10,i,iii)
3901 > gacontm_hb1(3,nnn,ii)=zapas_recv(11,i,iii)
3902 > gacontp_hb1(1,nnn,ii)=zapas_recv(12,i,iii)
3903 > gacontp_hb1(2,nnn,ii)=zapas_recv(13,i,iii)
3904 > gacontp_hb1(3,nnn,ii)=zapas_recv(14,i,iii)
3905 > gacontm_hb2(1,nnn,ii)=zapas_recv(15,i,iii)
3906 > gacontm_hb2(2,nnn,ii)=zapas_recv(16,i,iii)
3907 > gacontm_hb2(3,nnn,ii)=zapas_recv(17,i,iii)
3908 > gacontp_hb2(1,nnn,ii)=zapas_recv(18,i,iii)
3909 > gacontp_hb2(2,nnn,ii)=zapas_recv(19,i,iii)
3910 > gacontp_hb2(3,nnn,ii)=zapas_recv(20,i,iii)
3911 > gacontm_hb3(1,nnn,ii)=zapas_recv(21,i,iii)
3912 > gacontm_hb3(2,nnn,ii)=zapas_recv(22,i,iii)
3913 > gacontm_hb3(3,nnn,ii)=zapas_recv(23,i,iii)
3914 > gacontp_hb3(1,nnn,ii)=zapas_recv(24,i,iii)
3915 > gacontp_hb3(2,nnn,ii)=zapas_recv(25,i,iii)
3916 > gacontp_hb3(3,nnn,ii)=zapas_recv(26,i,iii)
3921 > write (iout,'(a)') 'Contact function values after receive:'
3923 > write (iout,'(2i3,50(1x,i3,f5.2))')
3924 > & i,num_cont_hb(i),(jcont_hb(j,i),facont_hb(j,i),
3925 > & j=1,num_cont_hb(i))
3930 < write (iout,'(2i3,50(1x,i2,f5.2))')
3932 > write (iout,'(2i3,50(1x,i3,f5.2))')
3934 < do i=iatel_s,iatel_e+1
3936 > do i=min0(iatel_s,iturn4_start),max0(iatel_e,iturn3_end)
3942 < if (j1.eq.j+1 .or. j1.eq.j-1) then
3944 > if ((j.gt.0 .and. j1.gt.0 .or. j.gt.0 .and. j1.lt.0
3945 > & .or. j.lt.0 .and. j1.gt.0) .and.
3946 > & (jp1.eq.jp+1 .or. jp1.eq.jp-1)) then
3948 < ecorr=ecorr+ehbcorr(i,j,i+1,j1,jj,kk,0.72D0,0.32D0)
3950 > ecorr=ecorr+ehbcorr(i,jp,i+1,jp1,jj,kk,0.72D0,0.32D0)
3951 > if (energy_dec) write (iout,'(a6,2i5,0pf7.3)')
3952 > & 'ecorrh',i,j,ehbcorr(i,j,i+1,j1,jj,kk,0.72D0,0.32D0)
3954 > subroutine add_hb_contact(ii,jj,itask)
3955 > implicit real*8 (a-h,o-z)
3956 > include "DIMENSIONS"
3957 > include "COMMON.IOUNITS"
3960 > parameter (max_cont=maxconts)
3961 > parameter (max_dim=26)
3962 > include "COMMON.CONTACTS"
3963 > double precision zapas(max_dim,maxconts,max_fg_procs),
3964 > & zapas_recv(max_dim,maxconts,max_fg_procs)
3965 > common /przechowalnia/ zapas
3966 > integer i,j,ii,jj,iproc,itask(4),nn
3967 > c write (iout,*) "itask",itask
3970 > if (iproc.gt.0) then
3971 > do j=1,num_cont_hb(ii)
3972 > jjc=jcont_hb(j,ii)
3973 > c write (iout,*) "i",ii," j",jj," jjc",jjc
3974 > if (jjc.eq.jj) then
3975 > ncont_sent(iproc)=ncont_sent(iproc)+1
3976 > nn=ncont_sent(iproc)
3977 > zapas(1,nn,iproc)=ii
3978 > zapas(2,nn,iproc)=jjc
3979 > zapas(3,nn,iproc)=facont_hb(j,ii)
3980 > zapas(4,nn,iproc)=ees0p(j,ii)
3981 > zapas(5,nn,iproc)=ees0m(j,ii)
3982 > zapas(6,nn,iproc)=gacont_hbr(1,j,ii)
3983 > zapas(7,nn,iproc)=gacont_hbr(2,j,ii)
3984 > zapas(8,nn,iproc)=gacont_hbr(3,j,ii)
3985 > zapas(9,nn,iproc)=gacontm_hb1(1,j,ii)
3986 > zapas(10,nn,iproc)=gacontm_hb1(2,j,ii)
3987 > zapas(11,nn,iproc)=gacontm_hb1(3,j,ii)
3988 > zapas(12,nn,iproc)=gacontp_hb1(1,j,ii)
3989 > zapas(13,nn,iproc)=gacontp_hb1(2,j,ii)
3990 > zapas(14,nn,iproc)=gacontp_hb1(3,j,ii)
3991 > zapas(15,nn,iproc)=gacontm_hb2(1,j,ii)
3992 > zapas(16,nn,iproc)=gacontm_hb2(2,j,ii)
3993 > zapas(17,nn,iproc)=gacontm_hb2(3,j,ii)
3994 > zapas(18,nn,iproc)=gacontp_hb2(1,j,ii)
3995 > zapas(19,nn,iproc)=gacontp_hb2(2,j,ii)
3996 > zapas(20,nn,iproc)=gacontp_hb2(3,j,ii)
3997 > zapas(21,nn,iproc)=gacontm_hb3(1,j,ii)
3998 > zapas(22,nn,iproc)=gacontm_hb3(2,j,ii)
3999 > zapas(23,nn,iproc)=gacontm_hb3(3,j,ii)
4000 > zapas(24,nn,iproc)=gacontp_hb3(1,j,ii)
4001 > zapas(25,nn,iproc)=gacontp_hb3(2,j,ii)
4002 > zapas(26,nn,iproc)=gacontp_hb3(3,j,ii)
4010 > c------------------------------------------------------------------------------
4012 < include 'DIMENSIONS.ZSCOPT'
4015 < include 'COMMON.INFO'
4019 > parameter (max_cont=maxconts)
4020 > parameter (max_dim=70)
4021 > integer source,CorrelType,CorrelID,CorrelType1,CorrelID1,Error
4022 > double precision zapas(max_dim,maxconts,max_fg_procs),
4023 > & zapas_recv(max_dim,maxconts,max_fg_procs)
4024 > common /przechowalnia/ zapas
4025 > integer status(MPI_STATUS_SIZE),req(maxconts*2),
4026 > & status_array(MPI_STATUS_SIZE,maxconts*2)
4028 > include 'COMMON.SETUP'
4030 > include 'COMMON.LOCAL'
4033 < parameter (max_cont=maxconts)
4034 < parameter (max_dim=2*(8*3+2))
4035 < parameter (msglen1=max_cont*max_dim*4)
4036 < parameter (msglen2=2*msglen1)
4037 < integer source,CorrelType,CorrelID,Error
4038 < double precision buffer(max_cont,max_dim)
4041 > include 'COMMON.CHAIN'
4042 > include 'COMMON.CONTROL'
4044 > integer num_cont_hb_old(maxres)
4048 > double precision eello4,eello5,eelo6,eello_turn6
4049 > external eello4,eello5,eello6,eello_turn6
4055 > num_cont_hb_old(i)=num_cont_hb(i)
4058 < if (fgProcs.le.1) goto 30
4060 > if (nfgtasks.le.1) goto 30
4062 < write (iout,'(a)') 'Contact function values:'
4064 > write (iout,'(a)') 'Contact function values before RECEIVE:'
4066 < C Caution! Following code assumes that electrostatic interactions concerning
4067 < C a given atom are split among at most two processors!
4070 > do i=1,ntask_cont_from
4073 > do i=1,ntask_cont_to
4076 > c write (iout,*) "ntask_cont_from",ntask_cont_from," ntask_cont_to",
4078 > C Make the list of contacts to send to send to other procesors
4079 > do i=iturn3_start,iturn3_end
4080 > c write (iout,*) "make contact list turn3",i," num_cont",
4081 > c & num_cont_hb(i)
4082 > call add_hb_contact_eello(i,i+2,iturn3_sent_local(1,i))
4084 > do i=iturn4_start,iturn4_end
4085 > c write (iout,*) "make contact list turn4",i," num_cont",
4086 > c & num_cont_hb(i)
4087 > call add_hb_contact_eello(i,i+3,iturn4_sent_local(1,i))
4091 > c write (iout,*) "make contact list longrange",i,ii," num_cont",
4092 > c & num_cont_hb(i)
4093 > do j=1,num_cont_hb(i)
4096 > iproc=iint_sent_local(k,jjc,ii)
4097 > c write (iout,*) "i",i," j",j," k",k," jjc",jjc," iproc",iproc
4098 > if (iproc.ne.0) then
4099 > ncont_sent(iproc)=ncont_sent(iproc)+1
4100 > nn=ncont_sent(iproc)
4101 > zapas(1,nn,iproc)=i
4102 > zapas(2,nn,iproc)=jjc
4103 > zapas(3,nn,iproc)=d_cont(j,i)
4107 > zapas(ind,nn,iproc)=grij_hb_cont(kk,j,i)
4112 > zapas(ind,nn,iproc)=a_chuj(ll,kk,j,i)
4120 > zapas(ind,nn,iproc)=a_chuj_der(mm,ll,kk,jj,j,i)
4131 > & "Numbers of contacts to be sent to other processors",
4132 > & (ncont_sent(i),i=1,ntask_cont_to)
4133 > write (iout,*) "Contacts sent"
4134 > do ii=1,ntask_cont_to
4136 > iproc=itask_cont_to(ii)
4137 > write (iout,*) nn," contacts to processor",iproc,
4138 > & " of CONT_TO_COMM group"
4140 > write(iout,'(2f5.0,10f10.5)')(zapas(j,i,ii),j=1,10)
4154 < cd write (iout,*) 'MyRank',MyRank,' mm',mm
4157 < cd write (iout,*) 'Sending: MyRank',MyRank,' mm',mm,' ldone',ldone
4158 < if (MyRank.gt.0) then
4159 < C Send correlation contributions to the preceding processor
4161 < nn=num_cont_hb(iatel_s)
4162 < call pack_buffer(max_cont,max_dim,iatel_s,0,buffer)
4163 < cd write (iout,*) 'The BUFFER array:'
4165 < cd write (iout,'(i2,9(3f8.3,2x))') i,(buffer(i,j),j=1,26)
4167 < if (ielstart(iatel_s).gt.iatel_s+ispp) then
4169 < call pack_buffer(max_cont,max_dim,iatel_s+1,26,buffer)
4170 < C Clear the contacts of the atom passed to the neighboring processor
4171 < nn=num_cont_hb(iatel_s+1)
4173 < cd write (iout,'(i2,9(3f8.3,2x))') i,(buffer(i,j+26),j=1,26)
4175 < num_cont_hb(iatel_s)=0
4177 < cd write (iout,*) 'Processor ',MyID,MyRank,
4178 < cd & ' is sending correlation contribution to processor',MyID-1,
4179 < cd & ' msglen=',msglen
4180 < cd write (*,*) 'Processor ',MyID,MyRank,
4181 < cd & ' is sending correlation contribution to processor',MyID-1,
4182 < cd & ' msglen=',msglen,' CorrelType=',CorrelType
4183 < call mp_bsend(buffer,msglen,MyID-1,CorrelType,CorrelID)
4184 < cd write (iout,*) 'Processor ',MyID,
4185 < cd & ' has sent correlation contribution to processor',MyID-1,
4186 < cd & ' msglen=',msglen,' CorrelID=',CorrelID
4187 < cd write (*,*) 'Processor ',MyID,
4188 < cd & ' has sent correlation contribution to processor',MyID-1,
4189 < cd & ' msglen=',msglen,' CorrelID=',CorrelID
4191 < endif ! (MyRank.gt.0)
4192 < if (ldone) goto 30
4195 < cd write (iout,*) 'Receiving: MyRank',MyRank,' mm',mm,' ldone',ldone
4196 < if (MyRank.lt.fgProcs-1) then
4197 < C Receive correlation contributions from the next processor
4199 < if (ielend(iatel_e).lt.nct-1) msglen=msglen2
4200 < cd write (iout,*) 'Processor',MyID,
4201 < cd & ' is receiving correlation contribution from processor',MyID+1,
4202 < cd & ' msglen=',msglen,' CorrelType=',CorrelType
4203 < cd write (*,*) 'Processor',MyID,
4204 < cd & ' is receiving correlation contribution from processor',MyID+1,
4205 < cd & ' msglen=',msglen,' CorrelType=',CorrelType
4207 < do while (nbytes.le.0)
4208 < call mp_probe(MyID+1,CorrelType,nbytes)
4210 < cd print *,'Processor',MyID,' msglen',msglen,' nbytes',nbytes
4211 < call mp_brecv(buffer,msglen,MyID+1,CorrelType,nbytes)
4212 < cd write (iout,*) 'Processor',MyID,
4213 < cd & ' has received correlation contribution from processor',MyID+1,
4214 < cd & ' msglen=',msglen,' nbytes=',nbytes
4215 < cd write (iout,*) 'The received BUFFER array:'
4216 < cd do i=1,max_cont
4217 < cd write (iout,'(i2,9(3f8.3,2x))') i,(buffer(i,j),j=1,52)
4219 < if (msglen.eq.msglen1) then
4220 < call unpack_buffer(max_cont,max_dim,iatel_e+1,0,buffer)
4221 < else if (msglen.eq.msglen2) then
4222 < call unpack_buffer(max_cont,max_dim,iatel_e,0,buffer)
4223 < call unpack_buffer(max_cont,max_dim,iatel_e+1,26,buffer)
4226 < & 'ERROR!!!! message length changed while processing correlations.'
4228 < & 'ERROR!!!! message length changed while processing correlations.'
4229 < call mp_stopall(Error)
4230 < endif ! msglen.eq.msglen1
4231 < endif ! MyRank.lt.fgProcs-1
4232 < if (ldone) goto 30
4236 > CorrelID=fg_rank+1
4238 > CorrelID1=nfgtasks+fg_rank+1
4240 > C Receive the numbers of needed contacts from other processors
4241 > do ii=1,ntask_cont_from
4242 > iproc=itask_cont_from(ii)
4244 > call MPI_Irecv(ncont_recv(ii),1,MPI_INTEGER,iproc,CorrelType,
4245 > & FG_COMM,req(ireq),IERR)
4247 > c write (iout,*) "IRECV ended"
4248 > c call flush(iout)
4249 > C Send the number of contacts needed by other processors
4250 > do ii=1,ntask_cont_to
4251 > iproc=itask_cont_to(ii)
4253 > call MPI_Isend(ncont_sent(ii),1,MPI_INTEGER,iproc,CorrelType,
4254 > & FG_COMM,req(ireq),IERR)
4256 > c write (iout,*) "ISEND ended"
4257 > c write (iout,*) "number of requests (nn)",ireq
4260 > & call MPI_Waitall(ireq,req,status_array,ierr)
4262 > c & "Numbers of contacts to be received from other processors",
4263 > c & (ncont_recv(i),i=1,ntask_cont_from)
4264 > c call flush(iout)
4265 > C Receive contacts
4267 > do ii=1,ntask_cont_from
4268 > iproc=itask_cont_from(ii)
4270 > c write (iout,*) "Receiving",nn," contacts from processor",iproc,
4271 > c & " of CONT_TO_COMM group"
4275 > call MPI_Irecv(zapas_recv(1,1,ii),nn*max_dim,
4276 > & MPI_DOUBLE_PRECISION,iproc,CorrelType1,FG_COMM,req(ireq),IERR)
4277 > c write (iout,*) "ireq,req",ireq,req(ireq)
4280 > C Send the contacts to processors that need them
4281 > do ii=1,ntask_cont_to
4282 > iproc=itask_cont_to(ii)
4284 > c write (iout,*) nn," contacts to processor",iproc,
4285 > c & " of CONT_TO_COMM group"
4288 > call MPI_Isend(zapas(1,1,ii),nn*max_dim,MPI_DOUBLE_PRECISION,
4289 > & iproc,CorrelType1,FG_COMM,req(ireq),IERR)
4290 > c write (iout,*) "ireq,req",ireq,req(ireq)
4292 > c write(iout,'(2f5.0,4f10.5)')(zapas(j,i,ii),j=1,5)
4296 > c write (iout,*) "number of requests (contacts)",ireq
4297 > c write (iout,*) "req",(req(i),i=1,4)
4298 > c call flush(iout)
4300 > & call MPI_Waitall(ireq,req,status_array,ierr)
4301 > do iii=1,ntask_cont_from
4302 > iproc=itask_cont_from(iii)
4303 > nn=ncont_recv(iii)
4305 > write (iout,*) "Received",nn," contacts from processor",iproc,
4306 > & " of CONT_FROM_COMM group"
4309 > write(iout,'(2f5.0,10f10.5)')(zapas_recv(j,i,iii),j=1,10)
4314 > ii=zapas_recv(1,i,iii)
4315 > c Flag the received contacts to prevent double-counting
4316 > jj=-zapas_recv(2,i,iii)
4317 > c write (iout,*) "iii",iii," i",i," ii",ii," jj",jj
4318 > c call flush(iout)
4319 > nnn=num_cont_hb(ii)+1
4320 > num_cont_hb(ii)=nnn
4321 > jcont_hb(nnn,ii)=jj
4322 > d_cont(nnn,ii)=zapas_recv(3,i,iii)
4326 > grij_hb_cont(kk,nnn,ii)=zapas_recv(ind,i,iii)
4331 > a_chuj(ll,kk,nnn,ii)=zapas_recv(ind,i,iii)
4339 > a_chuj_der(mm,ll,kk,jj,nnn,ii)=zapas_recv(ind,i,iii)
4348 > write (iout,'(a)') 'Contact function values after receive:'
4350 > write (iout,'(2i3,50(1x,i3,5f6.3))')
4351 > & i,num_cont_hb(i),(jcont_hb(j,i),d_cont(j,i),
4352 > & ((a_chuj(ll,kk,j,i),ll=1,2),kk=1,2),j=1,num_cont_hb(i))
4357 < write (iout,'(2i3,50(1x,i2,f5.2))')
4358 < & i,num_cont_hb(i),(jcont_hb(j,i),facont_hb(j,i),
4359 < & j=1,num_cont_hb(i))
4361 > write (iout,'(2i3,50(1x,i2,5f6.3))')
4362 > & i,num_cont_hb(i),(jcont_hb(j,i),d_cont(j,i),
4363 > & ((a_chuj(ll,kk,j,i),ll=1,2),kk=1,2),j=1,num_cont_hb(i))
4369 < do i=iatel_s,iatel_e+1
4371 > c write (iout,*) "gradcorr5 in eello5 before loop"
4373 > c write (iout,'(i5,3f10.5)')
4374 > c & iii,(gradcorr5(jjj,iii),jjj=1,3)
4376 > do i=min0(iatel_s,iturn4_start),max0(iatel_e+1,iturn3_end+1)
4377 > c write (iout,*) "corr loop i",i
4381 < c write (*,*) 'i=',i,' j=',j,' i1=',i1,' j1=',j1,
4384 > c write (iout,*) 'i=',i,' j=',j,' i1=',i1,' j1=',j1,
4386 < if (j1.eq.j+1 .or. j1.eq.j-1) then
4388 > c if (j1.eq.j+1 .or. j1.eq.j-1) then
4389 > if ((j.gt.0 .and. j1.gt.0 .or. j.gt.0 .and. j1.lt.0
4390 > & .or. j.lt.0 .and. j1.gt.0) .and.
4391 > & (jp1.eq.jp+1 .or. jp1.eq.jp-1)) then
4393 < c write (*,*) 'i=',i,' j=',j,' i1=',i1,' j1=',j1,
4394 < c & ' jj=',jj,' kk=',kk
4396 > cd write (iout,*) 'i=',i,' j=',jp,' i1=',i1,' j1=',jp1,
4397 > cd & ' jj=',jj,' kk=',kk
4399 < cd & ' ekont=',ekont,' fprim=',fprimcont
4400 < call calc_eello(i,j,i+1,j1,jj,kk)
4402 > cd & ' ekont=',ekont,' fprim=',fprimcont,
4403 > cd & ' fac_prim1',fac_prim1,' fac_prim2',fac_prim2
4404 > cd write (iout,*) "g_contij",g_contij
4405 > cd write (iout,*) "grij_hb_cont i",grij_hb_cont(:,jj,i)
4406 > cd write (iout,*) "grij_hb_cont i1",grij_hb_cont(:,jj,i1)
4407 > call calc_eello(i,jp,i+1,jp1,jj,kk)
4409 < & ecorr=ecorr+eello4(i,j,i+1,j1,jj,kk)
4411 > & ecorr=ecorr+eello4(i,jp,i+1,jp1,jj,kk)
4412 > if (energy_dec.and.wcorr4.gt.0.0d0)
4413 > 1 write (iout,'(a6,4i5,0pf7.3)')
4414 > 2 'ecorr4',i,j,i+1,j1,eello4(i,jp,i+1,jp1,jj,kk)
4415 > c write (iout,*) "gradcorr5 before eello5"
4417 > c write (iout,'(i5,3f10.5)')
4418 > c & iii,(gradcorr5(jjj,iii),jjj=1,3)
4421 < & ecorr5=ecorr5+eello5(i,j,i+1,j1,jj,kk)
4422 < c print *,"wcorr5",ecorr5
4424 > & ecorr5=ecorr5+eello5(i,jp,i+1,jp1,jj,kk)
4425 > c write (iout,*) "gradcorr5 after eello5"
4427 > c write (iout,'(i5,3f10.5)')
4428 > c & iii,(gradcorr5(jjj,iii),jjj=1,3)
4430 > if (energy_dec.and.wcorr5.gt.0.0d0)
4431 > 1 write (iout,'(a6,4i5,0pf7.3)')
4432 > 2 'ecorr5',i,j,i+1,j1,eello5(i,jp,i+1,jp1,jj,kk)
4434 < cd write(2,*)'ijkl',i,j,i+1,j1
4435 < if (wcorr6.gt.0.0d0 .and. (j.ne.i+4 .or. j1.ne.i+3
4437 > cd write(2,*)'ijkl',i,jp,i+1,jp1
4438 > if (wcorr6.gt.0.0d0 .and. (jp.ne.i+4 .or. jp1.ne.i+3
4440 < ecorr6=ecorr6+eello6(i,j,i+1,j1,jj,kk)
4442 > ecorr6=ecorr6+eello6(i,jp,i+1,jp1,jj,kk)
4443 > if (energy_dec) write (iout,'(a6,4i5,0pf7.3)')
4444 > 1 'ecorr6',i,j,i+1,j1,eello6(i,jp,i+1,jp1,jj,kk)
4446 < cd & dabs(eello4(i,j,i+1,j1,jj,kk)),
4447 < cd & dabs(eello5(i,j,i+1,j1,jj,kk)),
4448 < cd & dabs(eello6(i,j,i+1,j1,jj,kk))
4450 > cd & dabs(eello4(i,jp,i+1,jp1,jj,kk)),
4451 > cd & dabs(eello5(i,jp,i+1,jp1,jj,kk)),
4452 > cd & dabs(eello6(i,jp,i+1,jp1,jj,kk))
4454 < & .and. (j.eq.i+4 .and. j1.eq.i+3)) then
4455 < cd write (iout,*) '******eturn6: i,j,i+1,j1',i,j,i+1,j1
4457 > & .and. (jp.eq.i+4 .and. jp1.eq.i+3)) then
4458 > cd write (iout,*) '******eturn6: i,j,i+1,j1',i,jip,i+1,jp1
4460 > if (energy_dec) write (iout,'(a6,4i5,0pf7.3)')
4461 > 1 'eturn6',i,j,i+1,j1,eello_turn6(i,jj,kk)
4463 < else if (j1.eq.j) then
4464 < C Contacts I-J and I-(J+1) occur simultaneously.
4465 < C The system loses extra energy.
4466 < c ecorr=ecorr+ehbcorr(i,j,i+1,j,jj,kk,0.60D0,-0.40D0)
4470 < c write (iout,*) 'i=',i,' j=',j,' i1=',i1,' j1=',j1,
4471 < c & ' jj=',jj,' kk=',kk
4472 < if (j1.eq.j+1) then
4473 < C Contacts I-J and (I+1)-J occur simultaneously.
4474 < C The system loses extra energy.
4475 < c ecorr=ecorr+ehbcorr(i,j,i,j+1,jj,kk,0.60D0,-0.40D0)
4480 > num_cont_hb(i)=num_cont_hb_old(i)
4482 > c write (iout,*) "gradcorr5 in eello5"
4484 > c write (iout,'(i5,3f10.5)')
4485 > c & iii,(gradcorr5(jjj,iii),jjj=1,3)
4489 > c------------------------------------------------------------------------------
4490 > subroutine add_hb_contact_eello(ii,jj,itask)
4491 > implicit real*8 (a-h,o-z)
4492 > include "DIMENSIONS"
4493 > include "COMMON.IOUNITS"
4496 > parameter (max_cont=maxconts)
4497 > parameter (max_dim=70)
4498 > include "COMMON.CONTACTS"
4499 > double precision zapas(max_dim,maxconts,max_fg_procs),
4500 > & zapas_recv(max_dim,maxconts,max_fg_procs)
4501 > common /przechowalnia/ zapas
4502 > integer i,j,ii,jj,iproc,itask(4),nn
4503 > c write (iout,*) "itask",itask
4506 > if (iproc.gt.0) then
4507 > do j=1,num_cont_hb(ii)
4508 > jjc=jcont_hb(j,ii)
4509 > c write (iout,*) "send turns i",ii," j",jj," jjc",jjc
4510 > if (jjc.eq.jj) then
4511 > ncont_sent(iproc)=ncont_sent(iproc)+1
4512 > nn=ncont_sent(iproc)
4513 > zapas(1,nn,iproc)=ii
4514 > zapas(2,nn,iproc)=jjc
4515 > zapas(3,nn,iproc)=d_cont(j,ii)
4519 > zapas(ind,nn,iproc)=grij_hb_cont(kk,j,ii)
4524 > zapas(ind,nn,iproc)=a_chuj(ll,kk,j,ii)
4532 > zapas(ind,nn,iproc)=a_chuj_der(mm,ll,kk,jj,j,ii)
4543 < c write (iout,*)'Contacts have occurred for peptide groups',i,j,
4545 < c write (iout,*)'Contacts have occurred for peptide groups',
4546 < c & i,j,' fcont:',eij,' eij',' eesij',ees0pij,ees0mij,' and ',k,l
4547 < c & ,' fcont ',ekl,' eeskl',ees0pkl,ees0mkl,' ees=',ees
4549 > c write (iout,'(2(a,2i3,a,f10.5,a,2f10.5),a,f10.5,a,$)')
4550 > c & 'Contacts ',i,j,
4551 > c & ' eij',eij,' eesij',ees0pij,ees0mij,' and ',k,l
4552 > c & ,' fcont ',ekl,' eeskl',ees0pkl,ees0mkl,' energy=',ekont*ees,
4553 > c & 'gradcorr_long'
4555 < ecorr=ecorr+ekont*ees
4556 < if (calc_grad) then
4558 > c ecorr=ecorr+ekont*ees
4560 > coeffpees0pij=coeffp*ees0pij
4561 > coeffmees0mij=coeffm*ees0mij
4562 > coeffpees0pkl=coeffp*ees0pkl
4563 > coeffmees0mkl=coeffm*ees0mkl
4565 < ghalf=0.5D0*ees*ekl*gacont_hbr(ll,jj,i)
4566 < gradcorr(ll,i)=gradcorr(ll,i)+ghalf
4567 < & -ekont*(coeffp*ees0pkl*gacontp_hb1(ll,jj,i)+
4568 < & coeffm*ees0mkl*gacontm_hb1(ll,jj,i))
4569 < gradcorr(ll,j)=gradcorr(ll,j)+ghalf
4570 < & -ekont*(coeffp*ees0pkl*gacontp_hb2(ll,jj,i)+
4571 < & coeffm*ees0mkl*gacontm_hb2(ll,jj,i))
4572 < ghalf=0.5D0*ees*eij*gacont_hbr(ll,kk,k)
4573 < gradcorr(ll,k)=gradcorr(ll,k)+ghalf
4574 < & -ekont*(coeffp*ees0pij*gacontp_hb1(ll,kk,k)+
4575 < & coeffm*ees0mij*gacontm_hb1(ll,kk,k))
4576 < gradcorr(ll,l)=gradcorr(ll,l)+ghalf
4577 < & -ekont*(coeffp*ees0pij*gacontp_hb2(ll,kk,k)+
4578 < & coeffm*ees0mij*gacontm_hb2(ll,kk,k))
4582 < gradcorr(ll,m)=gradcorr(ll,m)+
4583 < & ees*ekl*gacont_hbr(ll,jj,i)-
4584 < & ekont*(coeffp*ees0pkl*gacontp_hb3(ll,jj,i)+
4585 < & coeffm*ees0mkl*gacontm_hb3(ll,jj,i))
4590 < gradcorr(ll,m)=gradcorr(ll,m)+
4591 < & ees*eij*gacont_hbr(ll,kk,k)-
4592 < & ekont*(coeffp*ees0pij*gacontp_hb3(ll,kk,k)+
4593 < & coeffm*ees0mij*gacontm_hb3(ll,kk,k))
4598 > cgrad ghalfi=ees*ekl*gacont_hbr(ll,jj,i)
4599 > gradcorr(ll,i)=gradcorr(ll,i)!+0.5d0*ghalfi
4600 > & -ekont*(coeffpees0pkl*gacontp_hb1(ll,jj,i)+
4601 > & coeffmees0mkl*gacontm_hb1(ll,jj,i))
4602 > gradcorr(ll,j)=gradcorr(ll,j)!+0.5d0*ghalfi
4603 > & -ekont*(coeffpees0pkl*gacontp_hb2(ll,jj,i)+
4604 > & coeffmees0mkl*gacontm_hb2(ll,jj,i))
4605 > cgrad ghalfk=ees*eij*gacont_hbr(ll,kk,k)
4606 > gradcorr(ll,k)=gradcorr(ll,k)!+0.5d0*ghalfk
4607 > & -ekont*(coeffpees0pij*gacontp_hb1(ll,kk,k)+
4608 > & coeffmees0mij*gacontm_hb1(ll,kk,k))
4609 > gradcorr(ll,l)=gradcorr(ll,l)!+0.5d0*ghalfk
4610 > & -ekont*(coeffpees0pij*gacontp_hb2(ll,kk,k)+
4611 > & coeffmees0mij*gacontm_hb2(ll,kk,k))
4612 > gradlongij=ees*ekl*gacont_hbr(ll,jj,i)-
4613 > & ekont*(coeffpees0pkl*gacontp_hb3(ll,jj,i)+
4614 > & coeffmees0mkl*gacontm_hb3(ll,jj,i))
4615 > gradcorr_long(ll,j)=gradcorr_long(ll,j)+gradlongij
4616 > gradcorr_long(ll,i)=gradcorr_long(ll,i)-gradlongij
4617 > gradlongkl=ees*eij*gacont_hbr(ll,kk,k)-
4618 > & ekont*(coeffpees0pij*gacontp_hb3(ll,kk,k)+
4619 > & coeffmees0mij*gacontm_hb3(ll,kk,k))
4620 > gradcorr_long(ll,l)=gradcorr_long(ll,l)+gradlongkl
4621 > gradcorr_long(ll,k)=gradcorr_long(ll,k)-gradlongkl
4622 > c write (iout,'(2f10.5,2x,$)') gradlongij,gradlongkl
4625 > cgrad do m=i+1,j-1
4627 > cgrad gradcorr(ll,m)=gradcorr(ll,m)+
4628 > cgrad & ees*ekl*gacont_hbr(ll,jj,i)-
4629 > cgrad & ekont*(coeffp*ees0pkl*gacontp_hb3(ll,jj,i)+
4630 > cgrad & coeffm*ees0mkl*gacontm_hb3(ll,jj,i))
4633 > cgrad do m=k+1,l-1
4635 > cgrad gradcorr(ll,m)=gradcorr(ll,m)+
4636 > cgrad & ees*eij*gacont_hbr(ll,kk,k)-
4637 > cgrad & ekont*(coeffp*ees0pij*gacontp_hb3(ll,kk,k)+
4638 > cgrad & coeffm*ees0mij*gacontm_hb3(ll,kk,k))
4641 > c write (iout,*) "ehbcorr",ekont*ees
4645 < include 'DIMENSIONS.ZSCOPT'
4647 < if (.not.calc_grad) return
4651 < include 'DIMENSIONS.ZSCOPT'
4653 > cd write (iout,*) "a_chujij",((a_chuj(iii,jjj,jj,i),iii=1,2),jjj=1,2)
4654 > cd write (iout,*) "a_chujkl",((a_chuj(iii,jjj,kk,k),iii=1,2),jjj=1,2)
4656 < include 'DIMENSIONS.ZSCOPT'
4658 < if (calc_grad) then
4660 < cold ghalf=0.5d0*eel4*ekl*gacont_hbr(ll,jj,i)
4661 < ggg1(ll)=eel4*g_contij(ll,1)
4662 < ggg2(ll)=eel4*g_contij(ll,2)
4663 < ghalf=0.5d0*ggg1(ll)
4665 < gradcorr(ll,i)=gradcorr(ll,i)+ghalf+ekont*derx(ll,2,1)
4667 > cgrad ggg1(ll)=eel4*g_contij(ll,1)
4668 > cgrad ggg2(ll)=eel4*g_contij(ll,2)
4669 > glongij=eel4*g_contij(ll,1)+ekont*derx(ll,1,1)
4670 > glongkl=eel4*g_contij(ll,2)+ekont*derx(ll,1,2)
4671 > cgrad ghalf=0.5d0*ggg1(ll)
4672 > gradcorr(ll,i)=gradcorr(ll,i)+ekont*derx(ll,2,1)
4674 < gradcorr(ll,j)=gradcorr(ll,j)+ghalf+ekont*derx(ll,4,1)
4676 > gradcorr(ll,j)=gradcorr(ll,j)+ekont*derx(ll,4,1)
4678 < cold ghalf=0.5d0*eel4*eij*gacont_hbr(ll,kk,k)
4679 < ghalf=0.5d0*ggg2(ll)
4681 < gradcorr(ll,k)=gradcorr(ll,k)+ghalf+ekont*derx(ll,2,2)
4683 > gradcorr_long(ll,j)=gradcorr_long(ll,j)+glongij
4684 > gradcorr_long(ll,i)=gradcorr_long(ll,i)-glongij
4685 > cgrad ghalf=0.5d0*ggg2(ll)
4686 > gradcorr(ll,k)=gradcorr(ll,k)+ekont*derx(ll,2,2)
4688 < gradcorr(ll,l)=gradcorr(ll,l)+ghalf+ekont*derx(ll,4,2)
4690 > gradcorr(ll,l)=gradcorr(ll,l)+ekont*derx(ll,4,2)
4692 > gradcorr_long(ll,l)=gradcorr_long(ll,l)+glongkl
4693 > gradcorr_long(ll,k)=gradcorr_long(ll,k)-glongkl
4698 < cold gradcorr(ll,m)=gradcorr(ll,m)+eel4*ekl*gacont_hbr(ll,jj,i)
4699 < gradcorr(ll,m)=gradcorr(ll,m)+ggg1(ll)
4704 < cold gradcorr(ll,m)=gradcorr(ll,m)+eel4*eij*gacont_hbr(ll,kk,k)
4705 < gradcorr(ll,m)=gradcorr(ll,m)+ggg2(ll)
4711 < gradcorr(ll,m)=gradcorr(ll,m)+ekont*derx(ll,1,1)
4716 < gradcorr(ll,m)=gradcorr(ll,m)+ekont*derx(ll,1,2)
4720 > cgrad do m=i+1,j-1
4722 > cgrad gradcorr(ll,m)=gradcorr(ll,m)+ggg1(ll)
4725 > cgrad do m=k+1,l-1
4727 > cgrad gradcorr(ll,m)=gradcorr(ll,m)+ggg2(ll)
4732 > cgrad gradcorr(ll,m)=gradcorr(ll,m)+ekont*derx(ll,1,1)
4737 > cgrad gradcorr(ll,m)=gradcorr(ll,m)+ekont*derx(ll,1,2)
4743 < include 'DIMENSIONS.ZSCOPT'
4745 < if (calc_grad) then
4749 < if (calc_grad) then
4753 < if (calc_grad) then
4757 < if (calc_grad) then
4761 < if (calc_grad) then
4765 < if (calc_grad) then
4769 < if (calc_grad) then
4771 > C 2/11/08 AL Gradients over DC's connecting interacting sites will be
4772 > C summed up outside the subrouine as for the other subroutines
4773 > C handling long-range interactions. The old code is commented out
4774 > C with "cgrad" to keep track of changes.
4776 < ggg1(ll)=eel5*g_contij(ll,1)
4777 < ggg2(ll)=eel5*g_contij(ll,2)
4779 > cgrad ggg1(ll)=eel5*g_contij(ll,1)
4780 > cgrad ggg2(ll)=eel5*g_contij(ll,2)
4781 > gradcorr5ij=eel5*g_contij(ll,1)+ekont*derx(ll,1,1)
4782 > gradcorr5kl=eel5*g_contij(ll,2)+ekont*derx(ll,1,2)
4783 > c write (iout,'(a,3i3,a,5f8.3,2i3,a,5f8.3,a,f8.3)')
4784 > c & "ecorr5",ll,i,j," derx",derx(ll,2,1),derx(ll,3,1),derx(ll,4,1),
4785 > c & derx(ll,5,1),k,l," derx",derx(ll,2,2),derx(ll,3,2),
4786 > c & derx(ll,4,2),derx(ll,5,2)," ekont",ekont
4787 > c write (iout,'(a,3i3,a,3f8.3,2i3,a,3f8.3)')
4788 > c & "ecorr5",ll,i,j," gradcorr5",g_contij(ll,1),derx(ll,1,1),
4790 > c & k,l," gradcorr5",g_contij(ll,2),derx(ll,1,2),gradcorr5kl
4792 < ghalf=0.5d0*ggg1(ll)
4794 > cgrad ghalf=0.5d0*ggg1(ll)
4796 < gradcorr5(ll,i)=gradcorr5(ll,i)+ghalf+ekont*derx(ll,2,1)
4798 > gradcorr5(ll,i)=gradcorr5(ll,i)+ekont*derx(ll,2,1)
4800 < gradcorr5(ll,j)=gradcorr5(ll,j)+ghalf+ekont*derx(ll,4,1)
4802 > gradcorr5(ll,j)=gradcorr5(ll,j)+ekont*derx(ll,4,1)
4804 > gradcorr5_long(ll,j)=gradcorr5_long(ll,j)+gradcorr5ij
4805 > gradcorr5_long(ll,i)=gradcorr5_long(ll,i)-gradcorr5ij
4807 < ghalf=0.5d0*ggg2(ll)
4809 > cgrad ghalf=0.5d0*ggg2(ll)
4811 > gradcorr5_long(ll,l)=gradcorr5_long(ll,l)+gradcorr5kl
4812 > gradcorr5_long(ll,k)=gradcorr5_long(ll,k)-gradcorr5kl
4817 > cgrad do m=i+1,j-1
4820 < gradcorr5(ll,m)=gradcorr5(ll,m)+ggg1(ll)
4826 > cgrad gradcorr5(ll,m)=gradcorr5(ll,m)+ggg1(ll)
4829 > cgrad do m=k+1,l-1
4832 < gradcorr5(ll,m)=gradcorr5(ll,m)+ggg2(ll)
4836 > cgrad gradcorr5(ll,m)=gradcorr5(ll,m)+ggg2(ll)
4842 < gradcorr5(ll,m)=gradcorr5(ll,m)+ekont*derx(ll,1,1)
4847 < gradcorr5(ll,m)=gradcorr5(ll,m)+ekont*derx(ll,1,2)
4853 > cgrad gradcorr5(ll,m)=gradcorr5(ll,m)+ekont*derx(ll,1,1)
4858 > cgrad gradcorr5(ll,m)=gradcorr5(ll,m)+ekont*derx(ll,1,2)
4864 < include 'DIMENSIONS.ZSCOPT'
4866 < cd write(iout,*) 'eello6_1',eello6_1,' eel6_1_num',16*eel6_1_num
4867 < cd write(iout,*) 'eello6_2',eello6_2,' eel6_2_num',16*eel6_2_num
4868 < cd write(iout,*) 'eello6_3',eello6_3,' eel6_3_num',16*eel6_3_num
4869 < cd write(iout,*) 'eello6_4',eello6_4,' eel6_4_num',16*eel6_4_num
4870 < cd write(iout,*) 'eello6_5',eello6_5,' eel6_5_num',16*eel6_5_num
4871 < cd write(iout,*) 'eello6_6',eello6_6,' eel6_6_num',16*eel6_6_num
4873 > cd write(iout,*) 'eello6_1',eello6_1!,' eel6_1_num',16*eel6_1_num
4874 > cd write(iout,*) 'eello6_2',eello6_2!,' eel6_2_num',16*eel6_2_num
4875 > cd write(iout,*) 'eello6_3',eello6_3!,' eel6_3_num',16*eel6_3_num
4876 > cd write(iout,*) 'eello6_4',eello6_4!,' eel6_4_num',16*eel6_4_num
4877 > cd write(iout,*) 'eello6_5',eello6_5!,' eel6_5_num',16*eel6_5_num
4878 > cd write(iout,*) 'eello6_6',eello6_6!,' eel6_6_num',16*eel6_6_num
4880 < if (calc_grad) then
4882 < ggg1(ll)=eel6*g_contij(ll,1)
4883 < ggg2(ll)=eel6*g_contij(ll,2)
4885 > cgrad ggg1(ll)=eel6*g_contij(ll,1)
4886 > cgrad ggg2(ll)=eel6*g_contij(ll,2)
4888 < ghalf=0.5d0*ggg1(ll)
4890 > cgrad ghalf=0.5d0*ggg1(ll)
4892 < gradcorr6(ll,i)=gradcorr6(ll,i)+ghalf+ekont*derx(ll,2,1)
4894 > gradcorr6ij=eel6*g_contij(ll,1)+ekont*derx(ll,1,1)
4895 > gradcorr6kl=eel6*g_contij(ll,2)+ekont*derx(ll,1,2)
4896 > gradcorr6(ll,i)=gradcorr6(ll,i)+ekont*derx(ll,2,1)
4898 < gradcorr6(ll,j)=gradcorr6(ll,j)+ghalf+ekont*derx(ll,4,1)
4900 > gradcorr6(ll,j)=gradcorr6(ll,j)+ekont*derx(ll,4,1)
4902 < ghalf=0.5d0*ggg2(ll)
4904 > gradcorr6_long(ll,j)=gradcorr6_long(ll,j)+gradcorr6ij
4905 > gradcorr6_long(ll,i)=gradcorr6_long(ll,i)-gradcorr6ij
4906 > cgrad ghalf=0.5d0*ggg2(ll)
4908 < gradcorr6(ll,k)=gradcorr6(ll,k)+ghalf+ekont*derx(ll,2,2)
4910 > gradcorr6(ll,k)=gradcorr6(ll,k)+ekont*derx(ll,2,2)
4912 < gradcorr6(ll,l)=gradcorr6(ll,l)+ghalf+ekont*derx(ll,4,2)
4914 > gradcorr6(ll,l)=gradcorr6(ll,l)+ekont*derx(ll,4,2)
4916 > gradcorr6_long(ll,l)=gradcorr6_long(ll,l)+gradcorr6kl
4917 > gradcorr6_long(ll,k)=gradcorr6_long(ll,k)-gradcorr6kl
4922 > cgrad do m=i+1,j-1
4925 < gradcorr6(ll,m)=gradcorr6(ll,m)+ggg1(ll)
4931 > cgrad gradcorr6(ll,m)=gradcorr6(ll,m)+ggg1(ll)
4934 > cgrad do m=k+1,l-1
4937 < gradcorr6(ll,m)=gradcorr6(ll,m)+ggg2(ll)
4943 < gradcorr6(ll,m)=gradcorr6(ll,m)+ekont*derx(ll,1,1)
4948 < gradcorr6(ll,m)=gradcorr6(ll,m)+ekont*derx(ll,1,2)
4952 > cgrad gradcorr6(ll,m)=gradcorr6(ll,m)+ggg2(ll)
4955 > cgrad1112 continue
4958 > cgrad gradcorr6(ll,m)=gradcorr6(ll,m)+ekont*derx(ll,1,1)
4963 > cgrad gradcorr6(ll,m)=gradcorr6(ll,m)+ekont*derx(ll,1,2)
4969 < include 'DIMENSIONS.ZSCOPT'
4971 < if (.not. calc_grad) return
4973 < include 'DIMENSIONS.ZSCOPT'
4975 < if (.not. calc_grad) return
4977 < include 'DIMENSIONS.ZSCOPT'
4979 < cd write (2,*) 'eello6_graph3:','s1',s1,' s2',s2,' s3',s3,' s4',s4
4981 > cd write (2,*) 'eello6_graph3:','s1',s1,' s2',s2,' s3',s3,' s4',s4,
4982 > cd & "sum",-(s2+s3+s4)
4984 < if (.not. calc_grad) return
4986 < include 'DIMENSIONS.ZSCOPT'
4988 < if (.not. calc_grad) return
4990 < include 'DIMENSIONS.ZSCOPT'
5006 < if (calc_grad) then
5038 < ggg1(ll)=eel_turn6*g_contij(ll,1)
5039 < ggg2(ll)=eel_turn6*g_contij(ll,2)
5040 < ghalf=0.5d0*ggg1(ll)
5042 > cgrad ggg1(ll)=eel_turn6*g_contij(ll,1)
5043 > cgrad ggg2(ll)=eel_turn6*g_contij(ll,2)
5044 > cgrad ghalf=0.5d0*ggg1(ll)
5046 < gcorr6_turn(ll,i)=gcorr6_turn(ll,i)+ghalf
5048 > gturn6ij=eel_turn6*g_contij(ll,1)+ekont*derx_turn(ll,1,1)
5049 > gturn6kl=eel_turn6*g_contij(ll,2)+ekont*derx_turn(ll,1,2)
5050 > gcorr6_turn(ll,i)=gcorr6_turn(ll,i)!+ghalf
5052 < gcorr6_turn(ll,j)=gcorr6_turn(ll,j)+ghalf
5054 > gcorr6_turn(ll,j)=gcorr6_turn(ll,j)!+ghalf
5056 < ghalf=0.5d0*ggg2(ll)
5058 > gcorr6_turn_long(ll,j)=gcorr6_turn_long(ll,j)+gturn6ij
5059 > gcorr6_turn_long(ll,i)=gcorr6_turn_long(ll,i)-gturn6ij
5060 > cgrad ghalf=0.5d0*ggg2(ll)
5062 < gcorr6_turn(ll,k)=gcorr6_turn(ll,k)+ghalf
5064 > gcorr6_turn(ll,k)=gcorr6_turn(ll,k)!+ghalf
5066 < gcorr6_turn(ll,l)=gcorr6_turn(ll,l)+ghalf
5068 > gcorr6_turn(ll,l)=gcorr6_turn(ll,l)!+ghalf
5070 > gcorr6_turn_long(ll,l)=gcorr6_turn_long(ll,l)+gturn6kl
5071 > gcorr6_turn_long(ll,k)=gcorr6_turn_long(ll,k)-gturn6kl
5075 < gcorr6_turn(ll,m)=gcorr6_turn(ll,m)+ggg1(ll)
5080 < gcorr6_turn(ll,m)=gcorr6_turn(ll,m)+ggg2(ll)
5086 < gcorr6_turn(ll,m)=gcorr6_turn(ll,m)+ekont*derx_turn(ll,1,1)
5091 < gcorr6_turn(ll,m)=gcorr6_turn(ll,m)+ekont*derx_turn(ll,1,2)
5095 > cgrad do m=i+1,j-1
5097 > cgrad gcorr6_turn(ll,m)=gcorr6_turn(ll,m)+ggg1(ll)
5100 > cgrad do m=k+1,l-1
5102 > cgrad gcorr6_turn(ll,m)=gcorr6_turn(ll,m)+ggg2(ll)
5105 > cgrad1112 continue
5108 > cgrad gcorr6_turn(ll,m)=gcorr6_turn(ll,m)+ekont*derx_turn(ll,1,1)
5113 > cgrad gcorr6_turn(ll,m)=gcorr6_turn(ll,m)+ekont*derx_turn(ll,1,2)
5120 > C-----------------------------------------------------------------------------
5121 > double precision function scalar(u,v)
5122 > !DIR$ INLINEALWAYS scalar
5124 > cDEC$ ATTRIBUTES FORCEINLINE::scalar
5127 > double precision u(3),v(3)
5128 > cd double precision sc
5132 > cd sc=sc+u(i)*v(i)
5136 > scalar=u(1)*v(1)+u(2)*v(2)+u(3)*v(3)
5140 > !DIR$ INLINEALWAYS MATVEC2
5142 > cDEC$ ATTRIBUTES FORCEINLINE::MATVEC2
5146 > cDEC$ ATTRIBUTES FORCEINLINE::MATMAT2
5149 > !DIR$ INLINEALWAYS scalar2
5151 > !DIR$ INLINEALWAYS transpose2
5153 > cDEC$ ATTRIBUTES FORCEINLINE::transpose2
5156 > !DIR$ INLINEALWAYS prodmat3
5158 > cDEC$ ATTRIBUTES FORCEINLINE::prodmat3
5161 < C-----------------------------------------------------------------------------
5162 < double precision function scalar(u,v)
5164 < double precision u(3),v(3)
5165 < double precision sc