User Tools

Site Tools


tutorials:fortran

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
tutorials:fortran [2014/01/10 05:19]
papa
tutorials:fortran [2022/03/19 09:52]
papa [CPU/Elapsed time report on program termination]
Line 3: Line 3:
 **FORTRAN-20** is a FORTRAN compiler for TOPS-20. It supports the FORTRAN-77 standard (ANSI X3.9-1978 American National Standard Programming Language FORTRAN) with extensions and additions.  **FORTRAN-20** is a FORTRAN compiler for TOPS-20. It supports the FORTRAN-77 standard (ANSI X3.9-1978 American National Standard Programming Language FORTRAN) with extensions and additions. 
  
-The purpose of this tutorial +The purpose of this tutorial is to document the peculiarities of using FORTRAN-20 on TOPS-20 as opposed to other FORTRAN implementations on other operating systems; to highlight useful FORTRAN-20 extensions and additions that are not found in standard FORTRAN-77; and to briefly introduce the FORTRAN-77 programming language for those unfamiliar with it.
  
 +The order of presentation moves from more to less specialized and technical which runs counter to traditional organization, but the author feels this order is more convenient for the primary audience of programmers already familiar with FORTRAN but unfamiliar with the TOPS-20 operating system environment.
  
 +===== Peculiarities =====
  
-===== Hello World =====+==== CPU/Elapsed time report on program termination ====
  
-A sample program for the FORTRAN-20 compiler.+The FORTRAN compiler adds a report on CPU and elapsed time used by the program that prints at the end of every program run, like:
  
-<code> +  CPU time 0.08 Elapsed time 0.09
-c2345+---^---------^---------^---------^---------^---------^---------^--........ +
-      program hello                    ! The above line is a comment. +
-                                       ! Text from exclamation pt. to  +
-                                          end of line is a comment. +
-      write(5,*) ' Hello, World!'      ! 5 is the user TTY logical unit. +
-                                       ! Space before Hello is significant!+
  
-      stop                             ! The compiler ignores blank lines. +This message can be suppressed by adding the following line to your program source:
-      end                               +
-</code>+
  
-The same program without annotation:  +        CALL QUIETX 
 + 
 +==== DATE subroutine bug ==== 
 + 
 +Although the TOPS-20 operating system as a whole survived the Y2K crisis, the FORTRAN DATE subroutine did not fare as well. 
 + 
 +DATE is supposed to return a ten-character string representing the current system date with the format: 
 + 
 +''dd-mmm-yyb'' 
 + 
 +Where: 
 + 
 +| ''dd'' | Day of month (leading zero converted to blank) | 
 +| ''mmm'' | Three-character abbreviation of month ("Jan", "Feb", ...) | 
 +| ''yy'' | Last two digits of year | 
 +| ''b'' | blank character | 
 + 
 +However, since the year 2000, the DATE has set the ''yyb'' portion of the returned date to the //first three// digits of the current year, giving the same value for all years of a given decade. For example, for every year between 2010 and 2019, DATE returned "201" in the ''yyb'' portion of the date string. 
 + 
 +This renders the year portion of DATE's output useless for most purposes. A work-around is to program a date subroutine in another language that correctly processes the TOPS-20 system date (such as MACRO assembly language) and call that subroutine from your FORTRAN program instead of the FORTRAN DATE subroutine. 
 + 
 +==== Input/Output Devices ==== 
 + 
 +FORTRAN uses logical device numbers for transmitting data to and from various input and output devices. In FORTRAN-20, some of these logical unit numbers were assigned to specific equipment that was common in the computer rooms of the 1970s and '80s but are not available in TWENEX.ORG's simulated PDP-10 environment. 
 + 
 +When you are coding input/output statements, be sure to use a logical unit that is both valid and is associated with a device that is available on TWENEX.ORG. 
 + 
 +The default logical unit (specified by "*" on READ and WRITE statements) varies according to the input/output statement: 
 + 
 + Statement  ^Default unit^Remarks^ 
 +|  ACCEPT  |5 (User teletype)|Recommended for user keyboard input.| 
 +|  PRINT  |3 (Line printer)|Not available. Do not use.| 
 +|  PUNCH  |7 (Paper tape punch)|Not available. Do not use.| 
 +|  READ  |2 (Card reader)|Do not use default. Specify unit 5 for user keyboard input or other unit for file input.| 
 +|  TYPE  |5 (User teletype)|Recommended for user terminal output.| 
 +|  WRITE  |3 (Line printer)|Do not use default. Specify unit 5 for user terminal output or other unit for file output.| 
 + 
 +Below is a list of FORTRAN-20 logical unit assignments. For file input or output, you may use any of the units assigned to disk (0, 1, 20-24, 30-99). If you do not specify a file name when you open the logical unit, FORTRAN-20 will use the default file name (in your currently connected directory) corresponding to the unit you are opening as shown in the table. 
 + 
 +^  Unit  ^Device^Default filename^Usage^  Available 
 +|  0  |DSK|FOR00.DAT|Disk|  YES  | 
 +|  1  |DSK|FOR01.DAT|Disk|  YES  | 
 +|  2  |CDR|FOR02.DAT|Card reader|  NO  | 
 +|  3  |LPT|FOR03.DAT|Line printer|  NO  | 
 +|  4  |CTY|FOR04.DAT|Console teletype|  NO  | 
 +|  5  |TTY|FOR05.DAT|User teletype|  YES  | 
 +|  6  |PTR|FOR06.DAT|Paper tape reader|  NO  | 
 +|  7  |PTP|FOR07.DAT|Paper tape punch|  NO  | 
 +|  8  |DIS|FOR08.DAT|Display|  NO  | 
 +|  9  |DTA1|FOR09.DAT|DECtape|  NO  | 
 +|  10-15  |DTA2-7|FOR10 - 15.DAT|  |  NO  | 
 +|  16-18  |MTA0-2|FOR16 - 18.DAT|Magnetic tape|  NO  | 
 +|  19  |FORTR|FOR19.DAT|Assignable device|  NO  | 
 +|  20-24  |DSK|FOR20 - 24.DAT|Disk|  YES  | 
 +|  25-29  |DEV1-5|FOR25 - 29.DAT|Assignable devices|  NO  | 
 +|  30-99  |DSK|FOR30 - 99.DAT|Disk|  YES  | 
 +  
 +===== Extensions and additions ===== 
 + 
 +This section introduces potentially useful features that are unique to FORTRAN-20 and not included in the FORTRAN-77 standard. 
 + 
 +//(More to come: structured programming statements, in-line comments, ...)// 
 + 
 +===== FORTRAN overview ===== 
 + 
 +This section gives an brief overview of the FORTRAN-77 programming language for programmers with at least some experience with one or more other programming languages. It is not intended to be a comprehensive description or tutorial. Readers desiring a more complete introduction to FORTRAN are recommended to read the //Fortran 77 Tutorial// linked in the References section below.  
 + 
 +//(More to come: FORTRAN-77 cheat sheet, idiosyncracies (line layout, ...).)// 
 + 
 +===== Hello World ===== 
 + 
 +A sample program for the FORTRAN-20 compiler. 
  
 <code> <code>
       program hello       program hello
-      write(5,*' Hello, World!'+      type *' Hello, World!'
       stop       stop
       end                                     end                              
 </code> </code>
 +
 +(Text on each line is preceded by six spaces.)
  
 ===== References ===== ===== References =====
Line 36: Line 103:
 [[http://bitsavers.trailing-edge.com/pdf/dec/pdp10/TOPS20/fortran/AA-N383B-TK_FORTRAN_Language_Manual_Ver_10_May85.pdf|Digital Equipment Corporation. (1987, February). AA-N383B-TK FORTRAN Language Manual [Online]. Available: http://bitsavers.trailing-edge.com/pdf/dec/pdp10/TOPS20/fortran/AA-N383B-TK_FORTRAN_Language_Manual_Ver_10_May85.pdf.]] [[http://bitsavers.trailing-edge.com/pdf/dec/pdp10/TOPS20/fortran/AA-N383B-TK_FORTRAN_Language_Manual_Ver_10_May85.pdf|Digital Equipment Corporation. (1987, February). AA-N383B-TK FORTRAN Language Manual [Online]. Available: http://bitsavers.trailing-edge.com/pdf/dec/pdp10/TOPS20/fortran/AA-N383B-TK_FORTRAN_Language_Manual_Ver_10_May85.pdf.]]
  
-[[http://www.stanford.edu/class/me200c/tutorial_77/|P. H. Hargrove, S. T. Whitlock, E. Boman. (1997, December). Fortran 77 Tutorial [Online]. Available: http://www.stanford.edu/class/me200c/tutorial_77.]]    +[[http://www.stanford.edu/class/me200c/tutorial_77/|P.H. Hargrove, S.T. Whitlock, E. Boman. (1997, December). Fortran 77 Tutorial [Online]. Available: http://www.stanford.edu/class/me200c/tutorial_77.]]    
tutorials/fortran.txt · Last modified: 2022/03/19 09:52 by papa