parallel DFA_D DFA_T DFA_N
[unres.git] / source / unres / src_MD / dfa.F
index 66e1ccb..412943a 100644 (file)
@@ -75,6 +75,8 @@ C
       include 'COMMON.CHAIN'
       include 'COMMON.DFA'
       include 'COMMON.FFIELD'
+      include 'COMMON.CONTROL'
+      include 'COMMON.SETUP'
 
 
 C     NOTE THAT FILENAMES are FIXED, CURRENTLY!!
@@ -240,6 +242,36 @@ C            write(*,*) 'READ NEI:',i,j,fnei(i,j)
       close(iodfa)
 C     END OF NEIGHBORING CA
 
+C     init parallel
+C     BETA is not parallel !
+#ifdef MPI
+      if (wdfa_beta.ne.0.0 .and. nfgtasks.gt.1) then
+            write (iout,*) "ERRROR dfa_beta works only for FGPROCS=1"
+            print *,"ERRROR dfa_beta works only for FGPROCS=1"
+            stop
+      endif 
+      call int_bounds(idfadis,idfadis_start,idfadis_end)
+      call int_bounds(idfaphi,idfaphi_start,idfaphi_end)
+      call int_bounds(idfathe,idfathe_start,idfathe_end)
+      call int_bounds(idfanei,idfanei_start,idfanei_end)
+      if (me.eq.king .or. .not. out1file) 
+     &  write (iout,*) "DFA MPI ",
+     & "idfadis ",idfadis,idfadis_start,idfadis_end,
+     & "idfaphi ",idfaphi,idfaphi_start,idfaphi_end,
+     & "idfathe ",idfathe,idfathe_start,idfathe_end,
+     & "idfanei ",idfanei,idfanei_start,idfanei_end
+#else
+      idfadis_start=1
+      idfadis_end=idfadis
+      idfaphi_start=1
+      idfaphi_end=idfaphi
+      idfathe_start=1
+      idfathe_end=idfathe
+      idfanei_start=1
+      idfanei_end=idfanei
+#endif
+
+
 C     READ BETA RESTRAINT
       if (wdfa_beta.eq.0.0) return
       open(iodfa, file='beta_dfa.dat',status='old',err=39)
@@ -265,6 +297,7 @@ c            write(*,*) 'BETA:',i,j,wtmp,wshet(i,j)
       
       close(iodfa)
 C     END OF BETA RESTRAINT
+
       
       return
       END
@@ -285,7 +318,7 @@ C     END OF BETA RESTRAINT
       edfadis=0
       gdfad=0.0d0
 
-      do i=1, idfadis
+      do i=idfadis_start,idfadis_end
 
          iatm1=idislis(1,i)+ishiftca
          iatm2=idislis(2,i)+ishiftca
@@ -368,7 +401,7 @@ C     DFA torsion angle
       gdfat(:,:) = 0.0d0
 
 C     START OF PHI ANGLE
-      do i=1, idfaphi
+      do i=idfaphi_start,idfaphi_end
 
          aphi = 0.0d0
          do iii=1,5
@@ -567,7 +600,7 @@ c     end of single assignment statement
 C     END OF PHI RESTRAINT
 
 C     START OF THETA ANGLE
-      do i=1, idfathe
+      do i=idfathe_start,idfathe_end
 
          athe = 0.0d0
          do iii=1,5
@@ -801,7 +834,7 @@ C     DFA neighboring CA restraint
 c      print*, 's1:', s1(:)
 c      print*, 's2:', s2(:)
 
-      do i=1, idfanei
+      do i=idfanei_start,idfanei_end
 
          kshnum=kshell(i)
          n1atom=ineilis(i)+ishiftca