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
249 #if defined(WHAM_RUN) || defined(CLUSTER)
251 ! setting the mpi variables for WHAM
258 ! Set default weights of the energy terms.
260 wsc=1.0D0 ! in wham: wlong=1.0D0
269 ! print '(a,$)','Inside initialize'
270 ! call memmon_print_usage()
304 ! athet(j,i,ichir1,ichir2)=0.0D0
305 ! bthet(j,i,ichir1,ichir2)=0.0D0
325 ! gaussc(l,k,j,i)=0.0D0
333 ! do i=-maxtor,maxtor
335 !c write (iout,*) "TU DOCHODZE",i,itortyp(i)
337 ! do j=-maxtor,maxtor
339 ! v1(k,j,i,iblock)=0.0D0
340 ! v2(k,j,i,iblock)=0.0D0
346 ! do i=-maxtor,maxtor
347 ! do j=-maxtor,maxtor
348 ! do k=-maxtor,maxtor
350 ! v1c(1,l,i,j,k,iblock)=0.0D0
351 ! v1s(1,l,i,j,k,iblock)=0.0D0
352 ! v1c(2,l,i,j,k,iblock)=0.0D0
353 ! v1s(2,l,i,j,k,iblock)=0.0D0
357 ! v2c(m,l,i,j,k,iblock)=0.0D0
358 ! v2s(m,l,i,j,k,iblock)=0.0D0
370 ! Initialize the bridge arrays
389 ! Initialize variables used in minimization.
398 ! Initialize the variables responsible for the mode of gradient storage.
404 allocate(iww(max_eneW))
407 if (print_order(i).eq.j) then
408 iww(print_order(i))=j
416 #if defined(WHAM_RUN) || defined(CLUSTER)
419 ! allocate(ww0(max_eneW))
420 ! ww0 = reshape((/1.0d0,1.0d0,1.0d0,1.0d0,1.0d0,1.0d0,1.0d0,1.0d0,&
421 ! 1.0d0,1.0d0,1.0d0,1.0d0,1.0d0,1.0d0,1.0d0,1.0d0,0.4d0,1.0d0,&
422 ! 1.0d0,0.0d0,0.0/), shape(ww0))
425 ! Set timers and counters for the respective routines
445 ! Initialize constants used to split the energy into long- and short-range
451 nprint_ene=nprint_ene-1
454 end subroutine initialize
455 !-----------------------------------------------------------------------------
456 subroutine init_int_table
458 use geometry, only:int_bounds1
461 ! implicit real*8 (a-h,o-z)
462 ! include 'DIMENSIONS'
465 integer,dimension(15) :: blocklengths,displs
467 ! include 'COMMON.CONTROL'
468 ! include 'COMMON.SETUP'
469 ! include 'COMMON.CHAIN'
470 ! include 'COMMON.INTERACT'
471 ! include 'COMMON.LOCAL'
472 ! include 'COMMON.SBRIDGE'
473 ! include 'COMMON.TORCNSTR'
474 ! include 'COMMON.IOUNITS'
475 ! include 'COMMON.DERIV'
476 ! include 'COMMON.CONTACTS'
477 !el integer,dimension(0:nfgtasks) :: iturn3_start_all,iturn3_end_all,&
478 !el iturn4_start_all,iturn4_end_all,iatel_s_all,iatel_e_all !(0:max_fg_procs)
479 !el integer,dimension(nres,0:nfgtasks) :: ielstart_all,&
480 !el ielend_all !(maxres,0:max_fg_procs-1)
481 !el integer,dimension(0:nfgtasks-1) :: ntask_cont_from_all,&
482 !el ntask_cont_to_all !(0:max_fg_procs-1),
483 !el integer,dimension(0:nfgtasks-1,0:nfgtasks-1) :: itask_cont_from_all,&
484 !el itask_cont_to_all !(0:max_fg_procs-1,0:max_fg_procs-1)
486 !el common /przechowalnia/ iturn3_start_all,iturn3_end_all,&
487 !el iturn4_start_all,iturn4_end_all,iatel_s_all,iatel_e_all,&
488 !el ielstart_all,ielend_all,ntask_cont_from_all,itask_cont_from_all,&
489 !el ntask_cont_to_all,itask_cont_to_all
491 integer :: FG_GROUP,CONT_FROM_GROUP,CONT_TO_GROUP
492 logical :: scheck,lprint,flag
495 integer :: ind_scint=0,ind_scint_old,ii,jj,i,j,iint,itmp
496 integer :: ind_scint_nucl=0
498 integer :: my_sc_int(0:nfgtasks-1),my_ele_int(0:nfgtasks-1)
499 integer :: my_sc_intt(0:nfgtasks),my_ele_intt(0:nfgtasks)
500 integer :: n_sc_int_tot,my_sc_inde,my_sc_inds,ind_sctint,npept
501 integer :: n_sc_int_tot_nucl,my_sc_inde_nucl,my_sc_inds_nucl, &
502 ind_sctint_nucl,npept_nucl
504 integer :: nele_int_tot,my_ele_inds,my_ele_inde,ind_eleint_old,&
505 ind_eleint,ijunk,nele_int_tot_vdw,my_ele_inds_vdw,&
506 my_ele_inde_vdw,ind_eleint_vdw,ind_eleint_vdw_old,&
507 nscp_int_tot,my_scp_inds,my_scp_inde,ind_scpint,&
508 ind_scpint_old,nsumgrad,nlen,ngrad_start,ngrad_end,&
509 ierror,k,ierr,iaux,ncheck_to,ncheck_from,ind_typ,&
511 integer :: nele_int_tot_nucl,my_ele_inds_nucl,my_ele_inde_nucl,&
512 ind_eleint_old_nucl,ind_eleint_nucl,nele_int_tot_vdw_nucl,&
513 my_ele_inds_vdw_nucl,my_ele_inde_vdw_nucl,ind_eleint_vdw_nucl,&
514 ind_eleint_vdw_old_nucl,nscp_int_tot_nucl,my_scp_inds_nucl,&
515 my_scp_inde_nucl,ind_scpint_nucl,ind_scpint_old_nucl
516 ! integer,dimension(5) :: nct_molec,nnt_molec
517 !el allocate(itask_cont_from(0:nfgtasks-1)) !(0:max_fg_procs-1)
518 !el allocate(itask_cont_to(0:nfgtasks-1)) !(0:max_fg_procs-1)
520 !... Determine the numbers of start and end SC-SC interaction
521 !... to deal with by current processor.
522 !write (iout,*) '******INIT_INT_TABLE nres=',nres,' nnt=',nnt,' nct=',nct
524 itask_cont_from(i)=fg_rank
525 itask_cont_to(i)=fg_rank
530 if (nres_molec(i).eq.0) cycle
531 itmp=itmp+nres_molec(i)
532 if (itype(itmp,i).eq.ntyp1_molec(i)) then
538 ! nct_molec(1)=nres_molec(1)-1
541 itmp=itmp+nres_molec(i-1)
542 if (itype(itmp+1,i).eq.ntyp1_molec(i)) then
548 print *,"nres_molec",nres_molec(:)
549 print *,"nnt_molec",nnt_molec(:)
550 print *,"nct_molec",nct_molec(:)
553 write (iout,*)'INIT_INT_TABLE nres=',nres,' nnt=',nnt,' nct=',nct
554 n_sc_int_tot=(nct_molec(1)-nnt+1)*(nct_molec(1)-nnt)/2-nss
555 call int_bounds(n_sc_int_tot,my_sc_inds,my_sc_inde)
556 !write (iout,*) 'INIT_INT_TABLE nres=',nres,' nnt=',nnt,' nct=',nct
558 write (iout,*) 'Processor',fg_rank,' CG group',kolor,&
559 ' absolute rank',MyRank,&
560 ' n_sc_int_tot',n_sc_int_tot,' my_sc_inds=',my_sc_inds,&
561 ' my_sc_inde',my_sc_inde
566 !el common /przechowalnia/
567 allocate(iturn3_start_all(0:nfgtasks))
568 allocate(iturn3_end_all(0:nfgtasks))
569 allocate(iturn4_start_all(0:nfgtasks))
570 allocate(iturn4_end_all(0:nfgtasks))
571 allocate(iatel_s_all(0:nfgtasks))
572 allocate(iatel_e_all(0:nfgtasks))
573 allocate(ielstart_all(nres,0:nfgtasks-1))
574 allocate(ielend_all(nres,0:nfgtasks-1))
576 allocate(ntask_cont_from_all(0:nfgtasks-1))
577 allocate(ntask_cont_to_all(0:nfgtasks-1))
578 allocate(itask_cont_from_all(0:nfgtasks-1,0:nfgtasks-1))
579 allocate(itask_cont_to_all(0:nfgtasks-1,0:nfgtasks-1))
582 print *,"NCT",nct_molec(1),nct
583 do i=1,nres !el !maxres
597 !d write (iout,*) 'ns=',ns,' nss=',nss,' ihpb,jhpb',
598 !d & (ihpb(i),jhpb(i),i=1,nss)
599 ! print *,nnt,nct_molec(1)
600 do i=nnt,nct_molec(1)-1
605 if (ihpb(ii).eq.i+nres) then
612 ! print *,'i=',i,' scheck=',scheck,' jj=',jj
613 !d write (iout,*) 'i=',i,' scheck=',scheck,' jj=',jj
617 ! write (iout,*) 'jj=i+1'
618 call int_partition(ind_scint,my_sc_inds,my_sc_inde,i,&
619 iatsc_s,iatsc_e,i+2,nct_molec(1),nint_gr(i),istart(i,1),iend(i,1),*12)
625 else if (jj.eq.nct_molec(1)) then
627 ! write (iout,*) 'jj=nct'
628 call int_partition(ind_scint,my_sc_inds,my_sc_inde,i,&
629 iatsc_s,iatsc_e,i+1,nct_molec(1)-1,nint_gr(i),istart(i,1),iend(i,1),*12)
633 iend(i,1)=nct_molecule(1)-1
637 call int_partition(ind_scint,my_sc_inds,my_sc_inde,i,&
638 iatsc_s,iatsc_e,i+1,jj-1,nint_gr(i),istart(i,1),iend(i,1),*12)
640 call int_partition(ind_scint,my_sc_inds,my_sc_inde,i,&
641 iatsc_s,iatsc_e,jj+1,nct_molec(1),nint_gr(i),istart(i,ii),iend(i,ii),*12)
648 iend(i,2)=nct_molec(1)
653 ! print *,"i for EVDW",iatsc_s,iatsc_e,istart(i,1),iend(i,1),&
654 ! i+1,nct_molec(1),nint_gr(i),ind_scint,my_sc_inds,my_sc_inde,i
655 call int_partition(ind_scint,my_sc_inds,my_sc_inde,i,&
656 iatsc_s,iatsc_e,i+1,nct_molec(1),nint_gr(i), &
657 istart(i,1),iend(i,1),*12)
658 ! print *,"i for EVDW",iatsc_s,iatsc_e,istart(i,1),iend(i,1)
662 iend(i,1)=nct_molec(1)
663 ind_scint=ind_scint+nct_molec(1)-i
667 ind_scint_old=ind_scint
671 ! print *,"i for EVDW",iatsc_s,iatsc_e,istart(i,1),iend(i,1)
677 if (iatsc_s.eq.0) iatsc_s=1
678 !----------------- scaling for nucleic acid GB
679 n_sc_int_tot_nucl=(nct_molec(2)-nnt_molec(2)+1)*(nct_molec(2)-nnt_molec(2))/2
680 call int_bounds(n_sc_int_tot_nucl,my_sc_inds_nucl,my_sc_inde_nucl)
681 !write (iout,*) 'INIT_INT_TABLE nres=',nres,' nnt=',nnt,' nct=',nct
683 write (iout,*) 'Processor',fg_rank,' CG group',kolor,&
684 ' absolute rank',MyRank,&
685 ' n_sc_int_tot',n_sc_int_tot_nucl,' my_sc_inds=',my_sc_inds_nucl,&
686 ' my_sc_inde',my_sc_inde_nucl
690 do i=1,nres !el !maxres
698 iscpstart_nucl(i,j)=0
702 do i=nnt_molec(2),nct_molec(2)-1
704 call int_partition(ind_scint_nucl,my_sc_inds_nucl,my_sc_inde_nucl,i,&
705 iatsc_s_nucl,iatsc_e_nucl,i+1,nct_molec(2),nint_gr_nucl(i), &
706 istart_nucl(i,1),iend_nucl(i,1),*112)
707 print *,istart_nucl(i,1)
710 if (iatsc_s_nucl.eq.0) iatsc_s_nucl=1
711 print *,"tu mam",iatsc_s_nucl,iatsc_e_nucl
714 if (lprint) write (*,*) 'Processor',fg_rank,' CG Group',kolor,&
715 ' absolute rank',myrank,' iatsc_s=',iatsc_s,' iatsc_e=',iatsc_e
719 write (iout,'(a)') 'Interaction array:'
721 write (iout,'(i3,2(2x,2i3))') &
722 i,(istart(i,iint),iend(i,iint),iint=1,nint_gr(i))
726 write (iout,'(a)') 'Interaction array2:'
727 do i=iatsc_s_nucl,iatsc_e_nucl
728 write (iout,'(i3,2(2x,2i4))') &
729 i,(istart_nucl(i,iint),iend_nucl(i,iint),iint=1,nint_gr_nucl(i))
732 ispp=4 !?? wham ispp=2
734 ! Now partition the electrostatic-interaction array
735 if (nres_molec(1).eq.0) then
737 elseif (itype(nres_molec(1),1).eq.ntyp1_molec(1)) then
738 npept=nres_molec(1)-nnt-1
740 npept=nres_molec(1)-nnt
742 nele_int_tot=(npept-ispp)*(npept-ispp+1)/2
743 call int_bounds(nele_int_tot,my_ele_inds,my_ele_inde)
745 write (*,*) 'Processor',fg_rank,' CG group',kolor,&
746 ' absolute rank',MyRank,&
747 ' nele_int_tot',nele_int_tot,' my_ele_inds=',my_ele_inds,&
748 ' my_ele_inde',my_ele_inde
753 ! if (itype(nres_molec(1),1).eq.ntyp1_molec(1)) then
754 ! nct_molec(1)=nres_molec(1)-1
756 ! nct_molec(1)=nres_molec(1)
758 ! print *,"nct",nct,nct_molec(1),itype(nres_molec(1),1),ntyp_molec(1)
759 do i=nnt,nct_molec(1)-3
761 call int_partition(ind_eleint,my_ele_inds,my_ele_inde,i,&
762 iatel_s,iatel_e,i+ispp,nct_molec(1)-1,ijunk,ielstart(i),ielend(i),*13)
765 if (iatel_s.eq.0) iatel_s=1
766 !----------now nucleic acid
767 ! if (itype(nres_molec(2),2).eq.ntyp1_molec(2)) then
768 npept_nucl=nct_molec(2)-nnt_molec(2)
770 ! npept_nucl=nct_molec(2)-nnt_molec(2)
772 nele_int_tot_nucl=(npept_nucl-ispp)*(npept_nucl-ispp+1)/2
773 call int_bounds(nele_int_tot_nucl,my_ele_inds_nucl,my_ele_inde_nucl)
775 write (*,*) 'Processor',fg_rank,' CG group',kolor,&
776 ' absolute rank',MyRank,&
777 ' nele_int_tot',nele_int_tot,' my_ele_inds=',my_ele_inds,&
778 ' my_ele_inde',my_ele_inde
782 ind_eleint_old_nucl=0
783 ! if (itype(nres_molec(1),1).eq.ntyp1_molec(1)) then
784 ! nct_molec(1)=nres_molec(1)-1
786 ! nct_molec(1)=nres_molec(1)
788 ! print *,"nct",nct,nct_molec(1),itype(nres_molec(1),1),ntyp_molec(1)
789 do i=nnt_molec(2),nct_molec(2)-3
791 call int_partition(ind_eleint_nucl,my_ele_inds_nucl,my_ele_inde_nucl,i,&
792 iatel_s_nucl,iatel_e_nucl,i+ispp,nct_molec(2)-1,&
793 ijunk,ielstart_nucl(i),ielend_nucl(i),*113)
796 if (iatel_s_nucl.eq.0) iatel_s_nucl=1
798 nele_int_tot_vdw=(npept-2)*(npept-2+1)/2
799 ! write (iout,*) "nele_int_tot_vdw",nele_int_tot_vdw
800 call int_bounds(nele_int_tot_vdw,my_ele_inds_vdw,my_ele_inde_vdw)
801 ! write (iout,*) "my_ele_inds_vdw",my_ele_inds_vdw,
802 ! & " my_ele_inde_vdw",my_ele_inde_vdw
807 do i=nnt,nct_molec(1)-3
809 call int_partition(ind_eleint_vdw,my_ele_inds_vdw,&
811 iatel_s_vdw,iatel_e_vdw,i+2,nct_molec(1)-1,ijunk,ielstart_vdw(i),&
813 ! write (iout,*) i," ielstart_vdw",ielstart_vdw(i),
814 ! & " ielend_vdw",ielend_vdw(i)
816 if (iatel_s_vdw.eq.0) iatel_s_vdw=1
818 if (iatel_s.eq.0) iatel_s=1
819 if (iatel_s_vdw.eq.0) iatel_s_vdw=1
820 nele_int_tot_vdw_nucl=(npept_nucl-2)*(npept_nucl-2+1)/2
821 ! write (iout,*) "nele_int_tot_vdw",nele_int_tot_vdw
822 call int_bounds(nele_int_tot_vdw_nucl,my_ele_inds_vdw_nucl,&
823 my_ele_inde_vdw_nucl)
824 ! write (iout,*) "my_ele_inds_vdw",my_ele_inds_vdw,
825 ! & " my_ele_inde_vdw",my_ele_inde_vdw
826 ind_eleint_vdw_nucl=0
827 ind_eleint_vdw_old_nucl=0
830 do i=nnt_molec(2),nct_molec(2)-3
832 call int_partition(ind_eleint_vdw_nucl,my_ele_inds_vdw_nucl,&
833 my_ele_inde_vdw_nucl,i,&
834 iatel_s_vdw_nucl,iatel_e_vdw_nucl,i+2,nct_molec(2)-1,&
835 ijunk,ielstart_vdw_nucl(i),&
837 ! write (iout,*) i," ielstart_vdw",ielstart_vdw(i),
838 ! & " ielend_vdw",ielend_vdw(i)
840 if (iatel_s_vdw.eq.0) iatel_s_vdw_nucl=1
845 iatel_e=nct_molec(1)-5 ! ?? wham iatel_e=nct-3
847 ielstart(i)=i+4 ! ?? wham +2
848 ielend(i)=nct_molec(1)-1
851 iatel_e_vdw=nct_molec(1)-3
852 do i=iatel_s_vdw,iatel_e_vdw
854 ielend_vdw(i)=nct_molec(1)-1
858 write (*,'(a)') 'Processor',fg_rank,' CG group',kolor,&
859 ' absolute rank',MyRank
860 write (iout,*) 'Electrostatic interaction array:'
862 write (iout,'(i3,2(2x,2i3))') i,ielstart(i),ielend(i)
868 ! Partition the SC-p interaction array
870 nscp_int_tot=(npept-iscp+1)*(npept-iscp+1)
871 call int_bounds(nscp_int_tot,my_scp_inds,my_scp_inde)
872 if (lprint) write (iout,*) 'Processor',fg_rank,' CG group',kolor,&
873 ' absolute rank',myrank,&
874 ' nscp_int_tot',nscp_int_tot,' my_scp_inds=',my_scp_inds,&
875 ' my_scp_inde',my_scp_inde
880 do i=nnt,nct_molec(1)-1
881 if (i.lt.nnt+iscp) then
882 !d write (iout,*) 'i.le.nnt+iscp'
883 call int_partition(ind_scpint,my_scp_inds,my_scp_inde,i,&
884 iatscp_s,iatscp_e,i+iscp,nct_molec(1),nscp_gr(i),iscpstart(i,1),&
886 else if (i.gt.nct-iscp) then
887 !d write (iout,*) 'i.gt.nct-iscp'
888 call int_partition(ind_scpint,my_scp_inds,my_scp_inde,i,&
889 iatscp_s,iatscp_e,nnt,i-iscp,nscp_gr(i),iscpstart(i,1),&
892 call int_partition(ind_scpint,my_scp_inds,my_scp_inde,i,&
893 iatscp_s,iatscp_e,nnt,i-iscp,nscp_gr(i),iscpstart(i,1),&
896 call int_partition(ind_scpint,my_scp_inds,my_scp_inde,i,&
897 iatscp_s,iatscp_e,i+iscp,nct_molec(1),nscp_gr(i),iscpstart(i,ii),&
902 print *,"before inloop3",iatscp_s,iatscp_e,iscp_nucl
903 nscp_int_tot_nucl=(npept_nucl-iscp_nucl+1)*(npept_nucl-iscp_nucl+1)
904 call int_bounds(nscp_int_tot_nucl,my_scp_inds_nucl,my_scp_inde_nucl)
905 if (lprint) write (iout,*) 'Processor',fg_rank,' CG group',kolor,&
906 ' absolute rank',myrank,&
907 ' nscp_int_tot',nscp_int_tot_nucl,' my_scp_inds=',my_scp_inds_nucl,&
908 ' my_scp_inde',my_scp_inde_nucl
909 print *,"nscp_int_tot_nucl",nscp_int_tot_nucl,my_scp_inds_nucl,my_scp_inde_nucl
913 ind_scpint_old_nucl=0
914 do i=nnt_molec(2),nct_molec(2)-1
915 print *,"inloop3",i,nnt_molec(2)+iscp,nct_molec(2)-iscp
916 if (i.lt.nnt_molec(2)+iscp) then
917 !d write (iout,*) 'i.le.nnt+iscp'
918 call int_partition(ind_scpint_nucl,my_scp_inds_nucl,&
919 my_scp_inde_nucl,i,iatscp_s_nucl,iatscp_e_nucl,i+iscp,&
920 nct_molec(2),nscp_gr_nucl(i),iscpstart_nucl(i,1),&
921 iscpend_nucl(i,1),*114)
922 else if (i.gt.nct_molec(2)-iscp) then
923 !d write (iout,*) 'i.gt.nct-iscp'
924 call int_partition(ind_scpint_nucl,my_scp_inds_nucl,&
926 iatscp_s_nucl,iatscp_e_nucl,nnt_molec(2),i-iscp,nscp_gr_nucl(i),&
927 iscpstart_nucl(i,1),&
928 iscpend_nucl(i,1),*114)
930 call int_partition(ind_scpint_nucl,my_scp_inds_nucl,&
931 my_scp_inde_nucl,i,iatscp_s_nucl,iatscp_e_nucl,nnt_molec(2),&
932 i-iscp,nscp_gr_nucl(i),iscpstart_nucl(i,1),&
933 iscpend_nucl(i,1),*114)
935 call int_partition(ind_scpint_nucl,my_scp_inds_nucl,&
936 my_scp_inde_nucl,i,iatscp_s_nucl,iatscp_e_nucl,i+iscp,&
937 nct_molec(2),nscp_gr_nucl(i),iscpstart_nucl(i,ii),&
938 iscpend_nucl(i,ii),*114)
942 print *, "after inloop3",iatscp_s_nucl,iatscp_e_nucl
943 if (iatscp_s_nucl.eq.0) iatscp_s_nucl=1
946 iatscp_e=nct_molec(1)-1
947 do i=nnt,nct_molec(1)-1
948 if (i.lt.nnt+iscp) then
950 iscpstart(i,1)=i+iscp
951 iscpend(i,1)=nct_molec(1)
952 elseif (i.gt.nct-iscp) then
960 iscpstart(i,2)=i+iscp
961 iscpend(i,2)=nct_molec(1)
965 if (iatscp_s.eq.0) iatscp_s=1
967 write (iout,'(a)') 'SC-p interaction array:'
968 do i=iatscp_s,iatscp_e
969 write (iout,'(i3,2(2x,2i3))') &
970 i,(iscpstart(i,j),iscpend(i,j),j=1,nscp_gr(i))
973 ! Partition local interactions
975 call int_bounds(nres_molec(1)-2,loc_start,loc_end)
976 loc_start=loc_start+1
978 call int_bounds(nres_molec(2)-2,loc_start_nucl,loc_end_nucl)
979 loc_start_nucl=loc_start_nucl+1+nres_molec(1)
980 loc_end_nucl=loc_end_nucl+1+nres_molec(1)
981 call int_bounds(nres_molec(1)-2,ithet_start,ithet_end)
982 ithet_start=ithet_start+2
983 ithet_end=ithet_end+2
984 call int_bounds(nres_molec(2)-2,ithet_nucl_start,ithet_nucl_end)
985 ithet_nucl_start=ithet_nucl_start+2+nres_molec(1)
986 ithet_nucl_end=ithet_nucl_end+2+nres_molec(1)
987 call int_bounds(nct_molec(1)-nnt-2,iturn3_start,iturn3_end)
988 iturn3_start=iturn3_start+nnt
989 iphi_start=iturn3_start+2
990 iturn3_end=iturn3_end+nnt
991 iphi_end=iturn3_end+2
992 iturn3_start=iturn3_start-1
993 iturn3_end=iturn3_end-1
994 call int_bounds(nct_molec(2)-nnt_molec(2)-2,iphi_nucl_start,iphi_nucl_end)
995 iphi_nucl_start=iphi_nucl_start+nnt_molec(2)+2
996 iphi_nucl_end=iphi_nucl_end+nnt_molec(2)+2
997 print *,"KURDE",iphi_nucl_start,iphi_nucl_end
998 call int_bounds(nres_molec(1)-3,itau_start,itau_end)
999 itau_start=itau_start+3
1001 call int_bounds(nres_molec(1)-3,iphi1_start,iphi1_end)
1002 iphi1_start=iphi1_start+3
1003 iphi1_end=iphi1_end+3
1004 call int_bounds(nct_molec(1)-nnt-3,iturn4_start,iturn4_end)
1005 iturn4_start=iturn4_start+nnt
1006 iphid_start=iturn4_start+2
1007 iturn4_end=iturn4_end+nnt
1008 iphid_end=iturn4_end+2
1009 iturn4_start=iturn4_start-1
1010 iturn4_end=iturn4_end-1
1011 ! print *,"TUTUTU",nres_molec(1),nres
1012 call int_bounds(nres_molec(1)-2,ibond_start,ibond_end)
1013 ibond_start=ibond_start+1
1014 ibond_end=ibond_end+1
1015 ! print *,ibond_start,ibond_end
1016 call int_bounds(nct_molec(1)-nnt,ibondp_start,ibondp_end)
1017 ibondp_start=ibondp_start+nnt
1018 ibondp_end=ibondp_end+nnt
1019 call int_bounds(nres_molec(2)-2,ibond_nucl_start,ibond_nucl_end)
1020 ibond_nucl_start=ibond_nucl_start+nnt_molec(2)-1
1021 ibond_nucl_end=ibond_nucl_end+nnt_molec(2)-1
1022 print *,"NUCLibond",ibond_nucl_start,ibond_nucl_end
1023 print *, "before devision",nnt_molec(2),nct_molec(2)-nnt_molec(2)
1024 call int_bounds(nct_molec(2)-nnt_molec(2),ibondp_nucl_start,ibondp_nucl_end)
1025 ibondp_nucl_start=ibondp_nucl_start+nnt_molec(2)
1026 ibondp_nucl_end=ibondp_nucl_end+nnt_molec(2)
1027 print *,"NUCLibond2",ibondp_nucl_start,ibondp_nucl_end
1030 call int_bounds1(nres_molec(1)-1,ivec_start,ivec_end)
1031 ! print *,"Processor",myrank,fg_rank,fg_rank1,
1032 ! & " ivec_start",ivec_start," ivec_end",ivec_end
1033 iset_start=loc_start+2
1035 call int_bounds(nres_molec(1),ilip_start,ilip_end)
1036 ilip_start=ilip_start
1038 call int_bounds(nres_molec(1)-1,itube_start,itube_end)
1039 itube_start=itube_start
1041 if (ndih_constr.eq.0) then
1045 call int_bounds(ndih_constr,idihconstr_start,idihconstr_end)
1047 if (ntheta_constr.eq.0) then
1048 ithetaconstr_start=1
1052 (ntheta_constr,ithetaconstr_start,ithetaconstr_end)
1055 ! nsumgrad=(nres-nnt)*(nres-nnt+1)/2
1057 nsumgrad=(nres-nnt)*(nres-nnt+1)/2
1059 call int_bounds(nsumgrad,ngrad_start,ngrad_end)
1060 igrad_start=((2*nlen+1) &
1061 -sqrt(float((2*nlen-1)**2-8*(ngrad_start-1))))/2
1062 igrad_end=((2*nlen+1) &
1063 -sqrt(float((2*nlen-1)**2-8*(ngrad_end-1))))/2
1064 !el allocate(jgrad_start(igrad_start:igrad_end))
1065 !el allocate(jgrad_end(igrad_start:igrad_end)) !(maxres)
1066 jgrad_start(igrad_start)= &
1067 ngrad_start-(2*nlen-igrad_start)*(igrad_start-1)/2 &
1069 jgrad_end(igrad_start)=nres
1070 if (igrad_end.gt.igrad_start) jgrad_start(igrad_end)=igrad_end+1
1071 jgrad_end(igrad_end)=ngrad_end-(2*nlen-igrad_end)*(igrad_end-1)/2 &
1073 do i=igrad_start+1,igrad_end-1
1078 write (*,*) 'Processor:',fg_rank,' CG group',kolor,&
1079 ' absolute rank',myrank,&
1080 ' loc_start',loc_start,' loc_end',loc_end,&
1081 ' ithet_start',ithet_start,' ithet_end',ithet_end,&
1082 ' iphi_start',iphi_start,' iphi_end',iphi_end,&
1083 ' iphid_start',iphid_start,' iphid_end',iphid_end,&
1084 ' ibond_start',ibond_start,' ibond_end',ibond_end,&
1085 ' ibondp_start',ibondp_start,' ibondp_end',ibondp_end,&
1086 ' iturn3_start',iturn3_start,' iturn3_end',iturn3_end,&
1087 ' iturn4_start',iturn4_start,' iturn4_end',iturn4_end,&
1088 ' ivec_start',ivec_start,' ivec_end',ivec_end,&
1089 ' iset_start',iset_start,' iset_end',iset_end,&
1090 ' idihconstr_start',idihconstr_start,' idihconstr_end',&
1092 write (*,*) 'Processor:',fg_rank,myrank,' igrad_start',&
1093 igrad_start,' igrad_end',igrad_end,' ngrad_start',ngrad_start,&
1094 ' ngrad_end',ngrad_end
1095 ! do i=igrad_start,igrad_end
1096 ! write(*,*) 'Processor:',fg_rank,myrank,i,&
1097 ! jgrad_start(i),jgrad_end(i)
1100 if (nfgtasks.gt.1) then
1101 call MPI_Allgather(ivec_start,1,MPI_INTEGER,ivec_displ(0),1,&
1102 MPI_INTEGER,FG_COMM1,IERROR)
1103 iaux=ivec_end-ivec_start+1
1104 call MPI_Allgather(iaux,1,MPI_INTEGER,ivec_count(0),1,&
1105 MPI_INTEGER,FG_COMM1,IERROR)
1106 call MPI_Allgather(iset_start-2,1,MPI_INTEGER,iset_displ(0),1,&
1107 MPI_INTEGER,FG_COMM,IERROR)
1108 iaux=iset_end-iset_start+1
1109 call MPI_Allgather(iaux,1,MPI_INTEGER,iset_count(0),1,&
1110 MPI_INTEGER,FG_COMM,IERROR)
1111 call MPI_Allgather(ibond_start,1,MPI_INTEGER,ibond_displ(0),1,&
1112 MPI_INTEGER,FG_COMM,IERROR)
1113 iaux=ibond_end-ibond_start+1
1114 call MPI_Allgather(iaux,1,MPI_INTEGER,ibond_count(0),1,&
1115 MPI_INTEGER,FG_COMM,IERROR)
1116 call MPI_Allgather(ithet_start,1,MPI_INTEGER,ithet_displ(0),1,&
1117 MPI_INTEGER,FG_COMM,IERROR)
1118 iaux=ithet_end-ithet_start+1
1119 call MPI_Allgather(iaux,1,MPI_INTEGER,ithet_count(0),1,&
1120 MPI_INTEGER,FG_COMM,IERROR)
1121 call MPI_Allgather(iphi_start,1,MPI_INTEGER,iphi_displ(0),1,&
1122 MPI_INTEGER,FG_COMM,IERROR)
1123 iaux=iphi_end-iphi_start+1
1124 call MPI_Allgather(iaux,1,MPI_INTEGER,iphi_count(0),1,&
1125 MPI_INTEGER,FG_COMM,IERROR)
1126 call MPI_Allgather(iphi1_start,1,MPI_INTEGER,iphi1_displ(0),1,&
1127 MPI_INTEGER,FG_COMM,IERROR)
1128 iaux=iphi1_end-iphi1_start+1
1129 call MPI_Allgather(iaux,1,MPI_INTEGER,iphi1_count(0),1,&
1130 MPI_INTEGER,FG_COMM,IERROR)
1137 call MPI_Allgather(iturn3_start,1,MPI_INTEGER,&
1138 iturn3_start_all(0),1,MPI_INTEGER,FG_COMM,IERROR)
1139 call MPI_Allgather(iturn4_start,1,MPI_INTEGER,&
1140 iturn4_start_all(0),1,MPI_INTEGER,FG_COMM,IERROR)
1141 call MPI_Allgather(iturn3_end,1,MPI_INTEGER,&
1142 iturn3_end_all(0),1,MPI_INTEGER,FG_COMM,IERROR)
1143 call MPI_Allgather(iturn4_end,1,MPI_INTEGER,&
1144 iturn4_end_all(0),1,MPI_INTEGER,FG_COMM,IERROR)
1145 call MPI_Allgather(iatel_s,1,MPI_INTEGER,&
1146 iatel_s_all(0),1,MPI_INTEGER,FG_COMM,IERROR)
1147 call MPI_Allgather(iatel_e,1,MPI_INTEGER,&
1148 iatel_e_all(0),1,MPI_INTEGER,FG_COMM,IERROR)
1149 call MPI_Allgather(ielstart(1),nres,MPI_INTEGER,&
1150 ielstart_all(1,0),nres,MPI_INTEGER,FG_COMM,IERROR)
1151 call MPI_Allgather(ielend(1),nres,MPI_INTEGER,&
1152 ielend_all(1,0),nres,MPI_INTEGER,FG_COMM,IERROR)
1154 write (iout,*) "iatel_s_all",(iatel_s_all(i),i=0,nfgtasks)
1155 write (iout,*) "iatel_e_all",(iatel_e_all(i),i=0,nfgtasks)
1156 write (iout,*) "iturn3_start_all",&
1157 (iturn3_start_all(i),i=0,nfgtasks-1)
1158 write (iout,*) "iturn3_end_all",&
1159 (iturn3_end_all(i),i=0,nfgtasks-1)
1160 write (iout,*) "iturn4_start_all",&
1161 (iturn4_start_all(i),i=0,nfgtasks-1)
1162 write (iout,*) "iturn4_end_all",&
1163 (iturn4_end_all(i),i=0,nfgtasks-1)
1164 write (iout,*) "The ielstart_all array"
1166 write (iout,'(20i4)') i,(ielstart_all(i,j),j=0,nfgtasks-1)
1168 write (iout,*) "The ielend_all array"
1170 write (iout,'(20i4)') i,(ielend_all(i,j),j=0,nfgtasks-1)
1176 itask_cont_from(0)=fg_rank
1177 itask_cont_to(0)=fg_rank
1179 !el allocate(iturn3_sent(4,iturn3_start:iturn3_end))
1180 !el allocate(iturn4_sent(4,iturn4_start:iturn4_end)) !(4,maxres)
1181 do ii=iturn3_start,iturn3_end
1182 call add_int(ii,ii+2,iturn3_sent(1,ii),&
1183 ntask_cont_to,itask_cont_to,flag)
1185 do ii=iturn4_start,iturn4_end
1186 call add_int(ii,ii+3,iturn4_sent(1,ii),&
1187 ntask_cont_to,itask_cont_to,flag)
1189 do ii=iturn3_start,iturn3_end
1190 call add_int_from(ii,ii+2,ntask_cont_from,itask_cont_from)
1192 do ii=iturn4_start,iturn4_end
1193 call add_int_from(ii,ii+3,ntask_cont_from,itask_cont_from)
1196 write (iout,*) "After turn3 ntask_cont_from",ntask_cont_from,&
1197 " ntask_cont_to",ntask_cont_to
1198 write (iout,*) "itask_cont_from",&
1199 (itask_cont_from(i),i=1,ntask_cont_from)
1200 write (iout,*) "itask_cont_to",&
1201 (itask_cont_to(i),i=1,ntask_cont_to)
1204 ! write (iout,*) "Loop forward"
1206 do i=iatel_s,iatel_e
1207 ! write (iout,*) "from loop i=",i
1209 do j=ielstart(i),ielend(i)
1210 call add_int_from(i,j,ntask_cont_from,itask_cont_from)
1213 ! write (iout,*) "Loop backward iatel_e-1",iatel_e-1,
1214 ! & " iatel_e",iatel_e
1217 do i=iatel_s,iatel_e
1218 ! write (iout,*) "i",i," ielstart",ielstart(i),
1219 ! & " ielend",ielend(i)
1222 do j=ielstart(i),ielend(i)
1223 call add_int(i,j,iint_sent(1,j,nat_sent+1),ntask_cont_to,&
1228 iat_sent(nat_sent)=i
1232 write (iout,*)"After longrange ntask_cont_from",ntask_cont_from,&
1233 " ntask_cont_to",ntask_cont_to
1234 write (iout,*) "itask_cont_from",&
1235 (itask_cont_from(i),i=1,ntask_cont_from)
1236 write (iout,*) "itask_cont_to",&
1237 (itask_cont_to(i),i=1,ntask_cont_to)
1239 write (iout,*) "iint_sent"
1242 write (iout,'(20i4)') ii,(j,(iint_sent(k,j,i),k=1,4),&
1243 j=ielstart(ii),ielend(ii))
1245 write (iout,*) "iturn3_sent iturn3_start",iturn3_start,&
1246 " iturn3_end",iturn3_end
1247 write (iout,'(20i4)') (i,(iturn3_sent(j,i),j=1,4),&
1248 i=iturn3_start,iturn3_end)
1249 write (iout,*) "iturn4_sent iturn4_start",iturn4_start,&
1250 " iturn4_end",iturn4_end
1251 write (iout,'(20i4)') (i,(iturn4_sent(j,i),j=1,4),&
1252 i=iturn4_start,iturn4_end)
1255 call MPI_Gather(ntask_cont_from,1,MPI_INTEGER,&
1256 ntask_cont_from_all,1,MPI_INTEGER,king,FG_COMM,IERR)
1257 ! write (iout,*) "Gather ntask_cont_from ended"
1259 call MPI_Gather(itask_cont_from(0),nfgtasks,MPI_INTEGER,&
1260 itask_cont_from_all(0,0),nfgtasks,MPI_INTEGER,king,&
1262 ! write (iout,*) "Gather itask_cont_from ended"
1264 call MPI_Gather(ntask_cont_to,1,MPI_INTEGER,ntask_cont_to_all,&
1265 1,MPI_INTEGER,king,FG_COMM,IERR)
1266 ! write (iout,*) "Gather ntask_cont_to ended"
1268 call MPI_Gather(itask_cont_to,nfgtasks,MPI_INTEGER,&
1269 itask_cont_to_all,nfgtasks,MPI_INTEGER,king,FG_COMM,IERR)
1270 ! write (iout,*) "Gather itask_cont_to ended"
1272 if (fg_rank.eq.king) then
1273 write (iout,*)"Contact receive task map (proc, #tasks, tasks)"
1275 write (iout,'(20i4)') i,ntask_cont_from_all(i),&
1276 (itask_cont_from_all(j,i),j=1,ntask_cont_from_all(i))
1280 write (iout,*) "Contact send task map (proc, #tasks, tasks)"
1282 write (iout,'(20i4)') i,ntask_cont_to_all(i),&
1283 (itask_cont_to_all(j,i),j=1,ntask_cont_to_all(i))
1287 ! Check if every send will have a matching receive
1291 ncheck_to=ncheck_to+ntask_cont_to_all(i)
1292 ncheck_from=ncheck_from+ntask_cont_from_all(i)
1294 write (iout,*) "Control sums",ncheck_from,ncheck_to
1295 if (ncheck_from.ne.ncheck_to) then
1296 write (iout,*) "Error: #receive differs from #send."
1297 write (iout,*) "Terminating program...!"
1303 do j=1,ntask_cont_to_all(i)
1304 ii=itask_cont_to_all(j,i)
1305 do k=1,ntask_cont_from_all(ii)
1306 if (itask_cont_from_all(k,ii).eq.i) then
1307 if(lprint)write(iout,*)"Matching send/receive",i,ii
1311 if (k.eq.ntask_cont_from_all(ii)+1) then
1313 write (iout,*) "Error: send by",j," to",ii,&
1314 " would have no matching receive"
1320 write (iout,*) "Unmatched sends; terminating program"
1324 call MPI_Bcast(flag,1,MPI_LOGICAL,king,FG_COMM,IERROR)
1325 ! write (iout,*) "flag broadcast ended flag=",flag
1328 call MPI_Finalize(IERROR)
1329 stop "Error in INIT_INT_TABLE: unmatched send/receive."
1331 call MPI_Comm_group(FG_COMM,fg_group,IERR)
1332 ! write (iout,*) "MPI_Comm_group ended"
1334 call MPI_Group_incl(fg_group,ntask_cont_from+1,&
1335 itask_cont_from(0),CONT_FROM_GROUP,IERR)
1336 call MPI_Group_incl(fg_group,ntask_cont_to+1,itask_cont_to(0),&
1340 iaux=4*(ielend(ii)-ielstart(ii)+1)
1341 call MPI_Group_translate_ranks(fg_group,iaux,&
1342 iint_sent(1,ielstart(ii),i),CONT_TO_GROUP,&
1343 iint_sent_local(1,ielstart(ii),i),IERR )
1344 ! write (iout,*) "Ranks translated i=",i
1347 iaux=4*(iturn3_end-iturn3_start+1)
1348 call MPI_Group_translate_ranks(fg_group,iaux,&
1349 iturn3_sent(1,iturn3_start),CONT_TO_GROUP,&
1350 iturn3_sent_local(1,iturn3_start),IERR)
1351 iaux=4*(iturn4_end-iturn4_start+1)
1352 call MPI_Group_translate_ranks(fg_group,iaux,&
1353 iturn4_sent(1,iturn4_start),CONT_TO_GROUP,&
1354 iturn4_sent_local(1,iturn4_start),IERR)
1356 write (iout,*) "iint_sent_local"
1359 write (iout,'(20i4)') ii,(j,(iint_sent_local(k,j,i),k=1,4),&
1360 j=ielstart(ii),ielend(ii))
1363 write (iout,*) "iturn3_sent_local iturn3_start",iturn3_start,&
1364 " iturn3_end",iturn3_end
1365 write (iout,'(20i4)') (i,(iturn3_sent_local(j,i),j=1,4),&
1366 i=iturn3_start,iturn3_end)
1367 write (iout,*) "iturn4_sent_local iturn4_start",iturn4_start,&
1368 " iturn4_end",iturn4_end
1369 write (iout,'(20i4)') (i,(iturn4_sent_local(j,i),j=1,4),&
1370 i=iturn4_start,iturn4_end)
1373 call MPI_Group_free(fg_group,ierr)
1374 call MPI_Group_free(cont_from_group,ierr)
1375 call MPI_Group_free(cont_to_group,ierr)
1376 call MPI_Type_contiguous(3,MPI_DOUBLE_PRECISION,MPI_UYZ,IERROR)
1377 call MPI_Type_commit(MPI_UYZ,IERROR)
1378 call MPI_Type_contiguous(18,MPI_DOUBLE_PRECISION,MPI_UYZGRAD,&
1380 call MPI_Type_commit(MPI_UYZGRAD,IERROR)
1381 call MPI_Type_contiguous(2,MPI_DOUBLE_PRECISION,MPI_MU,IERROR)
1382 call MPI_Type_commit(MPI_MU,IERROR)
1383 call MPI_Type_contiguous(4,MPI_DOUBLE_PRECISION,MPI_MAT1,IERROR)
1384 call MPI_Type_commit(MPI_MAT1,IERROR)
1385 call MPI_Type_contiguous(8,MPI_DOUBLE_PRECISION,MPI_MAT2,IERROR)
1386 call MPI_Type_commit(MPI_MAT2,IERROR)
1387 call MPI_Type_contiguous(6,MPI_DOUBLE_PRECISION,MPI_THET,IERROR)
1388 call MPI_Type_commit(MPI_THET,IERROR)
1389 call MPI_Type_contiguous(9,MPI_DOUBLE_PRECISION,MPI_GAM,IERROR)
1390 call MPI_Type_commit(MPI_GAM,IERROR)
1392 !el allocate(lentyp(0:nfgtasks-1))
1394 ! 9/22/08 Derived types to send matrices which appear in correlation terms
1396 if (ivec_count(i).eq.ivec_count(0)) then
1402 do ind_typ=lentyp(0),lentyp(nfgtasks-1)
1403 if (ind_typ.eq.0) then
1404 ichunk=ivec_count(0)
1406 ichunk=ivec_count(1)
1413 ! displs(i)=displs(i-1)+blocklengths(i-1)*maxres
1416 ! blocklengths(i)=blocklengths(i)*ichunk
1418 ! write (iout,*) "blocklengths and displs"
1420 ! write (iout,*) i,blocklengths(i),displs(i)
1423 ! call MPI_Type_indexed(4,blocklengths(1),displs(1),
1424 ! & MPI_DOUBLE_PRECISION,MPI_ROTAT1(ind_typ),IERROR)
1425 ! call MPI_Type_commit(MPI_ROTAT1(ind_typ),IERROR)
1426 ! write (iout,*) "MPI_ROTAT1",MPI_ROTAT1
1432 ! displs(i)=displs(i-1)+blocklengths(i-1)*maxres
1435 ! blocklengths(i)=blocklengths(i)*ichunk
1437 ! write (iout,*) "blocklengths and displs"
1439 ! write (iout,*) i,blocklengths(i),displs(i)
1442 ! call MPI_Type_indexed(4,blocklengths(1),displs(1),
1443 ! & MPI_DOUBLE_PRECISION,MPI_ROTAT2(ind_typ),IERROR)
1444 ! call MPI_Type_commit(MPI_ROTAT2(ind_typ),IERROR)
1445 ! write (iout,*) "MPI_ROTAT2",MPI_ROTAT2
1451 displs(i)=displs(i-1)+blocklengths(i-1)*nres !maxres
1454 blocklengths(i)=blocklengths(i)*ichunk
1456 call MPI_Type_indexed(8,blocklengths,displs,&
1457 MPI_DOUBLE_PRECISION,MPI_PRECOMP11(ind_typ),IERROR)
1458 call MPI_Type_commit(MPI_PRECOMP11(ind_typ),IERROR)
1464 displs(i)=displs(i-1)+blocklengths(i-1)*nres !maxres
1467 blocklengths(i)=blocklengths(i)*ichunk
1469 call MPI_Type_indexed(8,blocklengths,displs,&
1470 MPI_DOUBLE_PRECISION,MPI_PRECOMP12(ind_typ),IERROR)
1471 call MPI_Type_commit(MPI_PRECOMP12(ind_typ),IERROR)
1477 displs(i)=displs(i-1)+blocklengths(i-1)*nres !maxres
1480 blocklengths(i)=blocklengths(i)*ichunk
1482 call MPI_Type_indexed(6,blocklengths,displs,&
1483 MPI_DOUBLE_PRECISION,MPI_PRECOMP22(ind_typ),IERROR)
1484 call MPI_Type_commit(MPI_PRECOMP22(ind_typ),IERROR)
1490 displs(i)=displs(i-1)+blocklengths(i-1)*nres !maxres
1493 blocklengths(i)=blocklengths(i)*ichunk
1495 call MPI_Type_indexed(2,blocklengths,displs,&
1496 MPI_DOUBLE_PRECISION,MPI_PRECOMP23(ind_typ),IERROR)
1497 call MPI_Type_commit(MPI_PRECOMP23(ind_typ),IERROR)
1503 displs(i)=displs(i-1)+blocklengths(i-1)*nres !maxres
1506 blocklengths(i)=blocklengths(i)*ichunk
1508 call MPI_Type_indexed(4,blocklengths,displs,&
1509 MPI_DOUBLE_PRECISION,MPI_ROTAT_OLD(ind_typ),IERROR)
1510 call MPI_Type_commit(MPI_ROTAT_OLD(ind_typ),IERROR)
1514 iint_start=ivec_start+1
1517 iint_count(i)=ivec_count(i)
1518 iint_displ(i)=ivec_displ(i)
1519 ivec_displ(i)=ivec_displ(i)-1
1520 iset_displ(i)=iset_displ(i)-1
1521 ithet_displ(i)=ithet_displ(i)-1
1522 iphi_displ(i)=iphi_displ(i)-1
1523 iphi1_displ(i)=iphi1_displ(i)-1
1524 ibond_displ(i)=ibond_displ(i)-1
1526 if (nfgtasks.gt.1 .and. fg_rank.eq.king &
1527 .and. (me.eq.0 .or. .not. out1file)) then
1528 write (iout,*) "IVEC_DISPL, IVEC_COUNT, ISET_START, ISET_COUNT"
1530 write (iout,*) i,ivec_displ(i),ivec_count(i),iset_displ(i),&
1533 write (iout,*) "iphi_start",iphi_start," iphi_end",iphi_end,&
1534 " iphi1_start",iphi1_start," iphi1_end",iphi1_end
1535 write (iout,*)"IPHI_COUNT, IPHI_DISPL, IPHI1_COUNT, IPHI1_DISPL"
1537 write (iout,*) i,iphi_count(i),iphi_displ(i),iphi1_count(i),&
1540 write(iout,'(i10,a,i10,a,i10,a/a,i3,a)') n_sc_int_tot,' SC-SC ',&
1541 nele_int_tot,' electrostatic and ',nscp_int_tot,&
1542 ' SC-p interactions','were distributed among',nfgtasks,&
1543 ' fine-grain processors.'
1547 loc_end=nres_molec(1)-1
1549 ithet_end=nres_molec(1)
1550 ithet_nucl_start=3+nres_molec(1)
1551 ithet_nucl_end=nres_molec(1)+nres_molec(2)
1553 iturn3_end=nct_molec(1)-3
1555 iturn4_end=nct_molec(1)-4
1557 iphi_end=nct_molec(1)
1559 iphi1_end=nres_molec(1)
1560 iphi_nucl_start=4+nres_molec(1)
1561 iphi_nucl_end=nres_molec(1)+nres_molec(2)
1563 idihconstr_end=ndih_constr
1564 ithetaconstr_start=1
1565 ithetaconstr_end=ntheta_constr
1566 iphid_start=iphi_start
1567 iphid_end=iphi_end-1
1569 itau_end=nres_molec(1)
1571 ibond_end=nres_molec(1)-1
1572 ibond_nucl_start=2+nres_molec(1)
1573 ibond_nucl_end=nres_molec(2)-1
1575 ibondp_end=nct_molec(1)-1
1576 ibondp_nucl_start=nnt_molec(2)
1577 ibondp_nucl_end=nct_molec(2)
1579 ivec_end=nres_molec(1)-1
1581 iset_end=nres_molec(1)+1
1583 iint_end=nres_molec(1)-1
1585 ilip_end=nres_molec(1)
1587 itube_end=nres_molec(1)
1589 !el common /przechowalnia/
1590 ! deallocate(iturn3_start_all)
1591 ! deallocate(iturn3_end_all)
1592 ! deallocate(iturn4_start_all)
1593 ! deallocate(iturn4_end_all)
1594 ! deallocate(iatel_s_all)
1595 ! deallocate(iatel_e_all)
1596 ! deallocate(ielstart_all)
1597 ! deallocate(ielend_all)
1599 ! deallocate(ntask_cont_from_all)
1600 ! deallocate(ntask_cont_to_all)
1601 ! deallocate(itask_cont_from_all)
1602 ! deallocate(itask_cont_to_all)
1605 end subroutine init_int_table
1607 !-----------------------------------------------------------------------------
1608 subroutine add_int(ii,jj,itask,ntask_cont_to,itask_cont_to,flag)
1611 ! include "DIMENSIONS"
1612 ! include "COMMON.INTERACT"
1613 ! include "COMMON.SETUP"
1614 ! include "COMMON.IOUNITS"
1615 integer :: ii,jj,ntask_cont_to
1616 integer,dimension(4) :: itask
1617 integer :: itask_cont_to(0:nfgtasks-1) !(0:max_fg_procs-1)
1619 !el integer,dimension(0:nfgtasks) :: iturn3_start_all,iturn3_end_all,iturn4_start_all,&
1620 !el iturn4_end_all,iatel_s_all,iatel_e_all !(0:max_fg_procs)
1621 !el integer,dimension(nres,0:nfgtasks-1) :: ielstart_all,ielend_all !(maxres,0:max_fg_procs-1)
1622 !el common /przechowalnia/ iturn3_start_all,iturn3_end_all,iturn4_start_all,&
1623 !el iturn4_end_all,iatel_s_all,iatel_e_all,ielstart_all,ielend_all
1624 integer :: iproc,isent,k,l
1625 ! Determines whether to send interaction ii,jj to other processors; a given
1626 ! interaction can be sent to at most 2 processors.
1627 ! Sets flag=.true. if interaction ii,jj needs to be sent to at least
1628 ! one processor, otherwise flag is unchanged from the input value.
1634 ! write (iout,*) "ii",ii," jj",jj
1635 ! Loop over processors to check if anybody could need interaction ii,jj
1636 do iproc=0,fg_rank-1
1637 ! Check if the interaction matches any turn3 at iproc
1638 do k=iturn3_start_all(iproc),iturn3_end_all(iproc)
1640 if (k.eq.ii-1 .and. l.eq.jj-1 .or. k.eq.ii-1 .and. l.eq.jj+1 &
1641 .or. k.eq.ii+1 .and. l.eq.jj+1 .or. k.eq.ii+1 .and. l.eq.jj-1) &
1643 ! write (iout,*) "turn3 to iproc",iproc," ij",ii,jj,"kl",k,l
1646 if (iproc.ne.itask(1).and.iproc.ne.itask(2) &
1647 .and.iproc.ne.itask(3).and.iproc.ne.itask(4)) then
1650 call add_task(iproc,ntask_cont_to,itask_cont_to)
1654 ! Check if the interaction matches any turn4 at iproc
1655 do k=iturn4_start_all(iproc),iturn4_end_all(iproc)
1657 if (k.eq.ii-1 .and. l.eq.jj-1 .or. k.eq.ii-1 .and. l.eq.jj+1 &
1658 .or. k.eq.ii+1 .and. l.eq.jj+1 .or. k.eq.ii+1 .and. l.eq.jj-1) &
1660 ! write (iout,*) "turn3 to iproc",iproc," ij",ii,jj," kl",k,l
1663 if (iproc.ne.itask(1).and.iproc.ne.itask(2) &
1664 .and.iproc.ne.itask(3).and.iproc.ne.itask(4)) then
1667 call add_task(iproc,ntask_cont_to,itask_cont_to)
1671 if (iatel_s_all(iproc).gt.0 .and. iatel_e_all(iproc).gt.0 .and. &
1672 iatel_s_all(iproc).le.ii-1 .and. iatel_e_all(iproc).ge.ii-1)then
1673 if (ielstart_all(ii-1,iproc).le.jj-1.and. &
1674 ielend_all(ii-1,iproc).ge.jj-1) then
1676 if (iproc.ne.itask(1).and.iproc.ne.itask(2) &
1677 .and.iproc.ne.itask(3).and.iproc.ne.itask(4)) then
1680 call add_task(iproc,ntask_cont_to,itask_cont_to)
1683 if (ielstart_all(ii-1,iproc).le.jj+1.and. &
1684 ielend_all(ii-1,iproc).ge.jj+1) then
1686 if (iproc.ne.itask(1).and.iproc.ne.itask(2) &
1687 .and.iproc.ne.itask(3).and.iproc.ne.itask(4)) then
1690 call add_task(iproc,ntask_cont_to,itask_cont_to)
1696 end subroutine add_int
1697 !-----------------------------------------------------------------------------
1698 subroutine add_int_from(ii,jj,ntask_cont_from,itask_cont_from)
1702 ! include "DIMENSIONS"
1703 ! include "COMMON.INTERACT"
1704 ! include "COMMON.SETUP"
1705 ! include "COMMON.IOUNITS"
1706 integer :: ii,jj,itask(2),ntask_cont_from,&
1707 itask_cont_from(0:nfgtasks-1) !(0:max_fg_procs)
1709 !el integer,dimension(0:nfgtasks) :: iturn3_start_all,iturn3_end_all,&
1710 !el iturn4_start_all,iturn4_end_all,iatel_s_all,iatel_e_all !(0:max_fg_procs)
1711 !el integer,dimension(nres,0:nfgtasks-1) :: ielstart_all,ielend_all !(maxres,0:max_fg_procs-1)
1712 !el common /przechowalnia/ iturn3_start_all,iturn3_end_all,iturn4_start_all,&
1713 !el iturn4_end_all,iatel_s_all,iatel_e_all,ielstart_all,ielend_all
1714 integer :: iproc,k,l
1715 do iproc=fg_rank+1,nfgtasks-1
1716 do k=iturn3_start_all(iproc),iturn3_end_all(iproc)
1718 if (k.eq.ii+1 .and. l.eq.jj+1 .or. k.eq.ii+1.and.l.eq.jj-1 &
1719 .or. k.eq.ii-1 .and. l.eq.jj-1 .or. k.eq.ii-1 .and. l.eq.jj+1) &
1721 ! write (iout,*)"turn3 from iproc",iproc," ij",ii,jj," kl",k,l
1722 call add_task(iproc,ntask_cont_from,itask_cont_from)
1725 do k=iturn4_start_all(iproc),iturn4_end_all(iproc)
1727 if (k.eq.ii+1 .and. l.eq.jj+1 .or. k.eq.ii+1.and.l.eq.jj-1 &
1728 .or. k.eq.ii-1 .and. l.eq.jj-1 .or. k.eq.ii-1 .and. l.eq.jj+1) &
1730 ! write (iout,*)"turn4 from iproc",iproc," ij",ii,jj," kl",k,l
1731 call add_task(iproc,ntask_cont_from,itask_cont_from)
1734 if (iatel_s_all(iproc).gt.0 .and. iatel_e_all(iproc).gt.0) then
1735 if (ii+1.ge.iatel_s_all(iproc).and.ii+1.le.iatel_e_all(iproc)) &
1737 if (jj+1.ge.ielstart_all(ii+1,iproc).and. &
1738 jj+1.le.ielend_all(ii+1,iproc)) then
1739 call add_task(iproc,ntask_cont_from,itask_cont_from)
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)
1746 if (ii-1.ge.iatel_s_all(iproc).and.ii-1.le.iatel_e_all(iproc)) &
1748 if (jj-1.ge.ielstart_all(ii-1,iproc).and. &
1749 jj-1.le.ielend_all(ii-1,iproc)) then
1750 call add_task(iproc,ntask_cont_from,itask_cont_from)
1752 if (jj+1.ge.ielstart_all(ii-1,iproc).and. &
1753 jj+1.le.ielend_all(ii-1,iproc)) then
1754 call add_task(iproc,ntask_cont_from,itask_cont_from)
1760 end subroutine add_int_from
1761 !-----------------------------------------------------------------------------
1762 subroutine add_task(iproc,ntask_cont,itask_cont)
1766 ! include "DIMENSIONS"
1767 integer :: iproc,ntask_cont,itask_cont(0:nfgtasks-1) !(0:max_fg_procs-1)
1770 if (itask_cont(ii).eq.iproc) return
1772 ntask_cont=ntask_cont+1
1773 itask_cont(ntask_cont)=iproc
1775 end subroutine add_task
1777 !-----------------------------------------------------------------------------
1778 #if defined MPI || defined WHAM_RUN
1779 subroutine int_partition(int_index,lower_index,upper_index,atom,&
1780 at_start,at_end,first_atom,last_atom,int_gr,jat_start,jat_end,*)
1782 ! implicit real*8 (a-h,o-z)
1783 ! include 'DIMENSIONS'
1784 ! include 'COMMON.IOUNITS'
1785 integer :: int_index,lower_index,upper_index,atom,at_start,at_end,&
1786 first_atom,last_atom,int_gr,jat_start,jat_end,int_index_old
1789 if (lprn) write (iout,*) 'int_index=',int_index
1790 int_index_old=int_index
1791 int_index=int_index+last_atom-first_atom+1
1793 write (iout,*) 'int_index=',int_index,&
1794 ' int_index_old',int_index_old,&
1795 ' lower_index=',lower_index,&
1796 ' upper_index=',upper_index,&
1797 ' atom=',atom,' first_atom=',first_atom,&
1798 ' last_atom=',last_atom
1799 if (int_index.ge.lower_index) then
1801 if (at_start.eq.0) then
1803 jat_start=first_atom-1+lower_index-int_index_old
1805 jat_start=first_atom
1807 if (lprn) write (iout,*) 'jat_start',jat_start
1808 if (int_index.ge.upper_index) then
1810 jat_end=first_atom-1+upper_index-int_index_old
1815 if (lprn) write (iout,*) 'jat_end',jat_end
1818 end subroutine int_partition
1820 !-----------------------------------------------------------------------------
1822 subroutine hpb_partition
1824 ! implicit real*8 (a-h,o-z)
1825 ! include 'DIMENSIONS'
1829 ! include 'COMMON.SBRIDGE'
1830 ! include 'COMMON.IOUNITS'
1831 ! include 'COMMON.SETUP'
1833 call int_bounds(nhpb,link_start,link_end)
1834 write (iout,*) 'Processor',fg_rank,' CG group',kolor,&
1835 ' absolute rank',MyRank,&
1836 ' nhpb',nhpb,' link_start=',link_start,&
1837 ' link_end',link_end
1843 end subroutine hpb_partition
1845 !-----------------------------------------------------------------------------
1846 ! misc.f in module io_base
1847 !-----------------------------------------------------------------------------
1848 !-----------------------------------------------------------------------------
1850 !-----------------------------------------------------------------------------
1851 subroutine getenv_loc(var, val)
1853 character(*) :: var, val
1856 character(len=2000) :: line
1859 open (196,file='env',status='old',readonly,shared)
1861 ! write(*,*)'looking for ',var
1862 10 read(196,*,err=11,end=11)line
1863 iread=index(line,var)
1864 ! write(*,*)iread,' ',var,' ',line
1865 if (iread.eq.0) go to 10
1866 ! write(*,*)'---> ',line
1872 iread=iread+ilen(var)+1
1873 read (line(iread:),*,err=12,end=12) val
1874 ! write(*,*)'OK: ',var,' = ',val
1880 #elif (defined CRAY)
1881 integer :: lennam,lenval,ierror
1883 ! getenv using a POSIX call, useful on the T3D
1884 ! Sept 1996, comment out error check on advice of H. Pritchard
1887 if(lennam.le.0) stop '--error calling getenv--'
1888 call pxfgetenv(var,lennam,val,lenval,ierror)
1889 !-HP- if(ierror.ne.0) stop '--error returned by pxfgetenv--'
1891 call getenv(var,val)
1895 end subroutine getenv_loc
1896 !-----------------------------------------------------------------------------
1898 !-----------------------------------------------------------------------------
1899 subroutine setup_var
1902 ! implicit real*8 (a-h,o-z)
1903 ! include 'DIMENSIONS'
1904 ! include 'COMMON.IOUNITS'
1905 ! include 'COMMON.GEO'
1906 ! include 'COMMON.VAR'
1907 ! include 'COMMON.INTERACT'
1908 ! include 'COMMON.LOCAL'
1909 ! include 'COMMON.NAMES'
1910 ! include 'COMMON.CHAIN'
1911 ! include 'COMMON.FFIELD'
1912 ! include 'COMMON.SBRIDGE'
1913 ! include 'COMMON.HEADER'
1914 ! include 'COMMON.CONTROL'
1915 ! include 'COMMON.DBASE'
1916 ! include 'COMMON.THREAD'
1917 ! include 'COMMON.TIME1'
1918 ! Set up variable list.
1926 if (itype(i,1).ne.10) then
1928 if (itype(i,1).ne.10 .and. itype(i,mnum).ne.ntyp1_molec(mnum) .and. mnum.ne.5) then
1931 ialph(i,1)=nvar+nside
1935 if (indphi.gt.0) then
1937 else if (indback.gt.0) then
1942 !d write (iout,'(3i4)') (i,ialph(i,1),ialph(i,2),i=2,nres-1)
1944 end subroutine setup_var
1945 !-----------------------------------------------------------------------------
1947 !-----------------------------------------------------------------------------
1948 integer function rescode(iseq,nam,itype,molecule)
1950 use io_base, only: ucase
1951 ! implicit real*8 (a-h,o-z)
1952 ! include 'DIMENSIONS'
1953 ! include 'COMMON.NAMES'
1954 ! include 'COMMON.IOUNITS'
1955 character(len=3) :: nam !,ucase
1956 integer :: iseq,itype,i
1958 print *,molecule,nam
1959 if (molecule.eq.1) then
1960 if (itype.eq.0) then
1962 do i=-ntyp1_molec(molecule),ntyp1_molec(molecule)
1963 if (ucase(nam).eq.restyp(i,molecule)) then
1971 do i=-ntyp1_molec(molecule),ntyp1_molec(molecule)
1972 if (nam(1:1).eq.onelet(i)) then
1979 else if (molecule.eq.2) then
1980 do i=1,ntyp1_molec(molecule)
1981 print *,nam(1:1),restyp(i,molecule)(1:1)
1982 if (nam(2:2).eq.restyp(i,molecule)(1:1)) then
1987 else if (molecule.eq.3) then
1988 write(iout,*) "SUGAR not yet implemented"
1990 else if (molecule.eq.4) then
1991 write(iout,*) "Explicit LIPID not yet implemented"
1993 else if (molecule.eq.5) then
1994 do i=1,ntyp1_molec(molecule)
1995 print *,i,restyp(i,molecule)(1:2)
1996 if (ucase(nam(1:2)).eq.restyp(i,molecule)(1:2)) then
2002 write(iout,*) "molecule not defined"
2004 write (iout,10) iseq,nam
2006 10 format ('**** Error - residue',i4,' has an unresolved name ',a3)
2007 end function rescode
2008 integer function sugarcode(sugar,ires)
2011 if (sugar.eq.'D') then
2013 else if (sugar.eq.' ') then
2016 write (iout,*) 'UNKNOWN sugar type for residue',ires,' ',sugar
2020 end function sugarcode
2022 !-----------------------------------------------------------------------------
2024 !-----------------------------------------------------------------------------
2025 ! $Date: 1994/10/05 16:41:52 $
2028 subroutine set_timers
2031 !el real(kind=8) :: tcpu
2032 ! include 'COMMON.TIME1'
2037 ! Diminish the assigned time limit a little so that there is some time to
2039 ! timlim=batime-150.0
2040 ! Calculate the initial time, if it is not zero (e.g. for the SUN).
2042 #if .not. defined(WHAM_RUN) && .not. defined(CLUSTER)
2044 walltime=MPI_WTIME()
2046 time_allreduce=0.0d0
2051 time_scatter_fmat=0.0d0
2052 time_scatter_ginv=0.0d0
2053 time_scatter_fmatmult=0.0d0
2054 time_scatter_ginvmult=0.0d0
2055 time_barrier_e=0.0d0
2056 time_barrier_g=0.0d0
2059 time_lagrangian=0.0d0
2060 time_sumgradient=0.0d0
2061 time_intcartderiv=0.0d0
2062 time_inttocart=0.0d0
2064 time_fricmatmult=0.0d0
2074 time_fricmatmult=0.0d0
2078 !d print *,' in SET_TIMERS stime=',stime
2080 end subroutine set_timers
2081 !-----------------------------------------------------------------------------
2083 logical function stopx(nf)
2084 ! This function returns .true. if one of the following reasons to exit SUMSL
2085 ! occurs. The "reason" code is stored in WHATSUP passed thru a COMMON block:
2087 !... WHATSUP = 0 - go on, no reason to stop. Stopx will return .false.
2088 !... 1 - Time up in current node;
2089 !... 2 - STOP signal was received from another node because the
2090 !... node's task was accomplished (parallel only);
2091 !... -1 - STOP signal was received from another node because of error;
2092 !... -2 - STOP signal was received from another node, because
2093 !... the node's time was up.
2094 ! implicit real*8 (a-h,o-z)
2095 ! include 'DIMENSIONS'
2097 !el use control_data, only:WhatsUp
2100 !el use MPI_data !include 'COMMON.INFO'
2104 !el logical :: ovrtim
2106 ! include 'COMMON.IOUNITS'
2107 ! include 'COMMON.TIME1'
2110 !d print *,'Processor',MyID,' NF=',nf
2111 !d write (iout,*) "stopx: ",nf
2115 ! Finish if time is up.
2119 else if (mod(nf,100).eq.0) then
2120 ! Other processors might have finished. Check this every 100th function
2122 ! Master checks if any other processor has sent accepted conformation(s) to it.
2123 if (MyID.ne.MasterID) call receive_mcm_info
2124 if (MyID.eq.MasterID) call receive_conf
2125 !d print *,'Processor ',MyID,' is checking STOP: nf=',nf
2126 call recv_stop_sig(Kwita)
2127 if (Kwita.eq.-1) then
2128 write (iout,'(a,i4,a,i5)') 'Processor',&
2129 MyID,' has received STOP signal in STOPX; NF=',nf
2130 write (*,'(a,i4,a,i5)') 'Processor',&
2131 MyID,' has received STOP signal in STOPX; NF=',nf
2134 elseif (Kwita.eq.-2) then
2136 'Processor',MyID,' received TIMEUP-STOP signal in SUMSL.'
2138 'Processor',MyID,' received TIMEUP-STOP signal in SUMSL.'
2141 else if (Kwita.eq.-3) then
2143 'Processor',MyID,' received ERROR-STOP signal in SUMSL.'
2145 'Processor',MyID,' received ERROR-STOP signal in SUMSL.'
2159 !d write (iout,*) "stopx set at .false."
2163 ! Check for FOUND_NAN flag
2165 write(iout,*)" *** stopx : Found a NaN"
2171 ! Finish if time is up.
2174 else if (cutoffviol) then
2183 !-----------------------------------------------------------------------------
2185 logical function stopx(nf)
2187 ! ..................................................................
2190 ! THIS FUNCTION MAY SERVE AS THE STOPX (ASYNCHRONOUS INTERRUPTION)
2191 ! FUNCTION FOR THE NL2SOL (NONLINEAR LEAST-SQUARES) PACKAGE AT
2192 ! THOSE INSTALLATIONS WHICH DO NOT WISH TO IMPLEMENT A
2195 ! *****ALGORITHM NOTES...
2196 ! AT INSTALLATIONS WHERE THE NL2SOL SYSTEM IS USED
2197 ! INTERACTIVELY, THIS DUMMY STOPX SHOULD BE REPLACED BY A
2198 ! FUNCTION THAT RETURNS .TRUE. IF AND ONLY IF THE INTERRUPT
2199 ! (BREAK) KEY HAS BEEN PRESSED SINCE THE LAST CALL ON STOPX.
2201 ! $$$ MODIFIED FOR USE AS THE TIMER ROUTINE.
2202 ! $$$ WHEN THE TIME LIMIT HAS BEEN
2203 ! $$$ REACHED STOPX IS SET TO .TRUE AND INITIATES (IN ITSUM)
2204 ! $$$ AND ORDERLY EXIT OUT OF SUMSL. IF ARRAYS IV AND V ARE
2205 ! $$$ SAVED, THE SUMSL ROUTINES CAN BE RESTARTED AT THE SAME
2206 ! $$$ POINT AT WHICH THEY WERE INTERRUPTED.
2208 ! ..................................................................
2210 ! include 'DIMENSIONS'
2213 ! include 'COMMON.IOUNITS'
2214 ! include 'COMMON.TIME1'
2216 ! include 'COMMON.INFO'
2219 !d print *,'Processor',MyID,' NF=',nf
2222 ! Finish if time is up.
2225 else if (mod(nf,100).eq.0) then
2226 ! Other processors might have finished. Check this every 100th function
2228 !d print *,'Processor ',MyID,' is checking STOP: nf=',nf
2229 call recv_stop_sig(Kwita)
2230 if (Kwita.eq.-1) then
2231 write (iout,'(a,i4,a,i5)') 'Processor',&
2232 MyID,' has received STOP signal in STOPX; NF=',nf
2233 write (*,'(a,i4,a,i5)') 'Processor',&
2234 MyID,' has received STOP signal in STOPX; NF=',nf
2246 !-----------------------------------------------------------------------------
2247 logical function ovrtim()
2249 ! include 'DIMENSIONS'
2250 ! include 'COMMON.IOUNITS'
2251 ! include 'COMMON.TIME1'
2252 !el real(kind=8) :: tcpu
2253 real(kind=8) :: curtim
2256 curtim = MPI_Wtime()-walltime
2260 ! curtim is the current time in seconds.
2261 ! write (iout,*) "curtim",curtim," timlim",timlim," safety",safety
2263 if (curtim .ge. timlim - safety) then
2264 write (iout,'(a,f10.2,a,f10.2,a,f10.2,a)') &
2265 "***************** Elapsed time (",curtim,&
2266 " s) is within the safety limit (",safety,&
2267 " s) of the allocated time (",timlim," s). Terminating."
2275 !elwrite (iout,*) "ovrtim",ovrtim
2278 !-----------------------------------------------------------------------------
2279 real(kind=8) function tcpu()
2281 ! include 'COMMON.TIME1'
2282 real(kind=8) :: seconds
2284 !***************************
2285 ! Next definition for EAGLE (ibm-es9000)
2286 real(kind=8) :: micseconds
2288 tcpu=cputime(micseconds,rcode)
2289 tcpu=(micseconds/1.0E6) - stime
2290 !***************************
2293 !***************************
2294 ! Next definitions for sun
2295 REAL(kind=8) :: ECPU,ETIME,ETCPU
2296 real(kind=8),dimension(2) :: tarray
2299 !***************************
2302 !***************************
2303 ! Next definitions for ksr
2304 ! this function uses the ksr timer ALL_SECONDS from the PMON library to
2305 ! return the elapsed time in seconds
2306 tcpu= all_seconds() - stime
2307 !***************************
2310 !***************************
2311 ! Next definitions for sgi
2312 real(kind=4) :: timar(2), etime
2313 seconds = etime(timar)
2314 !d print *,'seconds=',seconds,' stime=',stime
2317 tcpu=seconds - stime
2318 !***************************
2322 !***************************
2323 ! Next definitions for sgi
2324 real(kind=4) :: timar(2), etime
2325 seconds = etime(timar)
2326 !d print *,'seconds=',seconds,' stime=',stime
2329 tcpu=seconds - stime
2330 !***************************
2335 !***************************
2336 ! Next definitions for Cray
2338 ! curdat=curdat(1:9)
2339 ! call clock(curtim)
2340 ! curtim=curtim(1:8)
2343 !***************************
2346 !***************************
2347 ! Next definitions for RS6000
2348 integer(kind=4) :: i1,mclock
2350 tcpu = (i1+0.0D0)/100.0D0
2353 !***************************
2354 ! next definitions for windows NT Digital fortran
2355 real(kind=4) :: time_real
2356 call cpu_time(time_real)
2360 !***************************
2361 ! next definitions for windows NT Digital fortran
2362 real(kind=4) :: time_real
2363 call cpu_time(time_real)
2369 !-----------------------------------------------------------------------------
2371 subroutine dajczas(rntime,hrtime,mintime,sectime)
2373 ! include 'COMMON.IOUNITS'
2374 integer :: ihr,imn,isc
2375 real(kind=8) :: rntime,hrtime,mintime,sectime
2376 hrtime=rntime/3600.0D0
2378 mintime=aint((rntime-3600.0D0*hrtime)/60.0D0)
2379 sectime=aint((rntime-3600.0D0*hrtime-60.0D0*mintime)+0.5D0)
2380 if (sectime.eq.60.0D0) then
2382 mintime=mintime+1.0D0
2387 write (iout,328) ihr,imn,isc
2388 328 FORMAT(//'***** Computation time: ',I4 ,' hours ',I2 ,&
2389 ' minutes ', I2 ,' seconds *****')
2391 end subroutine dajczas
2392 !-----------------------------------------------------------------------------
2393 subroutine print_detailed_timing
2396 ! implicit real*8 (a-h,o-z)
2397 ! include 'DIMENSIONS'
2401 ! include 'COMMON.IOUNITS'
2402 ! include 'COMMON.TIME1'
2403 ! include 'COMMON.SETUP'
2404 real(kind=8) :: time1,time_barrier
2405 time_barrier = 0.0d0
2409 write (iout,'(80(1h=)/a/(80(1h=)))') &
2410 "Details of FG communication time"
2411 write (*,'(7(a40,1pe15.5/),40(1h-)/a40,1pe15.5/80(1h=))') &
2412 "BROADCAST:",time_bcast,"REDUCE:",time_reduce,&
2413 "GATHER:",time_gather,&
2414 "SCATTER:",time_scatter,"SENDRECV:",time_sendrecv,&
2415 "BARRIER ene",time_barrier_e,&
2416 "BARRIER grad",time_barrier_g,&
2418 time_bcast+time_reduce+time_gather+time_scatter+time_sendrecv
2419 write (*,*) fg_rank,myrank,&
2420 ': Total wall clock time',time1-walltime,' sec'
2421 write (*,*) "Processor",fg_rank,myrank,&
2422 ": BROADCAST time",time_bcast," REDUCE time",&
2423 time_reduce," GATHER time",time_gather," SCATTER time",&
2425 " SCATTER fmatmult",time_scatter_fmatmult,&
2426 " SCATTER ginvmult",time_scatter_ginvmult,&
2427 " SCATTER fmat",time_scatter_fmat,&
2428 " SCATTER ginv",time_scatter_ginv,&
2429 " SENDRECV",time_sendrecv,&
2430 " BARRIER ene",time_barrier_e,&
2431 " BARRIER GRAD",time_barrier_g,&
2432 " BCAST7",time_bcast7," BCASTC",time_bcastc,&
2433 " BCASTW",time_bcastw," ALLREDUCE",time_allreduce,&
2435 time_bcast+time_reduce+time_gather+time_scatter+ &
2436 time_sendrecv+time_barrier+time_bcastc
2438 write (*,*) "Processor",fg_rank,myrank," enecalc",time_enecalc
2439 write (*,*) "Processor",fg_rank,myrank," sumene",time_sumene
2440 write (*,*) "Processor",fg_rank,myrank," intfromcart",&
2442 write (*,*) "Processor",fg_rank,myrank," vecandderiv",&
2444 write (*,*) "Processor",fg_rank,myrank," setmatrices",&
2446 write (*,*) "Processor",fg_rank,myrank," ginvmult",&
2448 write (*,*) "Processor",fg_rank,myrank," fricmatmult",&
2450 write (*,*) "Processor",fg_rank,myrank," inttocart",&
2452 write (*,*) "Processor",fg_rank,myrank," sumgradient",&
2454 write (*,*) "Processor",fg_rank,myrank," intcartderiv",&
2456 if (fg_rank.eq.0) then
2457 write (*,*) "Processor",fg_rank,myrank," lagrangian",&
2459 write (*,*) "Processor",fg_rank,myrank," cartgrad",&
2463 end subroutine print_detailed_timing
2465 !-----------------------------------------------------------------------------
2466 !-----------------------------------------------------------------------------