FORTRAN

 22 July 01:42   

    Here is the [http://en.wikipedia.org/wiki/Fortran wikipedia entry].

    The afterward briefly describes . Fortran 77 was a clarification of Fortran 66 and Fortran IV, but added some adorable new features. Alotof conspicuously CHARACTERtypes.

    Fortran is a abounding procedural language.

    The capital access point to a program is at a PROGRAM statement.

    


     program XYZ

    


    Fortran was advised with bite agenda in mind, appropriately the absolute Fortran cipher alpha on the 7th appearance offset. Characters are prefix by 6 characters. Characters 1 to 5 announce a label, appearance 6 indicates a band continuation.

    For example:

    


    12345 program

     +HLO WLD

    67890 Book +HELLO WORLD

    99999 END

    


    N.B. inserting an added appearance at the amiss abode may couldcause abrupt behaviour. c.f. apropos the Mariner_program#Mariners_1_and_2.

    A PROGRAM and the account are alternative in this example.

    Note also:

    # The characters from postion 76 alee are ignored. So be accurate if you admit a appearance into a continued line. (IBM FORT/VS compiler acclimated to admit band numbers in this cavalcade for some odd reason)

    # The amplitude appearance is ignored, except in quotes, alotof conspicuously these two curve are interpreted the same, appropriately the suspicion apropos to the Bluejacket crash.

    


     DO 19,I=1,99

     DO19I=1,99

    


    A C, For example:

    


    12345 program

     +HLO WLD

    C Achievement Accost World

    67890 Book +HELLO WORLD

    c all done, Im out of here...

    99999 END

    


    In the blazon of a capricious is around authentic by the first letter of the capricious name. Variables alpha with the belletrist I through N were automatically advised to be s, while A through H and O through Z were advised to be s.

    This behavior can be adapted with an Absolute Accumulation acknowledgment (setting the letter ambit of integers) or an absolute acknowledgment of a capricious giving its type.

    Hence GOD is Absolute (unless declared INTEGER).

    Example:

    


     program EG DEC

     Accumulation I,J,K

     Accumulation II Accumulation M(2),N(3),O(4)

     Accumulation MM(2)/1,2/,NNN(3)/1,2,3/,OOOO(4)/1,2,3,4/

     Absolute R/1.0/,S/2.0/,T/3.0/

     Absolute Bifold Attention SS/2.0D/

     END

    


     has several affectionate of FUNCTIONS/SUBROUTINES.

    Example:

    
 

     program P

     Book Book END

     Action CUBE(X)

     FILSQ(X)=X CUBE=FILSQ(X) RETURN

     Access SQUARE(X)

     CUBE=FILSQ(X)

     END

    


    Produces:

    


     The cube of 2 is 8.

     The aboveboard of 2 is 4.

    


    Note that in the achievement the first appearance is commonly a bare character. By inserting additional characters in the first cavalcade you can force the printer to do anatomy feeds, and accomplish additional absorbing behaviors.

    The ambit of capricious was carefully bound to the accepted PROGRAM/SUBROUTINE or Data BLOCK. Data BLOCK can be aggregate amid PROGRAM/SUBROUTINEs, accustomed the program mer to extend the ambit of a variable.

    

    


     IF(1 .EQ. 2)PRINT IF(1 .EQ. 1)THEN

     Book ELIF(2 .EQ. 2)THEN

     Book ELSE

     Book ENDIF

    


    Conditional statements aswell cover GOTO statements.

    


     I=3

     GOTO(111,112,113,114)I

     Book GOTO 119

    111 CONTINUE

     book GOTO 119

    112 CONTINUE

     book GOTO 119

    113 CONTINUE

     book GOTO 119

    114 CONTINUE

     book GOTO 119

    119 Abide

    


    FORTRAN aswell has a 3 way condition.

    


     I=1

     IF(I)121,122,123

    121 CONTINUE

     book GOTO 129

    122 CONTINUE

     book GOTO 129

    123 CONTINUE

     book GOTO 129

    129 CONTINUE

    


    FORTRAN 77 > DO / WHILE LOOP

    


     A = 1

     DO WHILE (A .LT. 10)

     Book A = A + 1

     END DO

    


    In earlier FORTRANS labels and GOTOs would be acclimated to the aforementioned effect.

    For example:

    


     Accumulation A

     IF(.NOT.(A .LT. 10))GO TO 139

     Book A = A + 1

    139 CONTINUE

    


    Example one accost world:

    


     Book


    Or:

    


     Address (


    Or (The angle achievement approach is 6):

    


     Address (6,


    Or:

    


     Address (6,( A))Hello World

    


    Or:

    


     Address (UNIT=6,FMT=( A))Hello World

    


    Or:

    


     Address (UNIT=6,FMT=141)Hello World

    141 FORMAT(A)

    


    Fortran includes OPEN, CLOSE, READ, Address and Book statements. The Apprehend and Address commands could admission recored in a book by almanac number, appropriately Fortran contains a semblence of accidental book access. Abominably on Book IO the admeasurement of a chat is accomplishing dependent, and ranges from 6 $.25 on CDC, 8bits on IBM and 32 $.25 on VAXVMS.

    FORTRAN 77 has no anatomy or chic definition. The abutting archetype was the Accepted statement.

    


     Appearance NAME FLOAT Antithesis COMMOM /CSTREC/NAME,ADDRESS,BALANCE

    


    An Adequation account allows such Accepted block account be be overlayed, and acquiesce absolute assignment. But this is problematic.

    


     Appearance ALLREC EQUIVALENCE(ALLREC,CUSREC)

    


    An Adequation aswell accept a agnate aftereffect as the abutment from Algol68 (and then C) accent abutment statement. The net aftereffect is two variables ALLREC,CUSREC allotment the aforementioned area in memory.

    Access to additional languages was alone accessible if the accent accurate FORTRANs SUBROUTINE calling conventions (Not all FORTRANs acclimated the stack!). And the absolute conventions assorted from apparatus to machine.

    Garbage accumulating is not allotment of the language, but has been implemented alone using datablock. In Fortran the anamnesis at program startup was all that would be accessible to the program until it terminated. (The barring would be if the compiler accurate recursion with bounded variables, but this was not consistently the case.)

    The external scoping rules of Fortran is agnate to the scoping begin in the C programming language. About Fortran 77 does not accept a accepted INCLUDE statement.

    

    

 


Tags: access, program, example, block, language, character, characters, statements, write, statement, effect, hence, entry, print

 print, fortran, program, character, write, integer, statement, example, variable, language, characters, hence, entry, access, equivalence, allrec, effect, block, output, variables, filsq, statements, fortrans, , print goto, worldor write unit, example 12345 program,

Share FORTRAN: Digg it!   Google Bookmarks   Del.icio.us   Yahoo! MyWeb   Furl  Binklist   Reddit!   Stumble Upon   Technorati   Windows Live   Bookmark

Text link code :
Hyper link code:

Also see ...

Permalink
Article In : Reference & Education  -  Book