Fortran Program Won't run


by FortranFreaks
Tags: fortran, program
FortranFreaks
FortranFreaks is offline
#1
Apr15-10, 07:07 PM
P: 7
We made a program for our thermo class and when we go to run it, it tells us errors were encountered but will not display what errors it has. It won't print out anything. I appreciate any help you guys have to offer.

Print *, 'Nicholas Grover / Corey Demers'
Print *, 'Thermodynamics II FORTRAN problem'
C 4/16/06


C Program Thermo
Implicit None

Real T2, T3, T5, thN, Tpe
Real Wcs, Wts, Wc, Wt, Wnet, regN, Qh, Qr
Integer rv, T4


Print *, 'Pr Temp Nreg Nth Wnet'
Print *, '============================='


Do 10 rv = 4,4,2
Do 20 T4 = 1620, 4, 360
Do 30 regN = 0,.05,19

Call Compressor(Wc,rv,Wcs)
Call Turbine(Wts,Wt,T5,rv,regN,T4)
Call HighHEX(T3,T2,T5,Tpe,Qr,Qh,regN,rv)

Wnet = Wt - Wc
thN = Wnet/Qh

Print 40, rv,T4,regN,thN,Wnet

30 Continue
20 Continue
10 Continue

40 Format(1x,F1.0,F8.0,F7.2,F6.2,F7.2)
END


C *--------------------------------------------------------------*
Subroutine Compressor(Wc,rv,Wcs)

Real Wc,T2,Wcs
Integer rv

T2=540*rv**(.4/1.4)
Wcs= .24*(540-T2)
Wc=(Wcs/.81)

END
C *--------------------------------------------------------------*

C *--------------------------------------------------------------*
Subroutine Turbine(Wts,Wt,T5,rv,regN,T4)

Real Wts,Wt,T5,dP,regN
Integer T4,rv

dP=(.5*regN)/(1-regN)
P2=rv*14.7
P4=dP+P2
P5=14.7+dP
T5=T4*(P5/P4)**(.4/1.4)
Wts=(-.24)*(T5-T4)
Wt=Wts*.87

END
C *--------------------------------------------------------------*
Subroutine HighHEX(T3,T2,T5,Tpe,Qr,Qh,regN,rv)

Real T3,T2,T5,Tpe,Qr,Qh,regN
integer rv

T2=540*rv**(.4/1.4)
T3=T2+(T5-T2)*regN
Tpe=T3+180
Qr=(-.24)*(Tpe-3060)
Qh=Qr*(-1)

END
C *---------------------------------------------------------------*

Thanks again!
Phys.Org News Partner Science news on Phys.org
Better thermal-imaging lens from waste sulfur
Hackathon team's GoogolPlex gives Siri extra powers
Bright points in Sun's atmosphere mark patterns deep in its interior
berkeman
berkeman is online now
#2
Apr15-10, 07:09 PM
Mentor
berkeman's Avatar
P: 39,606
Quote Quote by FortranFreaks View Post
We made a program for our thermo class and when we go to run it, it tells us errors were encountered but will not display what errors it has. It won't print out anything. I appreciate any help you guys have to offer.

Print *, 'Nicholas Grover / Corey Demers'
Print *, 'Thermodynamics II FORTRAN problem'
C 4/16/06


C Program Thermo
Implicit None

Real T2, T3, T5, thN, Tpe
Real Wcs, Wts, Wc, Wt, Wnet, regN, Qh, Qr
Integer rv, T4


Print *, 'Pr Temp Nreg Nth Wnet'
Print *, '============================='


Do 10 rv = 4,4,2
Do 20 T4 = 1620, 4, 360
Do 30 regN = 0,.05,19

Call Compressor(Wc,rv,Wcs)
Call Turbine(Wts,Wt,T5,rv,regN,T4)
Call HighHEX(T3,T2,T5,Tpe,Qr,Qh,regN,rv)

Wnet = Wt - Wc
thN = Wnet/Qh

Print 40, rv,T4,regN,thN,Wnet

30 Continue
20 Continue
10 Continue

40 Format(1x,F1.0,F8.0,F7.2,F6.2,F7.2)
END


C *--------------------------------------------------------------*
Subroutine Compressor(Wc,rv,Wcs)

Real Wc,T2,Wcs
Integer rv

T2=540*rv**(.4/1.4)
Wcs= .24*(540-T2)
Wc=(Wcs/.81)

END
C *--------------------------------------------------------------*

C *--------------------------------------------------------------*
Subroutine Turbine(Wts,Wt,T5,rv,regN,T4)

Real Wts,Wt,T5,dP,regN
Integer T4,rv

dP=(.5*regN)/(1-regN)
P2=rv*14.7
P4=dP+P2
P5=14.7+dP
T5=T4*(P5/P4)**(.4/1.4)
Wts=(-.24)*(T5-T4)
Wt=Wts*.87

END
C *--------------------------------------------------------------*
Subroutine HighHEX(T3,T2,T5,Tpe,Qr,Qh,regN,rv)

Real T3,T2,T5,Tpe,Qr,Qh,regN
integer rv

T2=540*rv**(.4/1.4)
T3=T2+(T5-T2)*regN
Tpe=T3+180
Qr=(-.24)*(Tpe-3060)
Qh=Qr*(-1)

END
C *---------------------------------------------------------------*

Thanks again!
What compiler are you using? Any clues why it won't show you the error messages? Are they maybe getting piped to some error file somewhere?

If you strip the program down (comment out stuff), can you get the simplified version to compile?
FortranFreaks
FortranFreaks is offline
#3
Apr15-10, 07:13 PM
P: 7
Force 2.0

We tried it without the subroutines but it gave us the same problem.

C Program Thermo
Implicit None

Real T2, T3, T5, thN, Tpe, dP, P2, P4, P5
Real Wcs, Wts, Wc, Wt, Wnet, regN, Qh, Qr
Integer rv, T4


Print *, 'Pr Temp Nreg Nth Wnet'
Print *, '============================='


Do 10 rv = 4,4,2
Do 20 T4 = 1620, 4, 360
Do 30 regN = 0,.05,19

T2=540*rv**(.4/1.4)
Wcs= .24*(540-T2)
Wc=(Wcs/.81)

dP=(.5*regN)/(1-regN)
P2=rv*14.7
P4=dP+P2
P5=14.7+dP
T5=T4*(P5/P4)**(.4/1.4)
Wts=(-.24)*(T5-T4)
Wt=Wts*.87

T2=540*rv**(.4/1.4)
T3=T2+(T5-T2)*regN
Tpe=T3+180
Qr=(-.24)*(Tpe-3060)
Qh=Qr*(-1)

Wnet = Wt - Wc
thN = Wnet/Qh

Print 40, rv,T4,regN,thN,Wnet

30 Continue
20 Continue
10 Continue

40 Format(1x,F1.0,F8.0,F7.2,F6.2,F7.2)
END

Mark44
Mark44 is online now
#4
Apr15-10, 07:29 PM
Mentor
P: 20,971

Fortran Program Won't run


These lines are screwy.
Do 10 rv = 4,4,2
Do 20 T4 = 1620, 4, 360
Do 30 regN = 0,.05,19
The first one says to do (execute) the code up through line 10, starting with rv = 4, up through rv = 4, in increments of 2.
The second one says to execute the code up through line 20, starting with T4 = 1620, up through T4 = 4, in increments of 360.
The third one says to execute the code up through line 30, starting with regN = 0, up through regN = 0.05, in increments of 19.
I haven't done any Fortran for awhile, but I don't think any of your loops will run at all.

What values do you want rv to have (start, end, increment)? Same for T4 and regN.
berkeman
berkeman is online now
#5
Apr15-10, 07:30 PM
Mentor
berkeman's Avatar
P: 39,606
How much do you have to strip out to get it to run? Have you successfully compiled previous programs, or is this your first one?

If you've used this compiler before, has it shown you error messages? Have you looked in its Help files to see if you have to turn on a verbose mode or something?

EDIT -- good catches by Mark. Still seems like the compiler must be tossing those error statements someplace though...
Antiphon
Antiphon is offline
#6
Apr15-10, 08:12 PM
P: 1,781
Even a bad compiler will give a line number where it has trouble.
FortranFreaks
FortranFreaks is offline
#7
Apr15-10, 08:24 PM
P: 7
Quote Quote by Mark44 View Post
These lines are screwy.
Do 10 rv = 4,4,2
Do 20 T4 = 1620, 4, 360
Do 30 regN = 0,.05,19
The first one says to do (execute) the code up through line 10, starting with rv = 4, up through rv = 4, in increments of 2.
The second one says to execute the code up through line 20, starting with T4 = 1620, up through T4 = 4, in increments of 360.
The third one says to execute the code up through line 30, starting with regN = 0, up through regN = 0.05, in increments of 19.
I haven't done any Fortran for awhile, but I don't think any of your loops will run at all.

What values do you want rv to have (start, end, increment)? Same for T4 and regN.
Is this better?
Do 10 rv = 4,10,2
Do 20 T4 = 1620, 2700, 360
Do 30 regN = 0, .95, .05

I need it to do all combinations for
rv: 4, 6, 8, 10
T4: 1620, 1980, 2340, 2700
regN: 0, .4, .5, .6, .7, .8, .9, .95

Quote Quote by berkeman View Post
How much do you have to strip out to get it to run? Have you successfully compiled previous programs, or is this your first one?

If you've used this compiler before, has it shown you error messages? Have you looked in its Help files to see if you have to turn on a verbose mode or something?

EDIT -- good catches by Mark. Still seems like the compiler must be tossing those error statements someplace though...
I have not used it before but it will run if I make a very basic program. When I first wrote it, it would display all the errors at the bottom and I fixed them one by one until they were all gone. So it no longer displays any errors but will say some were encountered.
FortranFreaks
FortranFreaks is offline
#8
Apr15-10, 08:26 PM
P: 7
It is giving me this as output

C:\Documents and Settings\Corey\My Documents\THERMO FORTRAN PROBLEM.f: In program `MAIN__':
C:\Documents and Settings\Corey\My Documents\THERMO FORTRAN PROBLEM.f:1:
Print *, 'Nicholas Grover / Corey Demers'
1
C:\Documents and Settings\Corey\My Documents\THERMO FORTRAN PROBLEM.f:7: (continued):
Implicit None
2
Statement at (2) invalid in context established by statement at (1)
C:\Documents and Settings\Corey\My Documents\THERMO FORTRAN PROBLEM.f:1:
Print *, 'Nicholas Grover / Corey Demers'
1
C:\Documents and Settings\Corey\My Documents\THERMO FORTRAN PROBLEM.f:9: (continued):
Real T2, T3, T5, thN, Tpe
2
Statement at (2) invalid in context established by statement at (1)
C:\Documents and Settings\Corey\My Documents\THERMO FORTRAN PROBLEM.f:1:
Print *, 'Nicholas Grover / Corey Demers'
1
C:\Documents and Settings\Corey\My Documents\THERMO FORTRAN PROBLEM.f:10: (continued):
Real Wcs, Wts, Wc, Wt, Wnet, regN, Qh, Qr
2
Statement at (2) invalid in context established by statement at (1)
C:\Documents and Settings\Corey\My Documents\THERMO FORTRAN PROBLEM.f:1:
Print *, 'Nicholas Grover / Corey Demers'
1
C:\Documents and Settings\Corey\My Documents\THERMO FORTRAN PROBLEM.f:11: (continued):
Integer rv, T4
2
Statement at (2) invalid in context established by statement at (1)
C:\Documents and Settings\Corey\My Documents\THERMO FORTRAN PROBLEM.f: In subroutine `compressor':
C:\Documents and Settings\Corey\My Documents\THERMO FORTRAN PROBLEM.f:22: warning:
Call Compressor(Wc,rv,Wcs)
1
C:\Documents and Settings\Corey\My Documents\THERMO FORTRAN PROBLEM.f:42: (continued):
Subroutine Compressor(Wc,rv,Wcs)
2
Argument #2 (named `rv') of `compressor' is one type at (2) but is some other type at (1) [info -f g77 M GLOBALS]
C:\Documents and Settings\Corey\My Documents\THERMO FORTRAN PROBLEM.f: In subroutine `turbine':
C:\Documents and Settings\Corey\My Documents\THERMO FORTRAN PROBLEM.f:23: warning:
Call Turbine(Wts,Wt,T5,rv,regN,T4)
1
C:\Documents and Settings\Corey\My Documents\THERMO FORTRAN PROBLEM.f:55: (continued):
Subroutine Turbine(Wts,Wt,T5,rv,regN,T4)
2
Argument #4 (named `rv') of `turbine' is one type at (2) but is some other type at (1) [info -f g77 M GLOBALS]
C:\Documents and Settings\Corey\My Documents\THERMO FORTRAN PROBLEM.f:23: warning:
Call Turbine(Wts,Wt,T5,rv,regN,T4)
1
C:\Documents and Settings\Corey\My Documents\THERMO FORTRAN PROBLEM.f:55: (continued):
Subroutine Turbine(Wts,Wt,T5,rv,regN,T4)
2
Argument #6 (named `t4') of `turbine' is one type at (2) but is some other type at (1) [info -f g77 M GLOBALS]
C:\Documents and Settings\Corey\My Documents\THERMO FORTRAN PROBLEM.f: In subroutine `highhex':
C:\Documents and Settings\Corey\My Documents\THERMO FORTRAN PROBLEM.f:24: warning:
Call HighHEX(T3,T2,T5,Tpe,Qr,Qh,regN,rv)
1
C:\Documents and Settings\Corey\My Documents\THERMO FORTRAN PROBLEM.f:70: (continued):
Subroutine HighHEX(T3,T2,T5,Tpe,Qr,Qh,regN,rv)
2
Argument #8 (named `rv') of `highhex' is one type at (2) but is some other type at (1) [info -f g77 M GLOBALS]
Mark44
Mark44 is online now
#9
Apr15-10, 08:31 PM
Mentor
P: 20,971
Quote Quote by FortranFreaks View Post
Is this better?
Do 10 rv = 4,10,2
Do 20 T4 = 1620, 2700, 360
Do 30 regN = 0, .95, .05

I need it to do all combinations for
rv: 4, 6, 8, 10
T4: 1620, 1980, 2340, 2700
regN: 0, .4, .5, .6, .7, .8, .9, .95
Yes, these look reasonable.
Mark44
Mark44 is online now
#10
Apr15-10, 08:33 PM
Mentor
P: 20,971
I think that the compiler is complaining about the two PRINT statements at the top. I believe that they need to be after your declarations, not before them. See if that makes a difference.
FortranFreaks
FortranFreaks is offline
#11
Apr15-10, 08:59 PM
P: 7
Quote Quote by Mark44 View Post
I think that the compiler is complaining about the two PRINT statements at the top. I believe that they need to be after your declarations, not before them. See if that makes a difference.
Sweet! That was the problem, just need to figure out the new problems I'm encountering.
Mark44
Mark44 is online now
#12
Apr15-10, 09:01 PM
Mentor
P: 20,971
Keep us posted. I'll be offline for awhile.
FortranFreaks
FortranFreaks is offline
#13
Apr15-10, 09:56 PM
P: 7
Does anyone know why my given rv and T4 values are being printed as all zeros?
Mark44
Mark44 is online now
#14
Apr15-10, 10:50 PM
Mentor
P: 20,971
Real T2, T3, T5, thN, Tpe, dP, P2, P4, P5
Real Wcs, Wts, Wc, Wt, Wnet, regN, Qh, Qr
Integer rv, T4

.
.
.

Print 40, rv,T4,regN,thN,Wnet

40 Format(1x,F1.0,F8.0,F7.2,F6.2,F7.2)
First off rv and T4 are declared as Integer types. Your format statement doesn't match these types. The Fx.x field specifiers are for real values, with F1.0 being used to print a real number in a field of width 1 space. The next one, F8.0 is used for T4, printing it in a field of width 8 characters, but with no places to the right of the decimal point. The appropriate specifier for Integer values is I4 or I6, or something big enough to hold the values you need printed. You should ask yourself though, whether Integer is the right type for these two variables. I haven't looked at your code close enough to say one way or the other.

If you fix these things, and you're still getting 0's for rv and T4, then the time-honored way of debugging is to sprinkle PRINT (or WRITE) statements at places in your code where these variables are getting set. Knowing the value of a variable is always better than guessing its value.

That's an obvious place to star
FortranFreaks
FortranFreaks is offline
#15
Apr18-10, 12:59 PM
P: 7
Thanks for the help! We ended up getting it running.
Mark44
Mark44 is online now
#16
Apr18-10, 10:28 PM
Mentor
P: 20,971
Quote Quote by Mark44 View Post
Real T2, T3, T5, thN, Tpe, dP, P2, P4, P5
Real Wcs, Wts, Wc, Wt, Wnet, regN, Qh, Qr
Integer rv, T4

.
.
.

Print 40, rv,T4,regN,thN,Wnet

40 Format(1x,F1.0,F8.0,F7.2,F6.2,F7.2)
First off rv and T4 are declared as Integer types. Your format statement doesn't match these types. The Fx.x field specifiers are for real values, with F1.0 being used to print a real number in a field of width 1 space. The next one, F8.0 is used for T4, printing it in a field of width 8 characters, but with no places to the right of the decimal point. The appropriate specifier for Integer values is I4 or I6, or something big enough to hold the values you need printed. You should ask yourself though, whether Integer is the right type for these two variables. I haven't looked at your code close enough to say one way or the other.

If you fix these things, and you're still getting 0's for rv and T4, then the time-honored way of debugging is to sprinkle PRINT (or WRITE) statements at places in your code where these variables are getting set. Knowing the value of a variable is always better than guessing its value.

That's an obvious place to start.
xxxx


Register to reply

Related Discussions
c program Programming & Computer Science 0
running a Fortran 77 program in a C++ enviorment/program Programming & Computer Science 2
how to program? Programming & Computer Science 4
Astro simulation program problem - program bugs? Astrophysics 4