24小时热门版块排行榜    

查看: 2819  |  回复: 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的回帖

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的回帖
查看全部 7 个回答

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的回帖

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的回帖
普通表情 高级回复 (可上传附件)
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 0703化学调剂 +6 妮妮ninicgb 2026-03-15 9/450 2026-03-16 16:40 by houyaoxu
[考研] 070303一志愿西北大学学硕310找调剂 +5 d如愿上岸 2026-03-12 8/400 2026-03-16 15:19 by peike
[考研] 327求调剂 +6 拾光任染 2026-03-15 11/550 2026-03-15 22:47 by 拾光任染
[考研] 294求调剂 +3 Zys010410@ 2026-03-13 4/200 2026-03-15 10:59 by zhq0425
[考研] 复试调剂 +3 呼呼?~+123456 2026-03-14 3/150 2026-03-14 16:53 by WTUChen
[考研] 267一志愿南京工业大学0817化工求调剂 +5 SUICHILD 2026-03-12 5/250 2026-03-14 14:53 by jean5056
[考研] 【0703化学调剂】-一志愿华中师范大学-六级475 +5 Becho359 2026-03-11 5/250 2026-03-14 11:35 by 哦哦123
[考研] 求调剂,一志愿江南大学环境工程085701 +3 Djdjj12 2026-03-10 4/200 2026-03-14 00:31 by JourneyLucky
[考研] 复试调剂 +9 Copy267 2026-03-10 9/450 2026-03-13 23:45 by userper
[考研] 0805,333求调剂 +3 112253525 2026-03-10 3/150 2026-03-13 23:42 by JourneyLucky
[考研] 材料与化工304求B区调剂 +5 邱gl 2026-03-11 6/300 2026-03-13 22:37 by JourneyLucky
[考研] 336求调剂 +6 Iuruoh 2026-03-11 6/300 2026-03-13 22:06 by JourneyLucky
[考研] 315求调剂 +9 小羊小羊_ 2026-03-11 10/500 2026-03-13 21:13 by SXNU李老师
[考研] 考研调剂 +4 芬达46 2026-03-12 4/200 2026-03-13 16:04 by ruiyingmiao
[考研] 材料专硕350 求调剂 +4 王金科 2026-03-12 4/200 2026-03-13 16:02 by ruiyingmiao
[考研] 0817化学工程与技术考研312分调剂 +3 T123 tt 2026-03-12 3/150 2026-03-13 10:49 by houyaoxu
[考博] 26读博 +4 Rui135246 2026-03-12 10/500 2026-03-13 07:15 by gaobiao
[考研] 333求调剂 +3 152697 2026-03-12 4/200 2026-03-13 07:08 by Iveryant
[考研] 081200-11408-276学硕求调剂 +3 崔wj 2026-03-12 4/200 2026-03-12 19:33 by 求调剂zz
[考研] 研究生招生 +3 徐海涛11 2026-03-10 7/350 2026-03-12 14:26 by 徐海涛11
信息提示
请填处理意见