Newsgroups: bit.listserv.stat-l
Date:         Tue, 21 Jul 1992 07:22:35 EDT
Comments:     Resent-From: Linda Atkinson <ATKINSON@ERS>
Comments:     Originally-From: William Greene <wgreene@option.stern.nyu.edu>
From:         "Linda Atkinson" <ATKINSON@ERS.BITNET>
Subject:      LIMDEP

This is a second message I received from Dr. Greene about LIMDEP, with
more detailed information on work-arounds for the mainframe version.

+----------------------------------------------------------------------+
| Linda Atkinson, Statistician     | BITNET:  ATKINSON@ERS             |
| U.S. Department of Agriculture   | Tel:     (202) 219-0505           |
| Economic Research Service        | FAX:     (202) 219-1292           |
| Washington, D.C.                 |          (ATTN: RM 240)           |
+----------------------------------------------------------------------+

----------------------------Original message----------------------------
Dear Linda:  (Listen closely and see if you can pick up my frustration.)

	The problem you are having with LIMDEP is now very familiar to me,
and is arising from two sources:  (1) An incompatibility between IBM's Fortran
and every other Fortran with which I am familiar, which, as you can
imagine, is a lot and (2) A bug in the IBM fortran compiler which, as far
as I know, has always been present, and shows no sign of being eradicated.
For your programmer's benefit, the offending statement is

	READ(IUD,2421,END=993,ERR=992)(LINE(J),J=ONE,255)

which follows statement number 241 in subroutine LOAD.  This line is
attempting to read a character string of indeterminate length, in
individual bytes.  Since I do not know how long the line is to be, I just
read a long line.  Here is what happens if the line has less than 255
characters:

	IBM fortran (MVS, CMS, all of them): Program crashes, as you saw.
	All other fortrans:  Unread characters are filled with blanks.

Now, notice that the statement contains an ERR=992.  This is designed to
prevent programs which encounter data errors from crashing.  It is not
working.  That is the bug.  There is no ambiguity about it as far as I can
see.  The odd thing about this, once again, unique to IBM, is that this
whole problem disappears a) if the 255 above is changed to an 80, whether
or not the line read is actually 80 characters long or not and b) if
the line really is 255 characters long, for obvious reasons.

	From your point of view, there are a couple of short term fixes
you can use:
	(1)  Use only formatted data sets, and include format statements
in the READ statement.
	(2)  The following block of code can replace its current
counterpart in subroutine LOAD.  This reverts back to the 80 character
limit of version 5.1, but apparently IBM fortran will not choke on it.

  240  IRD=ZERO
  241  DO 242 J=ONE,80
  242  LINE(J)=' '
       READ(IUD,2421,END=993,ERR=992)(LINE(J),J=ONE,80)
 2421  FORMAT(255A1)
       IF(LINE(1).EQ.'.'.AND.LINE(2).EQ.' ')LINE(1)='*'
       DO 2473 J=ONE,79
 2473  IF(J.GT.ONE.AND.LINE(J).EQ.'.'.AND.LINE(J-ONE).EQ.' '.AND.
     &    LINE(J+ONE).EQ.' ')LINE(J)='*'
       DO 243 J=ONE,80
       IF(LINE(81-J).EQ.' '.OR.LINE(81-J).EQ.',')GO TO 243
       LINE(82-J)='$'
       GO TO 244
  243  CONTINUE
       GO TO 241
  244  IFR=ZERO
       DO 245 J=ONE,80
       IF(LINE(J).EQ.' ')LINE(J)=','
  245  IF(LINE(J).NE.','.AND.IFR.EQ.ZERO)IFR=J

Once again, it is a mystery to me why IBM has locked itself into this 80
character format, but apparently, it is the bottleneck.  Keep in mind,
again, for unformatted data sets, you are limited to 80 character lines.

	It might be helpful if you could put this out on to the network,
since I do not access it.

		Regards,
		Bill Greene


Comments: Gated by NETNEWS@AUVM.AMERICAN.EDU