Re. Charles Richmond's code. Great stuff - it works well, as I've
confirmed,
and just wanted to provide a couple of caveats in case anyone else is
messing about with old DEC20 Fortran code;
1) - the MTHPRM and FORPRM (as .UNV files, I think),
are located in the PS:<FORTRAN.OTS-DEBUGGER> directory.
One needs to copy the MTHPRM.UNV and FORPRM.UNV files
into PS:<SUBSYS> so that the MACRO compiler can find them.
2) - What you get in the 3-word integer array, are packed (A5)
chars.
I had thougth maybe it returned 3 integers (as per. what
APLSF
does with a quadTS[1 2 3]), but it returns word-packed
ascii.
"26-Dec-2011" (without the quotes of course)
But this is just fine. You can use a Fortran DECODE
to parse up the string into three integers, if you need to do
date arithmetic, or whatever.
Here is a trivial Fortran program, that shows exactly what the
Fortran DATE() function returns, and what DATE4Y gives (and how
to call it, if you are a Fortran newbie (could there be such a
thing?? ) or maybe just historically curious...
C= TSM ***** MAIN START ROUTINE FOR TSM *****
C
C Version 2.1 - TSM
C
C=================================================================
C
IMPLICIT INTEGER (A-Z)
C
COMMON /TSMPLE/ SAMPLE(44)
DATA ITTY/5/
DIMENSION BIGDAT(3)
C
C
C... MUST call CHANNL, CLEARC in order for the program to operate
C correctly. The loop clears the global sample bounds.
C
100 CONTINUE
CALL CHANNL (IDUMMY)
CALL CLEARC
DO 200 I=1,44
SAMPLE(I) = 0
200 CONTINUE
C
WRITE (ITTY,210)
210 FORMAT ('+',/,' TSM - Time Series Manager',/,
1 ' < Interactive',
1 ' Economic Analysis >',/,' ',70('_')//)
C
C--- The DECSYSTEM-20 Fortran Date Bug: Program Example, with
C--- a simple fix provided, for those who might wish to resurrect
C--- their ancient Fortran code. [What could be more fun!!] :)
C
C--- first call result is obviously wrong: => 3-digit year of 201
WRITE (ITTY,250)
250 FORMAT ('+','Getting Year by Original Fortran DATE() call ',
1 'gives silly value.'/,
1 ' ','This is obviously wrong: => returns 3 digit ',
1 'year...'/)
C
C--- TMDATE is a function that calls DATE() and calcs the date
C--- as an integer into YYYYMMDD form. It also reports the
C--- result from DATE, as "26-Dec-201". This has the most
C--- amusing effect of making 2011 become 2010, as a result
C--- of the way TMDATE generates the YYYYMMDD integer
TD = TMDATE(IDUMMY)
C
WRITE (ITTY,300) TD
300 FORMAT (' ','TSM Running on: ',I10,' ...(Yikes! Year off ',
1 'by one!) '//)
C
C
WRITE (ITTY,350)
350 FORMAT ('+','Now, the DATE4Y call, => 3-word A5 char array...'/)
C
C--- NEW SYS-DATE ROUTINE - GET DATE AS THREE WORD PACKED A5 char-
array.
CALL DATE4Y(BIGDAT)
C
WRITE (ITTY,400) BIGDAT(1),BIGDAT(2),BIGDAT(3)
400 FORMAT ('+','System Date from DATE4Y call: ',3A5,
1 ' ... Ah! Much better!!',//)
C
C
WRITE (ITTY,500) BIGDAT(1),BIGDAT(2),BIGDAT(3)
500 FORMAT ('+',70('-')//' TSM Running on: ',3A5,/,71('-'),/)
C
C
C--- DATE4Y gives proper result, but as a packed (3A5) 3-word char
array.
CALL PARSER (IEND)
IF (IEND.EQ.1) GOTO 100
C
STOP
END
----------------------------------------------------------
This above code calls TMDATE, which is just a call to DATE(), and
returns the
broken date, "26-Dec-201" (the three-digit year version.)
The result of Charles Richmond's DATE4Y code (which appears below),
will
return a proper "26-Dec-2011", as A5 character data (5 ascii
characters
packed into each 36-bit DEC20 word).
This of course is all painfully trivial for anyone who actually used
this DEC20's
or Dec10's, but I include this here, in all its gory detail, for those
who might
be curious.
It was non-trivial, to take all that DEC20 Fortran code - that had all
those
A5-isms salted everywhere, and turn it into VAX Fortran that had the
32-bit
word - and so packed 4, 8-bit ascii chars to a 32-bit word, versus the
DEC20,
which put 5, 7-bit ascii chars to a 36-bit word. The strategy of
just leaving
it alone, and writing a machine-emulator, just never occurred to those
who
were told so long ago to convert to VAXes - (and then one more time,
to
some flavour of Unix, and then Win2000, and now maybe Linux...
etc.)
The emulation approach is quite surprisingly effective and
actionable.
The group I worked for (as a youngster) had actually paid serious
money
to have special "controlled precision" routines custom developed so
that
bond-amortization calculations - which have legal mandates on what
digit
you must round calcs to when doing amortization schedules - could
be done so that they generated the correct answers. Just giving
bigger
precision was *not* enough. You had to actually control on what digit
you did the rounding (6th decimal place, I think it was..), to ensure
that
a multi-million dollar bond portfolio amortization calculation had
the
correct answer. And of course, the date-arithmetic was just as
critical.
(We had to map holidays, for example, in Canada, USA, the UK,
Europe, Japan, etc.. )
- Mark Langdon
(Charles Richmond's DATE4Y.MAC code example follows...)
> | Charles Richmond
numer...@aquaporin4.com |
> +<><><><><><><><><><><><><><><><><><><>+