| Thread Closed |
Fortran Program Won't run |
Share Thread |
| Apr15-10, 07:07 PM | #1 |
|
|
Fortran Program Won't run
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! |
| Apr15-10, 07:09 PM | #2 |
|
Mentor
|
If you strip the program down (comment out stuff), can you get the simplified version to compile? |
| Apr15-10, 07:13 PM | #3 |
|
|
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 |
| Apr15-10, 07:29 PM | #4 |
|
Mentor
|
Fortran Program Won't run
These lines are screwy.
Code:
Do 10 rv = 4,4,2 Do 20 T4 = 1620, 4, 360 Do 30 regN = 0,.05,19 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. |
| Apr15-10, 07:30 PM | #5 |
|
Mentor
|
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... |
| Apr15-10, 08:12 PM | #6 |
|
|
Even a bad compiler will give a line number where it has trouble.
|
| Apr15-10, 08:24 PM | #7 |
|
|
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 |
| Apr15-10, 08:26 PM | #8 |
|
|
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] |
| Apr15-10, 08:31 PM | #9 |
|
Mentor
|
|
| Apr15-10, 08:33 PM | #10 |
|
Mentor
|
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.
|
| Apr15-10, 08:59 PM | #11 |
|
|
|
| Apr15-10, 09:01 PM | #12 |
|
Mentor
|
Keep us posted. I'll be offline for awhile.
|
| Apr15-10, 09:56 PM | #13 |
|
|
Does anyone know why my given rv and T4 values are being printed as all zeros?
|
| Apr15-10, 10:50 PM | #14 |
|
Mentor
|
Code:
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) 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 |
| Apr18-10, 12:59 PM | #15 |
|
|
Thanks for the help! We ended up getting it running.
|
| Apr18-10, 10:28 PM | #16 |
|
Mentor
|
|
| Thread Closed |
Similar discussions for: Fortran Program Won't run
|
||||
| Thread | Forum | Replies | ||
| c program | Programming & Comp Sci | 0 | ||
| running a Fortran 77 program in a C++ enviorment/program | Programming & Comp Sci | 2 | ||
| how to program? | Programming & Comp Sci | 4 | ||
| Astro simulation program problem - program bugs? | Astrophysics | 4 | ||