working microcanonical for CA2+ protein
[unres4.git] / source / unres / io.f90
index 584c4ed..dbc5ce0 100644 (file)
 !      include 'COMMON.BOUNDS'
 !      include 'COMMON.MD'
 !      include 'COMMON.SETUP'
-      character(len=4),dimension(:),allocatable :: sequence    !(maxres)
+      character(len=4),dimension(:,:),allocatable :: sequence  !(maxres,maxmolecules)
 !      integer :: rescode
 !      double precision x(maxvar)
       character(len=256) :: pdbfile
-      character(len=320) :: weightcard
+      character(len=800) :: weightcard
       character(len=80) :: weightcard_t!,ucase
 !      integer,dimension(:),allocatable :: itype_pdb   !(maxres)
 !      common /pizda/ itype_pdb
       allocate(c(3,2*maxres+2)) !(3,maxres2+2) maxres2=2*maxres
       allocate(dc(3,0:2*maxres)) !(3,0:maxres2)
       allocate(itype(maxres,5)) !(maxres)
+      allocate(istype(maxres))
 !
 ! Zero out tables.
 !
       call reada(weightcard,'WTURN6',wturn6,1.0D0)
       call reada(weightcard,'WSCCOR',wsccor,1.0D0)
       call reada(weightcard,'WSTRAIN',wstrain,1.0D0)
+      call reada(weightcard,'WVDWPP_NUCL',wvdwpp_nucl,1.0D0)
+      call reada(weightcard,'WELPP',welpp,1.0d0)
+      call reada(weightcard,'WVDWPSB',wvdwpsb,1.0d0)
+      call reada(weightcard,'WELPSB',welpsb,1.0D0)
+      call reada(weightcard,'WVDWSB',wvdwsb,1.0d0)
+      call reada(weightcard,'WELSB',welsb,1.0D0)
+      call reada(weightcard,'WBOND_NUCL',wbond_nucl,1.0D0)
+      call reada(weightcard,'WANG_NUCL',wang_nucl,1.0D0)
+      call reada(weightcard,'WSBLOC',wsbloc,1.0D0)
+      call reada(weightcard,'WTOR_NUCL',wtor_nucl,1.0D0)
+      call reada(weightcard,'WTORD_NUCL',wtor_d_nucl,1.0D0)
+      call reada(weightcard,'WCORR_NUCL',wcorr_nucl,1.0D0)
+      call reada(weightcard,'WCORR3_NUCL',wcorr3_nucl,1.0D0)
       call reada(weightcard,'WBOND',wbond,1.0D0)
       call reada(weightcard,'WTOR',wtor,1.0D0)
       call reada(weightcard,'WTORD',wtor_d,1.0D0)
       call reada(weightcard,'DELT_CORR',delt_corr,0.5d0)
       call reada(weightcard,'TEMP0',temp0,300.0d0)
       if (index(weightcard,'SOFT').gt.0) ipot=6
+      call reada(weightcard,'WBOND_NUCL',wbond_nucl,1.0D0)
+      call reada(weightcard,'WCATCAT',wcatcat,0.0d0)
+      call reada(weightcard,'WCATPROT',wcatprot,0.0d0)
 ! 12/1/95 Added weight for the multi-body term WCORR
       call reada(weightcard,'WCORRH',wcorr,1.0D0)
       if (wcorr4.gt.0.0d0) wcorr=wcorr4
          enddo
         endif  
       endif
-
+      
       if (indpdb.eq.0) then
+      nres_molec(:)=0
+        allocate(sequence(maxres,5))
+
+     if (protein) then
 ! Read sequence if not taken from the pdb file.
-        read (inp,*) nres
+        molec=1
+        read (inp,*) nres_molec(molec)
 !        print *,'nres=',nres
-        allocate(sequence(nres))
         if (iscode.gt.0) then
-          read (inp,'(80a1)') (sequence(i)(1:1),i=1,nres)
+          read (inp,'(80a1)') (sequence(i,molec)(1:1),i=1,nres_molec(molec))
         else
-          read (inp,'(20(1x,a3))') (sequence(i),i=1,nres)
+          read (inp,'(20(1x,a3))') (sequence(i,molec),i=1,nres_molec(molec))
         endif
 ! Convert sequence to numeric code
-        do i=1,nres
-          itype(i,1)=rescode(i,sequence(i),iscode)
+        
+        do i=1,nres_molec(molec)
+          itype(i,1)=rescode(i,sequence(i,molec),iscode,molec)
+        enddo
+       endif
+       if (nucleic) then
+! Read sequence if not taken from the pdb file.
+        molec=2
+        read (inp,*) nres_molec(molec)
+!        print *,'nres=',nres
+!        allocate(sequence(maxres,5))
+!        if (iscode.gt.0) then
+          read (inp,'(20a4)') (sequence(i,molec),i=1,nres_molec(molec))
+! Convert sequence to numeric code
+
+        do i=1,nres_molec(molec)
+          istype(i)=sugarcode(sequence(i,molec)(1:1),i)
+          itype(i,1)=rescode(i,sequence(i,molec)(2:2),iscode,molec)
         enddo
+       endif
+
+       if (ions) then
+! Read sequence if not taken from the pdb file.
+        molec=5
+        read (inp,*) nres_molec(molec)
+!        print *,'nres=',nres
+          read (inp,'(20(1x,a3))') (sequence(i,molec),i=1,nres_molec(molec))
+! Convert sequence to numeric code
+        print *,nres_molec(molec) 
+        do i=1,nres_molec(molec)
+          itype(i,1)=rescode(i,sequence(i,molec),iscode,molec)
+        enddo
+       endif
+       nres=0
+       do i=1,5
+        nres=nres+nres_molec(i)
+        print *,nres_molec(i)
+       enddo
+       
 ! Assign initial virtual bond lengths
 !elwrite(iout,*) "test_alloc"
         if(.not.allocated(vbld)) allocate(vbld(2*nres))
        write (iout,'(a)') 'Boundaries in phi angle sampling:'
        do i=1,nres
          write (iout,'(a3,i5,2f10.1)') &
-         restyp(itype(i,1)),i,phibound(1,i)*rad2deg,phibound(2,i)*rad2deg
+         restyp(itype(i,1),1),i,phibound(1,i)*rad2deg,phibound(2,i)*rad2deg
        enddo
 #ifdef MP
       endif
 #endif
       nct=nres
-!d      print *,'NNT=',NNT,' NCT=',NCT
-      if (itype(1,1).eq.ntyp1) nnt=2
-      if (itype(nres,1).eq.ntyp1) nct=nct-1
+      print *,'NNT=',NNT,' NCT=',NCT
+      if (itype(1,molnum(1)).eq.ntyp1_molec(molnum(1))) nnt=2
+      if (itype(nres,molnum(nres)).eq.ntyp1_molec(molnum(nres))) nct=nct-1
       if (pdbref) then
         if(me.eq.king.or..not.out1file) &
          write (iout,'(a,i3)') 'nsup=',nsup
             icont_ref(j,i)=icont_ref(j,i)+nstart_seq-nstart_sup
           enddo
           if(me.eq.king.or..not.out1file) &
-           write (2,*) i,' ',restyp(itype(icont_ref(1,i),1)),' ',&
+           write (2,*) i,' ',restyp(itype(icont_ref(1,i),1),1),' ',&
            icont_ref(1,i),' ',&
-           restyp(itype(icont_ref(2,i),1)),' ',icont_ref(2,i)
+           restyp(itype(icont_ref(2,i),1),1),' ',icont_ref(2,i)
         enddo
         endif
       endif
          it2=itype(i2,1)
          if (me.eq.king.or..not.out1file) &
           write (iout,'(2a,i3,3a,i3,a,3f10.3)') &
-          restyp(it1),'(',i1,') -- ',restyp(it2),'(',i2,')',dhpb(i),&
+          restyp(it1,1),'(',i1,') -- ',restyp(it2,1),'(',i2,')',dhpb(i),&
           ebr,forcon(i)
        enddo
        write (iout,'(a)')