unres Adam's changes
[unres.git] / source / unres / src-HCD-5D / energy_split-sep.F
index f16bc1b..51d5b2d 100644 (file)
@@ -13,7 +13,7 @@ cMS$ATTRIBUTES C ::  proc_proc
 #ifdef MPI
       include "mpif.h"
       double precision weights_(n_ene)
-      double precision time00,time_Bcast,time_BcastW
+      double precision time00
       integer ierror,ierr
 #endif
       include 'COMMON.SETUP'
@@ -29,6 +29,7 @@ cMS$ATTRIBUTES C ::  proc_proc
       include 'COMMON.QRESTR'
       include 'COMMON.MD'
       include 'COMMON.CONTROL'
+      include 'COMMON.TIME1'
       double precision evdw,evdw1,evdw2,evdw2_14,ees,eel_loc,
      & eello_turn3,eello_turn4,edfadis,estr,ehpb,ebe,ethetacnstr,
      & escloc,etors,edihcnstr,etors_d,esccor,ecorr,ecorr5,ecorr6,eturn6,
@@ -36,6 +37,9 @@ cMS$ATTRIBUTES C ::  proc_proc
      & esaxs_constr,ehomology_constr,edfator,edfanei,edfabet
       integer i,n_corr,n_corr1
 c      write(iout,'(a,i2)')'Calling etotal_long ipot=',ipot
+#ifdef TIMING_ENE
+      double precision time01
+#endif
       if (modecalc.eq.12.or.modecalc.eq.14) then
 #ifdef MPI
 c        if (fg_rank.eq.0) call int_from_cart1(.false.)
@@ -44,6 +48,13 @@ c        if (fg_rank.eq.0) call int_from_cart1(.false.)
 #endif
       endif
 #ifdef MPI      
+      edfadis=0.0d0
+      edfator=0.0d0
+      edfanei=0.0d0
+      edfabet=0.0d0
+      ehomology_constr=0.0d0
+      Uconst=0.0d0
+      Uconst_back=0.0d0
 c      write(iout,*) "ETOTAL_LONG Processor",fg_rank,
 c     & " absolute rank",myrank," nfgtasks",nfgtasks
 c      call flush(iout)
@@ -111,10 +122,10 @@ C FG slaves receive the WEIGHTS array
           wliptran=weights(22)
           wtube=weights(25)
           wsaxs=weights(26)
-          wdfa_dist=weights_(28)
-          wdfa_tor=weights_(29)
-          wdfa_nei=weights_(30)
-          wdfa_beta=weights_(31)
+          wdfa_dist=weights(28)
+          wdfa_tor=weights(29)
+          wdfa_nei=weights(30)
+          wdfa_beta=weights(31)
         endif
         call MPI_Bcast(dc(1,1),6*nres,MPI_DOUBLE_PRECISION,
      &    king,FG_COMM,IERR)
@@ -131,17 +142,25 @@ c      print *,'Processor',myrank,' nnt=',nnt,' nct=',nct
         call MPI_Bcast(itime_mat,1,MPI_INT,king,FG_COMM,IERROR)
       endif
       if (mod(itime_mat,imatupdate).eq.0) then
-        call make_SCp_inter_list
-        call make_SCSC_inter_list
+#ifdef TIMING_ENE
+        time01=MPI_Wtime()
+#endif
+        call make_SCp_inter_list_RESPA
+        call make_SCSC_inter_list_RESPA
         call make_pp_inter_list
-        call make_pp_vdw_inter_list
+        call make_pp_vdw_inter_list_RESPA
+#ifdef TIMING_ENE
+        time_list=time_list+MPI_Wtime()-time01
+#endif
       endif
 #endif     
-
 cd    print *,'nnt=',nnt,' nct=',nct
 C
 C Compute the side-chain and electrostatic interaction energy
 C
+#ifdef TIMING_ENE
+      time01=MPI_Wtime()
+#endif
       goto (101,102,103,104,105,106) ipot
 C Lennard-Jones potential.
   101 call elj_long(evdw)
@@ -165,8 +184,20 @@ C
 C Calculate electrostatic (H-bonding) energy of the main chain.
 C
   107 continue
+#ifdef TIMING_ENE
+      time_evdw_long=time_evdw_long+MPI_Wtime()-time01
+#endif
+#ifdef TIMING
+      time01=MPI_Wtime() 
+#endif
       call vec_and_deriv
+#ifdef TIMING
+      time_vec=time_vec+MPI_Wtime()-time01
+#endif
 c      write (iout,*) "etotal_long: shield_mode",shield_mode
+#ifdef TIMING_ENE
+      time01=MPI_Wtime()
+#endif
       if (shield_mode.eq.1) then
        call set_shield_fac
       else if  (shield_mode.eq.2) then
@@ -198,10 +229,16 @@ c        write (iout,*) "Soft-spheer ELEC potential"
         call eelec_soft_sphere(ees,evdw1,eel_loc,eello_turn3,
      &   eello_turn4)
       endif
+#ifdef TIMING_ENE
+      time_eelec_long=time_eelec_long+MPI_Wtime()-time01
+#endif
 C
 C Calculate excluded-volume interaction energy between peptide groups
 C and side chains.
 C
+#ifdef TIMING_ENE
+      time01=MPI_Wtime()
+#endif
       if (ipot.lt.6) then
        if(wscp.gt.0d0) then
         call escp_long(evdw2,evdw2_14)
@@ -212,6 +249,9 @@ C
       else
         call escp_soft_sphere(evdw2,evdw2_14)
       endif
+#ifdef TIMING_ENE
+      time_escp_long=time_escp_long+MPI_Wtime()-time01
+#endif
 #ifdef FOURBODY
 C 
 C 12/1/95 Multi-body terms
@@ -231,7 +271,17 @@ c     &" ecorr",ecorr," ecorr5",ecorr5," ecorr6",ecorr6," eturn6",eturn6
       endif
       if ((wcorr4.eq.0.0d0 .and. wcorr.gt.0.0d0) .and. ipot.lt.6) then
          call multibody_hb(ecorr,ecorr5,ecorr6,n_corr,n_corr1)
+      else
+         ecorr=0.0d0
+         ecorr5=0.0d0
+         ecorr6=0.0d0
+         eturn6=0.0d0
       endif
+#else
+         ecorr=0.0d0
+         ecorr5=0.0d0
+         ecorr6=0.0d0
+         eturn6=0.0d0
 #endif
 C 
 C If performing constraint dynamics, call the constraint energy
@@ -318,12 +368,16 @@ cMS$ATTRIBUTES C ::  proc_proc
       include 'COMMON.CONTROL'
       include 'COMMON.SAXS'
       include 'COMMON.TORCNSTR'
+      include 'COMMON.TIME1'
       double precision evdw,evdw1,evdw2,evdw2_14,ees,eel_loc,
      & eello_turn3,eello_turn4,edfadis,estr,ehpb,ebe,ethetacnstr,
      & escloc,etors,edihcnstr,etors_d,esccor,ecorr,ecorr5,ecorr6,eturn6,
      & eliptran,Eafmforce,Etube,
      & esaxs_constr,ehomology_constr,edfator,edfanei,edfabet
       integer i,n_corr,n_corr1
+#ifdef TIMING_ENE
+      double precision time01
+#endif
 c      write(iout,'(a,i2)')'Calling etotal_short ipot=',ipot
 c      call flush(iout)
       if (modecalc.eq.12.or.modecalc.eq.14) then
@@ -340,6 +394,18 @@ c      call flush(iout)
       edfanei=0.0d0
       edfabet=0.0d0
 #endif
+      evdw=0.0d0
+      ees=0.0d0
+      evdw1=0.0d0
+      eel_loc=0.0d0
+      eello_turn3=0.0d0
+      eello_turn4=0.0d0
+      evdw2=0
+      evdw2_14=0
+      ecorr=0.0d0
+      ecorr5=0.0d0
+      ecorr6=0.0d0
+      eturn6=0.0d0
 c      write(iout,*) "ETOTAL_SHORT Processor",fg_rank,
 c     & " absolute rank",myrank," nfgtasks",nfgtasks
 c      call flush(iout)
@@ -404,13 +470,13 @@ C FG slaves receive the WEIGHTS array
           wsaxs=weights(26)
         endif
 c        write (iout,*),"Processor",myrank," BROADCAST weights"
-        call MPI_Bcast(c(1,1),maxres6,MPI_DOUBLE_PRECISION,
+        call MPI_Bcast(c(1,1),6*nres,MPI_DOUBLE_PRECISION,
      &    king,FG_COMM,IERR)
 c        write (iout,*) "Processor",myrank," BROADCAST c"
-        call MPI_Bcast(dc(1,1),maxres6,MPI_DOUBLE_PRECISION,
+        call MPI_Bcast(dc(1,1),6*nres,MPI_DOUBLE_PRECISION,
      &    king,FG_COMM,IERR)
 c        write (iout,*) "Processor",myrank," BROADCAST dc"
-        call MPI_Bcast(dc_norm(1,1),maxres6,MPI_DOUBLE_PRECISION,
+        call MPI_Bcast(dc_norm(1,1),6*nres,MPI_DOUBLE_PRECISION,
      &    king,FG_COMM,IERR)
 c        write (iout,*) "Processor",myrank," BROADCAST dc_norm"
         call MPI_Bcast(theta(1),nres,MPI_DOUBLE_PRECISION,
@@ -442,6 +508,9 @@ c      call int_from_cart1(.false.)
 C
 C Compute the side-chain and electrostatic interaction energy
 C
+#ifdef TIMING_ENE
+      time01=MPI_Wtime()
+#endif
       goto (101,102,103,104,105,106) ipot
 C Lennard-Jones potential.
   101 call elj_short(evdw)
@@ -466,16 +535,31 @@ C
 C Calculate electrostatic (H-bonding) energy of the main chain.
 C
   107 continue
+#ifdef TIMING_ENE
+      time_evdw_short=time_evdw_short+MPI_Wtime()-time01
+#endif
 c
 c Calculate the short-range part of Evdwpp
 c
+#ifdef TIMING_ENE
+      time01=MPI_Wtime()
+#endif
       call evdwpp_short(evdw1)
+#ifdef TIMING_ENE
+      time_eelec_short=time_eelec_short+MPI_Wtime()-time01
+#endif
 c
 c Calculate the short-range part of ESCp
 c
+#ifdef TIMING_ENE
+      time01=MPI_Wtime()
+#endif
       if (ipot.lt.6) then
         call escp_short(evdw2,evdw2_14)
       endif
+#ifdef TIMING_ENE
+      time_escp_short=time_escp_short+MPI_Wtime()-time01
+#endif
 c
 c Calculate the bond-stretching energy
 c
@@ -503,7 +587,13 @@ C energy function
 C
 C Calculate the SC local energy.
 C
+#ifdef TIMING
+      time01=MPI_Wtime() 
+#endif
       call vec_and_deriv
+#ifdef TIMING
+      time_vec=time_vec+MPI_Wtime()-time01
+#endif
       call esc(escloc)
 C
 C Calculate the virtual-bond torsional energy.
@@ -526,6 +616,21 @@ c Lipid transfer
       else
         eliptran=0.0d0
       endif
+      if (AFMlog.gt.0) then
+        call AFMforce(Eafmforce)
+      else if (selfguide.gt.0) then
+        call AFMvel(Eafmforce)
+      else 
+        Eafmforce=0.0d0
+      endif
+      if (TUBElog.eq.1) then
+C      print *,"just before call"
+        call calctube(Etube)
+      elseif (TUBElog.eq.2) then
+        call calctube2(Etube)
+      else
+        Etube=0.0d0
+      endif
 
       if (ndih_constr.gt.0) call etor_constr(edihcnstr)
 c      print *,"Processor",myrank," computed Utor"