


( S - C ) ) WRITE ( 6, 601 ) A, B, C, AREA GO TO 10 50 WRITE ( 6, 602 ) STOP 90 WRITE ( 6, 603 ) STOP END Simple Fortran 77 program Multiple data card inputThis program has two input checks in the READ statement with the END and ERR parameters, one for a blank card to indicate end-of-data and the other for zero value along with valid data. 0 ) GO TO 90 S = ( A + B + C ) / 2.0 AREA = SQRT ( S. 2, $ 13 H SQUARE UNITS ) 602 FORMAT ( 10 HNORMAL END ) 603 FORMAT ( 23 HINPUT ERROR, ZERO VALUE ) INTEGER A, B, C 10 READ ( 5, 501 ) A, B, C IF ( A. C AREA OF A TRIANGLE - HERON'S FORMULA C INPUT - CARD READER UNIT 5, INTEGER INPUT, ONE BLANK CARD FOR END-OF-DATA C OUTPUT - LINE PRINTER UNIT 6, REAL OUTPUT C INPUT ERROR DISPAY ERROR MESSAGE ON OUTPUT 501 FORMAT ( 3 I5 ) 601 FORMAT ( 4 H A =, I5, 5 H B =, I5, 5 H C =, I5, 8 H AREA =, F10. ( S - IC ) ) WRITE ( 6, 601 ) IA, IB, IC, AREA 601 FORMAT ( 4 H A =, I5, 5 H B =, I5, 5 H C =, I5, 8 H AREA =, F10.Ģ, $ 13 H SQUARE UNITS ) STOP END Simple Fortran IV program Multiple data card inputThis program has two input checks: one for a blank card to indicate end-of-data, and the other for a zero value within the input data. 0 ) STOP 1 S = ( IA + IB + IC ) / 2.0 AREA = SQRT ( S. Or C! C AREA OF A TRIANGLE - HERON'S FORMULA C INPUT - CARD READER UNIT 5, INTEGER INPUT C OUTPUT - C INTEGER VARIABLES START WITH I,J,K,L,M OR N READ ( 5, 501 ) IA, IB, IC 501 FORMAT ( 3 I5 ) IF ( IA. Contents.FORTRAN II, IV, and 77 compilers NOTE: Before FORTRAN 90, most FORTRAN compilers enforced fixed-format source code, a carryover from. Other standards, if supported, may be selected manually with a command line option.

The remaining examples can be compiled and run with any newer standard Fortran compiler (see the for lists of compilers).īy convention most contemporary Fortran compilers select the language standard to use during compilation based on source code file name suffix: FORTRAN 77 for.f (or the less common.for), Fortran 90 for.f90, Fortran 95 for.f95. The first set of examples are for the Fortran II, IV, and 77 compilers. Part of the WikiBookThe following Fortran code examples or sample programs show different situations depending on the compiler.
