24小时热门版块排行榜    

查看: 2963  |  回复: 8
当前只显示满足指定条件的回帖,点击这里查看本话题的所有回帖

chk0521

金虫 (初入文坛)

[交流] 【求助成功】Band-procar 和Dos-procar 程序执行出错 已有8人参与

我从版内下载的分析PROCAR的程序Band-procar.f 和Dos-procar.f 通过g77 编译成可执行文件。但是执行后出现segmentation fault (core dumped)错误提示。这是为什么啊?我上网查了一下这表示指针使用出错。我的编程水平太差实在查不出问题在哪。麻烦哪位高人指点一下,十分感谢!以下是源程序
    implicit real*8(a-h,o-z)
      parameter (nbd = 200)
      parameter (nkd = 500)
      parameter (nxd = 300)
      parameter (natmd = 20)
      dimension a(3,3),b(3,3),c(3),e(nkd,nbd),sk(nkd,3)
      dimension xx(nxd) ,wei(nkd)
      dimension dump(20),oc(nkd,nbd,natmd,4)
      open(7,file='PROCAR',form='FORMATTED',status='OLD')
      pi = 3.141592654
      read(7,103) dump                    

      write(*,*) 'Spin polarized calculation? (no=1,yes=2):'
      read (*,*) ispin
      if ((ispin.ne.1).and.(ispin.ne.2)) then
      write(*,*) ' INPUT ERROR, ispin must equal to 1 or 2 '
      stop
      endif

c     write(*,*) 'Enter # of interval (npoints) and division (ndiv):'
c     read (*,*) npoints,ndiv
      open(9,file='KPOINTS',form='FORMATTED',status='OLD')
      read(9,100) temp
      read(9,*) ndiv

      write(*,*) 'Enter the range of energy to plot:'
      read (*,*) er1,er2
      emin=min(er1,er2)
      emax=max(er1,er2)
      write(*,*) 'Enter the value of fermi energy:'
      read(*,*)  ef

      if (ispin.eq.1) then
      open(11,file='band.dat')
      elseif (ispin.eq.2) then
      open(11,file='band-up.dat')
      open(12,file='band-dn.dat')
      endif

      open(8,file='POSCAR',form='FORMATTED',status='OLD')
      read(8,100) temp
c      write(6,100) temp
100   format(20a4)
      read (8,*) aa
c      WRITE(6,*) aa
c   
c      *** read lattice constant from POSCAR**
c            
      do i=1,3
         read (8,*) (a(i,j),j=1,3)
c       WRITE(6,500) (a(i,j),j=1,3)
500   format (3f12.8)
      enddo
      do i=1,3
         do j=1,3
         a(i,j)=aa*a(i,j)
         enddo
c       WRITE(6,500) (a(i,j),j=1,3)
      enddo
c
c     *** read lattice vector from POSCAR***
c
      volume=a(1,1)*a(2,2)*a(3,3)+a(1,2)*a(2,3)*a(3,1)
     &+a(1,3)*a(2,1)*a(3,2)-a(1,1)*a(2,3)*a(3,2)
     &-a(1,2)*a(2,1)*a(3,3)-a(1,3)*a(2,2)*a(3,1)
      do i=1,3
          if (i .eq. 1) then
            j=2
            k=3
          else if (i .eq. 2) then
            j=3
            k=1
          else
            j=1
            k=2
          endif
        c(1)=a(j,2)*a(k,3)-a(j,3)*a(k,2)
        c(2)=a(j,3)*a(k,1)-a(j,1)*a(k,3)
        c(3)=a(j,1)*a(k,2)-a(j,2)*a(k,1)
        do j=1,3
           b(i,j)=2*pi*c(j)/volume
c         WRITE (6,*) b(i,j)
        enddo
       enddo


      do 9000 isp=1,ispin

      read(7,104) nk,nband,nion
      do 1000 k = 1,nk
      read(7,103) dump
      read(7,105) kp,(sk(k,j),j=1,3),wei(k)
c     write(6,105) kp,(sk(k,j),j=1,3),wei(k)
      read(7,103) dump
      do  nb = 1,nband
      read(7,106) nb1,e(k,nb),occ
c     write(6,106) nb1,e(k,nb),occ
      read(7,103) dump
      read(7,103) dump
c     write(6,*) 'nion=',nion
      niont = nion +1
      if (nion .eq. 1) niont = 1
      do  ion = 1,niont
      read(7,107) (oc(k,nb,ion,j),j=1,4)
c     write(6,107) (oc(k,nb,ion,j),j=1,4)
      enddo
      read(7,103) dump
c     write(6,103) dump
      enddo
1000 continue

      weight = 0.0
      do k = 1, nk
      weight = weight + wei(k)
      enddo

      do k = 1,nk
      wei(k) =  wei(k) / weight
      enddo

101  format(10x,f9.5)
102  format(f10.5)
103  format(20a4)
104  format(16x,i3,20x,i5,19x,i4)
105  format(10x,i3,5x,3f11.8,13x,f11.8)
106  format(4x,i4,9x,f14.8,7x,f12.8)
107  format(3x,4f7.3)


c
c     *** find reciprocal lattice vector ***
      xx(1) = 0.0
      nn = 1
      do k = 1,nk-1
      dkx=(sk(k+1,1)-sk(k,1))*b(1,1) + (sk(k+1,2)-sk(k,2))*b(2,1)
     &   + (sk(k+1,3)- sk(k,3))*b(3,1)
      dky=(sk(k+1,1)-sk(k,1))*b(1,2) + (sk(k+1,2)-sk(k,2))*b(2,2)
     &   + (sk(k+1,3)- sk(k,3))*b(3,2)
      dkz=(sk(k+1,1)-sk(k,1))*b(1,3) + (sk(k+1,2)-sk(k,2))*b(2,3)
     &   + (sk(k+1,3)- sk(k,3))*b(3,3)
      del =  sqrt ( dkx**2 + dky**2 + dkz**2 )
      nn = nn +1
      xx(nn) = xx(nn-1) + del
      enddo

      do n=1,nband
        if (mod(n,2).ne.0) then
         do k=1,nk
          ee = e(k,n) - ef
          if ( ee .gt. emax ) ee = emax
          if ( ee .lt. emin ) ee = emin
         write (10+isp,300) xx(k),ee
         enddo
        elseif (mod(n,2).eq.0) then
         do i=nk,1,-1
          ee = e(i,n) - ef
          if ( ee .gt. emax ) ee = emax
          if ( ee .lt. emin ) ee = emin
          write (10+isp,300) xx(i),ee
         enddo
        endif
      enddo
300   format (f12.8,2x,f12.8)

      if (mod(nband,2) .ne. 0) then
          write (10+isp,300) xx(nk),emin
          write (10+isp,300) xx(1),emin
      else
          write (10+isp,300) xx(1),emin
      endif
c
c     *** write xx-ee ***
c
        npoints=nk/ndiv
       do n=2,npoints
         kk=(n-1)*ndiv
        write (10+isp,300) xx(kk),emin
        write (10+isp,300) xx(kk),emax
        write (10+isp,300) xx(kk),emin
      enddo
        write (10+isp,300) xx(nk),emin
        write (10+isp,300) xx(nk),emax
        write (10+isp,300) xx(1),emax
        write (10+isp,300) xx(1),emin
        zero=0.0
        write (10+isp,300) xx(1),zero
        write (10+isp,300) xx(nk),zero

9000  continue

      stop
      end

[ Last edited by chk0521 on 2010-6-25 at 16:36 ]
回复此楼

» 猜你喜欢

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

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

repent03

金虫 (小有名气)


小木虫: 金币+0.5, 给个红包,谢谢回帖
据本身前经验 只要修改parameter里面的数字 增大即可
9楼2012-03-22 00:45:22
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
查看全部 9 个回答

lvjian8596

木虫 (小有名气)

★ ★
小木虫(金币+0.5):给个红包,谢谢回帖交流
zzy870720z(金币+1):感谢交流 2010-06-24 08:50:43
segmentation fault (core dumped)出现这个问题很有可能是数组越界!
程序本身没有问题,但是当你的数据过大时可能出现问题!
比如一个数组a(100),但是你有200个数据读进来,这时可能出现这个问题!
2楼2010-06-24 08:44:53
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

chk0521

金虫 (初入文坛)

zzy870720z:如果问题解决,帮忙把【求助】改为【求助成功】,谢谢合作,如果在整理出解决办法,给予奖励,呵呵 2010-06-24 17:32:28
谢谢斑竹!确实是数组越界。已经解决了:)

[ Last edited by chk0521 on 2010-6-25 at 16:37 ]
3楼2010-06-24 15:51:51
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

calos818

木虫 (著名写手)

新人菜鸟


小木虫(金币+0.5):给个红包,谢谢回帖交流
引用回帖:
Originally posted by chk0521 at 2010-06-24 15:51:51:
谢谢斑竹!确实是数组越界。已经解决了:)

[ Last edited by chk0521 on 2010-6-25 at 16:37 ]

请问你做了哪些修改的,麻烦你提示下,谢谢
4楼2010-10-24 18:23:05
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
普通表情 高级回复 (可上传附件)
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 材料工程专硕调剂 +5 204818@lcx 2026-03-17 6/300 2026-03-18 22:55 by 204818@lcx
[考研] 0703化学调剂 +7 妮妮ninicgb 2026-03-15 11/550 2026-03-18 19:48 by macy2011
[考研] 295求调剂 +3 一志愿京区211 2026-03-18 5/250 2026-03-18 17:03 by zhaoqian0518
[考研] 材料与化工一志愿南昌大学327求调剂推荐 +8 Ncdx123456 2026-03-13 9/450 2026-03-18 14:40 by haxia
[考研] 0703化学求调剂 总分331 +3 ZY-05 2026-03-13 3/150 2026-03-18 10:58 by macy2011
[考研] 0703化学336分求调剂 +6 zbzihdhd 2026-03-15 7/350 2026-03-18 09:53 by zhukairuo
[考研] 293求调剂 +11 zjl的号 2026-03-16 16/800 2026-03-18 08:10 by zhukairuo
[考博] 26博士申请 +3 1042136743 2026-03-17 3/150 2026-03-17 23:30 by 轻松不少随
[考研] 考研求调剂 +3 橘颂. 2026-03-17 4/200 2026-03-17 21:43 by 有只狸奴
[考研] 277调剂 +5 自由煎饼果子 2026-03-16 6/300 2026-03-17 19:26 by 李leezz
[考研] 304求调剂 +5 素年祭语 2026-03-15 5/250 2026-03-16 17:00 by 我的船我的海
[考研] 070300化学学硕求调剂 +6 太想进步了0608 2026-03-16 6/300 2026-03-16 16:13 by kykm678
[考研] 283求调剂 +10 小楼。 2026-03-12 14/700 2026-03-16 16:08 by 13811244083
[考研] 26考研一志愿中国石油大学(华东)305分求调剂 +3 嘉年新程 2026-03-15 3/150 2026-03-15 13:58 by 哈哈哈哈嘿嘿嘿
[考研] 0856专硕279求调剂 +5 加油加油!? 2026-03-15 5/250 2026-03-15 11:58 by 2020015
[考研] 304求调剂 +6 Mochaaaa 2026-03-12 7/350 2026-03-13 22:18 by 星空星月
[考研] 求材料调剂 085600英一数二总分302 前三科235 精通机器学习 一志愿哈工大 +4 林yaxin 2026-03-12 4/200 2026-03-13 22:04 by 星空星月
[考研] 0856材料与化工301求调剂 +5 奕束光 2026-03-13 5/250 2026-03-13 22:00 by 星空星月
[考研] 工科278分求调剂 +5 周慢热啊 2026-03-12 7/350 2026-03-13 15:49 by JourneyLucky
[考研] 0817化学工程与技术考研312分调剂 +3 T123 tt 2026-03-12 3/150 2026-03-13 10:49 by houyaoxu
信息提示
请填处理意见