respa cleaning (my bug) and shielding MPI and previous bug cleaning
[unres.git] / source / unres / src_MD-M / initialize_p.F
index c4baab2..e9af07a 100644 (file)
@@ -119,6 +119,9 @@ C
       icsa_in=40
 crc for ifc error 118
       icsa_pdb=42
+      itorkcc=43
+      ithetkcc=44
+      itube=45
 C Lipidic input file for parameters range 60-79
       iliptranpar=60
 C input file for transfer sidechain and peptide group inside the
@@ -154,8 +157,10 @@ c      call memmon_print_usage()
       enddo
       do i=1,ntyp
        do j=1,ntyp
-         aa(i,j)=0.0D0
-         bb(i,j)=0.0D0
+         aa_aq(i,j)=0.0D0
+         bb_aq(i,j)=0.0D0
+          aa_lip(i,j)=0.0D0
+          bb_lip(i,j)=0.0D0
          augm(i,j)=0.0D0
          sigma(i,j)=0.0D0
          r0(i,j)=0.0D0
@@ -254,20 +259,30 @@ C Initialize the bridge arrays
        jhpb(i)=0
       enddo
 C Initialize correlation arrays
-      do i=-maxtor,maxtor
+      do i=1,maxres
        do k=1,2
         b1(k,i)=0.0
         b2(k,i)=0.0
         b1tilde(k,i)=0.0
 c        b2tilde(k,i)=0.0
         do j=1,2
+C        CC(j,k,i)=0.0
+C        Ctilde(j,k,i)=0.0
+C        DD(j,k,i)=0.0
+C        Dtilde(j,k,i)=0.0
+        EE(j,k,i)=0.0
+        enddo
+       enddo
+      enddo
+      do i=-maxtor,maxtor
+       do k=1,2
+        do j=1,2
         CC(j,k,i)=0.0
         Ctilde(j,k,i)=0.0
         DD(j,k,i)=0.0
         Dtilde(j,k,i)=0.0
-        EE(j,k,i)=0.0
         enddo
-       enddo
+      enddo
       enddo
 C
 C Initialize timing.
@@ -321,14 +336,16 @@ c-------------------------------------------------------------------------
      &   "EVDW SC-SC","EVDW2 SC-p","EES p-p","ECORR4 ","ECORR5 ",
      &   "ECORR6 ","EELLO ","ETURN3 ","ETURN4 ","ETURN6 ",
      &   "EBE bend","ESC SCloc","ETORS ","ETORSD ","EHPB ","EVDWPP ",
-     &   "ESTR ","EVDW2_14 ","UCONST ", "      ","ESCCOR"/
+     &   "ESTR ","EVDW2_14 ","UCONST ", "      ","ESCCOR",
+     &    "ELIPTRAN", "EAFM", "ETHETCNSTR", " "/
       data wname /
      &   "WSC","WSCP","WELEC","WCORR","WCORR5","WCORR6","WEL_LOC",
      &   "WTURN3","WTURN4","WTURN6","WANG","WSCLOC","WTOR","WTORD",
-     &   "WSTRAIN","WVDWPP","WBOND","SCAL14","     ","    ","WSCCOR"/
+     &   "WSTRAIN","WVDWPP","WBOND","SCAL14","     ","    ","WSCCOR",
+     &    "WLT", "WAFM", "WTHETCNSR", " "/
       data nprint_ene /20/
       data print_order/1,2,3,11,12,13,14,4,5,6,7,8,9,10,19,18,15,17,16,
-     & 21,0/
+     & 21,0,22,23,24,25/
       end 
 c---------------------------------------------------------------------------
       subroutine init_int_table
@@ -368,7 +385,7 @@ C... to deal with by current processor.
         itask_cont_from(i)=fg_rank
         itask_cont_to(i)=fg_rank
       enddo
-      lprint=.false.
+      lprint=energy_dec
       if (lprint)
      &write (iout,*) 'INIT_INT_TABLE nres=',nres,' nnt=',nnt,' nct=',nct
       n_sc_int_tot=(nct-nnt+1)*(nct-nnt)/2-nss
@@ -467,6 +484,7 @@ c            write (iout,*) 'jj=nct'
       iatsc_s=nnt
       iatsc_e=nct-1
 #endif
+      if (iatsc_s.eq.0) iatsc_s=1
 #ifdef MPI
       if (lprint) write (*,*) 'Processor',fg_rank,' CG Group',kolor,
      &   ' absolute rank',myrank,' iatsc_s=',iatsc_s,' iatsc_e=',iatsc_e
@@ -599,6 +617,7 @@ cd        write (iout,*) 'i.gt.nct-iscp'
         endif 
       enddo ! i
 #endif
+      if (iatscp_s.eq.0) iatscp_s=1
       if (lprint) then
         write (iout,'(a)') 'SC-p interaction array:'
         do i=iatscp_s,iatscp_e
@@ -653,6 +672,13 @@ c     &  " ivec_start",ivec_start," ivec_end",ivec_end
       else
         call int_bounds(ndih_constr,idihconstr_start,idihconstr_end)
       endif
+      if (ntheta_constr.eq.0) then
+        ithetaconstr_start=1
+        ithetaconstr_end=0
+      else
+        call int_bounds
+     &  (ntheta_constr,ithetaconstr_start,ithetaconstr_end)
+      endif
 c      nsumgrad=(nres-nnt)*(nres-nnt+1)/2
 c      nlen=nres-nnt+1
       nsumgrad=(nres-nnt)*(nres-nnt+1)/2
@@ -687,7 +713,10 @@ c      nlen=nres-nnt+1
      & ' ivec_start',ivec_start,' ivec_end',ivec_end,
      & ' iset_start',iset_start,' iset_end',iset_end,
      & ' idihconstr_start',idihconstr_start,' idihconstr_end',
-     &   idihconstr_end
+     &   idihconstr_end,
+     & ' ithetaconstr_start',ithetaconstr_start,' ithetaconstr_end',
+     &   ithetaconstr_end
+
        write (*,*) 'Processor:',fg_rank,myrank,' igrad_start',
      &   igrad_start,' igrad_end',igrad_end,' ngrad_start',ngrad_start,
      &   ' ngrad_end',ngrad_end
@@ -972,9 +1001,15 @@ c          call flush(iout)
         call MPI_Group_free(cont_to_group,ierr)
         call MPI_Type_contiguous(3,MPI_DOUBLE_PRECISION,MPI_UYZ,IERROR)
         call MPI_Type_commit(MPI_UYZ,IERROR)
+        call MPI_Type_contiguous(maxcontsshi,MPI_INTEGER,MPI_I50,IERROR)
+        call MPI_Type_commit(MPI_I50,IERROR)
         call MPI_Type_contiguous(18,MPI_DOUBLE_PRECISION,MPI_UYZGRAD,
      &    IERROR)
         call MPI_Type_commit(MPI_UYZGRAD,IERROR)
+         impishi=maxcontsshi*3
+        call MPI_Type_contiguous(impishi,MPI_DOUBLE_PRECISION,
+     &   MPI_SHI,IERROR)
+        call MPI_Type_commit(MPI_SHI,IERROR)
         call MPI_Type_contiguous(2,MPI_DOUBLE_PRECISION,MPI_MU,IERROR)
         call MPI_Type_commit(MPI_MU,IERROR)
         call MPI_Type_contiguous(4,MPI_DOUBLE_PRECISION,MPI_MAT1,IERROR)
@@ -1152,6 +1187,8 @@ c        write (iout,*) "MPI_ROTAT2",MPI_ROTAT2
       iphi1_end=nres
       idihconstr_start=1
       idihconstr_end=ndih_constr
+      ithetaconstr_start=1
+      ithetaconstr_end=ntheta_constr
       iphid_start=iphi_start
       iphid_end=iphi_end-1
       itau_start=4
@@ -1159,7 +1196,8 @@ c        write (iout,*) "MPI_ROTAT2",MPI_ROTAT2
       ibond_start=2
       ibond_end=nres-1
       ibondp_start=nnt
-      ibondp_end=nct-1
+C      ibondp_end=nct-1
+      ibondp_end=nct
       ivec_start=1
       ivec_end=nres-1
       iset_start=3