Fortran Program Won't run

  1. 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!
     
  2. jcsd
  3. berkeman

    Staff: Mentor

    Re: Program Won't run

    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?
     
  4. 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
     
  5. Mark44

    Staff: Mentor

    These lines are screwy.
    Code (Text):
    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.
     
  6. berkeman

    Staff: 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...
     
  7. Even a bad compiler will give a line number where it has trouble.
     
  8. 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

    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.
     
  9. 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]
     
  10. Mark44

    Staff: Mentor

    Yes, these look reasonable.
     
  11. Mark44

    Staff: 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.
     
  12. Sweet! That was the problem, just need to figure out the new problems I'm encountering.
     
  13. Mark44

    Staff: Mentor

    Keep us posted. I'll be offline for awhile.
     
  14. Does anyone know why my given rv and T4 values are being printed as all zeros?
     
  15. Mark44

    Staff: Mentor

    Code (Text):

    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
     
  16. Thanks for the help! We ended up getting it running.
     
  17. Mark44

    Staff: Mentor

    xxxx
     
Know someone interested in this topic? Share a link to this question via email, Google+, Twitter, or Facebook

Have something to add?