2 implicit real*8 (a-h,o-z)
7 & /'pool','chain regrow','multi-bond','phi','theta','side chain',
9 c Conversion from poises to molecular unit and the gas constant
10 data cPoise /2.9361d0/, Rb /0.001986d0/
12 c--------------------------------------------------------------------------
15 C Define constants and zero out tables.
17 implicit real*8 (a-h,o-z)
25 cMS$ATTRIBUTES C :: proc_proc
28 include 'COMMON.IOUNITS'
29 include 'COMMON.CHAIN'
30 include 'COMMON.INTERACT'
32 include 'COMMON.LOCAL'
33 include 'COMMON.TORSION'
34 include 'COMMON.FFIELD'
35 include 'COMMON.SBRIDGE'
37 include 'COMMON.MINIM'
38 include 'COMMON.DERIV'
39 include 'COMMON.SPLITELE'
40 c Common blocks from the diagonalization routines
41 COMMON /IOFILE/ IR,IW,IP,IJK,IPK,IDAF,NAV,IODA(400)
42 COMMON /MACHSW/ KDIAG,ICORFL,IXDR
44 c real*8 text1 /'initial_i'/
62 C The following is just to define auxiliary variables used in angle conversion
99 crc for write_rmsbank1
101 cdr include secondary structure prediction bias
104 C CSA I/O units (separated from others especially for Jooyoung)
115 icsa_bank_reminimized=38
118 crc for ifc error 118
121 C Set default weights of the energy terms.
132 print '(a,$)','Inside initialize'
133 c call memmon_print_usage()
183 gaussc(l,k,j,i)=0.0D0
204 C Initialize the bridge arrays
223 C Initialize variables used in minimization.
232 C Initialize the variables responsible for the mode of gradient storage.
237 C Initialize constants used to split the energy into long- and short-range
243 nprint_ene=nprint_ene-1
247 c-------------------------------------------------------------------------
249 implicit real*8 (a-h,o-z)
251 include 'COMMON.NAMES'
252 include 'COMMON.FFIELD'
254 &'CYS','MET','PHE','ILE','LEU','VAL','TRP','TYR','ALA','GLY','THR',
255 &'SER','GLN','ASN','GLU','ASP','HIS','ARG','LYS','PRO','D'/
257 &'C','M','F','I','L','V','W','Y','A','G','T',
258 &'S','Q','N','E','D','H','R','K','P','X'/
259 data potname /'LJ','LJK','BP','GB','GBV'/
261 & "EVDW SC-SC","EVDW2 SC-p","EES p-p","ECORR4 ","ECORR5 ",
262 & "ECORR6 ","EELLO ","ETURN3 ","ETURN4 ","ETURN6 ",
263 & "EBE bend","ESC SCloc","ETORS ","ETORSD ","EHPB ","EVDWPP ",
264 & "ESTR ","EVDW2_14 ","UCONST ", " ","ESCCOR"/
266 & "WSC","WSCP","WELEC","WCORR","WCORR5","WCORR6","WEL_LOC",
267 & "WTURN3","WTURN4","WTURN6","WANG","WSCLOC","WTOR","WTORD",
268 & "WSTRAIN","WVDWPP","WBOND","SCAL14"," "," ","WSCCOR"/
270 data print_order/1,2,3,11,12,13,14,4,5,6,7,8,9,10,19,18,15,17,16,
273 c---------------------------------------------------------------------------
274 subroutine init_int_table
275 implicit real*8 (a-h,o-z)
279 integer blocklengths(15),displs(15)
281 include 'COMMON.CONTROL'
282 include 'COMMON.SETUP'
283 include 'COMMON.CHAIN'
284 include 'COMMON.INTERACT'
285 include 'COMMON.LOCAL'
286 include 'COMMON.SBRIDGE'
287 include 'COMMON.TORCNSTR'
288 include 'COMMON.IOUNITS'
289 logical scheck,lprint
291 integer my_sc_int(0:max_fg_Procs-1),my_sc_intt(0:max_fg_Procs),
292 & my_ele_int(0:max_fg_Procs-1),my_ele_intt(0:max_fg_Procs)
293 C... Determine the numbers of start and end SC-SC interaction
294 C... to deal with by current processor.
297 &write (iout,*) 'INIT_INT_TABLE nres=',nres,' nnt=',nnt,' nct=',nct
298 n_sc_int_tot=(nct-nnt+1)*(nct-nnt)/2-nss
299 call int_bounds(n_sc_int_tot,my_sc_inds,my_sc_inde)
301 & write (iout,*) 'Processor',fg_rank,' CG group',kolor,
302 & ' absolute rank',MyRank,
303 & ' n_sc_int_tot',n_sc_int_tot,' my_sc_inds=',my_sc_inds,
304 & ' my_sc_inde',my_sc_inde
324 cd write (iout,*) 'ns=',ns,' nss=',nss,' ihpb,jhpb',
325 cd & (ihpb(i),jhpb(i),i=1,nss)
329 if (ihpb(ii).eq.i+nres) then
336 cd write (iout,*) 'i=',i,' scheck=',scheck,' jj=',jj
340 write (iout,*) 'jj=i+1'
341 call int_partition(ind_scint,my_sc_inds,my_sc_inde,i,
342 & iatsc_s,iatsc_e,i+2,nct,nint_gr(i),istart(i,1),iend(i,1),*12)
348 else if (jj.eq.nct) then
350 write (iout,*) 'jj=nct'
351 call int_partition(ind_scint,my_sc_inds,my_sc_inde,i,
352 & iatsc_s,iatsc_e,i+1,nct-1,nint_gr(i),istart(i,1),iend(i,1),*12)
360 call int_partition(ind_scint,my_sc_inds,my_sc_inde,i,
361 & iatsc_s,iatsc_e,i+1,jj-1,nint_gr(i),istart(i,1),iend(i,1),*12)
363 call int_partition(ind_scint,my_sc_inds,my_sc_inde,i,
364 & iatsc_s,iatsc_e,jj+1,nct,nint_gr(i),istart(i,ii),iend(i,ii),*12)
375 call int_partition(ind_scint,my_sc_inds,my_sc_inde,i,
376 & iatsc_s,iatsc_e,i+1,nct,nint_gr(i),istart(i,1),iend(i,1),*12)
381 ind_scint=ind_scint+nct-i
385 ind_scint_old=ind_scint
394 if (lprint) write (*,*) 'Processor',fg_rank,' CG Group',kolor,
395 & ' absolute rank',myrank,' iatsc_s=',iatsc_s,' iatsc_e=',iatsc_e
398 write (iout,'(a)') 'Interaction array:'
400 write (iout,'(i3,2(2x,2i3))')
401 & i,(istart(i,iint),iend(i,iint),iint=1,nint_gr(i))
406 C Now partition the electrostatic-interaction array
408 nele_int_tot=(npept-ispp)*(npept-ispp+1)/2
409 call int_bounds(nele_int_tot,my_ele_inds,my_ele_inde)
411 & write (*,*) 'Processor',fg_rank,' CG group',kolor,
412 & ' absolute rank',MyRank,
413 & ' nele_int_tot',nele_int_tot,' my_ele_inds=',my_ele_inds,
414 & ' my_ele_inde',my_ele_inde
421 call int_partition(ind_eleint,my_ele_inds,my_ele_inde,i,
422 & iatel_s,iatel_e,i+ispp,nct-1,ijunk,ielstart(i),ielend(i),*13)
434 write (*,'(a)') 'Processor',fg_rank,' CG group',kolor,
435 & ' absolute rank',MyRank
436 write (iout,*) 'Electrostatic interaction array:'
438 write (iout,'(i3,2(2x,2i3))') i,ielstart(i),ielend(i)
443 C Partition the SC-p interaction array
445 nscp_int_tot=(npept-iscp+1)*(npept-iscp+1)
446 call int_bounds(nscp_int_tot,my_scp_inds,my_scp_inde)
447 if (lprint) write (iout,*) 'Processor',fg_rank,' CG group',kolor,
448 & ' absolute rank',myrank,
449 & ' nscp_int_tot',nscp_int_tot,' my_scp_inds=',my_scp_inds,
450 & ' my_scp_inde',my_scp_inde
456 if (i.lt.nnt+iscp) then
457 cd write (iout,*) 'i.le.nnt+iscp'
458 call int_partition(ind_scpint,my_scp_inds,my_scp_inde,i,
459 & iatscp_s,iatscp_e,i+iscp,nct,nscp_gr(i),iscpstart(i,1),
461 else if (i.gt.nct-iscp) then
462 cd write (iout,*) 'i.gt.nct-iscp'
463 call int_partition(ind_scpint,my_scp_inds,my_scp_inde,i,
464 & iatscp_s,iatscp_e,nnt,i-iscp,nscp_gr(i),iscpstart(i,1),
467 call int_partition(ind_scpint,my_scp_inds,my_scp_inde,i,
468 & iatscp_s,iatscp_e,nnt,i-iscp,nscp_gr(i),iscpstart(i,1),
471 call int_partition(ind_scpint,my_scp_inds,my_scp_inde,i,
472 & iatscp_s,iatscp_e,i+iscp,nct,nscp_gr(i),iscpstart(i,ii),
481 if (i.lt.nnt+iscp) then
483 iscpstart(i,1)=i+iscp
485 elseif (i.gt.nct-iscp) then
493 iscpstart(i,2)=i+iscp
499 write (iout,'(a)') 'SC-p interaction array:'
500 do i=iatscp_s,iatscp_e
501 write (iout,'(i3,2(2x,2i3))')
502 & i,(iscpstart(i,j),iscpend(i,j),j=1,nscp_gr(i))
505 C Partition local interactions
507 call int_bounds(nres-2,loc_start,loc_end)
508 loc_start=loc_start+1
510 call int_bounds(nres-2,ithet_start,ithet_end)
511 ithet_start=ithet_start+2
512 ithet_end=ithet_end+2
513 call int_bounds(nct-nnt-2,iphi_start,iphi_end)
514 iphi_start=iphi_start+nnt+2
515 iphi_end=iphi_end+nnt+2
516 call int_bounds(nct-nnt-3,iphid_start,iphid_end)
517 iphid_start=iphid_start+nnt+2
518 iphid_end=iphid_end+nnt+2
519 call int_bounds(nres-2,ibond_start,ibond_end)
520 ibond_start=ibond_start+1
521 ibond_end=ibond_end+1
522 call int_bounds(nct-nnt,ibondp_start,ibondp_end)
523 ibondp_start=ibondp_start+nnt
524 ibondp_end=ibondp_end+nnt
525 call int_bounds(nres-1,ivec_start,ivec_end)
526 iset_start=loc_start+2
528 if (ndih_constr.eq.0) then
532 call int_bounds(ndih_constr,idihconstr_start,idihconstr_end)
536 write (*,*) 'Processor:',fg_rank,' CG group',kolor,
537 & ' absolute rank',myrank,
538 & ' loc_start',loc_start,' loc_end',loc_end,
539 & ' ithet_start',ithet_start,' ithet_end',ithet_end,
540 & ' iphi_start',iphi_start,' iphi_end',iphi_end,
541 & ' iphid_start',iphid_start,' iphid_end',iphid_end,
542 & ' ibond_start',ibond_start,' ibond_end',ibond_end,
543 & ' ibondp_start',ibondp_start,' ibondp_end',ibondp_end,
544 & ' ivec_start',ivec_start,' ivec_end',ivec_end,
545 & ' iset_start',iset_start,' iset_end',iset_end,
546 & ' idihconstr_start',idihconstr_start,' idihconstr_end',
549 if (nfgtasks.gt.1) then
550 call MPI_Allgather(ivec_start,1,MPI_INTEGER,ivec_displ(0),1,
551 & MPI_INTEGER,FG_COMM,IERROR)
552 iaux=ivec_end-ivec_start+1
553 call MPI_Allgather(iaux,1,MPI_INTEGER,ivec_count(0),1,
554 & MPI_INTEGER,FG_COMM,IERROR)
555 call MPI_Allgather(iset_start-2,1,MPI_INTEGER,iset_displ(0),1,
556 & MPI_INTEGER,FG_COMM,IERROR)
557 iaux=iset_end-iset_start+1
558 call MPI_Allgather(iaux,1,MPI_INTEGER,iset_count(0),1,
559 & MPI_INTEGER,FG_COMM,IERROR)
560 call MPI_Type_contiguous(3,MPI_DOUBLE_PRECISION,MPI_UYZ,IERROR)
561 call MPI_Type_commit(MPI_UYZ,IERROR)
562 call MPI_Type_contiguous(18,MPI_DOUBLE_PRECISION,MPI_UYZGRAD,
564 call MPI_Type_commit(MPI_UYZGRAD,IERROR)
565 call MPI_Type_contiguous(2,MPI_DOUBLE_PRECISION,MPI_MU,IERROR)
566 call MPI_Type_commit(MPI_MU,IERROR)
567 call MPI_Type_contiguous(4,MPI_DOUBLE_PRECISION,MPI_MAT1,IERROR)
568 call MPI_Type_commit(MPI_MAT1,IERROR)
569 call MPI_Type_contiguous(8,MPI_DOUBLE_PRECISION,MPI_MAT2,IERROR)
570 call MPI_Type_commit(MPI_MAT2,IERROR)
572 c 9/22/08 Derived types to send matrices which appear in correlation terms
574 if (ivec_count(i).eq.ivec_count(0)) then
580 do ind_typ=lentyp(0),lentyp(nfgtasks-1)
581 if (ind_typ.eq.0) then
591 c displs(i)=displs(i-1)+blocklengths(i-1)*maxres
594 c blocklengths(i)=blocklengths(i)*ichunk
596 c write (iout,*) "blocklengths and displs"
598 c write (iout,*) i,blocklengths(i),displs(i)
601 c call MPI_Type_indexed(4,blocklengths(1),displs(1),
602 c & MPI_DOUBLE_PRECISION,MPI_ROTAT1(ind_typ),IERROR)
603 c call MPI_Type_commit(MPI_ROTAT1(ind_typ),IERROR)
604 c write (iout,*) "MPI_ROTAT1",MPI_ROTAT1
610 c displs(i)=displs(i-1)+blocklengths(i-1)*maxres
613 c blocklengths(i)=blocklengths(i)*ichunk
615 c write (iout,*) "blocklengths and displs"
617 c write (iout,*) i,blocklengths(i),displs(i)
620 c call MPI_Type_indexed(4,blocklengths(1),displs(1),
621 c & MPI_DOUBLE_PRECISION,MPI_ROTAT2(ind_typ),IERROR)
622 c call MPI_Type_commit(MPI_ROTAT2(ind_typ),IERROR)
623 c write (iout,*) "MPI_ROTAT2",MPI_ROTAT2
629 displs(i)=displs(i-1)+blocklengths(i-1)*maxres
632 blocklengths(i)=blocklengths(i)*ichunk
634 call MPI_Type_indexed(8,blocklengths,displs,
635 & MPI_DOUBLE_PRECISION,MPI_PRECOMP11(ind_typ),IERROR)
636 call MPI_Type_commit(MPI_PRECOMP11(ind_typ),IERROR)
642 displs(i)=displs(i-1)+blocklengths(i-1)*maxres
645 blocklengths(i)=blocklengths(i)*ichunk
647 call MPI_Type_indexed(8,blocklengths,displs,
648 & MPI_DOUBLE_PRECISION,MPI_PRECOMP12(ind_typ),IERROR)
649 call MPI_Type_commit(MPI_PRECOMP12(ind_typ),IERROR)
655 displs(i)=displs(i-1)+blocklengths(i-1)*maxres
658 blocklengths(i)=blocklengths(i)*ichunk
660 call MPI_Type_indexed(6,blocklengths,displs,
661 & MPI_DOUBLE_PRECISION,MPI_PRECOMP22(ind_typ),IERROR)
662 call MPI_Type_commit(MPI_PRECOMP22(ind_typ),IERROR)
668 displs(i)=displs(i-1)+blocklengths(i-1)*maxres
671 blocklengths(i)=blocklengths(i)*ichunk
673 call MPI_Type_indexed(2,blocklengths,displs,
674 & MPI_DOUBLE_PRECISION,MPI_PRECOMP23(ind_typ),IERROR)
675 call MPI_Type_commit(MPI_PRECOMP23(ind_typ),IERROR)
681 displs(i)=displs(i-1)+blocklengths(i-1)*maxres
684 blocklengths(i)=blocklengths(i)*ichunk
686 call MPI_Type_indexed(4,blocklengths,displs,
687 & MPI_DOUBLE_PRECISION,MPI_ROTAT_OLD(ind_typ),IERROR)
688 call MPI_Type_commit(MPI_ROTAT_OLD(ind_typ),IERROR)
693 ivec_displ(i)=ivec_displ(i)-1
694 iset_displ(i)=iset_displ(i)-1
696 if (nfgtasks.gt.1 .and. fg_rank.eq.king
697 & .and. (me.eq.0 .or. out1file)) then
698 write (iout,*) "IVEC_DISPL, IVEC_COUNT, ISET_START, ISET_COUNT"
700 write (iout,*) i,ivec_displ(i),ivec_count(i),iset_displ(i),
703 write(iout,'(i10,a,i10,a,i10,a/a,i3,a)') n_sc_int_tot,' SC-SC ',
704 & nele_int_tot,' electrostatic and ',nscp_int_tot,
705 & ' SC-p interactions','were distributed among',nfgtasks,
706 & ' fine-grain processors.'
716 idihconstr_end=ndih_constr
717 iphid_start=iphi_start
731 c---------------------------------------------------------------------------
732 subroutine int_bounds(total_ints,lower_bound,upper_bound)
733 implicit real*8 (a-h,o-z)
736 include 'COMMON.SETUP'
737 integer total_ints,lower_bound,upper_bound
738 integer int4proc(0:max_fg_procs),sint4proc(0:max_fg_procs)
739 nint=total_ints/nfgtasks
743 nexcess=total_ints-nint*nfgtasks
745 int4proc(nfgtasks-i)=int4proc(nfgtasks-i)+1
749 lower_bound=lower_bound+int4proc(i)
751 upper_bound=lower_bound+int4proc(fg_rank)
752 lower_bound=lower_bound+1
755 c---------------------------------------------------------------------------
756 subroutine int_partition(int_index,lower_index,upper_index,atom,
757 & at_start,at_end,first_atom,last_atom,int_gr,jat_start,jat_end,*)
758 implicit real*8 (a-h,o-z)
760 include 'COMMON.IOUNITS'
761 integer int_index,lower_index,upper_index,atom,at_start,at_end,
762 & first_atom,last_atom,int_gr,jat_start,jat_end
765 if (lprn) write (iout,*) 'int_index=',int_index
766 int_index_old=int_index
767 int_index=int_index+last_atom-first_atom+1
769 & write (iout,*) 'int_index=',int_index,
770 & ' int_index_old',int_index_old,
771 & ' lower_index=',lower_index,
772 & ' upper_index=',upper_index,
773 & ' atom=',atom,' first_atom=',first_atom,
774 & ' last_atom=',last_atom
775 if (int_index.ge.lower_index) then
777 if (at_start.eq.0) then
779 jat_start=first_atom-1+lower_index-int_index_old
783 if (lprn) write (iout,*) 'jat_start',jat_start
784 if (int_index.ge.upper_index) then
786 jat_end=first_atom-1+upper_index-int_index_old
791 if (lprn) write (iout,*) 'jat_end',jat_end
796 c------------------------------------------------------------------------------
797 subroutine hpb_partition
798 implicit real*8 (a-h,o-z)
803 include 'COMMON.SBRIDGE'
804 include 'COMMON.IOUNITS'
805 include 'COMMON.SETUP'
807 call int_bounds(nhpb,link_start,link_end)
808 cd write (*,*) 'Processor',fg_rank,' CG group',color,
809 cd ' absolute rank',MyRank,
810 cd & ' nhpb',nhpb,' link_start=',link_start,
811 cd & ' link_end',link_end