Hey there! Sign in to join this conversationNew here? Join for free
    • Thread Starter
    Offline

    1
    ReputationRep:
    I am trying to write a program on fortran using subroutines. The program needs to be able to integrate the function 3x^2-5x-4 from x=3 to x=8 using the trapezoidal rule.

    So far I have wrote:

    PROGRAM trap_rule

    IMPLICIT NONE

    REAL, EXTERNAL :: F

    SUBROUTINEtraprule(a,b,n,f,area)

    REAL,INTENT(IN)::a



    REAL,INTENT(IN)::b

    REAL,INTENT(OUT)::area

    INTEGER,INTENT(INOUT):: n

    EXTERNALf

    any help is hugely appreciated! thank you
    • Study Helper
    Offline

    21
    ReputationRep:
    Study Helper
    (Original post by Kaya_01)
    I am trying to write a program on fortran using subroutines. The program needs to be able to integrate the function 3x^2-5x-4 from x=3 to x=8 using the trapezoidal rule.

    So far I have wrote:

    PROGRAM trap_rule

    IMPLICIT NONE

    REAL, EXTERNAL :: F

    SUBROUTINEtraprule(a,b,n,f,area)

    REAL,INTENT(IN)::a



    REAL,INTENT(IN)::b

    REAL,INTENT(OUT)::area

    INTEGER,INTENT(INOUT):: n

    EXTERNALf

    any help is hugely appreciated! thank you

    1) Specify the problem
    2) Analyse the problem (draw a flow diagram)
    3) Design an algorithm to solve the problem (NB this is not code the problem)
    4) Code the solution
    5) Test

    Specify: Format of the I/O, i.e. numeric only? graph? device? Rounding to s.f., d.p.'s? etc. Range limits? Decide how you will test the finished program.

    Analyse: Break it down into logical steps. i.e. understand and break down the quadratic equation and trapezoidal rule. You should start making a list of easy to use variable names. What other declarations will you need?

    Design: Once you have the specification and analysis, then begin by structuring the MAIN part of the program in accordance with your flow diagram. Do this before tackling the algorithms

    i.e. inputs and outputs, If, THEN, ELSE conditional branch statements etc.

    Code: When you are happy with all of the above (and only when you are happy), then begin coding.

    Finally test your solution.

    This may be teaching you to suck eggs, but getting into good practice from the start will pay dividends when it comes to debug and working errors.
 
 
 
  • See more of what you like on The Student Room

    You can personalise what you see on TSR. Tell us a little about yourself to get started.

  • Poll
    Have you ever participated in a Secret Santa?
  • See more of what you like on The Student Room

    You can personalise what you see on TSR. Tell us a little about yourself to get started.

  • The Student Room, Get Revising and Marked by Teachers are trading names of The Student Room Group Ltd.

    Register Number: 04666380 (England and Wales), VAT No. 806 8067 22 Registered Office: International House, Queens Road, Brighton, BN1 3XE

    Quick reply
    Reputation gems: You get these gems as you gain rep from other members for making good contributions and giving helpful advice.