bug fix after Ana and cluster lipid (still in progress)
[unres.git] / source / cluster / wham / src-M / read_coords.F
index 37951bd..2911e60 100644 (file)
@@ -178,13 +178,13 @@ c through a ring.
 #endif
         endif
 
-#define DEBUG
+C#define DEBUG
 #ifdef DEBUG
         write (iout,*) "Opening file ",intinname(:ilen(intinname))
         write (iout,*) "lenrec",lenrec_in
         call flush(iout)
 #endif
-#undef DEBUG
+C#undef DEBUG
 c        write (iout,*) "maxconf",maxconf
         i=0
         do while (.true.)
@@ -218,10 +218,17 @@ c          call flush(iout)
             call xdrfint_(ixdrf, nss, iret)
             if (iret.eq.0) goto 101
             do j=1,nss
+           if (dyn_ss) then
+            call xdrfint(ixdrf, idssb(j), iret)
+            call xdrfint(ixdrf, jdssb(j), iret)
+        idssb(j)=idssb(j)-nres
+        jdssb(j)=jdssb(j)-nres
+           else
               call xdrfint_(ixdrf, ihpb(j), iret)
               if (iret.eq.0) goto 101
               call xdrfint_(ixdrf, jhpb(j), iret)
               if (iret.eq.0) goto 101
+           endif
             enddo
             call xdrffloat_(ixdrf,reini,iret)
             if (iret.eq.0) goto 101
@@ -243,10 +250,15 @@ c            write (iout,*) "nss",nss
             call flush(iout)
             if (iret.eq.0) goto 101
             do k=1,nss
+           if (dyn_ss) then
+            call xdrfint(ixdrf, idssb(k), iret)
+            call xdrfint(ixdrf, jdssb(k), iret)
+            else
               call xdrfint(ixdrf, ihpb(k), iret)
               if (iret.eq.0) goto 101
               call xdrfint(ixdrf, jhpb(k), iret)
               if (iret.eq.0) goto 101
+            endif
             enddo
             call xdrffloat(ixdrf,reini,iret)
             if (iret.eq.0) goto 101
@@ -271,6 +283,7 @@ c            write (iout,*) "nss",nss
               enddo
             enddo
           endif
+C#define DEBUG
 #ifdef DEBUG
           write (iout,'(5hREAD ,i5,3f15.4,i10)') 
      &     jj+1,energy(jj+1),entfac(jj+1),
@@ -280,6 +293,7 @@ c            write (iout,*) "nss",nss
           write (iout,'(8f10.5)') ((c(j,i+nres),j=1,3),i=nnt,nct)
           call flush(iout)
 #endif
+C#undef DEBUG
           call add_new_cconf(jjj,jj,jj_old,icount,Next)
         enddo
   101   continue
@@ -379,7 +393,8 @@ c------------------------------------------------------------------------------
       chalen=int((nct-nnt+2)/symetr)
       call int_from_cart1(.false.)
       do j=nnt+1,nct
-        if (vbld(j).lt.2.0d0 .or. vbld(j).gt.5.0d0) then
+        if ((vbld(j).lt.2.0d0 .or. vbld(j).gt.5.0d0)
+     &      .and.(itype(j).ne.ntyp1)) then
          if (j.gt.2) then
           if (itel(j).ne.0 .and. itel(j-1).ne.0) then
           write (iout,*) "Conformation",jjj,jj+1
@@ -404,8 +419,8 @@ c------------------------------------------------------------------------------
       enddo
       do j=nnt,nct
         itj=itype(j)
-        if (itype(j).ne.10 .and. (vbld(nres+j)-dsc(iabs(itj))).gt.2.0d0)
-     &  then
+        if (itype(j).ne.10 .and. (vbld(nres+j)-dsc(iabs(itj))).gt.2.0d0
+     &  .and. itype(j).ne.ntyp1) then
           write (iout,*) "Conformation",jjj,jj+1
           write (iout,*) "Bad CA-SC bond length",j," ",vbld(nres+j)
           write (iout,*) "The Cartesian geometry is:"
@@ -628,10 +643,11 @@ c------------------------------------------------------------------------------
       integer i,j,ij,ii,iii
       integer len
       character*16 form,acc
-      character*32 nam
+      character*80 nam
 c
 c Read conformations off a DA scratchfile.
 c
+C#define DEBUG
 #ifdef DEBUG
       write (iout,*) "DAREAD_COORDS"
       write (iout,*) "istart_conf",istart_conf," iend_conf",iend_conf
@@ -647,10 +663,17 @@ c
         write (iout,*) "Reading binary file, record",iii," ii",ii
         call flush(iout)
 #endif
+        if (dyn_ss) then
+        read(icbase,rec=iii) ((allcart(j,i,ij),j=1,3),i=1,nres),
+     &    ((allcart(j,i,ij),j=1,3),i=nnt+nres,nct+nres),
+c     &    nss_all(ij),(ihpb_all(i,ij),jhpb_all(i,ij),i=1,nss),
+     &    entfac(ii),rmstb(ii)
+        else
         read(icbase,rec=iii) ((allcart(j,i,ij),j=1,3),i=1,nres),
      &    ((allcart(j,i,ij),j=1,3),i=nnt+nres,nct+nres),
      &    nss_all(ij),(ihpb_all(i,ij),jhpb_all(i,ij),i=1,nss),
      &    entfac(ii),rmstb(ii)
+         endif
 #ifdef DEBUG
         write (iout,*) ii,iii,ij,entfac(ii)
         write (iout,'(8f10.5)') ((allcart(j,i,ij),j=1,3),i=1,nres)
@@ -661,7 +684,10 @@ c
      &    jhpb_all(i,ij),i=1,nss)
         call flush(iout)
 #endif
+C#undef DEBUG
       enddo
+      write (iout,*) "just before leave"
+      call flush(iout)
       return
       end
 c------------------------------------------------------------------------------
@@ -704,10 +730,17 @@ c
         write (iout,*) "Writing binary file, record",iii," ii",ii
         call flush(iout)
 #endif
+       if (dyn_ss) then
+        write(unit_out,rec=iii) ((allcart(j,i,ij),j=1,3),i=1,nres),
+     &    ((allcart(j,i,ij),j=1,3),i=nnt+nres,nct+nres),
+c     &    nss_all(ij),(ihpb_all(i,ij),jhpb_all(i,ij),i=1,nss_all(ij))
+     &    entfac(ii),rmstb(ii)
+        else
         write(unit_out,rec=iii) ((allcart(j,i,ij),j=1,3),i=1,nres),
      &    ((allcart(j,i,ij),j=1,3),i=nnt+nres,nct+nres),
      &    nss_all(ij),(ihpb_all(i,ij),jhpb_all(i,ij),i=1,nss_all(ij)),
      &    entfac(ii),rmstb(ii)
+       endif
 #ifdef DEBUG
         write (iout,'(8f10.5)') ((allcart(j,i,ij),j=1,3),i=1,nres)
         write (iout,'(8f10.4)') ((allcart(j,i,ij),j=1,3),i=nnt+nres,