24小时热门版块排行榜    

CyRhmU.jpeg
查看: 2730  |  回复: 6

astringent

铜虫 (著名写手)

[交流] 【求助】在编译时出错已有5人参与

when i execute the program, the following error appear:

At line 111 of file readmd.f90 (unit = 20, file = 'TRAJ1')
Fortran runtime error: I/O past end of record on unformatted file

How can solve this, please help me, thanks.
回复此楼

» 猜你喜欢

» 本主题相关价值贴推荐,对您同样有帮助:

已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

zyj8119

木虫 (著名写手)

引用回帖:
Originally posted by astringent at 2010-11-15 19:23:32:
when i execute the program, the following error appear:

At line 111 of file readmd.f90 (unit = 20, file = 'TRAJ1')
Fortran runtime error: I/O past end of record on unformatted file

How can s ...

无源代码无真相。。
好好学习,天天向上。
2楼2010-11-15 22:02:38
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

astringent

铜虫 (著名写手)

这个是源文件
open(nin,file='TRAJ1',status='old',form &
                ='unformatted')
      open(nout,file='csbw.out')
        do istep=1, nstep   
               call readmdinit (mdtype,nin)
               call readmd  &
                   (mdtype,nattot,nin,atomname,xxx,yyy,zzz,cell)

! loop over all waters

          do i=1, nattot
              if (('atomname'.eq.'O').and.('resname'.eq.'WAT')) then
                    io = i
                    ih1 = io+1
                    ih2 = io+2
              call test &
               (io,ih1,ia1,xxx,yyy,zzz,nattot,cell,atomname,resname,ihbnum)
                  if (ihbnum.eq.1)   then
                       acc(j)=ia1
                        call test  &
                    (io,ih2,ia2,xxx,yyy,zzz,nattot,cell, &
                     atomname,resname,ihbnum)
                        if (ihbnum.eq.1)   then
                             if (resindex(ia1).eq.resindex(ia2)+1 &
                               .or. resindex(ia1).eq. resindex(ia2)-1) then
                            write(*,*) 'not find a cswb'
                            else
                            write(*,*) 'find a cswb'
                            nhb=nhb+1  
                            endif
                        endif
                   endif
                 endif
              enddo
           sum=sum+nhb
          do j=1,nattot
          write (nout,"('acceptor is',i2)" acc(j)
          enddo
            enddo
          avgnhb=sum/nstep
          write (nout,"('avergaed number is',i2)" avgnhb
          close(nout)
         end
3楼2010-11-16 03:01:44
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

astringent

铜虫 (著名写手)

astringent  
新虫 (小有名气)



程序强帖: 0
金币: 72.5
帖子: 112
在线: 14.9小时
虫号: 900839
注册: 2009-11-12
状态: 在线
       
下面是各个子程序
subroutine findhbond &
          (io,ih,iat,xxx,yyy,zzz,nattot,cell,ihbnum)

      implicit none
      include 'constants.h'

      integer io,ih,iat,nattot,ihbnum
      double precision xxx(nattot),yyy(nattot),zzz(nattot)
      double precision cell(3)
      double precision theta,thetamax,roamax,rhamax
      double precision dx0,dy0,dz0,r0
      double precision dx1,dy1,dz1,r1
      double precision dx2,dy2,dz2,r2

      thetamax = 30.d0
      roamax = 3.5d0
      rhamax = 2.45d0
      ihbnum = 0

      call bondcalculation(io,ih,xxx,yyy,zzz,nattot,cell,dx0,dy0,dz0,r0)
      call bondcalculation(io,iat,xxx,yyy,zzz,nattot,cell,dx1,dy1,dz1,r1)
           if (r1.lt.roamax) then
              theta = dacos(dx0*dx1+dy0*dy1+dz0*dz1)
                  if(theta.lt.thetamax) then
                      call bondcalculation &
                         (ih,iat,xxx,yyy,zzz,nattot,cell,dx2,dy2,dz2,r2)
                        if (r2.lt.rhamax) then
                              ihbnum = 1
                        endif
                   endif
           endif
                 
      return
      end
subroutine test &
          (io,ih,ia,xxx,yyy,zzz,nattot,cell,atomname,resname,ihbnum)

      implicit none
      include 'constants.h'

      integer io,ih,ia,nattot,ihbnum
      double precision xxx(nattot),yyy(nattot),zzz(nattot)
      double precision cell(*)
      character*4 atomname(nattot),resname(nattot)

      integer iat

      ia = 0
      ihbnum = 0

      do iat=1, nattot
         if((('resname'.eq.'DC5').or.('resname'.eq.'DC')).and.&
          ('atomname'.eq.'N1'.or.'atomname'.eq.'N4'.or.'atomname'.eq.'N3'&
                &.or.'atomname'.eq.'O2')) then
                  call findhbond &
                   (io,ih,iat,xxx,yyy,zzz,nattot,cell,ihbnum)

          elseif (('resname'.eq.'DG3'.or.'resname'.eq.'DG').and.&
               &('atomname'.eq.'N9'.or.'atomname'.eq.'N7'.or.'atomname'.eq.&
                  &'O6'.or.'atomname'.eq.'N1'.or.'atomname'.eq.'N2'&
                &.or.'atomname'.eq.'N3')) then
              call findhbond &
                   (io,ih,iat,xxx,yyy,zzz,nattot,cell,ihbnum)

         elseif (('resname'.eq.'DA').and.('atomname'.eq.'N9'.or.&
               'atomname'.eq.'N7'.or.'atomname'.eq.  &
              'N6'.or.'atomname'.eq.'N1'&
                &.or.'atomname'.eq.'N3')) then
              call findhbond  &
                   (io,ih,iat,xxx,yyy,zzz,nattot,cell,ihbnum)

         elseif (('resname'.eq.'DT').and.('atomname'.eq.'N1'.or. &
              'atomname'.eq.'O4'.or.'atomname' &
               .eq.'N3'.or.'atomname'.eq.'O2')) then
              call findhbond &
                   (io,ih,iat,xxx,yyy,zzz,nattot,cell,ihbnum)
          endif
          if (ihbnum.eq.1) then
            ia=iat
          endif
         enddo
      
      return
      end
  subroutine bondcalculation &
          (i1,i2,xxx,yyy,zzz,nattot,cell,dx,dy,dz,roh)

      implicit none
      integer i1,i2,nattot
      double precision xxx(nattot),yyy(nattot),zzz(nattot)
      double precision cell(3),dx,dy,dz
      double precision xo,yo,zo,xh,yh,zh,roh

      xo = xxx(i1)
      yo = yyy(i1)
      zo = zzz(i1)
      xh = xxx(i2)
      yh = yyy(i2)
      zh = zzz(i2)
      dx = xh - xo
      dy = yh - yo
      dz = zh - zo
      dx = dx - anint(dx/cell(1))*cell(1)
      dy = dy - anint(dy/cell(2))*cell(2)
      dz = dz - anint(dz/cell(3))*cell(3)
      roh = dsqrt(dx**2+dy**2+dz**2)
      dx = dx / roh
      dy = dy / roh
      dz = dz / roh
      return
      end

subroutine readmd  &
          (mdtype,nattot,nin,atomname,xxx,yyy,zzz,cell)

      implicit none
      integer mdtype,nattot,nin
      double precision :: xxx(nattot),yyy(nattot),zzz(nattot)
      real*4 :: x_dcd(nattot),y_dcd(nattot),z_dcd(nattot)
      double precision cell(3)
      character*4 atomname(nattot)
      
      integer iatm,i
      double precision xtable(6)

      integer                             ::npdb=70
      
      if (mdtype.eq.0) then         ! original TINKER
         read(nin,*)
         do iatm=1, nattot
            read(nin,'(i6,2x,a2,x,3f12.6)')i,atomname(iatm),xxx(iatm),&
                yyy(iatm),zzz(iatm)
         enddo
      elseif (mdtype.eq.1) then     ! modified TINKER      
         read(nin,*)
         read(nin,*)
         do iatm=1, nattot
            read(nin,'(a2,9x,6f12.4)')atomname(iatm),xxx(iatm), &
                 yyy(iatm), zzz(iatm)
         enddo
      elseif ((mdtype.eq.2).or.(mdtype.eq.3)) then
      !  DLPOLY
         read(nin,*)
         read(nin,*)
         read(nin,*)
         read(nin,*)
         do iatm=1, nattot
            read(nin,'(a2,x,6f10.5)')atomname(iatm),xxx(iatm), &
                yyy(iatm), zzz(iatm)         
         enddo        
      elseif (mdtype.eq.4) then
      !   Orsay - FX COUDERT
         read(nin,*)
         read(nin,*)
         do iatm=1, nattot
            read(nin,'(2x,a2,6x,3f14.5)')atomname(iatm),xxx(iatm),&
              yyy(iatm),zzz(iatm)
         enddo        
      elseif (mdtype.eq.5) then
     !  xyz
         read(nin,*)
         read(nin,*)
         do iatm=1, nattot
            read(nin,'(a2,8x,3f12.4)')atomname(iatm),xxx(iatm),&
       yyy(iatm),zzz(iatm)
         enddo        

      elseif (mdtype.eq.6) then
  !    dcd binary
             read(nin) (xtable(i),i=1,6)
             read(nin) (x_dcd(i),i=1,nattot)
             read(nin) (y_dcd(i),i=1,nattot)
             read(nin) (z_dcd(i),i=1,nattot)
            

             cell(1)=xtable(1)
             cell(2)=xtable(3)
             cell(3)=xtable(6)


             OPEN(npdb,file='system.pdb',status='old')
             call read_pdb(atomname,npdb,nattot)


             CLOSE(npdb)

! send from single precision to double

             do i=1,nattot
                xxx(i)=x_dcd(i)
                yyy(i)=y_dcd(i)
                zzz(i)=z_dcd(i)
             enddo
            
      
      endif


      return
      end


      subroutine readmdinit(mdtype,nin)
         
      implicit none
      integer mdtype,nin

! local variables --------------

      integer      ntitle,nset,istart,icntrl(6),jcntrl(9)
      character*80 title(10)
      character*4 hdr
      double precision       delta
      integer      i,nfr,dfr,natms



      if (mdtype.eq.3) then
         read(nin,*)
         read(nin,*)
      elseif(mdtype.eq.6) then
         read(nin) hdr,nfr,istart,dfr,(icntrl(i),i=1,6),delta,(jcntrl(i) &
            ,i=1,9)         
         read(nin) ntitle,(title(i),i=1,ntitle)
         read(nin) natms
      endif

      return
      end



      subroutine read_pdb(atomname,n,nattot)
      
      integer                                            ::n,nattot
      character(len=4),dimension(nattot),intent(inout)   ::atomname
      character(len=4),dimension(nattot)                 ::resname
      character(len=4),dimension(nattot)                 ::itmp
      integer,dimension(nattot)                          ::resindex,label  
      
      
!--- local variables -------------------

      integer :: i

      do i=1,nattot

         read(n,1000,err=20,end=20) itmp,label(i),atomname(i),resname(i),&
       resindex(i)

      enddo
      

20   CONTINUE

1000 format(3x,a4,6x,i5,a4,x,a4,3x,i5)
4楼2010-11-16 03:22:17
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

gd88

金虫 (小有名气)

★ ★ ★
小木虫(金币+0.5):给个红包,谢谢回帖交流
nono2009(金币+2):鼓励应助 2010-11-17 10:14:06
LZ,今天Fortran的问题小爆发哦。

从错误信息来看,TRAJ1这个文件,格式错误。

另,你读取数据的程序,用F90的吗?
那么,open(nin,file='TRAJ1',status='old'
里面的  old
Fortran的标准这么多年可以是变化的,
你先了解一下  f90 和 f77 的不同把,格式方面。
5楼2010-11-17 02:03:42
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

cean

金虫 (职业作家)

屌绳一条

★ ★
小木虫(金币+0.5):给个红包,谢谢回帖交流
nono2009(金币+1):鼓励参与 2010-11-21 07:15:28
“Fortran runtime error: I/O past end of record on unformatted file”

There is not enough data to be read.
To do great work, you have to have a pure mind.
6楼2010-11-20 20:39:35
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

yangdafaok

铁杆木虫 (正式写手)

nono2009:何解? 2010-11-21 07:15:49
mayishi
掌握命运的不是人的指纹,而是拳头!
7楼2010-11-20 20:47:24
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 astringent 的主题更新
普通表情 高级回复(可上传附件)
信息提示
请填处理意见