24小时热门版块排行榜    

查看: 361  |  回复: 1

astringent

铜虫 (著名写手)

[交流] 【求助】segmentation fault 已有1人参与

when i execute the following program, segmentation fault always occur.
program main
--
do iat=1, nattot
                        if (((resname(iat).eq.'DC5'.or.resname(iat).eq.'DC ').and.&
                          (atomname(iat).eq.' N1 '.or.atomname(iat).eq.' N4 '.or.&
                           atomname(iat).eq.' N3 '.or.atomname(iat).eq.' O2 ')).or.&
                           ((resname(iat).eq.'DG3'.or.resname(iat).eq.'DG ').and.&
                           (atomname(iat).eq.' N9 '.or.atomname(iat).eq.' N7 '.or.&
                           atomname(iat).eq.' O6 '.or.atomname(iat).eq.' N1 '.or.&
                           atomname(iat).eq.' N2 '.or.atomname(iat).eq.' N3 ')).or.&
                           ((resname(iat).eq.'DA ').and.(atomname(iat).eq.' N9 '.or.&
                           atomname(iat).eq.' N7 '.or.atomname(iat).eq.' N6 '.or.&
                           atomname(iat).eq.' N1 '.or.atomname(iat).eq.' N3 ')).or.&
                           ((resname(iat).eq.'DT ').and.(atomname(iat).eq.' N1 '.or.&
                           atomname(iat).eq.' O4 '.or.atomname(iat).eq.' N3 '.or.&
                           atomname(iat).eq.' O2 '))) then
                           call findhbond &
                              (io,ih,iat,xxx,yyy,zzz,nattot,cell,ihbnum)
                           if(ihbnum.eq.1) then
                           acc(j)=iat
                           else
                           goto 200
                           endif
                       endif
                    enddo
                 enddo
                 if (acc(1)*acc(2)/=0) then
                    if ((resindex(acc(1))/=resindex(acc(2))+1).or.  &
                       (resindex(acc(1))/=resindex(acc(2))-1)) then
                       nhb=nhb+1
                    endif
                 endif
200     continue
           endif
         enddo
         sum=sum+nhb
      enddo
      avgnhb=sum/nstep
      write (nout,*) 'average cswb number is', avgnhb

      close(nout)
     end
how to solve this problem? thanks
回复此楼
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

astringent

铜虫 (著名写手)

this is my program, the last is wrong.
program main

open(nin,file='TRAJ1',status='old',form &
                ='unformatted')
      open(nout,file='cswb.out',form='formatted')
      open(21,file='check')
      call readmdinit (mdtype,nin)
      nhb = 0
      do istep=1, nstep

         call readmd  &
              (mdtype,nattot,nin,atomname,xxx,yyy,zzz,&
               cell,resname,resindex)
         open(npdb,file='newsystem.pdb',status='old')
         call readpdb (atomname,npdb,nattot,resname,resindex)
         close(npdb)
         sum=0

         do i=1, nattot
              if((atomname(i).eq.' O  ').and.(resname(i).eq.'WAT')) then
                 io = i
                 do j=1,2
                    acc(j)=0
                    ih=io+j
                    do iat=1, nattot
if (((resname(iat).eq.'DC5'.or.resname(iat).eq.'DC ').and.&
                          (atomname(iat).eq.' N1 '.or.atomname(iat).eq.' N4 '.or.&
                           atomname(iat).eq.' N3 '.or.atomname(iat).eq.' O2 ')).or.&
                           ((resname(iat).eq.'DG3'.or.resname(iat).eq.'DG ').and.&
                           (atomname(iat).eq.' N9 '.or.atomname(iat).eq.' N7 '.or.&
                           atomname(iat).eq.' O6 '.or.atomname(iat).eq.' N1 '.or.&
                           atomname(iat).eq.' N2 '.or.atomname(iat).eq.' N3 ')).or.&
                           ((resname(iat).eq.'DA ').and.(atomname(iat).eq.' N9 '.or.&
                           atomname(iat).eq.' N7 '.or.atomname(iat).eq.' N6 '.or.&
                           atomname(iat).eq.' N1 '.or.atomname(iat).eq.' N3 ')).or.&
                           ((resname(iat).eq.'DT ').and.(atomname(iat).eq.' N1 '.or.&
                           atomname(iat).eq.' O4 '.or.atomname(iat).eq.' N3 '.or.&
                           atomname(iat).eq.' O2 '))) then
                           call findhbond &
                              (io,ih,iat,xxx,yyy,zzz,nattot,cell,ihbnum)
                           if(ihbnum.eq.1) then
                           acc(j)=iat
                           else
                           goto 200
                           endif
                       endif
                    enddo
                 enddo
                 if (acc(1)*acc(2)/=0) then
                    if ((resindex(acc(1))/=resindex(acc(2))+1).or.  &
                       (resindex(acc(1))/=resindex(acc(2))-1)) then
                       nhb=nhb+1
                    endif
                 endif
200     continue
           endif
         enddo
         sum=sum+nhb
      enddo
      avgnhb=sum/nstep
      write (nout,*) 'average cswb number is
2楼2010-11-22 18:36:45
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 astringent 的主题更新
普通表情 高级回复 (可上传附件)
信息提示
请填处理意见