working martini
[unres4.git] / source / unres / control.F90
index 828a199..599a108 100644 (file)
       icsa_in=40
 !rc for ifc error 118
       icsa_pdb=42
+      irotam_end=43
 #endif
       iscpp=25
       icbase=16
 !     LIPID MARTINI
       ilipbond=301
       ilipnonbond=302
+      imartprot=303 ! this parameters are between protein and martini form of lipid
 !     IONS
       iion=401
       iionnucl=402
       iiontran=403 ! this is parameter file for transition metals
+      iwaterwater=404
+      iwatersc=405
 #if defined(WHAM_RUN) || defined(CLUSTER)
 !
 ! setting the mpi variables for WHAM
 !   
 !c     maxfun=5000
 !c     maxit=2000
-      maxfun=500
-      maxit=200
+      maxfun=1000
+      maxit=1000
       tolf=1.0D-2
       rtolf=5.0D-4
 ! 
             my_ele_inds_vdw_nucl,my_ele_inde_vdw_nucl,ind_eleint_vdw_nucl,&
             ind_eleint_vdw_old_nucl,nscp_int_tot_nucl,my_scp_inds_nucl,&
             my_scp_inde_nucl,ind_scpint_nucl,ind_scpint_old_nucl,impishi
-       integer,dimension(nres,nres) :: remmat
+       integer(kind=1),dimension(:,:),allocatable :: remmat
 !      integer,dimension(5) :: nct_molec,nnt_molec
 !el      allocate(itask_cont_from(0:nfgtasks-1)) !(0:max_fg_procs-1)
 !el      allocate(itask_cont_to(0:nfgtasks-1)) !(0:max_fg_procs-1)
 !... Determine the numbers of start and end SC-SC interaction
 !... to deal with by current processor.
 !write (iout,*) '******INIT_INT_TABLE nres=',nres,' nnt=',nnt,' nct=',nct
+      print *,"in spliting contacts"
       do i=0,nfgtasks-1
         itask_cont_from(i)=fg_rank
         itask_cont_to(i)=fg_rank
       lprint=energy_dec
       itmp=0
       do i=1,5
+       print *,i,nres_molec(i)
        if (nres_molec(i).eq.0) cycle
       itmp=itmp+nres_molec(i)
       if (itype(itmp,i).eq.ntyp1_molec(i)) then
       nnt_molec(i)=itmp+1
       endif
       enddo
+!      if (.not.allocated(nres_molec)) print *,"WHATS WRONG"
       print *,"nres_molec",nres_molec(:)
       print *,"nnt_molec",nnt_molec(:)
       print *,"nct_molec",nct_molec(:)
       iatsc_s=0
       iatsc_e=0
 #endif
+        if(.not.allocated(ielstart_all)) then
 !el       common /przechowalnia/
       allocate(iturn3_start_all(0:nfgtasks))
       allocate(iturn3_end_all(0:nfgtasks))
       allocate(itask_cont_from_all(0:nfgtasks-1,0:nfgtasks-1))
       allocate(itask_cont_to_all(0:nfgtasks-1,0:nfgtasks-1))
 !el----------
+      endif
 !      lprint=.false.
         print *,"NCT",nct_molec(1),nct
       do i=1,nres !el  !maxres
        ilipbond_start=1+itmp
        ilipbond_end=nres_molec(4)-1+itmp
 !angles
+       call int_bounds(nres_molec(4)-1,ilipbond_start_tub,ilipbond_end_tub)
+       ilipbond_start_tub=1+itmp
+       ilipbond_end_tub=nres_molec(4)-1+itmp
+
 !       call int_bounds(nres_molec(4)-2,ilipang_start,ilipang_end)
        ilipang_start=2+itmp
        ilipang_end=itmp+nres_molec(4)-1
 !      create LJ LIST MAXIMUM
 !      Eliminate branching from list
+       if(.not.allocated(remmat))&
+        allocate(remmat(itmp+1:nres_molec(4)+itmp,itmp+1:nres_molec(4)+itmp))
           remmat=0
        do i=1+itmp,nres_molec(4)-1+itmp
         if (itype(i,4).eq.12) ibra=i
         endif
        enddo
        maxljliplist=0
+       if (.not.allocated(mlipljlisti)) then
        allocate (mlipljlisti(nres_molec(4)*nres_molec(4)/2))
        allocate (mlipljlistj(nres_molec(4)*nres_molec(4)/2))
+       endif
        do i=1+itmp,nres_molec(4)-1+itmp
         do j=i+2,nres_molec(4)+itmp
         if ((itype(i,4).le.ntyp_molec(4)).and.(itype(j,4).le.ntyp_molec(4))&
        iliplj_end=iliplj_end
 !      now the electrostatic list
        maxelecliplist=0
+       if (.not.allocated(mlipeleclisti)) then
        allocate (mlipeleclisti(nres_molec(4)*nres_molec(4)/2))
        allocate (mlipeleclistj(nres_molec(4)*nres_molec(4)/2))
+       endif
        do i=1+itmp,nres_molec(4)-1+itmp
         do j=i+2,nres_molec(4)+itmp
         if ((itype(i,4).le.4).and.(itype(j,4).le.4)) then
         jgrad_start(i)=i+1
         jgrad_end(i)=nres
       enddo
+! THIS SHOULD BE FIXED
+      itmp=0
+      do i=1,4
+       itmp=itmp+nres_molec(i)
+      enddo
+      call int_bounds(nres_molec(5),icatb_start,icatb_end)
+      icatb_start=icatb_start+itmp
+      icatb_end=icatb_end+itmp
+
+
+
       if (lprint) then 
         write (*,*) 'Processor:',fg_rank,' CG group',kolor,&
        ' absolute rank',myrank,&
 !        write (iout,*) "Loop backward iatel_e-1",iatel_e-1,
 !     &     " iatel_e",iatel_e
 !        call flush(iout)
+#ifndef NEWCORR
         nat_sent=0
         do i=iatel_s,iatel_e
 !          write (iout,*) "i",i," ielstart",ielstart(i),
             iat_sent(nat_sent)=i
           endif
         enddo
+#endif
         if (lprint) then
         write (iout,*)"After longrange ntask_cont_from",ntask_cont_from,&
          " ntask_cont_to",ntask_cont_to
         write (iout,*) "itask_cont_to",&
           (itask_cont_to(i),i=1,ntask_cont_to)
         call flush(iout)
+#ifndef NEWCORR
         write (iout,*) "iint_sent"
         do i=1,nat_sent
           ii=iat_sent(i)
           write (iout,'(20i4)') ii,(j,(iint_sent(k,j,i),k=1,4),&
             j=ielstart(ii),ielend(ii))
         enddo
+#endif
         write (iout,*) "iturn3_sent iturn3_start",iturn3_start,&
           " iturn3_end",iturn3_end
         write (iout,'(20i4)') (i,(iturn3_sent(j,i),j=1,4),&
           itask_cont_from(0),CONT_FROM_GROUP,IERR)
         call MPI_Group_incl(fg_group,ntask_cont_to+1,itask_cont_to(0),&
           CONT_TO_GROUP,IERR)
+#ifndef NEWCORR
         do i=1,nat_sent
           ii=iat_sent(i)
           iaux=4*(ielend(ii)-ielstart(ii)+1)
 !          write (iout,*) "Ranks translated i=",i
 !          call flush(iout)
         enddo
+#endif
         iaux=4*(iturn3_end-iturn3_start+1)
           if (iaux.lt.0) iaux=0
         call MPI_Group_translate_ranks(fg_group,iaux,&
            iturn4_sent(1,iturn4_start),CONT_TO_GROUP,&
            iturn4_sent_local(1,iturn4_start),IERR)
         if (lprint) then
+#ifndef NEWCORR
+
         write (iout,*) "iint_sent_local"
         do i=1,nat_sent
           ii=iat_sent(i)
             j=ielstart(ii),ielend(ii))
           call flush(iout)
         enddo
+#endif
         if (iturn3_end.gt.0) then
         write (iout,*) "iturn3_sent_local iturn3_start",iturn3_start,&
           " iturn3_end",iturn3_end
       end subroutine print_detailed_timing
 #endif
 !-----------------------------------------------------------------------------
+      subroutine homology_partition
+      implicit none
+!      include 'DIMENSIONS'
+!#ifdef MPI
+!      include 'mpif.h'
+!#endif
+!      include 'COMMON.SBRIDGE'
+!      include 'COMMON.IOUNITS'
+!      include 'COMMON.SETUP'
+!      include 'COMMON.CONTROL'
+!      include 'COMMON.INTERACT'
+!      include 'COMMON.HOMOLOGY'
+!d      write(iout,*)"homology_partition: lim_odl=",lim_odl,
+!d     &   " lim_dih",lim_dih
+#ifdef MPI
+      if (me.eq.king .or. .not. out1file) write (iout,*) "MPI"
+      call int_bounds(lim_odl,link_start_homo,link_end_homo)
+      call int_bounds(lim_dih,idihconstr_start_homo, &
+       idihconstr_end_homo)
+      idihconstr_start_homo=idihconstr_start_homo+nnt-1+3
+      idihconstr_end_homo=idihconstr_end_homo+nnt-1+3
+      if (me.eq.king .or. .not. out1file)&
+       write (iout,*) 'Processor',fg_rank,' CG group',kolor,&
+       ' absolute rank',MyRank,&
+       ' lim_odl',lim_odl,' link_start=',link_start_homo,&
+       ' link_end',link_end_homo,' lim_dih',lim_dih,&
+       ' idihconstr_start_homo',idihconstr_start_homo,&
+       ' idihconstr_end_homo',idihconstr_end_homo
+#else
+      write (iout,*) "Not MPI"
+      link_start_homo=1
+      link_end_homo=lim_odl
+      idihconstr_start_homo=nnt+3
+      idihconstr_end_homo=lim_dih+nnt-1+3
+      write (iout,*) &
+       ' lim_odl',lim_odl,' link_start=',link_start_homo, &
+       ' link_end',link_end_homo,' lim_dih',lim_dih,&
+       ' idihconstr_start_homo',idihconstr_start_homo,&
+       ' idihconstr_end_homo',idihconstr_end_homo
+#endif
+      return
+      end subroutine homology_partition
+
 !-----------------------------------------------------------------------------
       end module control