- World's Largest Collection of Interview Questions
Start Your Own website Now
Sponsored Links

Interview Questions
Our Services

Get 9,000 Interview Questions & Answers in an eBook.

  • 9500+ Pages
  • 9000 Question & Answers
  • All Tech. Categories
  • 14 MB Content

    Get it now !!

    Send your Resume to 6000 Companies

    Question :
    What are the relative advantages of Function Subprograms, and Statement Functions?
    Category Fortran Interview Questions
    Rating (0.3) By 9 users
    Added on 6/10/2011
    Views 261
    Rate it!

    The Function Subprogram should be your choice when evaluation of the function takes more than one line of Fortran or the function is referenced from many places in your program, and size of your executable program is important. I am including liberal use of the line continuation option (character in column 6) in my definition of "one line of Fortran". It is not difficult to generate functions that need some IF tests to cover special cases or error processing (see viscl.f). These must be Function Subprograms. As for the space issue, you need to understand how each of these function types are implemented in machine code. The machine instructions for a Function Subprogram exist at only one location in the final executable code. When the Function Subprogram is referenced somewhere, some notes are made about the location of information and the location where program execution will continue after return from the function, then the flow of instruction execution branches to the Function Subprogram's code. All of this takes some extra computer time beyond what would be needed if the Function's programming was just imbedded in the rest of the code, but generally takes less space.

    When a statement function is referenced an interesting thing happens at compilation time. The statement function basically disappears from the final executable machine code. If I write the following Fortran, with the first line as a statement function:





    then what is effectively generated after the compiler is through is the machine code equivalent to:




    No branches are generated to statement function coding, the statement function is substituted into the locations where it is referenced. This results in code that takes less time to execute than code using an equivalent Function Subprogram, but when used too frequently with long functions can produce longer executable files than you want.

    If you have the better answer, then send it to us. We will display your answer after the approval.
    Rules to Post Answers in

  • There should not be any Spelling Mistakes.
  • There should not be any Gramatical Errors.
  • Answers must not contain any bad words.
  • Answers should not be the repeat of same answer, already approved.
  • Answer should be complete in itself.
  • Name :*
    Email Id :*
    Answer :*
    Verification Code Code Image - Please contact webmaster if you have problems seeing this image code Not readable? Load New Code
    Process Verification  Enter the above shown code:*
    Inform me about updated answers to this question

    Related Questions
    View Answer
    I am still unclear with Subprograms. Could you give a summary.
    View Answer
    What is the difference between a DATA statement and assigning a value to a variable with an =?
    View Answer
    Can more than one variable be stored in a Data Statement?
    View Answer
    Could you go over colons again in dealing with arrays?
    View Answer
    What a DATA statement does.
    View Answer
    About the exact use of arrays and their purpose
    View Answer
    Why are go to statements bad, and what can we do to avoid them?
    View Answer
    Is there a way to go back to the top of the error list after a failed compilation?
    View Answer
    Do spaces mater in equations?
    View Answer
    When accessing a data file in a program can I change directories?
    View Answer
    When accessing a data file in a program can I change directories?
    View Answer
    What does the function REAL(x) do?
    View Answer
    Explain Function Subprograms.
    View Answer
    Subprograms. What do they do and how do the help program.
    View Answer
    How can I format my output to look nicer (clear screen, double space, etc.)
    View Answer
    What is the advantage of an array over a spreadsheet format?
    View Answer
    What can I do if my lines wrap around to the next line?
    View Answer
    What is the difference between IF, THEN and DO WHILE statements.
    View Answer
    Why doesn't Fortran have intrinsic functions for something as simple as factorial?
    View Answer
    How do we know where various steps go in a Fortran program?
    View Answer

    Please Note: We keep on updating better answers to this site. In case you are looking for Jobs, Pls Click Here - Best Freshers & Experienced Jobs Website.

    View ALL Fortran Interview Questions

    User Options
    Sponsored Links

    Copyright ©2003-2015, All Rights Reserved.
    Privacy Policy | Terms and Conditions

    Download Yahoo Messenger | Placement Papers| FREE SMS | ASP .Net Tutorial | Web Hosting | Dedicated Servers | C Interview Questions & Answers

    Testing Articles | Testing Books | Testing Certifications | Testing FAQs | Testing Downloads | Testing Interview Questions | Testing Jobs | Testing Training Institutes

    Cache = 0.03125 Seconds