Unformatted text preview:

The FutureIntroduction to FORTRANFORTRAN HistoryStatement FormatSlide 5Slide 6Building a FORTRAN ProgramStructure of a Fortran ProgramSlide 9Fortran ProgramFortran SubroutineSlide 12Fortran FunctionSlide 14Fortran Block DataSlide 16Fortran Program OrganizationFortran VariableFortran Variable TypingSlide 20Slide 21Slide 22Slide 23Slide 24Slide 25Fortran ArraysSlide 27Slide 28Fortran Variables and SubroutinesFortran Common BlocksSlide 31Slide 32Fortran EquivalenceFortran ParameterFortran LiteralsSlide 36Fortran ExpressionsFortran Numerical OperatorsSlide 39Intrinsic FunctionsType ConversionSlide 42TruncationMath FunctionsSlide 45Slide 46Fortran StatementsFortran AssignmentFortran BranchingSlide 50Slide 51Slide 52Fortran ContinueFortran IFFortran 3-way IfFortran Logical IfSlide 57Fortran Modern IfSlide 59Slide 60Fortran LoopingSlide 62Slide 63Slide 64Slide 65Slide 66Slide 67Fortran Subroutine InvocationSlide 69Miscellaneous StatementsFortran I/O StatementsSlide 72Slide 73Slide 74Slide 75Slide 76Slide 77Slide 78Slide 79Fortran I/O ListFortran Formatted I/OSlide 82Slide 83FORMAT StatementFormat SpecifiersFormat Specifiers – cont’dSlide 87Slide 88Slide 89Slide 90Other FORMAT FeaturesOther I/O FeaturesSlide 93Slide 94Slide 95Slide 96Slide 97Sub ProgramsSlide 99Slide 100Slide 101Slide 102Slide 103Array StorageSlide 105Slide 106Slide 107Slide 108Slide 109Slide 110Statement FunctionsFortran BooksNot FortranAE6382 The FutureAE6382Introduction to FORTRANHistory and purpose of FORTRANFORTRAN essentialsProgram structureData types and specification statementsEssential program controlFORTRAN I/Osubfunctions and subroutinesExtensions for Fortran 95Pitfalls and common coding problemsSample problemsOBJECTIVESAE6382FORTRAN HistoryOne of the oldest computer languagescreated by John Backus and released in 1957designed for scientific and engineering computationsVersion historyFORTRAN 1957FORTRAN II FORTRAN IVFORTRAN 66 (released as ANSI standard in 1966)FORTRAN 77 (ANSI standard in 1977)FORTRAN 90 (ANSI standard in 1990)FORTRAN 95 (ANSI standard version)FORTRAN 2003 (ANSI standard version)Many different “dialects” produced by computer vendors (Digital VAX Fortran, now Intel Fortran)Large majority of existing engineering software is coded in FORTRAN (various versions)AE6382Statement FormatFORTRAN before 90 requires a fixed formatBased on the punch card in use when Fortran was created PROGRAM MAINC COMMENTS ARE ALLOWED IF A “C” IS PLACED IN COLUMN #1 DIMENSION X(10) READ(5,*) (X(I),I=1,10) WRITE(6,1000) X 1000 FORMAT(1X,’THIS IS A VERY LONG LINE OF TEXT TO SHOW HOW TO CONTINUE ’ * ‘THE STATEMENT TO A SECOND LINE’,/,10F12.4)1-5Label67-72 Statements73-80OptionalLine #sAny character: continuation lineAE6382Statement FormatFORTRAN fixed format“C” in column 1 indicates that line is a commentcolumns 1-5 are reserved for statement labels–statement labels are not required unless the statement is the target of a goto–labels are numeric values onlycolumn 6 is the continuation flag–any character in column 6, other than space or “0”, indicates that this line is a continuation of the previous line–there is usually a limit of 19 on the number of continuationscolumns 7-72 are contain Fortran statementscolumns 73-80 is for sequence information–only of any use when using punch cardsAE6382Statement FormatIBM punch cardAE6382Building a FORTRAN ProgramFORTRAN is a complied language (like C) so the source code (what you write) must be converted into machine code before it can be executed (e.g. Make command)FORTRANProgramFORTRANCompilerLibrariesLink withLibrariesExecutable FileSource CodeObject CodeExecutable CodeExecuteProgramTest & DebugProgramMake Changesin Source CodeAE6382Structure of a Fortran ProgramFortran is a compiled languageall memory is allocated statically at compile time–there is no standard method for allocating additional memory in a Fortran program before Fortran 90–memory is allocated in a predictable manner, a fact which can be used by the programmer to his advantage or distressthere is no official recursion before Fortran 90–some vendor implementations had recursive capabilities–static memory allocation is at odds with the use of a stack which is needed for recursionFortran does not guarantee value of un-initialized memoryAE6382Structure of a Fortran ProgramFortran consists of program unitsprogramfunctionsubroutineblock dataThe program unit contains the main code and the point where execution startsin Fortran 77 a program begins with the program statementearlier versions of Fortran did not have a program statement unless a vendor dialect provided onethe end statement terminates the program unitAE6382Fortran ProgramThe program unit contains the main code and the point where execution startsin Fortran 77 a program begins with the program statementearlier versions of Fortran did not have a program statement unless a vendor dialect provided onethe end statement terminates the program unit–marks end of statements that belong to program–during execution it will cause the program to halta program unit may contain internal sub-programs–internal functions–internal subroutinesAE6382Fortran SubroutineThe subroutine unit contains Fortran code that can be called from other Fortran codea subroutine begins with a subroutine statementcontains a name for the subroutinea list of formal argumentssubroutines may be internal or externalan internal subroutine is included in the code of program unit and is only callable by the programan external subroutine is created outside of a program unit and is callable from everywhereAE6382Fortran Subroutine SUBROUTINE MULT(A,B,C) C = A * B RETURN END CALL MULT(5.0,X,VALUE)AE6382Fortran FunctionThe function unit contains Fortran code that can be called from other Fortran codeIt differs from a subroutine in that it returns a valuea subroutine begins with a function statementcontains a name for the functiona list of formal argumentsspecifies a return typefunctions may be internal or externalan internal function is included in the code of program unit and is only callable by the programan external function is created outside of a program unit and is callable from


View Full Document

GT AE 6382 - LECTURE NOTES

Download LECTURE NOTES
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view LECTURE NOTES and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view LECTURE NOTES 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?