BUG found in SC-SC grad and FGPROC>1
authorAdam Sieradzan <adasko@piasek4.chem.univ.gda.pl>
Wed, 2 May 2018 18:51:46 +0000 (20:51 +0200)
committerAdam Sieradzan <adasko@piasek4.chem.univ.gda.pl>
Wed, 2 May 2018 18:51:46 +0000 (20:51 +0200)
source/unres/control.F90
source/unres/data/MPI_data.f90
source/unres/energy.f90

index 4c413ec..7160f8f 100644 (file)
         call MPI_Type_commit(MPI_UYZGRAD,IERROR)
         call MPI_Type_contiguous(maxcontsshi,MPI_INTEGER,MPI_I50,IERROR)
         call MPI_Type_commit(MPI_I50,IERROR)
+        call MPI_Type_contiguous(maxcontsshi,MPI_DOUBLE_PRECISION,MPI_D50,IERROR)
+        call MPI_Type_commit(MPI_D50,IERROR)
+
          impishi=maxcontsshi*3
         call MPI_Type_contiguous(impishi,MPI_DOUBLE_PRECISION, &
         MPI_SHI,IERROR)
index 06b6d0b..8df6152 100644 (file)
@@ -39,7 +39,7 @@
       logical :: yourjob,finished,cgdone
 !      common /types/
       integer :: MPI_UYZ,MPI_UYZGRAD,MPI_MU,MPI_MAT1,MPI_MAT2,&
-       MPI_THET,MPI_GAM,MPI_I50,MPI_SHI
+       MPI_THET,MPI_GAM,MPI_I50,MPI_SHI,MPI_D50
       integer,dimension(0:1) :: MPI_ROTAT1,MPI_ROTAT2,MPI_ROTAT_OLD,&
        MPI_PRECOMP11,MPI_PRECOMP12,MPI_PRECOMP22,MPI_PRECOMP23
 !-----------------------------------------------------------------------------
index 7d21f89..5915d7d 100644 (file)
       grad_shield_locbuf(3,maxcontsshi,-1:nres), &
       grad_shield_sidebuf(3,maxcontsshi,-1:nres), &
       grad_shieldbuf(3,-1:nres)
-       integer ishield_listbuf(nres), &
-       shield_listbuf(maxcontsshi,nres),k,j,i
+       integer ishield_listbuf(-1:nres), &
+       shield_listbuf(maxcontsshi,-1:nres),k,j,i
+
+!      real(kind=8),  dimension(:),allocatable::  fac_shieldbuf 
+!      real(kind=8), dimension(:,:,:),allocatable:: &
+!       grad_shield_locbuf,grad_shield_sidebuf
+!      real(kind=8), dimension(:,:),allocatable:: & 
+!        grad_shieldbuf
+!       integer, dimension(:),allocatable:: &
+!       ishield_listbuf
+!       integer, dimension(:,:),allocatable::  shield_listbuf
+!       integer :: k,j,i
+!      if (.not.allocated(fac_shieldbuf)) then
+!          allocate(fac_shieldbuf(nres))
+!          allocate(grad_shield_locbuf(3,maxcontsshi,-1:nres))
+!          allocate(grad_shield_sidebuf(3,maxcontsshi,-1:nres))
+!          allocate(grad_shieldbuf(3,-1:nres))
+!          allocate(ishield_listbuf(nres))
+!          allocate(shield_listbuf(maxcontsshi,nres))
+!       endif
 
 !      print*,"ETOTAL Processor",fg_rank," absolute rank",myrank,
 !     & " nfgtasks",nfgtasks
 !          print *,"Processor",myrank," BROADCAST iorder"
 ! FG master sets up the WEIGHTS_ array which will be broadcast to the 
 ! FG slaves as WEIGHTS array.
-          weights_(1)=wsc
+         ! weights_(1)=wsc
           weights_(2)=wscp
           weights_(3)=welec
           weights_(4)=wcorr
 ! shielding effect 
        if (shield_mode.eq.2) then
                  call set_shield_fac2
-       endif
+       
       if (nfgtasks.gt.1) then
+!#define DEBUG
+#ifdef DEBUG
+       write(iout,*) "befor reduce fac_shield reduce"
+       do i=1,nres
+        write(2,*) "fac",itype(i,1),fac_shield(i),grad_shield(1,i)
+        write(2,*) "list", shield_list(1,i),ishield_list(i), &
+       grad_shield_side(1,1,i),grad_shield_loc(1,1,i)
+       enddo
+#endif
+        do i=1,nres
+        ishield_listbuf(i)=0
+!        fac_shieldbuf(i)=0.0d0
+        enddo
         call MPI_Allgatherv(fac_shield(ivec_start), &
         ivec_count(fg_rank1), &
         MPI_DOUBLE_PRECISION,fac_shieldbuf(1),ivec_count(0), &
         MPI_I50,shield_listbuf(1,1),ivec_count(0), &
         ivec_displ(0), &
         MPI_I50,FG_COMM,IERROR)
+!        write(2,*) "After I50"
+!        call flush(iout)
         call MPI_Allgatherv(ishield_list(ivec_start), &
         ivec_count(fg_rank1), &
         MPI_INTEGER,ishield_listbuf(1),ivec_count(0), &
         ivec_displ(0), &
         MPI_INTEGER,FG_COMM,IERROR)
+        
         call MPI_Allgatherv(grad_shield(1,ivec_start), &
         ivec_count(fg_rank1), &
-        MPI_UYZ,grad_shieldbuf(1,1),ivec_count(0), &
+        MPI_D50,grad_shieldbuf(1,1),ivec_count(0), &
         ivec_displ(0), &
-        MPI_UYZ,FG_COMM,IERROR)
+        MPI_D50,FG_COMM,IERROR)
         call MPI_Allgatherv(grad_shield_side(1,1,ivec_start), &
         ivec_count(fg_rank1), &
         MPI_SHI,grad_shield_sidebuf(1,1,1),ivec_count(0), &
         MPI_SHI,grad_shield_locbuf(1,1,1),ivec_count(0), &
         ivec_displ(0), &
         MPI_SHI,FG_COMM,IERROR)
+!        write(2,*) "After MPI_SHI"
+        call flush(iout)
+
         do i=1,nres
          fac_shield(i)=fac_shieldbuf(i)
          ishield_list(i)=ishield_listbuf(i)
+!         write(iout,*) i,fac_shield(i)
          do j=1,3
          grad_shield(j,i)=grad_shieldbuf(j,i)
          enddo !j
          do j=1,ishield_list(i)
+          write (iout,*) "ishild", ishield_list(i),i
            shield_list(j,i)=shield_listbuf(j,i)
           do k=1,3
           grad_shield_loc(k,j,i)=grad_shield_locbuf(k,j,i)
         enddo !j
        enddo !i
        endif
-
+#ifdef DEBUG
+       write(iout,*) "after reduce fac_shield reduce"
+       do i=1,nres
+        write(2,*) "fac",itype(i,1),fac_shield(i),grad_shield(1,i)
+        write(2,*) "list", shield_list(1,i),ishield_list(i), &
+        grad_shield_side(1,1,i),grad_shield_loc(1,1,i)
+       enddo
+#endif
+!#undef DEBUG
+       endif
 
 
 
              .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.d0 &
              .or. wcorr6.gt.0.0d0 .or. wturn6.gt.0.0d0 ) then
 #endif
-!            print *,"just befor eelec call"
+            write(iout,*),"just befor eelec call"
             call eelec(ees,evdw1,eel_loc,eello_turn3,eello_turn4)
-!         write (iout,*) "ELEC calc"
+         write (iout,*) "ELEC calc"
          else
             ees=0.0d0
             evdw1=0.0d0
 ! Calculate excluded-volume interaction energy between peptide groups
 ! and side chains.
 !
-!elwrite(iout,*) "in etotal calc exc;luded",ipot
+       write(iout,*) "in etotal calc exc;luded",ipot
 
       if (ipot.lt.6) then
        if(wscp.gt.0d0) then
 !        write (iout,*) "Soft-sphere SCP potential"
         call escp_soft_sphere(evdw2,evdw2_14)
       endif
-!       write(iout,*) "in etotal before ebond",ipot
+        write(iout,*) "in etotal before ebond",ipot
 
 !
 ! Calculate the bond-stretching energy
 !
       call ebond(estr)
 !       print *,"EBOND",estr
-!       write(iout,*) "in etotal afer ebond",ipot
+       write(iout,*) "in etotal afer ebond",ipot
 
 ! 
 ! Calculate the disulfide-bridge and other energy and the contributions
        edihcnstr=0
       endif
 !      print *,"Processor",myrank," computed Utor"
+       
 !
 ! 6/23/01 Calculate double-torsional energy
 !
       else
         esccor=0.0d0
       endif
+
+      write(iout,*) "before multibody"
 !      print *,"Processor",myrank," computed Usccorr"
 ! 
 ! 12/1/95 Multi-body terms
 !
       n_corr=0
       n_corr1=0
+      call flush(iout)
       if ((wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0 &
           .or. wturn6.gt.0.0d0) .and. ipot.lt.6) then
          call multibody_eello(ecorr,ecorr5,ecorr6,eturn6,n_corr,n_corr1)
          call multibody_hb(ecorr,ecorr5,ecorr6,n_corr,n_corr1)
 !d         write (iout,*) "multibody_hb ecorr",ecorr
       endif
-!elwrite(iout,*) "afeter  multibody hb" 
-
+      write(iout,*) "afeter  multibody hb" 
+      
 !      print *,"Processor",myrank," computed Ucorr"
 ! 
 ! If performing constraint dynamics, call the constraint energy
          Uconst_back=0.0d0
       endif
       call flush(iout)
-!         write(iout,*) "after Econstr" 
+         write(iout,*) "after Econstr" 
 
       if (wliptran.gt.0) then
 !        print *,"PRZED WYWOLANIEM"
        etube=0.0d0
       endif
 !--------------------------------------------------------
-!      write (iout,*) "NRES_MOLEC(2),",nres_molec(2)
+       write (iout,*) "NRES_MOLEC(2),",nres_molec(2)
 !      print *,"before",ees,evdw1,ecorr
+!      write(iout,*) ecorr_nucl,"ecorr_nucl",nres_molec(2)
       if (nres_molec(2).gt.0) then
       call ebond_nucl(estr_nucl)
       call ebend_nucl(ebe_nucl)
       call epp_nucl_sub(evdwpp,eespp)
       call epsb(evdwpsb,eelpsb)
       call esb(esbloc)
-      call multibody_hb_nucl(ecorr_nucl,ecorr3_nucl,n_corr,n_corr1)
+!      call multibody_hb_nucl(ecorr_nucl,ecorr3_nucl,n_corr,n_corr1)
       else
        etors_nucl=0.0d0
        estr_nucl=0.0d0
+       ecorr3_nucl=0.0d0
        ebe_nucl=0.0d0
        evdwsb=0.0d0
        eelsb=0.0d0
        esbloc=0.0d0
+       evdwpsb=0.0d0
+       eelpsb=0.0d0
+       evdwpp=0.0d0
+       eespp=0.0d0
       endif
+!      write(iout,*) ecorr_nucl,"ecorr_nucl",nres_molec(2)
       if (nfgtasks.gt.1) then
       if (fg_rank.eq.0) then
       call ecatcat(ecationcation)
 #ifdef TIMING
       time_sumene=time_sumene+MPI_Wtime()-time00
 #endif
-!el        call enerprint(energia)
+        call enerprint(energia)
 !elwrite(iout,*)"finish etotal"
       return
       end subroutine etotal
       lprn=.false.
 !     if (icall.eq.0) lprn=.false.
 !el      ind=0
+      dCAVdOM2=0.0d0
+      dGCLdOM2=0.0d0
+      dPOLdOM2=0.0d0
+      dCAVdOM1=0.0d0 
+      dGCLdOM1=0.0d0 
+      dPOLdOM1=0.0d0
+
+
       do i=iatsc_s,iatsc_e
 !C        print *,"I am in EVDW",i
         itypi=iabs(itype(i,1))
               jj,jp,kk,j1,jp1,jjc,iii,nnn,iproc
 
 ! Set lprn=.true. for debugging
-      lprn=.false.
+      lprn=.true.
 #ifdef MPI
 !      maxconts=nres/4
       if(.not.allocated(zapas)) allocate(zapas(max_dim,maxconts,nfgtasks))
 !C      write(2,*) "ivec",ivec_start,ivec_end
       do i=1,nres
         fac_shield(i)=0.0d0
+        ishield_list(i)=0
         do j=1,3
         grad_shield(j,i)=0.0d0
         enddo
       do i=ivec_start,ivec_end
 !C      do i=1,nres-1
 !C      if ((itype(i,1).eq.ntyp1).and.itype(i+1,1).eq.ntyp1) cycle
-      ishield_list(i)=0
+!      ishield_list(i)=0
       if ((itype(i,1).eq.ntyp1).and.itype(i+1,1).eq.ntyp1) cycle
 !Cif there two consequtive dummy atoms there is no peptide group between them
 !C the line below has to be changed for FGPROC>1
       allocate(gradpepcatx(3,-1:nres))
       allocate(gradcatcat(3,-1:nres))
 !(3,maxres)
-      allocate(grad_shield_side(3,50,nres))
-      allocate(grad_shield_loc(3,50,nres))
+      allocate(grad_shield_side(3,maxcontsshi,-1:nres))
+      allocate(grad_shield_loc(3,maxcontsshi,-1:nres))
 ! grad for shielding surroing
       allocate(gloc(0:maxvar,0:2))
       allocate(gloc_x(0:maxvar,2))
 !        allocate(newihpb(nss),newjhpb(nss))
 !(maxdim)
 !      endif
-      allocate(ishield_list(nres))
-      allocate(shield_list(50,nres))
+      allocate(ishield_list(-1:nres))
+      allocate(shield_list(maxcontsshi,-1:nres))
       allocate(dyn_ss_mask(nres))
-      allocate(fac_shield(nres))
+      allocate(fac_shield(-1:nres))
       allocate(enetube(nres*2))
       allocate(enecavtube(nres*2))