我正在尝试使用 gfortran 求解方程,但我不断收到错误

发布于 2024-09-05 23:53:54 字数 776 浏览 1 评论 0原文

我正在使用下面的程序,但我不断收到错误。我的程序出了什么问题?

  real x
  complex y
  real m1,H0,Ms,P1,P2,P3,w0,wm,wh
  complex w1,w2,o1,o2
  integer i,n
  real pi
  n=4000000000  
  pi=4*atan(1.0)
  m1=4*pi*1e-7
  H0=39.79e3
  Ms=1400e3
  P1=0.7*0.12
  P2=0.3*0.12
  P3=P1-P2
  w0=m1*(1.76e11)*H0
  wm=m1*(1.76e11)*Ms
  wh=w0-P3*wm
  im=cmplx(0,1)
  w1=wm/2+wh-im*0.06*2*pi*x
  w2=wm/2-wh-im*0.06*2*pi*x
  o1=x**2-x*(2*wh-(P3*wm)/2)-w1*w2+(wm/2)*(P1*w2+P2*w1)
  o2=x**2+x*(2*wh-(P3*wm)/2)-w1*w2+(wm/2)*(P1*w2+P2*w1)

  do i=0,n
     x=i
     y=1+wm*(P1*w1*((w2)**2-x**2))/(o1*o2)
 &        +wm*(P2*w2*((w1)**2-x**2))/(o1*o2)
 &        -wm*((wm/2)*((P1*w2+P2*w1)**2)))/(o1*o2)
 &        +wm*((wm/2)*((P3*x)**2))/(o1*o2)
     write(10,*)x,y
  enddo
  return
  end

i'm using the below program but i keep getting error.What is wrong with my progam?

  real x
  complex y
  real m1,H0,Ms,P1,P2,P3,w0,wm,wh
  complex w1,w2,o1,o2
  integer i,n
  real pi
  n=4000000000  
  pi=4*atan(1.0)
  m1=4*pi*1e-7
  H0=39.79e3
  Ms=1400e3
  P1=0.7*0.12
  P2=0.3*0.12
  P3=P1-P2
  w0=m1*(1.76e11)*H0
  wm=m1*(1.76e11)*Ms
  wh=w0-P3*wm
  im=cmplx(0,1)
  w1=wm/2+wh-im*0.06*2*pi*x
  w2=wm/2-wh-im*0.06*2*pi*x
  o1=x**2-x*(2*wh-(P3*wm)/2)-w1*w2+(wm/2)*(P1*w2+P2*w1)
  o2=x**2+x*(2*wh-(P3*wm)/2)-w1*w2+(wm/2)*(P1*w2+P2*w1)

  do i=0,n
     x=i
     y=1+wm*(P1*w1*((w2)**2-x**2))/(o1*o2)
 &        +wm*(P2*w2*((w1)**2-x**2))/(o1*o2)
 &        -wm*((wm/2)*((P1*w2+P2*w1)**2)))/(o1*o2)
 &        +wm*((wm/2)*((P3*x)**2))/(o1*o2)
     write(10,*)x,y
  enddo
  return
  end

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

偏爱自由 2024-09-12 23:53:54

这一行(多行语句中的第三行):

-wm*((wm/2)*((P1*w2+P2*w1)**2)))/(o1*o2)
    ||    | ||           |   ||| |     |
    |+----+ |+-----------+   ||| +-----+
    |       +----------------+||
    +-------------------------+|
??? <--------------------------+

有太多右括号{为我出色的绘画技巧而颤抖:-)}。它应该是:

-wm*((wm/2)*((P1*w2+P2*w1)**2))/(o1*o2)

我从该来源得到的问题的完整列表是:

source.f90:7.18: n=4000000000
                             1
                 Error: Integer too big for its kind at (1). This check can
                 be disabled with the option -fno-range-check.
source.f90:26.9: y=1+wm*(P1*w1*((w2)**2-x**2))/(o1*o2) &
                 1
                 Error: Unclassifiable statement at (1)

第二个是您可能遇到的问题(并且您可以使用上述解决方案修复该问题)。第一个,如果你有它,会引起问题,但我怀疑这只是因为我的环境。

This line (the third in the multiline statement):

-wm*((wm/2)*((P1*w2+P2*w1)**2)))/(o1*o2)
    ||    | ||           |   ||| |     |
    |+----+ |+-----------+   ||| +-----+
    |       +----------------+||
    +-------------------------+|
??? <--------------------------+

has one too many closing parentheses {tremble in fear at my awesome drawing skills :-) }. It should be:

-wm*((wm/2)*((P1*w2+P2*w1)**2))/(o1*o2)

The full list of problems I got from that source was:

source.f90:7.18: n=4000000000
                             1
                 Error: Integer too big for its kind at (1). This check can
                 be disabled with the option -fno-range-check.
source.f90:26.9: y=1+wm*(P1*w1*((w2)**2-x**2))/(o1*o2) &
                 1
                 Error: Unclassifiable statement at (1)

The second of those is the one you're probably having (and the one you can fix with the above solution). The first, if you're having it, will cause a problem but I suspect it's just because of my environment.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文