24小时热门版块排行榜    

CyRhmU.jpeg
查看: 2066  |  回复: 9

新丰客

木虫 (小有名气)

[求助] 程序出现错误提示There has been an internal compiler error (C0000005)求解答已有1人参与

需要提取目标文件中的k点及band的数据,编了这两段但在fortran编译器上运行时都出现错误提示
There has been an internal compiler error (C0000005).请问该如何修改,另外,read语句在读取文本文档时是一个个读取直至截尾么?
怎样使在读取过程中遇到某一标识即结束呢?谢谢

其一是
module typedef
implicit none
type kpoint
real:
real::p
real::q
end type

type band
real::z,x,c,v,n,m,w,y
end type
end module



program shujutiqu
use typedef
implicit none
type(kpoint)::a
type(band)::b

integer::i,N
parameter(N=28)
open(10,access="direct",form="formatted",status="old"
open(20,access="direct",form="formatted",status="old"
read(10,rec="@"
  do i=0,N
     read(10,"(15XI6,1XI6,1XI6,/,4XI7,1XI7,1XI7,1XI7,1XI7,1XI7,1XI7,1XI7)"a,b
         write(20,"(F6.4,F6.4,F6.4,/,F6.4,F6.4,F6.4,F6.4,F6.4,F6.4,F6.4,F6.4)"a,b
  enddo
end



再一个是
program shujutiqu
implicit none
real::a(10000),b(3,10000),c(8,10000)
integer::i,j,k,t
open(10,file="source.txt",access="direct",form="formatted"
open(20,file="shuju.txt"


read(10,rec="@" a(i)



do i=0,10000
   do j=0,2
     if(a(i)=="k" .and. a(i+1)=="="then

   b(j,1)=a(i+2)
   b(j+1,2)=a(i+3)
   b(j+2,3)=a(i+4)
endif
  enddo
if(a(i)=="&"then
  goto 100
  endif
end do
100  do j=0,2
      do t=0,10000
        write(20,"(F6.4)"b(j,t)
      enddo
     enddo
  do i=0,10000
       do k=0,7
       if(a(i)==":"then
         c(k,1)=a(i+1)
         c(k+1,2)=a(i+2)   
         c(k+2,3)=a(i+3)
         c(k+3,4)=a(i+4)
         c(k+4,5)=a(i+5)
         c(k+5,6)=a(i+6)
         c(k+6,7)=a(i+7)
         c(k+7,8)=a(i+8)
       endif
       enddo
if(a(i)=="&"then
  goto 200
endif
enddo
200  do k=0,7
       do t=0,10000
      write(20,"(F6.4)"c(k,t)
       enddo
     enddo
close(10)
close(20)
end

数据在上传资料中
谢谢
回复此楼
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

virtualzx

木虫 (著名写手)

2楼2016-03-17 13:54:46
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

7152075

铁杆木虫 (著名写手)

解决问题的方法比遇到的问题多

编译器重新安装吧(PS:但愿别是你的系统出问题,因为系统有问题也可能出现报的那个错误)。
没有看见你的文件在哪里。把数据文件也上传上来,以及把你的需求也重新说明(PS:最好能弄一个最终你想得到的结果的的简单示意图,简单明了)。
Chemistry
3楼2016-03-17 14:27:16
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

新丰客

木虫 (小有名气)

其实就是把kpoint数据以及bands数据重新提取到shuju.txt文件中,供绘图操作使用,但在@之上以及&之下还有一些其他数据,不需要,只需要中间这一段,所以才有上面的两段程序。但在编译器中编译时出现There has been an internal compiler error (C0000005),网上也说是编译器的问题,但我换了几台电脑,都出现同样错误提示,所以觉得应该是我程序出的问题。而且两段程序出了同样的错误提示,不知道这是为什么,所以求助。
数据如下
@         k = 0.0000 0.0000 0.0000 (   113 PWs)   bands (ev):

    -3.1911  21.1779  21.1779  21.1779  22.5548  22.5548  22.5548  25.0594

          k = 0.0000 0.0000 0.1000 (   113 PWs)   bands (ev):

    -3.0960  20.2345  20.2345  20.4975  22.3537  23.6411  23.6411  25.9287

          k = 0.0000 0.0000 0.2000 (   109 PWs)   bands (ev):

    -2.8098  18.9731  18.9731  19.2306  21.8284  24.6166  25.3242  25.3242

          k = 0.0000 0.0000 0.3000 (   109 PWs)   bands (ev):

    -2.3374  17.8217  17.8217  17.9494  21.1220  21.9036  27.1376  27.1376

          k = 0.0000 0.0000 0.4000 (   101 PWs)   bands (ev):

    -1.6744  16.7876  16.8290  16.8290  19.2414  20.3615  28.9855  28.9855

          k = 0.0000 0.0000 0.5000 (   101 PWs)   bands (ev):

    -0.8358  15.7868  15.9782  15.9782  16.6943  19.6301  30.6861  30.7665

          k = 0.0000 0.0000 0.6000 (   105 PWs)   bands (ev):

     0.1793  14.2790  14.9597  15.2838  15.2838  18.9639  31.6188  32.4007

          k = 0.0000 0.0000 0.7000 (   104 PWs)   bands (ev):

     1.3652  12.0073  14.3128  14.7456  14.7456  18.4256  32.6725  33.8804

          k = 0.0000 0.0000 0.8000 (   104 PWs)   bands (ev):

     2.7094   9.8878  13.8493  14.3624  14.3624  18.0253  33.7772  35.2252

          k = 0.0000 0.0000 0.9000 (   108 PWs)   bands (ev):

     4.1820   7.9476  13.5676  14.1319  14.1319  17.7783  34.7373  36.3496

          k = 0.0000 0.0000 1.0000 (   108 PWs)   bands (ev):

     5.3310   6.6439  13.4746  14.0553  14.0553  17.6952  35.1698  36.8707

          k = 0.0000 0.0000 0.0000 (   113 PWs)   bands (ev):

    -3.1911  21.1779  21.1779  21.1779  22.5548  22.5548  22.5548  25.0594

          k = 0.0000 0.1000 0.1000 (   113 PWs)   bands (ev):

    -3.0010  18.9137  19.5392  21.3627  22.6653  23.4717  23.9539  26.8796

          k = 0.0000 0.2000 0.2000 (   105 PWs)   bands (ev):

    -2.4299  16.1143  17.2993  21.9193  22.8616  24.0951  24.5795  25.4076

          k = 0.0000 0.3000 0.3000 (    99 PWs)   bands (ev):

    -1.4870  13.5863  15.0769  21.6459  22.8444  23.7482  24.1181  24.8942

          k = 0.0000 0.4000 0.4000 (   101 PWs)   bands (ev):

    -0.1882  11.3801  13.0087  19.6780  21.7703  24.1281  24.9937  25.9732

          k = 0.0000 0.5000 0.5000 (    97 PWs)   bands (ev):

     1.4594   9.5217  11.1700  17.9574  19.9890  25.7807  26.2524  27.3595

          k = 0.0000 0.6000 0.6000 (   101 PWs)   bands (ev):

     3.4334   8.0054   9.6038  16.5473  18.4499  27.7656  27.8169  29.0388

          k = 0.0000 0.7000 0.7000 (   101 PWs)   bands (ev):

     5.6963   6.8315   8.3756  15.4530  17.1962  26.1511  29.6916  30.0710

          k = 0.0000 0.8000 0.8000 (   102 PWs)   bands (ev):

     5.9965   7.2958   8.4235  14.6760  16.2200  22.4583  31.8164  32.6384

          k = 0.0000 0.9000 0.9000 (   102 PWs)   bands (ev):

     5.4971   6.8278  11.0939  14.2121  15.3774  19.2154  33.9822  35.2747

          k = 0.0000 1.0000 1.0000 (   108 PWs)   bands (ev):

     5.3310   6.6439  13.4746  14.0553  14.0553  17.6952  35.1698  36.8707

          k = 0.0000 0.0000 0.0000 (   113 PWs)   bands (ev):

    -3.1911  21.1779  21.1779  21.1779  22.5548  22.5548  22.5548  25.0594

          k = 0.1000 0.1000 0.1000 (   113 PWs)   bands (ev):

    -2.9062  17.7709  20.4032  20.4032  23.3001  23.7477  23.7477  27.0024

          k = 0.2000 0.2000 0.2000 (   107 PWs)   bands (ev):

    -2.0533  13.7137  19.6279  19.6279  23.0615  24.2363  24.2363  26.4754

          k = 0.3000 0.3000 0.3000 (    98 PWs)   bands (ev):

    -0.6503   9.9632  19.2750  19.2750  22.4589  22.4589  22.9269  26.5121

          k = 0.4000 0.4000 0.4000 (   105 PWs)   bands (ev):

     1.2756   6.6142  19.3716  19.3716  20.9653  20.9653  23.1546  24.9938

          k = 0.5000 0.5000 0.5000 (   108 PWs)   bands (ev):

     3.5956   3.8189  19.8981  19.8981  19.9672  19.9672  23.7149  23.9816
&
Writing output data file al.save

     init_run     :      0.01s CPU      0.01s WALL (       1 calls)
     electrons    :      0.28s CPU      0.30s WALL (       1 calls)

     Called by init_run:
     wfcinit      :      0.00s CPU      0.00s WALL (       1 calls)
     potinit      :      0.00s CPU      0.00s WALL (       1 calls)

     Called by electrons:
     c_bands      :      0.28s CPU      0.30s WALL (       1 calls)
     v_of_rho     :      0.00s CPU      0.00s WALL (       1 calls)

     Called by c_bands:
     init_us_2    :      0.00s CPU      0.00s WALL (      28 calls)
     ccgdiagg     :      0.26s CPU      0.27s WALL (      56 calls)
     wfcrot       :      0.02s CPU      0.03s WALL (      56 calls)

     Called by sum_band:

     Called by *cgdiagg:
     h_psi        :      0.24s CPU      0.25s WALL (    4102 calls)
     cdiaghg      :      0.00s CPU      0.00s WALL (      56 calls)
4楼2016-03-17 15:13:20
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

7152075

铁杆木虫 (著名写手)

解决问题的方法比遇到的问题多

【答案】应助回帖

感谢参与,应助指数 +1
根据你的需求,我大概编了一下代码,如果感觉什么格式不对,请自行修改。
    Program readdata
    Implicit None
    Character(len=125)::str
    Real*8,Allocatable::bands1(,bands2(,bands3(,bands4(,bands5(,bands6(,&
    bands7(,bands8(,kpoint1(,kpoint2(,kpoint3(
    Integer::i,ierr,count,n
    Open(11,file=' 123.txt' )
    Open(12,file=' shuju.txt' )
    count=0
    Do
        Read(11," ( a125 ) ",iostat=ierr) str
        If(ierr/=0) Exit
        If( str(11:13)== 'k = ' ) Then
            count=count+1
        End If
    End Do
    Allocate(bands1(count))
    Allocate(bands2(count))
    Allocate(bands3(count))
    Allocate(bands4(count))
    Allocate(bands5(count))
    Allocate(bands6(count))
    Allocate(bands7(count))
    Allocate(bands8(count))
    Allocate(kpoint1(count))
    Allocate(kpoint2(count))
    Allocate(kpoint3(count))
    Rewind(11)
    i=1
    Do
        Read(11,' (a125) ' ,iostat=ierr) str
        If(ierr/=0) Exit
        If(str(11:13)== 'k =' ) Then
            Read(str(14:35),*) kpoint1(i),kpoint2(i),kpoint3(i)
            Read(11,*)
            Read(11,' (a125) ',iostat=ierr) str
            Read(str(5:75),*) bands1(i),bands2(i),bands3(i),bands4(i),&
            bands5(i),bands6(i),bands7(i),bands8(i)
            i=i+1
        End If
    End Do
    Do i=1,count
        Write(12,"(a3,3f7.4,1x,a9,8(f7.4,1x)) " 'k=',kpoint1(i),kpoint2(i),kpoint3(i),'bands(ev) ',&
        bands1(i),bands2(i),bands3(i),bands4(i),bands5(i),bands6(i),bands7(i),bands8(i)
    End Do
    Close(11)
    Close(12)
    End Program readdata
Chemistry
5楼2016-03-17 16:50:29
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

7152075

铁杆木虫 (著名写手)

解决问题的方法比遇到的问题多

【答案】应助回帖

★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★
新丰客: 金币+20, 有帮助 2016-03-18 13:47:29
引用回帖:
4楼: Originally posted by 新丰客 at 2016-03-17 15:13:20
其实就是把kpoint数据以及bands数据重新提取到shuju.txt文件中,供绘图操作使用,但在@之上以及&之下还有一些其他数据,不需要,只需要中间这一段,所以才有上面的两段程序。但在编译器中编译时出现There has b ...

重新弄了,这一粘贴出来了许多的表情…………………………其中123.txt是你提供的数据我在上面又加了几行,以增加程序的普遍性。源代码在Source1.f90中
CODE:
    Program readdata
    Implicit None
    Character(len=125)::str
    Real*8,Allocatable::bands1(:),bands2(:),bands3(:),bands4(:),bands5(:),bands6(:),&
    bands7(:),bands8(:),kpoint1(:),kpoint2(:),kpoint3(:)
    Integer::i,ierr,count,n
    Open(11,file=' 123.txt' )
    Open(12,file=' shuju.txt' )
    count=0
    Do
        Read(11," ( a125 ) ",iostat=ierr) str
        If(ierr/=0) Exit
        If( str(11:13)== 'k = ' ) Then
            count=count+1
        End If
    End Do
    Allocate(bands1(count))
    Allocate(bands2(count))
    Allocate(bands3(count))
    Allocate(bands4(count))
    Allocate(bands5(count))
    Allocate(bands6(count))
    Allocate(bands7(count))
    Allocate(bands8(count))
    Allocate(kpoint1(count))
    Allocate(kpoint2(count))
    Allocate(kpoint3(count))
    Rewind(11)
    i=1
    Do
        Read(11,' (a125) ' ,iostat=ierr) str
        If(ierr/=0) Exit
        If(str(11:13)== 'k =' ) Then
            Read(str(14:35),*) kpoint1(i),kpoint2(i),kpoint3(i)
            Read(11,*)
            Read(11,' (a125) ',iostat=ierr) str
            Read(str(5:75),*) bands1(i),bands2(i),bands3(i),bands4(i),&
            bands5(i),bands6(i),bands7(i),bands8(i)
            i=i+1
        End If
    End Do
    Do i=1,count
        Write(12,"(a3,3f7.4,1x,a9,8(f7.4,1x)) ") 'k=',kpoint1(i),kpoint2(i),kpoint3(i),'bands(ev) ',&
        bands1(i),bands2(i),bands3(i),bands4(i),bands5(i),bands6(i),bands7(i),bands8(i)
    End Do
    Close(11)
    Close(12)
    End Program readdata

» 本帖附件资源列表

  • 欢迎监督和反馈:小木虫仅提供交流平台,不对该内容负责。
    本内容由用户自主发布,如果其内容涉及到知识产权问题,其责任在于用户本人,如对版权有异议,请联系邮箱:xiaomuchong@tal.com
  • 附件 1 : 123.txt
  • 2016-03-17 16:51:59, 6.23 K
  • 附件 2 : Source1.f90
  • 2016-03-17 16:51:59, 1.51 K
Chemistry
6楼2016-03-17 16:53:39
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

新丰客

木虫 (小有名气)

引用回帖:
6楼: Originally posted by 7152075 at 2016-03-17 16:53:39
重新弄了,这一粘贴出来了许多的表情…………………………其中123.txt是你提供的数据我在上面又加了几行,以增加程序的普遍性。源代码在Source1.f90中
    Program readdata
    Implicit None
    Character(l ...

谢谢,您的答案,我修改了我的下程序可以运行了,关于read语句还有些疑问,read在读取一个文件时,可以付给一个字符串,但却不能付给一个数组,比如read(11,*)str这个可以,但read(11,*)str(1)其中character::str(N)就不可以了。这是什么原因?谢谢
7楼2016-03-18 13:59:04
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

7152075

铁杆木虫 (著名写手)

解决问题的方法比遇到的问题多

引用回帖:
7楼: Originally posted by 新丰客 at 2016-03-18 13:59:04
谢谢,您的答案,我修改了我的下程序可以运行了,关于read语句还有些疑问,read在读取一个文件时,可以付给一个字符串,但却不能付给一个数组,比如read(11,*)str这个可以,但read(11,*)str(1)其中charact ...

1.因为你开始并没有读取str,所以如果你直接str(N),会出现数组越界的问题,其实就是没有初始化的问题。
2.read(11,*)为表控,遇到空格时会自动断掉,比如数据为
2.20   3.0      4.34       5.67        6.78     9.08
如果你read(11,*) str,其只能读到2,后面的5个数全都读不到。
3.如果你想读取到,利用内部文件的方法去读取:
character(len=126)::str
real::a,b,c,d,e,f
read(11,"(a126)" str
read(str(x:y),*) a,b,c,d,e,f
这样那六个数就全可以读进去了。
祝一切顺利
Chemistry
8楼2016-03-18 14:21:39
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

7152075

铁杆木虫 (著名写手)

解决问题的方法比遇到的问题多

引用回帖:
7楼: Originally posted by 新丰客 at 2016-03-18 13:59:04
谢谢,您的答案,我修改了我的下程序可以运行了,关于read语句还有些疑问,read在读取一个文件时,可以付给一个字符串,但却不能付给一个数组,比如read(11,*)str这个可以,但read(11,*)str(1)其中charact ...

那个表情的部分为read(11,"(a126)" ) str。
read(11,*) str,只能读取到数据2.20。
Chemistry
9楼2016-03-18 14:23:36
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

新丰客

木虫 (小有名气)

引用回帖:
8楼: Originally posted by 7152075 at 2016-03-18 14:21:39
1.因为你开始并没有读取str,所以如果你直接str(N),会出现数组越界的问题,其实就是没有初始化的问题。
2.read(11,*)为表控,遇到空格时会自动断掉,比如数据为
2.20   3.0      4.34       5.67        6.78   ...

明白了,麻烦了,谢谢
10楼2016-03-18 14:49:27
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 新丰客 的主题更新
信息提示
请填处理意见