24小时热门版块排行榜    

查看: 2130  |  回复: 1

hznu2007

铁虫 (初入文坛)

[求助] FORTRAN程序DO WHILE出现语句错误,请哪位高手修改一下(紧急求助) 已有1人参与

program main
  use IMSL
  implicit none
  external FCN
  
  real, parameter :: ERRREL=0.0001
  integer, parameter :: N=2
  integer, parameter :: ITMAX=100
  real :: XGUESS(N)=(/ 0.5, 0.5 /)
  real X(N) , FNORM

  CALL NEQNF(FCN, ERRREL, N, ITMAX, XGUESS, X, FNORM)
  write(*,*) X
  stop
end

subroutine FCN(XA, F, N)
   implicit none
   integer N
   external FK, FE
   double precision a, b, c, Romberg
   real, target :: XA(N)
   real F(N)
   real, pointer :: x, ita
   x=> XA(1)
   ita=> XA(2)
  
   c=Romberg(a, b, ita, FK)
   F(1)=2*c/3.14159265+0.5/sqrt(1-ita**2)-0.5
   c=Romberg(a, b, ita, FE)
   F(2)=2*c/3.14159265+0.5*sqrt(1-ita**2)-2.5+x*(ita**2)
   
   return
end subroutine

double precision function FE(g,ita)
  double precision g, ita
  FE=( 1-(ita*cos(g))*(ita*cos(g))) **0.5
end


double precision function FK(g,ita)
  double precision g, ita
  FK=( 1-(ita*cos(g))*(ita*cos(g))) **0.5
  FK=1/FK
end

double precision function Romberg(a, b, ita, f)
  double precision a, b, ita, f, eps
  integer m, i, k, point
  parameter(m=30, eps=1e-9)
  double precision t(m), er, h, tt, t2, l

  h=b-a
  k=1
  er=1
  point=1
  t(1)=h/2*(f(a,ita)+f(b,ita))

    do 10 while( (er.gt.eps).and.(k.lt.n))
       tt=t(1)

           t(1)=0
           do 20 i=1,point
           t(1)=t(1)+f(a+i*h-h/2,ita)
           continue
           t(1)=tt/2+t(1)*h/2

           l=1
           do 30 i=2,k
             t2=t(i)
                 l=l*4
                 t(i)=(t(i-1)*l-tt)/(l-1)
                 tt=t2
           continue

           point=point*2
           k=k+1
           h=h/2
           l=l*4
           t(k)=(t(k-1)*1-tt)/(l-1)
           er=abs(t(k)-tt)

         continue
         Romberg=t(k)
   end do
  
end
--------------------Configuration: 201401 - Win32 Debug--------------------
Compiling Fortran...
D:\compaq visual fortran\MSDEV98\MyProjects\hello\01.f90
D:\compaq visual fortran\MSDEV98\MyProjects\hello\01.f90(70) : Error: This DO variable has already been used as an outer DO variable in the same nesting structure.   [I]
    do 30 i=2,k
-----------------^
D:\compaq visual fortran\MSDEV98\MyProjects\hello\01.f90(86) : Error: This ENDDO statement requires a label.   [30]
   end do
^
D:\compaq visual fortran\MSDEV98\MyProjects\hello\01.f90(70) : Error: There is an extra DO construct label.   [30]
    do 30 i=2,k
--------------^
D:\compaq visual fortran\MSDEV98\MyProjects\hello\01.f90(64) : Error: An unterminated block exists.
    do 20 i=1,point
^
D:\compaq visual fortran\MSDEV98\MyProjects\hello\01.f90(60) : Error: An unterminated block exists.
    do 10 while( (er.gt.eps).and.(k.lt.n))
^
D:\compaq visual fortran\MSDEV98\MyProjects\hello\01.f90(60) : Error: This label is undefined.   [10]
    do 10 while( (er.gt.eps).and.(k.lt.n))
-------^
D:\compaq visual fortran\MSDEV98\MyProjects\hello\01.f90(64) : Error: This label is undefined.   [20]
    do 20 i=1,point
--------------^
Error executing df.exe.

01.obj - 7 error(s), 0 warning(s)
回复此楼

» 猜你喜欢

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

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

jpchou

专家顾问 (著名写手)

【答案】应助回帖


感谢参与,应助指数 +1
jjdg: 金币+1, 感谢参与 2014-01-14 01:49:13
D:\compaq visual fortran\MSDEV98\MyProjects\hello\01.f90(70) : Error: This DO variable has already been used as an outer DO variable in the same nesting structure.   [I]
    do 30 i=2,k
-----------------^
D:\compaq visual fortran\MSDEV98\MyProjects\hello\01.f90(86) : Error: This ENDDO statement requires a label.   [30]
   end do
^

你 do 30 i=2,k 給了個 label "30"
可是 end do 忘了給
把 end do 改成 30 end do
就可以
其他地方也要做同樣的修改
2楼2014-01-13 20:23:47
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 hznu2007 的主题更新
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 307求调剂 +9 冷笙123 2026-03-17 9/450 2026-03-19 22:44 by 学员8dgXkO
[考博] 申博26年 +3 八6八68 2026-03-19 3/150 2026-03-19 19:43 by nxgogo
[考博] 东华理工大学化材专业26届硕士博士申请 +8 zlingli 2026-03-13 8/400 2026-03-19 16:32 by 轻松不少随
[考研] 271材料工程求调剂 +6 .6lL 2026-03-18 6/300 2026-03-19 15:41 by haoshis
[考研] 266求调剂 +5 阳阳哇塞 2026-03-14 10/500 2026-03-19 15:08 by 阳阳哇塞
[考研] 一志愿中海洋材料工程专硕330分求调剂 +7 小材化本科 2026-03-18 7/350 2026-03-19 10:46 by Linda Hu
[考研] 材料080500调剂求收留 +4 一颗meteor 2026-03-13 4/200 2026-03-19 10:32 by 30660438
[考研] 材料工程专硕调剂 +5 204818@lcx 2026-03-17 6/300 2026-03-18 22:55 by 204818@lcx
[考研] 一志愿华中科技大学,080502,354分求调剂 +4 守候夕阳CF 2026-03-18 4/200 2026-03-18 22:16 by li123456789.
[考研] 311求调剂 +4 冬十三 2026-03-18 4/200 2026-03-18 21:47 by 尽舜尧1
[考研] 一志愿西南交大,求调剂 +4 材化逐梦人 2026-03-18 4/200 2026-03-18 14:22 by 007_lilei
[考研] 070300化学319求调剂 +6 锦鲤0909 2026-03-17 6/300 2026-03-18 13:22 by Iveryant
[考研] 290求调剂 +3 p asserby. 2026-03-15 4/200 2026-03-17 16:35 by wangkm
[考研] 材料工程专硕274一志愿211求调剂 +6 薛云鹏 2026-03-15 6/300 2026-03-17 11:05 by 学员h26Tkc
[考研] 275求调剂 +4 太阳花天天开心 2026-03-16 4/200 2026-03-17 10:53 by 功夫疯狂
[考研] 药学383 求调剂 +3 药学chy 2026-03-15 4/200 2026-03-16 20:51 by 元子^0^
[考研] 机械专硕325,寻找调剂院校 +3 y9999 2026-03-15 5/250 2026-03-16 19:58 by y9999
[考研] 321求调剂 +5 大米饭! 2026-03-15 5/250 2026-03-16 16:33 by houyaoxu
[考研] 26考研一志愿中国石油大学(华东)305分求调剂 +3 嘉年新程 2026-03-15 3/150 2026-03-15 13:58 by 哈哈哈哈嘿嘿嘿
[考研] 一志愿哈工大材料324分求调剂 +5 闫旭东 2026-03-14 5/250 2026-03-14 14:53 by 木瓜膏
信息提示
请填处理意见