13

The 1974 Texas Regional Programming Contest (a predecessor of the ICPC) describes an input format:

A room description will be contained on a single card with the format: (1X, I2, 2X, 12 (A1, I2, 2X)).

The "number of corners" will be contained in columns 2 and 3 of the card and successive direction-distance pairs will be contained in columns 5-7, 10-12, 15-17, etc.

(I assume that the 12 is a typo and should be another I2.)

What does the format mean? What do 1X etc. and I2 denote?

23
  • 9
    No, 12 is 12. It's a repeat factor.
    – dave
    Commented Nov 17, 2021 at 11:25
  • 5
    See page 41 onwards in this IBM FORTRAN II manual.A 1974 programmer would likely be using FORTRAN IV, but the particular format in your question looks valid for FORTRAN II as well.
    – dave
    Commented Nov 17, 2021 at 13:06
  • 7
    @RBarryYoung - you don't need to be in CS to program, and many would say real CS has little to do with writing a program.
    – Jon Custer
    Commented Nov 17, 2021 at 14:54
  • 3
    @RBarryYoung - fair enough, but there was lots of computer programming going on at universities whether there was an official Computer Science degree or not. Lots of science and engineering courses used programming to solve their problems.
    – Jon Custer
    Commented Nov 17, 2021 at 14:57
  • 4
    The ICPC traces its roots to a competition held at Texas A&M in 1970 hosted by the Alpha Chapter of the UPE Computer Science Honor SocietyICPC Fact Sheet Commented Nov 17, 2021 at 15:13

3 Answers 3

32

The symbols are as follows:

  • () are used for grouping.
  • X → Value doesn't matter
  • I → Numeric (integer)
  • A → Alphabetic (in this case one of N, S, E, or W)
  • , → Used to separate each column or group definition

The numbers indicate how many columns the field takes up or how many times the group is repeated.

Given the desciption (1X, I2, 2X, 12 (A1, I2, 2X)) here's how it breaks down:

Column Description Contents
1 1X (don't care)
2 – 3 I2 Corner count (2-digit integer)
4 – 5 2X (don't care)
6 A1 Direction #1 (single letter)
7 – 8 I2 Length #1 (2-digit integer)
9 – 10 2X (don't care)
11 A1 Direction #2 (single letter)
12 – 13 I2 Length #2 (2-digit integer)
14 – 15 2X (don't care)
... ... ...
60 A1 Direction #12 (single letter)
61 – 62 I2 Length #12 (2-digit integer)
63 – 64 2X (don't care)

(The outer parentheses represent the entire card.)


The 12 that you premise is a typo is actually the repeat count for the definition of the list of corners. In other words there is space allocated for 12 corner points on a card. The actual number of corner points present on a given card is given in the first field (I2 → a 2-digit integer stored in columns 2 – 3).

5
  • 12
    This answer is thorough. It's worth adding that this format description comes from FORTRAN. Commented Nov 17, 2021 at 12:41
  • Interestingly, there is a typo/mistake in the original document: "in columns 5-7, 10-12, 15-17, etc." should be "in columns 6-8, 11-13, 16-18, etc." as the above table shows.
    – TripeHound
    Commented Nov 18, 2021 at 7:14
  • 1
    @TripeHound typical "do we start counting at 0 or 1" error...
    – Arsenal
    Commented Nov 18, 2021 at 14:53
  • @Arsenal Seems unlikey... punched cards were always columns 1..80, and they say the corner count is in columns 2 and 3 (which would be 1and 2 if counting from zero). I think it's "just an error".
    – TripeHound
    Commented Nov 18, 2021 at 16:09
  • "Premise" should be "surmise."
    – JRE
    Commented Nov 19, 2021 at 15:02
4

X is "space", prefixed by count, I is "integer", postfixed by the number of digits, A is "character", postfixed by character count, parentheses group items, a number before the parentheses indicates a repeat count. There is no typo.

Therefore, a line satisfying the format will be, for example,

 12  A23  B34  C45  D56  E67  F78  G89  H90  I01  J13  K24  L35
3
  • 1
    X is space on output, but skip on input.
    – dave
    Commented Nov 20, 2021 at 13:52
  • 1
    @another-dave Skipped positions are typically filled with spaces in actual input for clarity.
    – Leo B.
    Commented Nov 20, 2021 at 17:11
  • 2
    Or "it's on the data card but this particular program doesn't care about it".
    – dave
    Commented Nov 20, 2021 at 23:47
2

Using the example measurements, a data card would look like:

floor corners punched card data

or as a line of text (with ruler added to help with column count):

000000000111111111122222222223333333333444444444455555555556666666666777
123456789012345678901234567890123456789012345678901234567890123456789012
  6  N 9  E16  N 4  E 7  S13  W23  N 0  N 0  N 0  N 0  N 0  N 0

This line was generated from the FORTRAN code

      PROGRAM corners
      INTEGER LENGTHS(12), KOUNT
      CHARACTER*1 DIR(12)
      DATA KOUNT/6/
      DATA LENGTHS/9, 16, 4, 7, 13, 23, 0, 0, 0, 0, 0, 0/
      DATA DIR/'N', 'E', 'N', 'E', 'S', 'W', 
     *         'N', 'N', 'N', 'N', 'N', 'N'/
      WRITE(UNIT=*, FMT=100) KOUNT, (DIR(I), LENGTHS(I), I=1,12)
      STOP
  100 FORMAT (1X, I2, 2X, 12 (A1, I2, 2X))
      END

Format line 100 is the format you asked about.

(card image generated by Virtual Card Read-Punch)

2
  • Just for my curiosity, what version of FORTRAN is that? Specifically, with the keywords in the WRITE. (I stopped using FORTRAN in the mid-70s, so 66 was the last standard I cared about)
    – dave
    Commented Nov 20, 2021 at 13:54
  • Fortran 77, though IBM 7030 FORTRAN IV had that feature in 1963. DEC even managed to squeeze it into the PDP-8 FORTRAN-IV
    – scruss
    Commented Nov 20, 2021 at 16:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .