2 !-----------------------------------------------------------------------------
10 use geometry, only:int_bounds
18 !-----------------------------------------------------------------------------
21 ! integer :: modecalc,iscode,indpdb,indback,indphi,iranconf,&
22 ! icheckgrad,iprint,i2ndstr,mucadyn,constr_dist,symetr
23 ! logical :: minim,refstr,pdbref,outpdb,outmol2,overlapsc,&
24 ! energy_dec,sideadd,lsecondary,read_cart,unres_pdb,&
25 ! vdisulf,searchsc,lmuca,dccart,extconf,out1file,&
26 ! gnorm_check,gradout,split_ene
27 !... minim = .true. means DO minimization.
28 !... energy_dec = .true. means print energy decomposition matrix
29 !-----------------------------------------------------------------------------
31 ! FOUND_NAN - set by calcf to stop sumsl via stopx
33 real(kind=8) :: STIME,BATIME,PREVTIM,RSTIME
34 !el real(kind=8) :: TIMLIM,SAFETY
35 !el real(kind=8) :: WALLTIME
41 real(kind=8) :: t_init
42 ! time_bcast,time_reduce,time_gather,&
43 ! time_sendrecv,time_barrier_e,time_barrier_g,time_scatter,&
46 ! time_lagrangian,time_cartgrad,&
47 ! time_sumgradient,time_intcartderiv,time_inttocart,time_intfcart,&
48 ! time_mat,time_fricmatmult,&
49 ! time_scatter_fmat,time_scatter_ginv,&
50 ! time_scatter_fmatmult,time_scatter_ginvmult,&
51 ! t_eshort,t_elong,t_etotal
52 !-----------------------------------------------------------------------------
54 !-----------------------------------------------------------------------------
56 ! integer,parameter :: MaxMoveType = 4
57 ! character(len=14),dimension(-1:MaxMoveType+1) :: MovTypID=(/'pool','chain regrow',&
58 ! character :: MovTypID(-1:MaxMoveType+1)=(/'pool','chain regrow',&
59 ! 'multi-bond','phi','theta','side chain','total'/)
60 ! Conversion from poises to molecular unit and the gas constant
61 !el real(kind=8) :: cPoise=2.9361d0, Rb=0.001986d0
62 !-----------------------------------------------------------------------------
63 ! common /przechowalnia/ subroutines: init_int_table,add_int,add_int_from
64 integer,dimension(:),allocatable :: iturn3_start_all,&
65 iturn3_end_all,iturn4_start_all,iturn4_end_all,iatel_s_all,&
66 iatel_e_all !(0:max_fg_procs)
67 integer,dimension(:,:),allocatable :: ielstart_all,&
68 ielend_all !(maxres,0:max_fg_procs-1)
70 ! common /przechowalnia/ subroutine: init_int_table
71 integer,dimension(:),allocatable :: ntask_cont_from_all,&
72 ntask_cont_to_all !(0:max_fg_procs-1)
73 integer,dimension(:,:),allocatable :: itask_cont_from_all,&
74 itask_cont_to_all !(0:max_fg_procs-1,0:max_fg_procs-1)
75 !-----------------------------------------------------------------------------
78 !-----------------------------------------------------------------------------
80 !-----------------------------------------------------------------------------
82 !-----------------------------------------------------------------------------
85 ! Define constants and zero out tables.
89 use MCM_data, only: MovTypID
90 ! implicit real*8 (a-h,o-z)
91 ! include 'DIMENSIONS'
98 !MS$ATTRIBUTES C :: proc_proc
101 ! include 'COMMON.IOUNITS'
102 ! include 'COMMON.CHAIN'
103 ! include 'COMMON.INTERACT'
104 ! include 'COMMON.GEO'
105 ! include 'COMMON.LOCAL'
106 ! include 'COMMON.TORSION'
107 ! include 'COMMON.FFIELD'
108 ! include 'COMMON.SBRIDGE'
109 ! include 'COMMON.MCM'
110 ! include 'COMMON.MINIM'
111 ! include 'COMMON.DERIV'
112 ! include 'COMMON.SPLITELE'
114 ! Common blocks from the diagonalization routines
115 !el integer :: IR,IW,IP,IJK,IPK,IDAF,NAV,IODA(400)
116 !el integer :: KDIAG,ICORFL,IXDR
117 !el COMMON /IOFILE/ IR,IW,IP,IJK,IPK,IDAF,NAV,IODA
118 !el COMMON /MACHSW/ KDIAG,ICORFL,IXDR
120 ! real*8 text1 /'initial_i'/
124 integer :: i,j,k,l,ichir1,ichir2,iblock,m,maxit
126 #if .not. defined(WHAM_RUN) && .not. defined(CLUSTER)
129 ! NaNQ initialization
133 idumm=proc_proc(rr,i)
134 #elif defined(WHAM_RUN)
143 allocate(MovTypID(-1:MaxMoveType+1))
144 MovTypID=(/'pool ','chain regrow ',&
145 'multi-bond ','phi ','theta ',&
146 'side chain ','total '/)
149 ! The following is just to define auxiliary variables used in angle conversion
151 pi=4.0D0*datan(1.0D0)
156 rad2deg=1.0D0/deg2rad
157 angmin=10.0D0*deg2rad
184 !rc for write_rmsbank1
186 !dr include secondary structure prediction bias
197 #if defined(WHAM_RUN) || defined(CLUSTER)
201 ! CSA I/O units (separated from others especially for Jooyoung)
212 icsa_bank_reminimized=38
215 !rc for ifc error 118
245 #if defined(WHAM_RUN) || defined(CLUSTER)
247 ! setting the mpi variables for WHAM
254 ! Set default weights of the energy terms.
256 wsc=1.0D0 ! in wham: wlong=1.0D0
265 ! print '(a,$)','Inside initialize'
266 ! call memmon_print_usage()
300 ! athet(j,i,ichir1,ichir2)=0.0D0
301 ! bthet(j,i,ichir1,ichir2)=0.0D0
321 ! gaussc(l,k,j,i)=0.0D0
329 ! do i=-maxtor,maxtor
331 !c write (iout,*) "TU DOCHODZE",i,itortyp(i)
333 ! do j=-maxtor,maxtor
335 ! v1(k,j,i,iblock)=0.0D0
336 ! v2(k,j,i,iblock)=0.0D0
342 ! do i=-maxtor,maxtor
343 ! do j=-maxtor,maxtor
344 ! do k=-maxtor,maxtor
346 ! v1c(1,l,i,j,k,iblock)=0.0D0
347 ! v1s(1,l,i,j,k,iblock)=0.0D0
348 ! v1c(2,l,i,j,k,iblock)=0.0D0
349 ! v1s(2,l,i,j,k,iblock)=0.0D0
353 ! v2c(m,l,i,j,k,iblock)=0.0D0
354 ! v2s(m,l,i,j,k,iblock)=0.0D0
366 ! Initialize the bridge arrays
385 ! Initialize variables used in minimization.
394 ! Initialize the variables responsible for the mode of gradient storage.
400 allocate(iww(max_eneW))
403 if (print_order(i).eq.j) then
404 iww(print_order(i))=j
412 #if defined(WHAM_RUN) || defined(CLUSTER)
415 ! allocate(ww0(max_eneW))
416 ! ww0 = reshape((/1.0d0,1.0d0,1.0d0,1.0d0,1.0d0,1.0d0,1.0d0,1.0d0,&
417 ! 1.0d0,1.0d0,1.0d0,1.0d0,1.0d0,1.0d0,1.0d0,1.0d0,0.4d0,1.0d0,&
418 ! 1.0d0,0.0d0,0.0/), shape(ww0))
421 ! Set timers and counters for the respective routines
441 ! Initialize constants used to split the energy into long- and short-range
447 nprint_ene=nprint_ene-1
450 end subroutine initialize
451 !-----------------------------------------------------------------------------
452 subroutine init_int_table
454 use geometry, only:int_bounds1
457 ! implicit real*8 (a-h,o-z)
458 ! include 'DIMENSIONS'
461 integer,dimension(15) :: blocklengths,displs
463 ! include 'COMMON.CONTROL'
464 ! include 'COMMON.SETUP'
465 ! include 'COMMON.CHAIN'
466 ! include 'COMMON.INTERACT'
467 ! include 'COMMON.LOCAL'
468 ! include 'COMMON.SBRIDGE'
469 ! include 'COMMON.TORCNSTR'
470 ! include 'COMMON.IOUNITS'
471 ! include 'COMMON.DERIV'
472 ! include 'COMMON.CONTACTS'
473 !el integer,dimension(0:nfgtasks) :: iturn3_start_all,iturn3_end_all,&
474 !el iturn4_start_all,iturn4_end_all,iatel_s_all,iatel_e_all !(0:max_fg_procs)
475 !el integer,dimension(nres,0:nfgtasks) :: ielstart_all,&
476 !el ielend_all !(maxres,0:max_fg_procs-1)
477 !el integer,dimension(0:nfgtasks-1) :: ntask_cont_from_all,&
478 !el ntask_cont_to_all !(0:max_fg_procs-1),
479 !el integer,dimension(0:nfgtasks-1,0:nfgtasks-1) :: itask_cont_from_all,&
480 !el itask_cont_to_all !(0:max_fg_procs-1,0:max_fg_procs-1)
482 !el common /przechowalnia/ iturn3_start_all,iturn3_end_all,&
483 !el iturn4_start_all,iturn4_end_all,iatel_s_all,iatel_e_all,&
484 !el ielstart_all,ielend_all,ntask_cont_from_all,itask_cont_from_all,&
485 !el ntask_cont_to_all,itask_cont_to_all
487 integer :: FG_GROUP,CONT_FROM_GROUP,CONT_TO_GROUP
488 logical :: scheck,lprint,flag
491 integer :: ind_scint=0,ind_scint_old,ii,jj,i,j,iint,itmp
492 integer :: ind_scint_nucl=0
494 integer :: my_sc_int(0:nfgtasks-1),my_ele_int(0:nfgtasks-1)
495 integer :: my_sc_intt(0:nfgtasks),my_ele_intt(0:nfgtasks)
496 integer :: n_sc_int_tot,my_sc_inde,my_sc_inds,ind_sctint,npept
497 integer :: n_sc_int_tot_nucl,my_sc_inde_nucl,my_sc_inds_nucl, &
498 ind_sctint_nucl,npept_nucl
500 integer :: nele_int_tot,my_ele_inds,my_ele_inde,ind_eleint_old,&
501 ind_eleint,ijunk,nele_int_tot_vdw,my_ele_inds_vdw,&
502 my_ele_inde_vdw,ind_eleint_vdw,ind_eleint_vdw_old,&
503 nscp_int_tot,my_scp_inds,my_scp_inde,ind_scpint,&
504 ind_scpint_old,nsumgrad,nlen,ngrad_start,ngrad_end,&
505 ierror,k,ierr,iaux,ncheck_to,ncheck_from,ind_typ,&
507 integer :: nele_int_tot_nucl,my_ele_inds_nucl,my_ele_inde_nucl,&
508 ind_eleint_old_nucl,ind_eleint_nucl,nele_int_tot_vdw_nucl,&
509 my_ele_inds_vdw_nucl,my_ele_inde_vdw_nucl,ind_eleint_vdw_nucl,&
510 ind_eleint_vdw_old_nucl,nscp_int_tot_nucl,my_scp_inds_nucl,&
511 my_scp_inde_nucl,ind_scpint_nucl,ind_scpint_old_nucl
512 integer,dimension(5) :: nct_molec,nnt_molec
513 !el allocate(itask_cont_from(0:nfgtasks-1)) !(0:max_fg_procs-1)
514 !el allocate(itask_cont_to(0:nfgtasks-1)) !(0:max_fg_procs-1)
516 !... Determine the numbers of start and end SC-SC interaction
517 !... to deal with by current processor.
518 !write (iout,*) '******INIT_INT_TABLE nres=',nres,' nnt=',nnt,' nct=',nct
520 itask_cont_from(i)=fg_rank
521 itask_cont_to(i)=fg_rank
526 if (nres_molec(i).eq.0) cycle
527 itmp=itmp+nres_molec(i)
528 if (itype(itmp,i).eq.ntyp1_molec(i)) then
534 ! nct_molec(1)=nres_molec(1)-1
537 itmp=itmp+nres_molec(i-1)
538 if (itype(itmp+1,i).eq.ntyp1_molec(i)) then
544 print *,"nres_molec",nres_molec(:)
545 print *,"nnt_molec",nnt_molec(:)
546 print *,"nct_molec",nct_molec(:)
549 write (iout,*)'INIT_INT_TABLE nres=',nres,' nnt=',nnt,' nct=',nct
550 n_sc_int_tot=(nct_molec(1)-nnt+1)*(nct_molec(1)-nnt)/2-nss
551 call int_bounds(n_sc_int_tot,my_sc_inds,my_sc_inde)
552 !write (iout,*) 'INIT_INT_TABLE nres=',nres,' nnt=',nnt,' nct=',nct
554 write (iout,*) 'Processor',fg_rank,' CG group',kolor,&
555 ' absolute rank',MyRank,&
556 ' n_sc_int_tot',n_sc_int_tot,' my_sc_inds=',my_sc_inds,&
557 ' my_sc_inde',my_sc_inde
562 !el common /przechowalnia/
563 allocate(iturn3_start_all(0:nfgtasks))
564 allocate(iturn3_end_all(0:nfgtasks))
565 allocate(iturn4_start_all(0:nfgtasks))
566 allocate(iturn4_end_all(0:nfgtasks))
567 allocate(iatel_s_all(0:nfgtasks))
568 allocate(iatel_e_all(0:nfgtasks))
569 allocate(ielstart_all(nres,0:nfgtasks-1))
570 allocate(ielend_all(nres,0:nfgtasks-1))
572 allocate(ntask_cont_from_all(0:nfgtasks-1))
573 allocate(ntask_cont_to_all(0:nfgtasks-1))
574 allocate(itask_cont_from_all(0:nfgtasks-1,0:nfgtasks-1))
575 allocate(itask_cont_to_all(0:nfgtasks-1,0:nfgtasks-1))
578 print *,"NCT",nct_molec(1),nct
579 do i=1,nres !el !maxres
593 !d write (iout,*) 'ns=',ns,' nss=',nss,' ihpb,jhpb',
594 !d & (ihpb(i),jhpb(i),i=1,nss)
595 ! print *,nnt,nct_molec(1)
596 do i=nnt,nct_molec(1)-1
601 if (ihpb(ii).eq.i+nres) then
608 ! print *,'i=',i,' scheck=',scheck,' jj=',jj
609 !d write (iout,*) 'i=',i,' scheck=',scheck,' jj=',jj
613 ! write (iout,*) 'jj=i+1'
614 call int_partition(ind_scint,my_sc_inds,my_sc_inde,i,&
615 iatsc_s,iatsc_e,i+2,nct_molec(1),nint_gr(i),istart(i,1),iend(i,1),*12)
621 else if (jj.eq.nct_molec(1)) then
623 ! write (iout,*) 'jj=nct'
624 call int_partition(ind_scint,my_sc_inds,my_sc_inde,i,&
625 iatsc_s,iatsc_e,i+1,nct_molec(1)-1,nint_gr(i),istart(i,1),iend(i,1),*12)
629 iend(i,1)=nct_molecule(1)-1
633 call int_partition(ind_scint,my_sc_inds,my_sc_inde,i,&
634 iatsc_s,iatsc_e,i+1,jj-1,nint_gr(i),istart(i,1),iend(i,1),*12)
636 call int_partition(ind_scint,my_sc_inds,my_sc_inde,i,&
637 iatsc_s,iatsc_e,jj+1,nct_molec(1),nint_gr(i),istart(i,ii),iend(i,ii),*12)
644 iend(i,2)=nct_molec(1)
649 ! print *,"i for EVDW",iatsc_s,iatsc_e,istart(i,1),iend(i,1),&
650 ! i+1,nct_molec(1),nint_gr(i),ind_scint,my_sc_inds,my_sc_inde,i
651 call int_partition(ind_scint,my_sc_inds,my_sc_inde,i,&
652 iatsc_s,iatsc_e,i+1,nct_molec(1),nint_gr(i), &
653 istart(i,1),iend(i,1),*12)
654 ! print *,"i for EVDW",iatsc_s,iatsc_e,istart(i,1),iend(i,1)
658 iend(i,1)=nct_molec(1)
659 ind_scint=ind_scint+nct_molec(1)-i
663 ind_scint_old=ind_scint
667 ! print *,"i for EVDW",iatsc_s,iatsc_e,istart(i,1),iend(i,1)
673 if (iatsc_s.eq.0) iatsc_s=1
674 !----------------- scaling for nucleic acid GB
675 n_sc_int_tot_nucl=(nct_molec(2)-nnt_molec(2)+1)*(nct_molec(2)-nnt_molec(2))/2
676 call int_bounds(n_sc_int_tot_nucl,my_sc_inds_nucl,my_sc_inde_nucl)
677 !write (iout,*) 'INIT_INT_TABLE nres=',nres,' nnt=',nnt,' nct=',nct
679 write (iout,*) 'Processor',fg_rank,' CG group',kolor,&
680 ' absolute rank',MyRank,&
681 ' n_sc_int_tot',n_sc_int_tot_nucl,' my_sc_inds=',my_sc_inds_nucl,&
682 ' my_sc_inde',my_sc_inde_nucl
686 do i=1,nres !el !maxres
694 iscpstart_nucl(i,j)=0
698 do i=nnt_molec(2),nct_molec(2)-1
699 ! print*, "inloop2",i
700 call int_partition(ind_scint_nucl,my_sc_inds_nucl,my_sc_inde_nucl,i,&
701 iatsc_s_nucl,iatsc_e_nucl,i+1,nct_molec(2),nint_gr_nucl(i), &
702 istart_nucl(i,1),iend_nucl(i,1),*112)
703 print *,istart_nucl(i,1)
706 if (iatsc_s_nucl.eq.0) iatsc_s_nucl=1
707 print *,"tu mam",iatsc_s_nucl,iatsc_e_nucl
710 if (lprint) write (*,*) 'Processor',fg_rank,' CG Group',kolor,&
711 ' absolute rank',myrank,' iatsc_s=',iatsc_s,' iatsc_e=',iatsc_e
715 write (iout,'(a)') 'Interaction array:'
717 write (iout,'(i3,2(2x,2i3))') &
718 i,(istart(i,iint),iend(i,iint),iint=1,nint_gr(i))
722 write (iout,'(a)') 'Interaction array2:'
723 do i=iatsc_s_nucl,iatsc_e_nucl
724 write (iout,'(i3,2(2x,2i4))') &
725 i,(istart_nucl(i,iint),iend_nucl(i,iint),iint=1,nint_gr_nucl(i))
728 ispp=4 !?? wham ispp=2
730 ! Now partition the electrostatic-interaction array
731 if (itype(nres_molec(1),1).eq.ntyp1_molec(1)) then
732 npept=nres_molec(1)-nnt-1
734 npept=nres_molec(1)-nnt
736 nele_int_tot=(npept-ispp)*(npept-ispp+1)/2
737 call int_bounds(nele_int_tot,my_ele_inds,my_ele_inde)
739 write (*,*) 'Processor',fg_rank,' CG group',kolor,&
740 ' absolute rank',MyRank,&
741 ' nele_int_tot',nele_int_tot,' my_ele_inds=',my_ele_inds,&
742 ' my_ele_inde',my_ele_inde
747 ! if (itype(nres_molec(1),1).eq.ntyp1_molec(1)) then
748 ! nct_molec(1)=nres_molec(1)-1
750 ! nct_molec(1)=nres_molec(1)
752 ! print *,"nct",nct,nct_molec(1),itype(nres_molec(1),1),ntyp_molec(1)
753 do i=nnt,nct_molec(1)-3
755 call int_partition(ind_eleint,my_ele_inds,my_ele_inde,i,&
756 iatel_s,iatel_e,i+ispp,nct_molec(1)-1,ijunk,ielstart(i),ielend(i),*13)
759 if (iatel_s.eq.0) iatel_s=1
760 !----------now nucleic acid
761 ! if (itype(nres_molec(2),2).eq.ntyp1_molec(2)) then
762 npept_nucl=nct_molec(2)-nnt_molec(2)
764 ! npept_nucl=nct_molec(2)-nnt_molec(2)
766 nele_int_tot_nucl=(npept_nucl-ispp)*(npept_nucl-ispp+1)/2
767 call int_bounds(nele_int_tot_nucl,my_ele_inds_nucl,my_ele_inde_nucl)
769 write (*,*) 'Processor',fg_rank,' CG group',kolor,&
770 ' absolute rank',MyRank,&
771 ' nele_int_tot',nele_int_tot,' my_ele_inds=',my_ele_inds,&
772 ' my_ele_inde',my_ele_inde
776 ind_eleint_old_nucl=0
777 ! if (itype(nres_molec(1),1).eq.ntyp1_molec(1)) then
778 ! nct_molec(1)=nres_molec(1)-1
780 ! nct_molec(1)=nres_molec(1)
782 ! print *,"nct",nct,nct_molec(1),itype(nres_molec(1),1),ntyp_molec(1)
783 do i=nnt_molec(2),nct_molec(2)-3
785 call int_partition(ind_eleint_nucl,my_ele_inds_nucl,my_ele_inde_nucl,i,&
786 iatel_s_nucl,iatel_e_nucl,i+ispp,nct_molec(2)-1,&
787 ijunk,ielstart_nucl(i),ielend_nucl(i),*113)
790 if (iatel_s.eq.0) iatel_s=1
792 nele_int_tot_vdw=(npept-2)*(npept-2+1)/2
793 ! write (iout,*) "nele_int_tot_vdw",nele_int_tot_vdw
794 call int_bounds(nele_int_tot_vdw,my_ele_inds_vdw,my_ele_inde_vdw)
795 ! write (iout,*) "my_ele_inds_vdw",my_ele_inds_vdw,
796 ! & " my_ele_inde_vdw",my_ele_inde_vdw
801 do i=nnt,nct_molec(1)-3
803 call int_partition(ind_eleint_vdw,my_ele_inds_vdw,&
805 iatel_s_vdw,iatel_e_vdw,i+2,nct_molec(1)-1,ijunk,ielstart_vdw(i),&
807 ! write (iout,*) i," ielstart_vdw",ielstart_vdw(i),
808 ! & " ielend_vdw",ielend_vdw(i)
810 if (iatel_s_vdw.eq.0) iatel_s_vdw=1
812 if (iatel_s.eq.0) iatel_s=1
814 nele_int_tot_vdw_nucl=(npept_nucl-2)*(npept_nucl-2+1)/2
815 ! write (iout,*) "nele_int_tot_vdw",nele_int_tot_vdw
816 call int_bounds(nele_int_tot_vdw_nucl,my_ele_inds_vdw_nucl,&
817 my_ele_inde_vdw_nucl)
818 ! write (iout,*) "my_ele_inds_vdw",my_ele_inds_vdw,
819 ! & " my_ele_inde_vdw",my_ele_inde_vdw
820 ind_eleint_vdw_nucl=0
821 ind_eleint_vdw_old_nucl=0
824 do i=nnt_molec(2),nct_molec(2)-3
826 call int_partition(ind_eleint_vdw_nucl,my_ele_inds_vdw_nucl,&
827 my_ele_inde_vdw_nucl,i,&
828 iatel_s_vdw_nucl,iatel_e_vdw_nucl,i+2,nct_molec(2)-1,&
829 ijunk,ielstart_vdw_nucl(i),&
831 ! write (iout,*) i," ielstart_vdw",ielstart_vdw(i),
832 ! & " ielend_vdw",ielend_vdw(i)
834 if (iatel_s_vdw.eq.0) iatel_s_vdw=1
839 iatel_e=nct_molec(1)-5 ! ?? wham iatel_e=nct-3
841 ielstart(i)=i+4 ! ?? wham +2
842 ielend(i)=nct_molec(1)-1
845 iatel_e_vdw=nct_molec(1)-3
846 do i=iatel_s_vdw,iatel_e_vdw
848 ielend_vdw(i)=nct_molec(1)-1
852 write (*,'(a)') 'Processor',fg_rank,' CG group',kolor,&
853 ' absolute rank',MyRank
854 write (iout,*) 'Electrostatic interaction array:'
856 write (iout,'(i3,2(2x,2i3))') i,ielstart(i),ielend(i)
862 ! Partition the SC-p interaction array
864 nscp_int_tot=(npept-iscp+1)*(npept-iscp+1)
865 call int_bounds(nscp_int_tot,my_scp_inds,my_scp_inde)
866 if (lprint) write (iout,*) 'Processor',fg_rank,' CG group',kolor,&
867 ' absolute rank',myrank,&
868 ' nscp_int_tot',nscp_int_tot,' my_scp_inds=',my_scp_inds,&
869 ' my_scp_inde',my_scp_inde
874 do i=nnt,nct_molec(1)-1
875 if (i.lt.nnt+iscp) then
876 !d write (iout,*) 'i.le.nnt+iscp'
877 call int_partition(ind_scpint,my_scp_inds,my_scp_inde,i,&
878 iatscp_s,iatscp_e,i+iscp,nct_molec(1),nscp_gr(i),iscpstart(i,1),&
880 else if (i.gt.nct-iscp) then
881 !d write (iout,*) 'i.gt.nct-iscp'
882 call int_partition(ind_scpint,my_scp_inds,my_scp_inde,i,&
883 iatscp_s,iatscp_e,nnt,i-iscp,nscp_gr(i),iscpstart(i,1),&
886 call int_partition(ind_scpint,my_scp_inds,my_scp_inde,i,&
887 iatscp_s,iatscp_e,nnt,i-iscp,nscp_gr(i),iscpstart(i,1),&
890 call int_partition(ind_scpint,my_scp_inds,my_scp_inde,i,&
891 iatscp_s,iatscp_e,i+iscp,nct_molec(1),nscp_gr(i),iscpstart(i,ii),&
896 print *,"before inloop3",iatscp_s,iatscp_e,iscp_nucl
897 nscp_int_tot_nucl=(npept_nucl-iscp_nucl+1)*(npept_nucl-iscp_nucl+1)
898 call int_bounds(nscp_int_tot_nucl,my_scp_inds_nucl,my_scp_inde_nucl)
899 if (lprint) write (iout,*) 'Processor',fg_rank,' CG group',kolor,&
900 ' absolute rank',myrank,&
901 ' nscp_int_tot',nscp_int_tot_nucl,' my_scp_inds=',my_scp_inds_nucl,&
902 ' my_scp_inde',my_scp_inde_nucl
903 print *,"nscp_int_tot_nucl",nscp_int_tot_nucl,my_scp_inds_nucl,my_scp_inde_nucl
907 ind_scpint_old_nucl=0
908 do i=nnt_molec(2),nct_molec(2)-1
909 print *,"inloop3",i,nnt_molec(2)+iscp,nct_molec(2)-iscp
910 if (i.lt.nnt_molec(2)+iscp) then
911 !d write (iout,*) 'i.le.nnt+iscp'
912 call int_partition(ind_scpint_nucl,my_scp_inds_nucl,&
913 my_scp_inde_nucl,i,iatscp_s_nucl,iatscp_e_nucl,i+iscp,&
914 nct_molec(2),nscp_gr_nucl(i),iscpstart_nucl(i,1),&
915 iscpend_nucl(i,1),*114)
916 else if (i.gt.nct_molec(2)-iscp) then
917 !d write (iout,*) 'i.gt.nct-iscp'
918 call int_partition(ind_scpint_nucl,my_scp_inds_nucl,&
920 iatscp_s_nucl,iatscp_e_nucl,nnt_molec(2),i-iscp,nscp_gr_nucl(i),&
921 iscpstart_nucl(i,1),&
922 iscpend_nucl(i,1),*114)
924 call int_partition(ind_scpint_nucl,my_scp_inds_nucl,&
925 my_scp_inde_nucl,i,iatscp_s_nucl,iatscp_e_nucl,nnt_molec(2),&
926 i-iscp,nscp_gr_nucl(i),iscpstart_nucl(i,1),&
927 iscpend_nucl(i,1),*114)
929 call int_partition(ind_scpint_nucl,my_scp_inds_nucl,&
930 my_scp_inde_nucl,i,iatscp_s_nucl,iatscp_e_nucl,i+iscp,&
931 nct_molec(2),nscp_gr_nucl(i),iscpstart_nucl(i,ii),&
932 iscpend_nucl(i,ii),*114)
936 print *, "after inloop3",iatscp_s_nucl,iatscp_e_nucl
939 iatscp_e=nct_molec(1)-1
940 do i=nnt,nct_molec(1)-1
941 if (i.lt.nnt+iscp) then
943 iscpstart(i,1)=i+iscp
944 iscpend(i,1)=nct_molec(1)
945 elseif (i.gt.nct-iscp) then
953 iscpstart(i,2)=i+iscp
954 iscpend(i,2)=nct_molec(1)
958 if (iatscp_s.eq.0) iatscp_s=1
960 write (iout,'(a)') 'SC-p interaction array:'
961 do i=iatscp_s,iatscp_e
962 write (iout,'(i3,2(2x,2i3))') &
963 i,(iscpstart(i,j),iscpend(i,j),j=1,nscp_gr(i))
966 ! Partition local interactions
968 call int_bounds(nres_molec(1)-2,loc_start,loc_end)
969 loc_start=loc_start+1
971 call int_bounds(nres_molec(2)-2,loc_start_nucl,loc_end_nucl)
972 loc_start_nucl=loc_start_nucl+1+nres_molec(1)
973 loc_end_nucl=loc_end_nucl+1+nres_molec(1)
974 call int_bounds(nres_molec(1)-2,ithet_start,ithet_end)
975 ithet_start=ithet_start+2
976 ithet_end=ithet_end+2
977 call int_bounds(nres_molec(2)-2,ithet_nucl_start,ithet_nucl_end)
978 ithet_nucl_start=ithet_nucl_start+2+nres_molec(1)
979 ithet_nucl_end=ithet_nucl_end+2+nres_molec(1)
980 call int_bounds(nct_molec(1)-nnt-2,iturn3_start,iturn3_end)
981 iturn3_start=iturn3_start+nnt
982 iphi_start=iturn3_start+2
983 iturn3_end=iturn3_end+nnt
984 iphi_end=iturn3_end+2
985 iturn3_start=iturn3_start-1
986 iturn3_end=iturn3_end-1
987 call int_bounds(nct_molec(2)-nnt_molec(2)-2,iphi_nucl_start,iphi_nucl_end)
988 iphi_nucl_start=iphi_nucl_start+nnt_molec(2)+2
989 iphi_nucl_end=iphi_nucl_end+nnt_molec(2)+2
990 print *,"KURDE",iphi_nucl_start,iphi_nucl_end
991 call int_bounds(nres_molec(1)-3,itau_start,itau_end)
992 itau_start=itau_start+3
994 call int_bounds(nres_molec(1)-3,iphi1_start,iphi1_end)
995 iphi1_start=iphi1_start+3
996 iphi1_end=iphi1_end+3
997 call int_bounds(nct_molec(1)-nnt-3,iturn4_start,iturn4_end)
998 iturn4_start=iturn4_start+nnt
999 iphid_start=iturn4_start+2
1000 iturn4_end=iturn4_end+nnt
1001 iphid_end=iturn4_end+2
1002 iturn4_start=iturn4_start-1
1003 iturn4_end=iturn4_end-1
1004 ! print *,"TUTUTU",nres_molec(1),nres
1005 call int_bounds(nres_molec(1)-2,ibond_start,ibond_end)
1006 ibond_start=ibond_start+1
1007 ibond_end=ibond_end+1
1008 ! print *,ibond_start,ibond_end
1009 call int_bounds(nct_molec(1)-nnt,ibondp_start,ibondp_end)
1010 ibondp_start=ibondp_start+nnt
1011 ibondp_end=ibondp_end+nnt
1012 call int_bounds(nres_molec(2)-2,ibond_nucl_start,ibond_nucl_end)
1013 ibond_nucl_start=ibond_nucl_start+nnt_molec(2)-1
1014 ibond_nucl_end=ibond_nucl_end+nnt_molec(2)-1
1015 print *,"NUCLibond",ibond_nucl_start,ibond_nucl_end
1016 print *, "before devision",nnt_molec(2),nct_molec(2)-nnt_molec(2)
1017 call int_bounds(nct_molec(2)-nnt_molec(2),ibondp_nucl_start,ibondp_nucl_end)
1018 ibondp_nucl_start=ibondp_nucl_start+nnt_molec(2)
1019 ibondp_nucl_end=ibondp_nucl_end+nnt_molec(2)
1020 print *,"NUCLibond2",ibondp_nucl_start,ibondp_nucl_end
1023 call int_bounds1(nres_molec(1)-1,ivec_start,ivec_end)
1024 ! print *,"Processor",myrank,fg_rank,fg_rank1,
1025 ! & " ivec_start",ivec_start," ivec_end",ivec_end
1026 iset_start=loc_start+2
1028 call int_bounds(nres_molec(1),ilip_start,ilip_end)
1029 ilip_start=ilip_start
1031 call int_bounds(nres_molec(1)-1,itube_start,itube_end)
1032 itube_start=itube_start
1034 if (ndih_constr.eq.0) then
1038 call int_bounds(ndih_constr,idihconstr_start,idihconstr_end)
1040 if (ntheta_constr.eq.0) then
1041 ithetaconstr_start=1
1045 (ntheta_constr,ithetaconstr_start,ithetaconstr_end)
1048 ! nsumgrad=(nres-nnt)*(nres-nnt+1)/2
1050 nsumgrad=(nres-nnt)*(nres-nnt+1)/2
1052 call int_bounds(nsumgrad,ngrad_start,ngrad_end)
1053 igrad_start=((2*nlen+1) &
1054 -sqrt(float((2*nlen-1)**2-8*(ngrad_start-1))))/2
1055 igrad_end=((2*nlen+1) &
1056 -sqrt(float((2*nlen-1)**2-8*(ngrad_end-1))))/2
1057 !el allocate(jgrad_start(igrad_start:igrad_end))
1058 !el allocate(jgrad_end(igrad_start:igrad_end)) !(maxres)
1059 jgrad_start(igrad_start)= &
1060 ngrad_start-(2*nlen-igrad_start)*(igrad_start-1)/2 &
1062 jgrad_end(igrad_start)=nres
1063 if (igrad_end.gt.igrad_start) jgrad_start(igrad_end)=igrad_end+1
1064 jgrad_end(igrad_end)=ngrad_end-(2*nlen-igrad_end)*(igrad_end-1)/2 &
1066 do i=igrad_start+1,igrad_end-1
1071 write (*,*) 'Processor:',fg_rank,' CG group',kolor,&
1072 ' absolute rank',myrank,&
1073 ' loc_start',loc_start,' loc_end',loc_end,&
1074 ' ithet_start',ithet_start,' ithet_end',ithet_end,&
1075 ' iphi_start',iphi_start,' iphi_end',iphi_end,&
1076 ' iphid_start',iphid_start,' iphid_end',iphid_end,&
1077 ' ibond_start',ibond_start,' ibond_end',ibond_end,&
1078 ' ibondp_start',ibondp_start,' ibondp_end',ibondp_end,&
1079 ' iturn3_start',iturn3_start,' iturn3_end',iturn3_end,&
1080 ' iturn4_start',iturn4_start,' iturn4_end',iturn4_end,&
1081 ' ivec_start',ivec_start,' ivec_end',ivec_end,&
1082 ' iset_start',iset_start,' iset_end',iset_end,&
1083 ' idihconstr_start',idihconstr_start,' idihconstr_end',&
1085 write (*,*) 'Processor:',fg_rank,myrank,' igrad_start',&
1086 igrad_start,' igrad_end',igrad_end,' ngrad_start',ngrad_start,&
1087 ' ngrad_end',ngrad_end
1088 ! do i=igrad_start,igrad_end
1089 ! write(*,*) 'Processor:',fg_rank,myrank,i,&
1090 ! jgrad_start(i),jgrad_end(i)
1093 if (nfgtasks.gt.1) then
1094 call MPI_Allgather(ivec_start,1,MPI_INTEGER,ivec_displ(0),1,&
1095 MPI_INTEGER,FG_COMM1,IERROR)
1096 iaux=ivec_end-ivec_start+1
1097 call MPI_Allgather(iaux,1,MPI_INTEGER,ivec_count(0),1,&
1098 MPI_INTEGER,FG_COMM1,IERROR)
1099 call MPI_Allgather(iset_start-2,1,MPI_INTEGER,iset_displ(0),1,&
1100 MPI_INTEGER,FG_COMM,IERROR)
1101 iaux=iset_end-iset_start+1
1102 call MPI_Allgather(iaux,1,MPI_INTEGER,iset_count(0),1,&
1103 MPI_INTEGER,FG_COMM,IERROR)
1104 call MPI_Allgather(ibond_start,1,MPI_INTEGER,ibond_displ(0),1,&
1105 MPI_INTEGER,FG_COMM,IERROR)
1106 iaux=ibond_end-ibond_start+1
1107 call MPI_Allgather(iaux,1,MPI_INTEGER,ibond_count(0),1,&
1108 MPI_INTEGER,FG_COMM,IERROR)
1109 call MPI_Allgather(ithet_start,1,MPI_INTEGER,ithet_displ(0),1,&
1110 MPI_INTEGER,FG_COMM,IERROR)
1111 iaux=ithet_end-ithet_start+1
1112 call MPI_Allgather(iaux,1,MPI_INTEGER,ithet_count(0),1,&
1113 MPI_INTEGER,FG_COMM,IERROR)
1114 call MPI_Allgather(iphi_start,1,MPI_INTEGER,iphi_displ(0),1,&
1115 MPI_INTEGER,FG_COMM,IERROR)
1116 iaux=iphi_end-iphi_start+1
1117 call MPI_Allgather(iaux,1,MPI_INTEGER,iphi_count(0),1,&
1118 MPI_INTEGER,FG_COMM,IERROR)
1119 call MPI_Allgather(iphi1_start,1,MPI_INTEGER,iphi1_displ(0),1,&
1120 MPI_INTEGER,FG_COMM,IERROR)
1121 iaux=iphi1_end-iphi1_start+1
1122 call MPI_Allgather(iaux,1,MPI_INTEGER,iphi1_count(0),1,&
1123 MPI_INTEGER,FG_COMM,IERROR)
1130 call MPI_Allgather(iturn3_start,1,MPI_INTEGER,&
1131 iturn3_start_all(0),1,MPI_INTEGER,FG_COMM,IERROR)
1132 call MPI_Allgather(iturn4_start,1,MPI_INTEGER,&
1133 iturn4_start_all(0),1,MPI_INTEGER,FG_COMM,IERROR)
1134 call MPI_Allgather(iturn3_end,1,MPI_INTEGER,&
1135 iturn3_end_all(0),1,MPI_INTEGER,FG_COMM,IERROR)
1136 call MPI_Allgather(iturn4_end,1,MPI_INTEGER,&
1137 iturn4_end_all(0),1,MPI_INTEGER,FG_COMM,IERROR)
1138 call MPI_Allgather(iatel_s,1,MPI_INTEGER,&
1139 iatel_s_all(0),1,MPI_INTEGER,FG_COMM,IERROR)
1140 call MPI_Allgather(iatel_e,1,MPI_INTEGER,&
1141 iatel_e_all(0),1,MPI_INTEGER,FG_COMM,IERROR)
1142 call MPI_Allgather(ielstart(1),nres,MPI_INTEGER,&
1143 ielstart_all(1,0),nres,MPI_INTEGER,FG_COMM,IERROR)
1144 call MPI_Allgather(ielend(1),nres,MPI_INTEGER,&
1145 ielend_all(1,0),nres,MPI_INTEGER,FG_COMM,IERROR)
1147 write (iout,*) "iatel_s_all",(iatel_s_all(i),i=0,nfgtasks)
1148 write (iout,*) "iatel_e_all",(iatel_e_all(i),i=0,nfgtasks)
1149 write (iout,*) "iturn3_start_all",&
1150 (iturn3_start_all(i),i=0,nfgtasks-1)
1151 write (iout,*) "iturn3_end_all",&
1152 (iturn3_end_all(i),i=0,nfgtasks-1)
1153 write (iout,*) "iturn4_start_all",&
1154 (iturn4_start_all(i),i=0,nfgtasks-1)
1155 write (iout,*) "iturn4_end_all",&
1156 (iturn4_end_all(i),i=0,nfgtasks-1)
1157 write (iout,*) "The ielstart_all array"
1159 write (iout,'(20i4)') i,(ielstart_all(i,j),j=0,nfgtasks-1)
1161 write (iout,*) "The ielend_all array"
1163 write (iout,'(20i4)') i,(ielend_all(i,j),j=0,nfgtasks-1)
1169 itask_cont_from(0)=fg_rank
1170 itask_cont_to(0)=fg_rank
1172 !el allocate(iturn3_sent(4,iturn3_start:iturn3_end))
1173 !el allocate(iturn4_sent(4,iturn4_start:iturn4_end)) !(4,maxres)
1174 do ii=iturn3_start,iturn3_end
1175 call add_int(ii,ii+2,iturn3_sent(1,ii),&
1176 ntask_cont_to,itask_cont_to,flag)
1178 do ii=iturn4_start,iturn4_end
1179 call add_int(ii,ii+3,iturn4_sent(1,ii),&
1180 ntask_cont_to,itask_cont_to,flag)
1182 do ii=iturn3_start,iturn3_end
1183 call add_int_from(ii,ii+2,ntask_cont_from,itask_cont_from)
1185 do ii=iturn4_start,iturn4_end
1186 call add_int_from(ii,ii+3,ntask_cont_from,itask_cont_from)
1189 write (iout,*) "After turn3 ntask_cont_from",ntask_cont_from,&
1190 " ntask_cont_to",ntask_cont_to
1191 write (iout,*) "itask_cont_from",&
1192 (itask_cont_from(i),i=1,ntask_cont_from)
1193 write (iout,*) "itask_cont_to",&
1194 (itask_cont_to(i),i=1,ntask_cont_to)
1197 ! write (iout,*) "Loop forward"
1199 do i=iatel_s,iatel_e
1200 ! write (iout,*) "from loop i=",i
1202 do j=ielstart(i),ielend(i)
1203 call add_int_from(i,j,ntask_cont_from,itask_cont_from)
1206 ! write (iout,*) "Loop backward iatel_e-1",iatel_e-1,
1207 ! & " iatel_e",iatel_e
1210 do i=iatel_s,iatel_e
1211 ! write (iout,*) "i",i," ielstart",ielstart(i),
1212 ! & " ielend",ielend(i)
1215 do j=ielstart(i),ielend(i)
1216 call add_int(i,j,iint_sent(1,j,nat_sent+1),ntask_cont_to,&
1221 iat_sent(nat_sent)=i
1225 write (iout,*)"After longrange ntask_cont_from",ntask_cont_from,&
1226 " ntask_cont_to",ntask_cont_to
1227 write (iout,*) "itask_cont_from",&
1228 (itask_cont_from(i),i=1,ntask_cont_from)
1229 write (iout,*) "itask_cont_to",&
1230 (itask_cont_to(i),i=1,ntask_cont_to)
1232 write (iout,*) "iint_sent"
1235 write (iout,'(20i4)') ii,(j,(iint_sent(k,j,i),k=1,4),&
1236 j=ielstart(ii),ielend(ii))
1238 write (iout,*) "iturn3_sent iturn3_start",iturn3_start,&
1239 " iturn3_end",iturn3_end
1240 write (iout,'(20i4)') (i,(iturn3_sent(j,i),j=1,4),&
1241 i=iturn3_start,iturn3_end)
1242 write (iout,*) "iturn4_sent iturn4_start",iturn4_start,&
1243 " iturn4_end",iturn4_end
1244 write (iout,'(20i4)') (i,(iturn4_sent(j,i),j=1,4),&
1245 i=iturn4_start,iturn4_end)
1248 call MPI_Gather(ntask_cont_from,1,MPI_INTEGER,&
1249 ntask_cont_from_all,1,MPI_INTEGER,king,FG_COMM,IERR)
1250 ! write (iout,*) "Gather ntask_cont_from ended"
1252 call MPI_Gather(itask_cont_from(0),nfgtasks,MPI_INTEGER,&
1253 itask_cont_from_all(0,0),nfgtasks,MPI_INTEGER,king,&
1255 ! write (iout,*) "Gather itask_cont_from ended"
1257 call MPI_Gather(ntask_cont_to,1,MPI_INTEGER,ntask_cont_to_all,&
1258 1,MPI_INTEGER,king,FG_COMM,IERR)
1259 ! write (iout,*) "Gather ntask_cont_to ended"
1261 call MPI_Gather(itask_cont_to,nfgtasks,MPI_INTEGER,&
1262 itask_cont_to_all,nfgtasks,MPI_INTEGER,king,FG_COMM,IERR)
1263 ! write (iout,*) "Gather itask_cont_to ended"
1265 if (fg_rank.eq.king) then
1266 write (iout,*)"Contact receive task map (proc, #tasks, tasks)"
1268 write (iout,'(20i4)') i,ntask_cont_from_all(i),&
1269 (itask_cont_from_all(j,i),j=1,ntask_cont_from_all(i))
1273 write (iout,*) "Contact send task map (proc, #tasks, tasks)"
1275 write (iout,'(20i4)') i,ntask_cont_to_all(i),&
1276 (itask_cont_to_all(j,i),j=1,ntask_cont_to_all(i))
1280 ! Check if every send will have a matching receive
1284 ncheck_to=ncheck_to+ntask_cont_to_all(i)
1285 ncheck_from=ncheck_from+ntask_cont_from_all(i)
1287 write (iout,*) "Control sums",ncheck_from,ncheck_to
1288 if (ncheck_from.ne.ncheck_to) then
1289 write (iout,*) "Error: #receive differs from #send."
1290 write (iout,*) "Terminating program...!"
1296 do j=1,ntask_cont_to_all(i)
1297 ii=itask_cont_to_all(j,i)
1298 do k=1,ntask_cont_from_all(ii)
1299 if (itask_cont_from_all(k,ii).eq.i) then
1300 if(lprint)write(iout,*)"Matching send/receive",i,ii
1304 if (k.eq.ntask_cont_from_all(ii)+1) then
1306 write (iout,*) "Error: send by",j," to",ii,&
1307 " would have no matching receive"
1313 write (iout,*) "Unmatched sends; terminating program"
1317 call MPI_Bcast(flag,1,MPI_LOGICAL,king,FG_COMM,IERROR)
1318 ! write (iout,*) "flag broadcast ended flag=",flag
1321 call MPI_Finalize(IERROR)
1322 stop "Error in INIT_INT_TABLE: unmatched send/receive."
1324 call MPI_Comm_group(FG_COMM,fg_group,IERR)
1325 ! write (iout,*) "MPI_Comm_group ended"
1327 call MPI_Group_incl(fg_group,ntask_cont_from+1,&
1328 itask_cont_from(0),CONT_FROM_GROUP,IERR)
1329 call MPI_Group_incl(fg_group,ntask_cont_to+1,itask_cont_to(0),&
1333 iaux=4*(ielend(ii)-ielstart(ii)+1)
1334 call MPI_Group_translate_ranks(fg_group,iaux,&
1335 iint_sent(1,ielstart(ii),i),CONT_TO_GROUP,&
1336 iint_sent_local(1,ielstart(ii),i),IERR )
1337 ! write (iout,*) "Ranks translated i=",i
1340 iaux=4*(iturn3_end-iturn3_start+1)
1341 call MPI_Group_translate_ranks(fg_group,iaux,&
1342 iturn3_sent(1,iturn3_start),CONT_TO_GROUP,&
1343 iturn3_sent_local(1,iturn3_start),IERR)
1344 iaux=4*(iturn4_end-iturn4_start+1)
1345 call MPI_Group_translate_ranks(fg_group,iaux,&
1346 iturn4_sent(1,iturn4_start),CONT_TO_GROUP,&
1347 iturn4_sent_local(1,iturn4_start),IERR)
1349 write (iout,*) "iint_sent_local"
1352 write (iout,'(20i4)') ii,(j,(iint_sent_local(k,j,i),k=1,4),&
1353 j=ielstart(ii),ielend(ii))
1356 write (iout,*) "iturn3_sent_local iturn3_start",iturn3_start,&
1357 " iturn3_end",iturn3_end
1358 write (iout,'(20i4)') (i,(iturn3_sent_local(j,i),j=1,4),&
1359 i=iturn3_start,iturn3_end)
1360 write (iout,*) "iturn4_sent_local iturn4_start",iturn4_start,&
1361 " iturn4_end",iturn4_end
1362 write (iout,'(20i4)') (i,(iturn4_sent_local(j,i),j=1,4),&
1363 i=iturn4_start,iturn4_end)
1366 call MPI_Group_free(fg_group,ierr)
1367 call MPI_Group_free(cont_from_group,ierr)
1368 call MPI_Group_free(cont_to_group,ierr)
1369 call MPI_Type_contiguous(3,MPI_DOUBLE_PRECISION,MPI_UYZ,IERROR)
1370 call MPI_Type_commit(MPI_UYZ,IERROR)
1371 call MPI_Type_contiguous(18,MPI_DOUBLE_PRECISION,MPI_UYZGRAD,&
1373 call MPI_Type_commit(MPI_UYZGRAD,IERROR)
1374 call MPI_Type_contiguous(2,MPI_DOUBLE_PRECISION,MPI_MU,IERROR)
1375 call MPI_Type_commit(MPI_MU,IERROR)
1376 call MPI_Type_contiguous(4,MPI_DOUBLE_PRECISION,MPI_MAT1,IERROR)
1377 call MPI_Type_commit(MPI_MAT1,IERROR)
1378 call MPI_Type_contiguous(8,MPI_DOUBLE_PRECISION,MPI_MAT2,IERROR)
1379 call MPI_Type_commit(MPI_MAT2,IERROR)
1380 call MPI_Type_contiguous(6,MPI_DOUBLE_PRECISION,MPI_THET,IERROR)
1381 call MPI_Type_commit(MPI_THET,IERROR)
1382 call MPI_Type_contiguous(9,MPI_DOUBLE_PRECISION,MPI_GAM,IERROR)
1383 call MPI_Type_commit(MPI_GAM,IERROR)
1385 !el allocate(lentyp(0:nfgtasks-1))
1387 ! 9/22/08 Derived types to send matrices which appear in correlation terms
1389 if (ivec_count(i).eq.ivec_count(0)) then
1395 do ind_typ=lentyp(0),lentyp(nfgtasks-1)
1396 if (ind_typ.eq.0) then
1397 ichunk=ivec_count(0)
1399 ichunk=ivec_count(1)
1406 ! displs(i)=displs(i-1)+blocklengths(i-1)*maxres
1409 ! blocklengths(i)=blocklengths(i)*ichunk
1411 ! write (iout,*) "blocklengths and displs"
1413 ! write (iout,*) i,blocklengths(i),displs(i)
1416 ! call MPI_Type_indexed(4,blocklengths(1),displs(1),
1417 ! & MPI_DOUBLE_PRECISION,MPI_ROTAT1(ind_typ),IERROR)
1418 ! call MPI_Type_commit(MPI_ROTAT1(ind_typ),IERROR)
1419 ! write (iout,*) "MPI_ROTAT1",MPI_ROTAT1
1425 ! displs(i)=displs(i-1)+blocklengths(i-1)*maxres
1428 ! blocklengths(i)=blocklengths(i)*ichunk
1430 ! write (iout,*) "blocklengths and displs"
1432 ! write (iout,*) i,blocklengths(i),displs(i)
1435 ! call MPI_Type_indexed(4,blocklengths(1),displs(1),
1436 ! & MPI_DOUBLE_PRECISION,MPI_ROTAT2(ind_typ),IERROR)
1437 ! call MPI_Type_commit(MPI_ROTAT2(ind_typ),IERROR)
1438 ! write (iout,*) "MPI_ROTAT2",MPI_ROTAT2
1444 displs(i)=displs(i-1)+blocklengths(i-1)*nres !maxres
1447 blocklengths(i)=blocklengths(i)*ichunk
1449 call MPI_Type_indexed(8,blocklengths,displs,&
1450 MPI_DOUBLE_PRECISION,MPI_PRECOMP11(ind_typ),IERROR)
1451 call MPI_Type_commit(MPI_PRECOMP11(ind_typ),IERROR)
1457 displs(i)=displs(i-1)+blocklengths(i-1)*nres !maxres
1460 blocklengths(i)=blocklengths(i)*ichunk
1462 call MPI_Type_indexed(8,blocklengths,displs,&
1463 MPI_DOUBLE_PRECISION,MPI_PRECOMP12(ind_typ),IERROR)
1464 call MPI_Type_commit(MPI_PRECOMP12(ind_typ),IERROR)
1470 displs(i)=displs(i-1)+blocklengths(i-1)*nres !maxres
1473 blocklengths(i)=blocklengths(i)*ichunk
1475 call MPI_Type_indexed(6,blocklengths,displs,&
1476 MPI_DOUBLE_PRECISION,MPI_PRECOMP22(ind_typ),IERROR)
1477 call MPI_Type_commit(MPI_PRECOMP22(ind_typ),IERROR)
1483 displs(i)=displs(i-1)+blocklengths(i-1)*nres !maxres
1486 blocklengths(i)=blocklengths(i)*ichunk
1488 call MPI_Type_indexed(2,blocklengths,displs,&
1489 MPI_DOUBLE_PRECISION,MPI_PRECOMP23(ind_typ),IERROR)
1490 call MPI_Type_commit(MPI_PRECOMP23(ind_typ),IERROR)
1496 displs(i)=displs(i-1)+blocklengths(i-1)*nres !maxres
1499 blocklengths(i)=blocklengths(i)*ichunk
1501 call MPI_Type_indexed(4,blocklengths,displs,&
1502 MPI_DOUBLE_PRECISION,MPI_ROTAT_OLD(ind_typ),IERROR)
1503 call MPI_Type_commit(MPI_ROTAT_OLD(ind_typ),IERROR)
1507 iint_start=ivec_start+1
1510 iint_count(i)=ivec_count(i)
1511 iint_displ(i)=ivec_displ(i)
1512 ivec_displ(i)=ivec_displ(i)-1
1513 iset_displ(i)=iset_displ(i)-1
1514 ithet_displ(i)=ithet_displ(i)-1
1515 iphi_displ(i)=iphi_displ(i)-1
1516 iphi1_displ(i)=iphi1_displ(i)-1
1517 ibond_displ(i)=ibond_displ(i)-1
1519 if (nfgtasks.gt.1 .and. fg_rank.eq.king &
1520 .and. (me.eq.0 .or. .not. out1file)) then
1521 write (iout,*) "IVEC_DISPL, IVEC_COUNT, ISET_START, ISET_COUNT"
1523 write (iout,*) i,ivec_displ(i),ivec_count(i),iset_displ(i),&
1526 write (iout,*) "iphi_start",iphi_start," iphi_end",iphi_end,&
1527 " iphi1_start",iphi1_start," iphi1_end",iphi1_end
1528 write (iout,*)"IPHI_COUNT, IPHI_DISPL, IPHI1_COUNT, IPHI1_DISPL"
1530 write (iout,*) i,iphi_count(i),iphi_displ(i),iphi1_count(i),&
1533 write(iout,'(i10,a,i10,a,i10,a/a,i3,a)') n_sc_int_tot,' SC-SC ',&
1534 nele_int_tot,' electrostatic and ',nscp_int_tot,&
1535 ' SC-p interactions','were distributed among',nfgtasks,&
1536 ' fine-grain processors.'
1540 loc_end=nres_molec(1)-1
1542 ithet_end=nres_molec(1)
1543 ithet_nucl_start=3+nres_molec(1)
1544 ithet_nucl_end=nres_molec(1)+nres_molec(2)
1546 iturn3_end=nct_molec(1)-3
1548 iturn4_end=nct_molec(1)-4
1550 iphi_end=nct_molec(1)
1552 iphi1_end=nres_molec(1)
1553 iphi_nucl_start=4+nres_molec(1)
1554 iphi_nucl_end=nres_molec(1)+nres_molec(2)
1556 idihconstr_end=ndih_constr
1557 ithetaconstr_start=1
1558 ithetaconstr_end=ntheta_constr
1559 iphid_start=iphi_start
1560 iphid_end=iphi_end-1
1562 itau_end=nres_molec(1)
1564 ibond_end=nres_molec(1)-1
1565 ibond_nucl_start=2+nres_molec(1)
1566 ibond_nucl_end=nres_molec(2)-1
1568 ibondp_end=nct_molec(1)-1
1569 ibondp_nucl_start=nnt_molec(2)
1570 ibondp_nucl_end=nct_molec(2)
1572 ivec_end=nres_molec(1)-1
1574 iset_end=nres_molec(1)+1
1576 iint_end=nres_molec(1)-1
1578 ilip_end=nres_molec(1)
1580 itube_end=nres_molec(1)
1582 !el common /przechowalnia/
1583 ! deallocate(iturn3_start_all)
1584 ! deallocate(iturn3_end_all)
1585 ! deallocate(iturn4_start_all)
1586 ! deallocate(iturn4_end_all)
1587 ! deallocate(iatel_s_all)
1588 ! deallocate(iatel_e_all)
1589 ! deallocate(ielstart_all)
1590 ! deallocate(ielend_all)
1592 ! deallocate(ntask_cont_from_all)
1593 ! deallocate(ntask_cont_to_all)
1594 ! deallocate(itask_cont_from_all)
1595 ! deallocate(itask_cont_to_all)
1598 end subroutine init_int_table
1600 !-----------------------------------------------------------------------------
1601 subroutine add_int(ii,jj,itask,ntask_cont_to,itask_cont_to,flag)
1604 ! include "DIMENSIONS"
1605 ! include "COMMON.INTERACT"
1606 ! include "COMMON.SETUP"
1607 ! include "COMMON.IOUNITS"
1608 integer :: ii,jj,ntask_cont_to
1609 integer,dimension(4) :: itask
1610 integer :: itask_cont_to(0:nfgtasks-1) !(0:max_fg_procs-1)
1612 !el integer,dimension(0:nfgtasks) :: iturn3_start_all,iturn3_end_all,iturn4_start_all,&
1613 !el iturn4_end_all,iatel_s_all,iatel_e_all !(0:max_fg_procs)
1614 !el integer,dimension(nres,0:nfgtasks-1) :: ielstart_all,ielend_all !(maxres,0:max_fg_procs-1)
1615 !el common /przechowalnia/ iturn3_start_all,iturn3_end_all,iturn4_start_all,&
1616 !el iturn4_end_all,iatel_s_all,iatel_e_all,ielstart_all,ielend_all
1617 integer :: iproc,isent,k,l
1618 ! Determines whether to send interaction ii,jj to other processors; a given
1619 ! interaction can be sent to at most 2 processors.
1620 ! Sets flag=.true. if interaction ii,jj needs to be sent to at least
1621 ! one processor, otherwise flag is unchanged from the input value.
1627 ! write (iout,*) "ii",ii," jj",jj
1628 ! Loop over processors to check if anybody could need interaction ii,jj
1629 do iproc=0,fg_rank-1
1630 ! Check if the interaction matches any turn3 at iproc
1631 do k=iturn3_start_all(iproc),iturn3_end_all(iproc)
1633 if (k.eq.ii-1 .and. l.eq.jj-1 .or. k.eq.ii-1 .and. l.eq.jj+1 &
1634 .or. k.eq.ii+1 .and. l.eq.jj+1 .or. k.eq.ii+1 .and. l.eq.jj-1) &
1636 ! write (iout,*) "turn3 to iproc",iproc," ij",ii,jj,"kl",k,l
1639 if (iproc.ne.itask(1).and.iproc.ne.itask(2) &
1640 .and.iproc.ne.itask(3).and.iproc.ne.itask(4)) then
1643 call add_task(iproc,ntask_cont_to,itask_cont_to)
1647 ! Check if the interaction matches any turn4 at iproc
1648 do k=iturn4_start_all(iproc),iturn4_end_all(iproc)
1650 if (k.eq.ii-1 .and. l.eq.jj-1 .or. k.eq.ii-1 .and. l.eq.jj+1 &
1651 .or. k.eq.ii+1 .and. l.eq.jj+1 .or. k.eq.ii+1 .and. l.eq.jj-1) &
1653 ! write (iout,*) "turn3 to iproc",iproc," ij",ii,jj," kl",k,l
1656 if (iproc.ne.itask(1).and.iproc.ne.itask(2) &
1657 .and.iproc.ne.itask(3).and.iproc.ne.itask(4)) then
1660 call add_task(iproc,ntask_cont_to,itask_cont_to)
1664 if (iatel_s_all(iproc).gt.0 .and. iatel_e_all(iproc).gt.0 .and. &
1665 iatel_s_all(iproc).le.ii-1 .and. iatel_e_all(iproc).ge.ii-1)then
1666 if (ielstart_all(ii-1,iproc).le.jj-1.and. &
1667 ielend_all(ii-1,iproc).ge.jj-1) then
1669 if (iproc.ne.itask(1).and.iproc.ne.itask(2) &
1670 .and.iproc.ne.itask(3).and.iproc.ne.itask(4)) then
1673 call add_task(iproc,ntask_cont_to,itask_cont_to)
1676 if (ielstart_all(ii-1,iproc).le.jj+1.and. &
1677 ielend_all(ii-1,iproc).ge.jj+1) then
1679 if (iproc.ne.itask(1).and.iproc.ne.itask(2) &
1680 .and.iproc.ne.itask(3).and.iproc.ne.itask(4)) then
1683 call add_task(iproc,ntask_cont_to,itask_cont_to)
1689 end subroutine add_int
1690 !-----------------------------------------------------------------------------
1691 subroutine add_int_from(ii,jj,ntask_cont_from,itask_cont_from)
1695 ! include "DIMENSIONS"
1696 ! include "COMMON.INTERACT"
1697 ! include "COMMON.SETUP"
1698 ! include "COMMON.IOUNITS"
1699 integer :: ii,jj,itask(2),ntask_cont_from,&
1700 itask_cont_from(0:nfgtasks-1) !(0:max_fg_procs)
1702 !el integer,dimension(0:nfgtasks) :: iturn3_start_all,iturn3_end_all,&
1703 !el iturn4_start_all,iturn4_end_all,iatel_s_all,iatel_e_all !(0:max_fg_procs)
1704 !el integer,dimension(nres,0:nfgtasks-1) :: ielstart_all,ielend_all !(maxres,0:max_fg_procs-1)
1705 !el common /przechowalnia/ iturn3_start_all,iturn3_end_all,iturn4_start_all,&
1706 !el iturn4_end_all,iatel_s_all,iatel_e_all,ielstart_all,ielend_all
1707 integer :: iproc,k,l
1708 do iproc=fg_rank+1,nfgtasks-1
1709 do k=iturn3_start_all(iproc),iturn3_end_all(iproc)
1711 if (k.eq.ii+1 .and. l.eq.jj+1 .or. k.eq.ii+1.and.l.eq.jj-1 &
1712 .or. k.eq.ii-1 .and. l.eq.jj-1 .or. k.eq.ii-1 .and. l.eq.jj+1) &
1714 ! write (iout,*)"turn3 from iproc",iproc," ij",ii,jj," kl",k,l
1715 call add_task(iproc,ntask_cont_from,itask_cont_from)
1718 do k=iturn4_start_all(iproc),iturn4_end_all(iproc)
1720 if (k.eq.ii+1 .and. l.eq.jj+1 .or. k.eq.ii+1.and.l.eq.jj-1 &
1721 .or. k.eq.ii-1 .and. l.eq.jj-1 .or. k.eq.ii-1 .and. l.eq.jj+1) &
1723 ! write (iout,*)"turn4 from iproc",iproc," ij",ii,jj," kl",k,l
1724 call add_task(iproc,ntask_cont_from,itask_cont_from)
1727 if (iatel_s_all(iproc).gt.0 .and. iatel_e_all(iproc).gt.0) then
1728 if (ii+1.ge.iatel_s_all(iproc).and.ii+1.le.iatel_e_all(iproc)) &
1730 if (jj+1.ge.ielstart_all(ii+1,iproc).and. &
1731 jj+1.le.ielend_all(ii+1,iproc)) then
1732 call add_task(iproc,ntask_cont_from,itask_cont_from)
1734 if (jj-1.ge.ielstart_all(ii+1,iproc).and. &
1735 jj-1.le.ielend_all(ii+1,iproc)) then
1736 call add_task(iproc,ntask_cont_from,itask_cont_from)
1739 if (ii-1.ge.iatel_s_all(iproc).and.ii-1.le.iatel_e_all(iproc)) &
1741 if (jj-1.ge.ielstart_all(ii-1,iproc).and. &
1742 jj-1.le.ielend_all(ii-1,iproc)) then
1743 call add_task(iproc,ntask_cont_from,itask_cont_from)
1745 if (jj+1.ge.ielstart_all(ii-1,iproc).and. &
1746 jj+1.le.ielend_all(ii-1,iproc)) then
1747 call add_task(iproc,ntask_cont_from,itask_cont_from)
1753 end subroutine add_int_from
1754 !-----------------------------------------------------------------------------
1755 subroutine add_task(iproc,ntask_cont,itask_cont)
1759 ! include "DIMENSIONS"
1760 integer :: iproc,ntask_cont,itask_cont(0:nfgtasks-1) !(0:max_fg_procs-1)
1763 if (itask_cont(ii).eq.iproc) return
1765 ntask_cont=ntask_cont+1
1766 itask_cont(ntask_cont)=iproc
1768 end subroutine add_task
1770 !-----------------------------------------------------------------------------
1771 #if defined MPI || defined WHAM_RUN
1772 subroutine int_partition(int_index,lower_index,upper_index,atom,&
1773 at_start,at_end,first_atom,last_atom,int_gr,jat_start,jat_end,*)
1775 ! implicit real*8 (a-h,o-z)
1776 ! include 'DIMENSIONS'
1777 ! include 'COMMON.IOUNITS'
1778 integer :: int_index,lower_index,upper_index,atom,at_start,at_end,&
1779 first_atom,last_atom,int_gr,jat_start,jat_end,int_index_old
1782 if (lprn) write (iout,*) 'int_index=',int_index
1783 int_index_old=int_index
1784 int_index=int_index+last_atom-first_atom+1
1786 write (iout,*) 'int_index=',int_index,&
1787 ' int_index_old',int_index_old,&
1788 ' lower_index=',lower_index,&
1789 ' upper_index=',upper_index,&
1790 ' atom=',atom,' first_atom=',first_atom,&
1791 ' last_atom=',last_atom
1792 if (int_index.ge.lower_index) then
1794 if (at_start.eq.0) then
1796 jat_start=first_atom-1+lower_index-int_index_old
1798 jat_start=first_atom
1800 if (lprn) write (iout,*) 'jat_start',jat_start
1801 if (int_index.ge.upper_index) then
1803 jat_end=first_atom-1+upper_index-int_index_old
1808 if (lprn) write (iout,*) 'jat_end',jat_end
1811 end subroutine int_partition
1813 !-----------------------------------------------------------------------------
1815 subroutine hpb_partition
1817 ! implicit real*8 (a-h,o-z)
1818 ! include 'DIMENSIONS'
1822 ! include 'COMMON.SBRIDGE'
1823 ! include 'COMMON.IOUNITS'
1824 ! include 'COMMON.SETUP'
1826 call int_bounds(nhpb,link_start,link_end)
1827 write (iout,*) 'Processor',fg_rank,' CG group',kolor,&
1828 ' absolute rank',MyRank,&
1829 ' nhpb',nhpb,' link_start=',link_start,&
1830 ' link_end',link_end
1836 end subroutine hpb_partition
1838 !-----------------------------------------------------------------------------
1839 ! misc.f in module io_base
1840 !-----------------------------------------------------------------------------
1841 !-----------------------------------------------------------------------------
1843 !-----------------------------------------------------------------------------
1844 subroutine getenv_loc(var, val)
1846 character(*) :: var, val
1849 character(len=2000) :: line
1852 open (196,file='env',status='old',readonly,shared)
1854 ! write(*,*)'looking for ',var
1855 10 read(196,*,err=11,end=11)line
1856 iread=index(line,var)
1857 ! write(*,*)iread,' ',var,' ',line
1858 if (iread.eq.0) go to 10
1859 ! write(*,*)'---> ',line
1865 iread=iread+ilen(var)+1
1866 read (line(iread:),*,err=12,end=12) val
1867 ! write(*,*)'OK: ',var,' = ',val
1873 #elif (defined CRAY)
1874 integer :: lennam,lenval,ierror
1876 ! getenv using a POSIX call, useful on the T3D
1877 ! Sept 1996, comment out error check on advice of H. Pritchard
1880 if(lennam.le.0) stop '--error calling getenv--'
1881 call pxfgetenv(var,lennam,val,lenval,ierror)
1882 !-HP- if(ierror.ne.0) stop '--error returned by pxfgetenv--'
1884 call getenv(var,val)
1888 end subroutine getenv_loc
1889 !-----------------------------------------------------------------------------
1891 !-----------------------------------------------------------------------------
1892 subroutine setup_var
1895 ! implicit real*8 (a-h,o-z)
1896 ! include 'DIMENSIONS'
1897 ! include 'COMMON.IOUNITS'
1898 ! include 'COMMON.GEO'
1899 ! include 'COMMON.VAR'
1900 ! include 'COMMON.INTERACT'
1901 ! include 'COMMON.LOCAL'
1902 ! include 'COMMON.NAMES'
1903 ! include 'COMMON.CHAIN'
1904 ! include 'COMMON.FFIELD'
1905 ! include 'COMMON.SBRIDGE'
1906 ! include 'COMMON.HEADER'
1907 ! include 'COMMON.CONTROL'
1908 ! include 'COMMON.DBASE'
1909 ! include 'COMMON.THREAD'
1910 ! include 'COMMON.TIME1'
1911 ! Set up variable list.
1918 if (itype(i,1).ne.10) then
1920 if (itype(i,1).ne.10 .and. itype(i,1).ne.ntyp1) then
1923 ialph(i,1)=nvar+nside
1927 if (indphi.gt.0) then
1929 else if (indback.gt.0) then
1934 !d write (iout,'(3i4)') (i,ialph(i,1),ialph(i,2),i=2,nres-1)
1936 end subroutine setup_var
1937 !-----------------------------------------------------------------------------
1939 !-----------------------------------------------------------------------------
1940 integer function rescode(iseq,nam,itype,molecule)
1942 use io_base, only: ucase
1943 ! implicit real*8 (a-h,o-z)
1944 ! include 'DIMENSIONS'
1945 ! include 'COMMON.NAMES'
1946 ! include 'COMMON.IOUNITS'
1947 character(len=3) :: nam !,ucase
1948 integer :: iseq,itype,i
1950 print *,molecule,nam
1951 if (molecule.eq.1) then
1952 if (itype.eq.0) then
1954 do i=-ntyp1_molec(molecule),ntyp1_molec(molecule)
1955 if (ucase(nam).eq.restyp(i,molecule)) then
1963 do i=-ntyp1_molec(molecule),ntyp1_molec(molecule)
1964 if (nam(1:1).eq.onelet(i)) then
1971 else if (molecule.eq.2) then
1972 do i=1,ntyp1_molec(molecule)
1973 print *,nam(1:1),restyp(i,molecule)(1:1)
1974 if (nam(2:2).eq.restyp(i,molecule)(1:1)) then
1979 else if (molecule.eq.3) then
1980 write(iout,*) "SUGAR not yet implemented"
1982 else if (molecule.eq.4) then
1983 write(iout,*) "Explicit LIPID not yet implemented"
1985 else if (molecule.eq.5) then
1986 do i=1,ntyp1_molec(molecule)
1987 print *,i,restyp(i,molecule)(1:2)
1988 if (ucase(nam(1:2)).eq.restyp(i,molecule)(1:2)) then
1994 write(iout,*) "molecule not defined"
1996 write (iout,10) iseq,nam
1998 10 format ('**** Error - residue',i4,' has an unresolved name ',a3)
1999 end function rescode
2000 integer function sugarcode(sugar,ires)
2003 if (sugar.eq.'D') then
2005 else if (sugar.eq.' ') then
2008 write (iout,*) 'UNKNOWN sugar type for residue',ires,' ',sugar
2012 end function sugarcode
2014 !-----------------------------------------------------------------------------
2016 !-----------------------------------------------------------------------------
2017 ! $Date: 1994/10/05 16:41:52 $
2020 subroutine set_timers
2023 !el real(kind=8) :: tcpu
2024 ! include 'COMMON.TIME1'
2029 ! Diminish the assigned time limit a little so that there is some time to
2031 ! timlim=batime-150.0
2032 ! Calculate the initial time, if it is not zero (e.g. for the SUN).
2034 #if .not. defined(WHAM_RUN) && .not. defined(CLUSTER)
2036 walltime=MPI_WTIME()
2038 time_allreduce=0.0d0
2043 time_scatter_fmat=0.0d0
2044 time_scatter_ginv=0.0d0
2045 time_scatter_fmatmult=0.0d0
2046 time_scatter_ginvmult=0.0d0
2047 time_barrier_e=0.0d0
2048 time_barrier_g=0.0d0
2051 time_lagrangian=0.0d0
2052 time_sumgradient=0.0d0
2053 time_intcartderiv=0.0d0
2054 time_inttocart=0.0d0
2056 time_fricmatmult=0.0d0
2066 time_fricmatmult=0.0d0
2070 !d print *,' in SET_TIMERS stime=',stime
2072 end subroutine set_timers
2073 !-----------------------------------------------------------------------------
2075 logical function stopx(nf)
2076 ! This function returns .true. if one of the following reasons to exit SUMSL
2077 ! occurs. The "reason" code is stored in WHATSUP passed thru a COMMON block:
2079 !... WHATSUP = 0 - go on, no reason to stop. Stopx will return .false.
2080 !... 1 - Time up in current node;
2081 !... 2 - STOP signal was received from another node because the
2082 !... node's task was accomplished (parallel only);
2083 !... -1 - STOP signal was received from another node because of error;
2084 !... -2 - STOP signal was received from another node, because
2085 !... the node's time was up.
2086 ! implicit real*8 (a-h,o-z)
2087 ! include 'DIMENSIONS'
2089 !el use control_data, only:WhatsUp
2092 !el use MPI_data !include 'COMMON.INFO'
2096 !el logical :: ovrtim
2098 ! include 'COMMON.IOUNITS'
2099 ! include 'COMMON.TIME1'
2102 !d print *,'Processor',MyID,' NF=',nf
2103 !d write (iout,*) "stopx: ",nf
2107 ! Finish if time is up.
2111 else if (mod(nf,100).eq.0) then
2112 ! Other processors might have finished. Check this every 100th function
2114 ! Master checks if any other processor has sent accepted conformation(s) to it.
2115 if (MyID.ne.MasterID) call receive_mcm_info
2116 if (MyID.eq.MasterID) call receive_conf
2117 !d print *,'Processor ',MyID,' is checking STOP: nf=',nf
2118 call recv_stop_sig(Kwita)
2119 if (Kwita.eq.-1) then
2120 write (iout,'(a,i4,a,i5)') 'Processor',&
2121 MyID,' has received STOP signal in STOPX; NF=',nf
2122 write (*,'(a,i4,a,i5)') 'Processor',&
2123 MyID,' has received STOP signal in STOPX; NF=',nf
2126 elseif (Kwita.eq.-2) then
2128 'Processor',MyID,' received TIMEUP-STOP signal in SUMSL.'
2130 'Processor',MyID,' received TIMEUP-STOP signal in SUMSL.'
2133 else if (Kwita.eq.-3) then
2135 'Processor',MyID,' received ERROR-STOP signal in SUMSL.'
2137 'Processor',MyID,' received ERROR-STOP signal in SUMSL.'
2151 !d write (iout,*) "stopx set at .false."
2155 ! Check for FOUND_NAN flag
2157 write(iout,*)" *** stopx : Found a NaN"
2163 ! Finish if time is up.
2166 else if (cutoffviol) then
2175 !-----------------------------------------------------------------------------
2177 logical function stopx(nf)
2179 ! ..................................................................
2182 ! THIS FUNCTION MAY SERVE AS THE STOPX (ASYNCHRONOUS INTERRUPTION)
2183 ! FUNCTION FOR THE NL2SOL (NONLINEAR LEAST-SQUARES) PACKAGE AT
2184 ! THOSE INSTALLATIONS WHICH DO NOT WISH TO IMPLEMENT A
2187 ! *****ALGORITHM NOTES...
2188 ! AT INSTALLATIONS WHERE THE NL2SOL SYSTEM IS USED
2189 ! INTERACTIVELY, THIS DUMMY STOPX SHOULD BE REPLACED BY A
2190 ! FUNCTION THAT RETURNS .TRUE. IF AND ONLY IF THE INTERRUPT
2191 ! (BREAK) KEY HAS BEEN PRESSED SINCE THE LAST CALL ON STOPX.
2193 ! $$$ MODIFIED FOR USE AS THE TIMER ROUTINE.
2194 ! $$$ WHEN THE TIME LIMIT HAS BEEN
2195 ! $$$ REACHED STOPX IS SET TO .TRUE AND INITIATES (IN ITSUM)
2196 ! $$$ AND ORDERLY EXIT OUT OF SUMSL. IF ARRAYS IV AND V ARE
2197 ! $$$ SAVED, THE SUMSL ROUTINES CAN BE RESTARTED AT THE SAME
2198 ! $$$ POINT AT WHICH THEY WERE INTERRUPTED.
2200 ! ..................................................................
2202 ! include 'DIMENSIONS'
2205 ! include 'COMMON.IOUNITS'
2206 ! include 'COMMON.TIME1'
2208 ! include 'COMMON.INFO'
2211 !d print *,'Processor',MyID,' NF=',nf
2214 ! Finish if time is up.
2217 else if (mod(nf,100).eq.0) then
2218 ! Other processors might have finished. Check this every 100th function
2220 !d print *,'Processor ',MyID,' is checking STOP: nf=',nf
2221 call recv_stop_sig(Kwita)
2222 if (Kwita.eq.-1) then
2223 write (iout,'(a,i4,a,i5)') 'Processor',&
2224 MyID,' has received STOP signal in STOPX; NF=',nf
2225 write (*,'(a,i4,a,i5)') 'Processor',&
2226 MyID,' has received STOP signal in STOPX; NF=',nf
2238 !-----------------------------------------------------------------------------
2239 logical function ovrtim()
2241 ! include 'DIMENSIONS'
2242 ! include 'COMMON.IOUNITS'
2243 ! include 'COMMON.TIME1'
2244 !el real(kind=8) :: tcpu
2245 real(kind=8) :: curtim
2248 curtim = MPI_Wtime()-walltime
2252 ! curtim is the current time in seconds.
2253 ! write (iout,*) "curtim",curtim," timlim",timlim," safety",safety
2255 if (curtim .ge. timlim - safety) then
2256 write (iout,'(a,f10.2,a,f10.2,a,f10.2,a)') &
2257 "***************** Elapsed time (",curtim,&
2258 " s) is within the safety limit (",safety,&
2259 " s) of the allocated time (",timlim," s). Terminating."
2267 !elwrite (iout,*) "ovrtim",ovrtim
2270 !-----------------------------------------------------------------------------
2271 real(kind=8) function tcpu()
2273 ! include 'COMMON.TIME1'
2274 real(kind=8) :: seconds
2276 !***************************
2277 ! Next definition for EAGLE (ibm-es9000)
2278 real(kind=8) :: micseconds
2280 tcpu=cputime(micseconds,rcode)
2281 tcpu=(micseconds/1.0E6) - stime
2282 !***************************
2285 !***************************
2286 ! Next definitions for sun
2287 REAL(kind=8) :: ECPU,ETIME,ETCPU
2288 real(kind=8),dimension(2) :: tarray
2291 !***************************
2294 !***************************
2295 ! Next definitions for ksr
2296 ! this function uses the ksr timer ALL_SECONDS from the PMON library to
2297 ! return the elapsed time in seconds
2298 tcpu= all_seconds() - stime
2299 !***************************
2302 !***************************
2303 ! Next definitions for sgi
2304 real(kind=4) :: timar(2), etime
2305 seconds = etime(timar)
2306 !d print *,'seconds=',seconds,' stime=',stime
2309 tcpu=seconds - stime
2310 !***************************
2314 !***************************
2315 ! Next definitions for sgi
2316 real(kind=4) :: timar(2), etime
2317 seconds = etime(timar)
2318 !d print *,'seconds=',seconds,' stime=',stime
2321 tcpu=seconds - stime
2322 !***************************
2327 !***************************
2328 ! Next definitions for Cray
2330 ! curdat=curdat(1:9)
2331 ! call clock(curtim)
2332 ! curtim=curtim(1:8)
2335 !***************************
2338 !***************************
2339 ! Next definitions for RS6000
2340 integer(kind=4) :: i1,mclock
2342 tcpu = (i1+0.0D0)/100.0D0
2345 !***************************
2346 ! next definitions for windows NT Digital fortran
2347 real(kind=4) :: time_real
2348 call cpu_time(time_real)
2352 !***************************
2353 ! next definitions for windows NT Digital fortran
2354 real(kind=4) :: time_real
2355 call cpu_time(time_real)
2361 !-----------------------------------------------------------------------------
2363 subroutine dajczas(rntime,hrtime,mintime,sectime)
2365 ! include 'COMMON.IOUNITS'
2366 integer :: ihr,imn,isc
2367 real(kind=8) :: rntime,hrtime,mintime,sectime
2368 hrtime=rntime/3600.0D0
2370 mintime=aint((rntime-3600.0D0*hrtime)/60.0D0)
2371 sectime=aint((rntime-3600.0D0*hrtime-60.0D0*mintime)+0.5D0)
2372 if (sectime.eq.60.0D0) then
2374 mintime=mintime+1.0D0
2379 write (iout,328) ihr,imn,isc
2380 328 FORMAT(//'***** Computation time: ',I4 ,' hours ',I2 ,&
2381 ' minutes ', I2 ,' seconds *****')
2383 end subroutine dajczas
2384 !-----------------------------------------------------------------------------
2385 subroutine print_detailed_timing
2388 ! implicit real*8 (a-h,o-z)
2389 ! include 'DIMENSIONS'
2393 ! include 'COMMON.IOUNITS'
2394 ! include 'COMMON.TIME1'
2395 ! include 'COMMON.SETUP'
2396 real(kind=8) :: time1,time_barrier
2397 time_barrier = 0.0d0
2401 write (iout,'(80(1h=)/a/(80(1h=)))') &
2402 "Details of FG communication time"
2403 write (*,'(7(a40,1pe15.5/),40(1h-)/a40,1pe15.5/80(1h=))') &
2404 "BROADCAST:",time_bcast,"REDUCE:",time_reduce,&
2405 "GATHER:",time_gather,&
2406 "SCATTER:",time_scatter,"SENDRECV:",time_sendrecv,&
2407 "BARRIER ene",time_barrier_e,&
2408 "BARRIER grad",time_barrier_g,&
2410 time_bcast+time_reduce+time_gather+time_scatter+time_sendrecv
2411 write (*,*) fg_rank,myrank,&
2412 ': Total wall clock time',time1-walltime,' sec'
2413 write (*,*) "Processor",fg_rank,myrank,&
2414 ": BROADCAST time",time_bcast," REDUCE time",&
2415 time_reduce," GATHER time",time_gather," SCATTER time",&
2417 " SCATTER fmatmult",time_scatter_fmatmult,&
2418 " SCATTER ginvmult",time_scatter_ginvmult,&
2419 " SCATTER fmat",time_scatter_fmat,&
2420 " SCATTER ginv",time_scatter_ginv,&
2421 " SENDRECV",time_sendrecv,&
2422 " BARRIER ene",time_barrier_e,&
2423 " BARRIER GRAD",time_barrier_g,&
2424 " BCAST7",time_bcast7," BCASTC",time_bcastc,&
2425 " BCASTW",time_bcastw," ALLREDUCE",time_allreduce,&
2427 time_bcast+time_reduce+time_gather+time_scatter+ &
2428 time_sendrecv+time_barrier+time_bcastc
2430 write (*,*) "Processor",fg_rank,myrank," enecalc",time_enecalc
2431 write (*,*) "Processor",fg_rank,myrank," sumene",time_sumene
2432 write (*,*) "Processor",fg_rank,myrank," intfromcart",&
2434 write (*,*) "Processor",fg_rank,myrank," vecandderiv",&
2436 write (*,*) "Processor",fg_rank,myrank," setmatrices",&
2438 write (*,*) "Processor",fg_rank,myrank," ginvmult",&
2440 write (*,*) "Processor",fg_rank,myrank," fricmatmult",&
2442 write (*,*) "Processor",fg_rank,myrank," inttocart",&
2444 write (*,*) "Processor",fg_rank,myrank," sumgradient",&
2446 write (*,*) "Processor",fg_rank,myrank," intcartderiv",&
2448 if (fg_rank.eq.0) then
2449 write (*,*) "Processor",fg_rank,myrank," lagrangian",&
2451 write (*,*) "Processor",fg_rank,myrank," cartgrad",&
2455 end subroutine print_detailed_timing
2457 !-----------------------------------------------------------------------------
2458 !-----------------------------------------------------------------------------