INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

My error: REAL cannot be declared inside labelled DO block (perhaps missing CONTAINS or END statemen

My error: REAL cannot be declared inside labelled DO block (perhaps missing CONTAINS or END statemen

My error: REAL cannot be declared inside labelled DO block (perhaps missing CONTAINS or END statemen

(OP)
When I make a compile. the output shows me the following error:
-REAL cannot be declared inside labelled DO block (perhaps missing CONTAINS or END statement?)
Can any one help me with this problem?
Thank you!

Below is my code:

program researchwork
implicit none

integer, parameter :: ikind=selected_real_kind(p=15)
REAL (kind=ikind) :: nI,f10,f20,f30,f1,previousf1,f2,f3,phi1,previousphi1,phi2,phi10,phi20,n,H,smallnumber,error1,error2,Pr
REAL (kind=ikind) :: df1(1:4),df2(1:4),df3(1:4),dphi1(1:4),dphi2(1:4)


f10=0
f20=0
f30=2.0
phi10=1.0
phi20=1.0
nI=0
Pr=10.0


H=0.1

f1=f10
previousf1=0.0
f2=f20
f3=f30
phi1=phi10
previousphi1=0.0
phi2=phi20
smallnumber = 10.0_ikind**(-15.0)

do 10 n=nI,100,H
WRITE (2,*) n,f1,f2,f3,phi1,phi2,M1(f1,f2,f3,phi1,n),M2(f1,phi2,n)


df1(1)=H*f2
df2(1)=H*f3
df3(1)=H*M1(f1,f2,f3,phi1,n)
dphi1(1)=H*phi2
dphi2(1)=H*M2(f1,phi2,n)


df1(2)=H*(f2+df2(1)/2)
df2(2)=H*(f3+df3(1)/2)
df3(2)=H*M1(n + H/2,f1+df1(1)/2,f2+df2(1)/2,f3+df3(1)/2,phi1+dphi1(1)/2)
dphi1(2)=H*(phi2+dphi2(1)/2)
dphi2(2)=H*M2(n+H/2,f1+df1(1)/2,phi2+dphi2(1)/2)


df1(3)=H*(f2+df2(2)/2)
df2(3)=H*(f3+df3(2)/2)
df3(3)=H*M1(n + H/2,f1+df1(2)/2,f2+df2(2)/2,f3+df3(2)/2,phi1+dphi1(2)/2)
dphi1(3)=H*(phi2+dphi2(2)/2)
dphi2(3)=H*M2(n+H/2,f1+df1(2)/2,phi2+dphi2(2)/2)


df1(4)=H*(f2+df2(3))
df2(4)=H*(f3+df3(3))
df3(4)=H*M1(n + H,f1+df1(3),f2+df2(3),f3+df3(3),phi1+dphi1(3))
dphi1(4)=H*(phi2+dphi2(3))
dphi2(4)=H*M2(n+H,f1+df1(3),phi2+dphi2(3))

f1=f1+(df1(1)+2.0*df1(2)+2.0*df1(3)+df1(4))/6.0
f2=f2+(df2(1)+2.0*df2(2)+2.0*df2(3)+df2(4))/6.0
f3=f3+(df3(1)+2.0*df3(2)+2.0*df3(3)+df3(4))/6.0
phi1=phi1+(dphi1(1)+2.0*dphi1(2)+2.0*dphi1(3)+dphi1(4))/6.0
phi2=phi2+(dphi2(1)+2.0*dphi2(2)+2.0*dphi2(3)+dphi2(4))/6.0
error1=abs(f1-previousf1)
error2=abs(phi1-previousphi1)
if (error1<smallnumber .and. error2<smallnumber) then
print*,'f1 ',f1,'phi1 ',phi1
exit
end if
previousf1=f1
previousphi1=phi1


CONTINUE

REAL FUNCTION M1(n,f1,f2,f3,phi1)
REAL n,f1,f2,f3,phi1
M1=-3*f1*f3+2*f2*f2-phi1
end

REAL FUNCTION M2(n,f1,phi2)
REAL n,f1,phi2
M2=-3*Pr*f1*phi2
end

end program researchwork

RE: My error: REAL cannot be declared inside labelled DO block (perhaps missing CONTAINS or END statemen

What it is telling you is that the two function declarations cannot be inside the main program and that the end of your do block is missing.

CODE

...
do n = nI, 100, H  ! was do 10 nI, 100, H
...
end do ! was continue
end program researchwork

real function M1 ...
... 

RE: My error: REAL cannot be declared inside labelled DO block (perhaps missing CONTAINS or END statemen

(OP)
Thank Mr xwb for showing me my error. I have changed "do 10 nI, 100, H" into "do n = nI, 100, H" and put the two function declarartions out of do block. But when I look at the output, It seems that I have one more error.
Here is what Output says about the error:

M2 must appear in a type declaration because IMPLICIT NONE has been used
M1 must appear in a type declaration because IMPLICIT NONE has been used

Could you please tell me how can I fix this error?
Thank you!

RE: My error: REAL cannot be declared inside labelled DO block (perhaps missing CONTAINS or END statemen

Where your declarations are add

CODE

REAL M1, M2 

RE: My error: REAL cannot be declared inside labelled DO block (perhaps missing CONTAINS or END statemen

(OP)

I try to fix the program again. But then It does not run when I press 'start run'. Nothing happens even the black window
what's wrong with it?
Thank you!

Below is my code which has been edited.



program researchwork
implicit none

integer, parameter :: ikind=selected_real_kind(p=15)
real (kind=ikind :: nI,f10,f20,f30,f1,f2,previousf2,f3,phi1,previousphi1,phi2,phi10,phi20,n,H,smallnumber,error1,error2,Pr,df1(1:4),df2(1:4),df3(1:4),dphi1(1:4),dphi2(1:4),M1,M2

f10=0.0
f20=0.0
f30=2.0
phi10=1.0
phi20=1.0
nI=0.0
Pr=10.0


H=0.1

f1=f10
f2=f20
previousf2=0.0
f3=f30
phi1=phi10
previousphi1=0.0
phi2=phi20
smallnumber = 10.0_ikind**(-15.0)

do n=nI,100.0,H


df1(1)=H*f2
df2(1)=H*f3
df3(1)=H*M1(f1,f2,f3,phi1)
dphi1(1)=H*phi2
dphi2(1)=H*M2(f1,phi2)


df1(2)=H*(f2+df2(1)/2)
df2(2)=H*(f3+df3(1)/2)
df3(2)=H*M1(f1+df1(1)/2,f2+df2(1)/2,f3+df3(1)/2,phi1+dphi1(1)/2)
dphi1(2)=H*(phi2+dphi2(1)/2)
dphi2(2)=H*M2(f1+df1(1)/2,phi2+dphi2(1)/2)


df1(3)=H*(f2+df2(2)/2)
df2(3)=H*(f3+df3(2)/2)
df3(3)=H*M1(f1+df1(2)/2,f2+df2(2)/2,f3+df3(2)/2,phi1+dphi1(2)/2)
dphi1(3)=H*(phi2+dphi2(2)/2)
dphi2(3)=H*M2(f1+df1(2)/2,phi2+dphi2(2)/2)

df1(4)=H*(f2+df2(3))
df2(4)=H*(f3+df3(3))
df3(4)=H*M1(f1+df1(3),f2+df2(3),f3+df3(3),phi1+dphi1(3))
dphi1(4)=H*(phi2+dphi2(3))
dphi2(4)=H*M2(f1+df1(3),phi2+dphi2(3))

f1=f1+(df1(1)+2.0*df1(2)+2.0*df1(3)+df1(4))/6.0
f2=f2+(df2(1)+2.0*df2(2)+2.0*df2(3)+df2(4))/6.0
f3=f3+(df3(1)+2.0*df3(2)+2.0*df3(3)+df3(4))/6.0
phi1=phi1+(dphi1(1)+2.0*dphi1(2)+2.0*dphi1(3)+dphi1(4))/6.0
phi2=phi2+(dphi2(1)+2.0*dphi2(2)+2.0*dphi2(3)+dphi2(4))/6.0
error1=abs(f2-previousf2)
error2=abs(phi1-previousphi1)
if (error1<smallnumber .and. error2<smallnumber) then
write(*,10) 'f1 is ',f1
format(a,2f10.3)
exit
end if
previousf2=f2
previousphi1=phi1


end do
end program researchwork

real function M1(f1,f2,f3,phi1)
implicit none
integer, parameter :: ikind=selected_real_kind(p=15)
real (kind=ikind) :: f1,f2,f3,phi1
M1=-3.0*f1*f3+2*f2*f2-phi1
end function M1

real function M2(f1,phi2)
implicit none
integer, parameter :: ikind=selected_real_kind(p=15)
real (kind=ikind) :: f1,phi2
M2=-3.0*10.0*f1*phi2
end function M2

RE: My error: REAL cannot be declared inside labelled DO block (perhaps missing CONTAINS or END statemen

I suspect that your "smallnumber" is far too small so your program writes nothing.

Fran├žois Jacq

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close