Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

TOPS-20 Fortran DATE() routine fix. Is there one?

129 views
Skip to first unread message

gem...@idirect.com

unread,
Dec 24, 2011, 6:14:50 AM12/24/11
to
Hi again;
My holiday project is resurrecting some 30 year old Fortran code I
wrote on a DEC2020.
It's an economics/data-bashing package, and it will be fun to have it
back. It was nice.
I've got enough typed in and compiled, that it all looks quite doable
on Panda TOPS-20,
and my little DEC-5000 Linux box. Wow.. (I am still in awe of
this. I was going to OCR
the old listings - but keytyping lets me fix stuff on the fly..
compile/link & test each
routine..etc)
Only pain is that silly DATE() bug - "Happy Dec. 24th, 201", according
to my little system...
I just need a way to get a proper date for the system, from somewhere.
I've grabbed the DATE() MACRO code from one of Alderson's posts, and
even compiled
the DATIME.MAC library code from "Trailing Edge". I can't find tech.
specs. on how to
call JSYS routines from Fortran (and oddly enough, can't recall how I
did it 30 years ago!)

I can get the full date easily in APLSF ( .FM .BXTS[1 2 3] ) - no
problem. But I need
it in Fortran. This must be possible.
How do I call a JSYS routine from Fortran? No documentation one this,
it seems. Lots of
discussion, but no published solution. (Anyone know how I can call
APLSF from Fortran?)
Thx for any info..
- Rus

Charles Richmond

unread,
Dec 24, 2011, 2:00:39 PM12/24/11
to
<gem...@idirect.com> wrote in message
news:c43139b7-4973-4baf...@t16g2000vba.googlegroups.com...
> Hi again;
> My holiday project is resurrecting some 30 year old Fortran code I
> wrote on a DEC2020. It's an economics/data-bashing package, and it
> will be fun to have it back. It was nice. I've got enough typed in and
> compiled, that it all looks quite doable on Panda TOPS-20, and my
> little DEC-5000 Linux box. Wow.. (I am still in awe of this. I was
> going to OCR the old listings - but keytyping lets me fix stuff on the
> fly..
> compile/link & test each routine..etc)
>
> Only pain is that silly DATE() bug - "Happy Dec. 24th, 201", according
> to my little system... I just need a way to get a proper date for the
> system,
> from somewhere. I've grabbed the DATE() MACRO code from one of
> Alderson's posts, and even compiled the DATIME.MAC library code
> from "Trailing Edge". I can't find tech. specs. on how to call JSYS
> routines from Fortran (and oddly enough, can't recall how I
> did it 30 years ago!)
>

In the TOPS-20 FORTRAN manual I have (as a .pdf file), appendix C describes
how to write a MACRO routine that is callable by FORTRAN.

I have *no* idea how to do an operating system call directly from TOPS-20
FORTRAN. But I have some routines for getting the date, based largely on
code posted here by Mark Cripsin and Rich Alderson... and I got quite a bit
of help with my additional coding from both of them.

If you want a FORTRAN-callable MACRO routine that will return the date with
a 4-digit year (in a 3 element integer array), I think I can whip that up
from what I have. I wanted a routine that would return "24-DEC-11" for
today. I have added some code that will help with using this date in the
Adventure game I was working with.

Is the 4-digit year what you are after??? When I get the code done, I will
post it.

If you want to "remember" how to code in MACRO, you should get the book that
was recommended to me: _Introduction to DECSYSTEM-20 Assembly Language
Programming_, by Ralph Gorin. It is available from several of the used-book
sites on the internet, and you should be able to get a paper copy for under
$20.

> I can get the full date easily in APLSF ( .FM .BXTS[1 2 3] ) - no
> problem.
> But I need it in Fortran. This must be possible.
>
> How do I call a JSYS routine from Fortran? No documentation one this,
> it seems. Lots of discussion, but no published solution. (Anyone know
> how I can call APLSF from Fortran?)

Calling APLSF from FORTRAN is *overkill* IMHO.

Charles Richmond

unread,
Dec 25, 2011, 12:01:13 AM12/25/11
to
Okay, here is the FORTRAN-callable code for getting the date with a four
digit year. Call this as "CALL DATE4Y(INTRY)" and pass it a 3 element
integer array. The code worked when I tested it, but I do *no* error
checking. I'm sure that Mark Crispin, Rich Alderson, or several others here
can improve on this:

TITLE FORDAT - Return system date as characters to FORTRAN.

Comment $ Get system date with a 4-digit year for FORTRAN.

$
SEARCH MONSYM ;Add TOPS 20 symbols to MACRO
SEARCH MACSYM
SEARCH MTHPRM
SEARCH FORPRM

SEGMENT CODE

HELLO (DATE4Y) ;Entry to DATE() routine.

PUSH P,T2 ;Save AC's
PUSH P,T3


HRROI T1,@0(L) ;Point to address for result
SETO T2, ;Ask for today's date
MOVX T3,OT%NTM ;Do not want time
ODTIM% ;Do the JSYS



POP P,T3 ;Restore accumulators
POP P,T2
POPJ P, ;Return to FORTRAN


SEGMENT DATA


SVDT: BLOCK 3


FORPRG

END ;End of program


I am pretty much a beginner when dealing with MACRO, but this is how I get
it put together:

Put the MACRO code above in a file called DATE.MAC. If your FORTRAN
program is titled ECO.FOR, do the following:

COMPILE DATE.MAC

COMPILE ECO.FOR

LINK
*DATE
*/START=ECO
*/GO

This leaves the executable in core. Then do a...

SAVE ECO

...to save the ECO.EXE file that you can run.

+<><><><><><><><><><><><><><><><><><><>+
| Charles Richmond nume...@aquaporin4.com |
+<><><><><><><><><><><><><><><><><><><>+

gem...@idirect.com

unread,
Dec 25, 2011, 4:50:51 PM12/25/11
to
Charles, you are a Scholar and a Prince! This is exactly what I was
looking
for! What a great Christmas present! I am just gobsmacked by how
cool this DEC20
emulator is, and my hat is off to Mark Crispin, Rich Alderson, and
everyone else
involved in making it available. It is a truly remarkable
achievement. I don't
know any of its history, but I assume it was orginally done to
preserve someone's
software investment. Now, it provides an excellent, alive-and-
working, historical
example of something that I thought was just plain gone. I am happy
to have
it back.
I (we?) had access to all these library routines to do what we
needed. They
probably came from Decsystem-10 code, I don't know. The thing I am
restoring
is a simple timeseries-oriented data management tool... but it had the
flavour and
feel of a simple AI. You could dialogue with it, and it would do
stuff automagically,
that a thinking economist wants to do, to quick-test the barebones of
a theory.
I wrote the Editor and all the statistical and correlation routines in
it, so it feels
like a Ver. 0.7 of something that I just plain have wanted since my
university days.
It was built for a Canadian provincial gov't, and so it may still be
the property of
the Queen. Since I wrote half of it, and I have already changed a
*lot* of it, just
by typing it in, I don't think she (or her agents!) will object...
If I can get enough of it working in a way that is of some use, I will
port it up to
Linux. But since a lot of it uses A5-isms, having the DEC20 emulator
lets me proof
of concept the thing without doing too much violence to the code.
It is just such a totally different way of looking and thinking about
"data", than what
we now have. Everything is either a spreadsheet hack, or an SQL
table, with XML
stuff... ugh. I don't know MACRO to save my life, but I did build
a "Personal
Business Index" database (essentially an automated Rollodex) on my
1983 IBM
P/C in actual P/C MS-DOS Assembler! (I still can't believe it..
Imagine going from
PASCAL to Assembler. ) Long strange trip its been....
Thanx again for your reply and for this code and example. I will try
it tonite or
tomorrow.
Much appreciated. I will post any questions/results, etc. here, for
others to follow
if they might be interested... (I searched the group for this, but I
am accessing
via Google, so perhaps they are only holding a small amount of usenet
group history...)
- Mark L.




On Dec 25, 12:01 am, "Charles Richmond" <netn...@aquaporin4.com>
wrote:
> |      Charles Richmond       numer...@aquaporin4.com     |
> +<><><><><><><><><><><><><><><><><><><>+

Mark Crispin

unread,
Dec 25, 2011, 5:14:45 PM12/25/11
to
On Sun, 25 Dec 2011, gem...@idirect.com posted:
> I am just gobsmacked by how cool this DEC20 emulator is, and my hat is
> off to Mark Crispin, Rich Alderson, and everyone else involved in making
> it available.

The person who deserves the credit for the emulator is Ken Harrenstien
(the "KLH" of klh10). I have made some minor changes to the emulator; but
the vast bulk of it is Ken's work.

I put together the Panda TOPS-20 software distribution, much of which was
what I did (with others) at Stanford in the late 1970s-1980s. I did quite
a bit of OS patches, plus I wrote or co-wrote a number of application
problems (especially Internet applications).

I am glad to hear that you enjoy it.

-- Mark --

http://panda.com/mrc
Democracy is two wolves and a sheep deciding what to eat for lunch.
Liberty is a well-armed sheep contesting the vote.

gem...@idirect.com

unread,
Dec 26, 2011, 3:51:54 PM12/26/11
to
Hi,
Ah, thanx for this. I thought the KLH was a DEC system
designation... Tell Ken Harrenstein thanx if you are ever in
contact with him, and thanx also, Mark, for your work on
the distribution. I never thought I would be able to log into
a DEC-20 from an iPad, and run my 30year old stats-code..!
All the best from sunny Ontario.
- Mark L.


On Dec 25, 5:14 pm, Mark Crispin <m...@panda.com> wrote:
> On Sun, 25 Dec 2011, geme...@idirect.com posted:

gem...@idirect.com

unread,
Dec 26, 2011, 4:41:33 PM12/26/11
to
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     |
> +<><><><><><><><><><><><><><><><><><><>+

David Todd

unread,
Apr 25, 2012, 10:28:07 PM4/25/12
to
Sorry for the multiple postings, but I finally figured out how to post this as a reply to the original note.

On Dec 24 2011, 7:14 am, geme...@idirect.com wrote:

> Only pain is that silly DATE() bug - "Happy Dec. 24th, 201", according
> to my little system...
> I just need a way to get a proper date for the system, from somewhere.
> I've grabbed the DATE() MACRO code from one of Alderson's posts, and
> even compiled
> the DATIME.MAC library code from "Trailing Edge". I can't find tech.
> specs. on how to
> call JSYS routines from Fortran (and oddly enough, can't recall how I
> did it 30 years ago!)

Rus,

My earlier posting attempt seems not to have made it to the list, so here's another try.

I've been resurrecting old Chemistry programs from 30 years ago and ran into
the same date problem. I was using MDATE, which returns the data as a
two-word array or doubleword. I wrote a Macro routine that gets called the same
way and returns the date as "2012\04\25". The link to it as a .mac
file on Dropbox is:

https://www.dropbox.com/s/c5hntl4te6egiei/mdate.mac

and the code (perhaps badly formatted) is:

TITLE MDATE - FORTRAN Subroutine to return date in 2nd millenium
SEARCH MONSYM,MACSYM
.REQUIRE SYS:MACREL
;
; Replaces FORTRAN library DATE subroutine, which was not Y2K compatible
;
; Calling sequence
; CALL MDATE(A)
; where A is a 2-word array or double precision variable
; Returns ASCII date string in A in the format yyyy\mm\dd
; (NOT an ASCIZ string -- a 10-char ASCII string, printable as A10 or 2A5)
;
; Written by H D Todd, Williston, VT, December, 2011
;
T0==0
T1==1
T2==2
T3==3
T4==4
L==16
P==17
;
ENTRY MDATE
SIXBIT /MDATE/
MDATE: PUSH P,T1 ;SAVE REGS WE USE
PUSH P,T2
PUSH P,T3
PUSH P,T4
MOVX T2,-1 ;GET TODAY'S DATE AS COMPONENTS
SETZ T4,
ODCNV%
;RESULTS COME BACK AS
;T2: YEAR,,MONTH-1
;T3: DAY-OF-MONTH-1,,DAY-OF-WEEK-1
;T4: FLAGS FROM CONVERSION
PUSH P,T3 ;SAVE DOM-1,,DOW-1
PUSH P,T2 ;SAVE YEAR,,MO-1
MOVE T1,[POINT 7,DS] ;POINT TO BLOCK THAT WILL HOLD STRING
HLRZ T2,T2 ;GET YEAR
MOVX T3,[NO%MAG+NO%LFL+NO%ZRO+FLD(4,NO%COL)] ;FORMAT FOR 4-COL, NO SIGN, FILL IF NEEDED (!?)
HRRI T3,^D10 ;DECIMAL RADIX
NOUT% ;PUT OUT TEXT
EJSHLT ; IF ERROR
MOVEI T2,"\"
BOUT%
POP P,T2 ;RETRIEVE YEAR,,MO-1
HRLI T2,0 ;BLANK YEAR
ADDI T2,1 ;NOW HAVE MO IN T2
MOVX T3,[NO%MAG+NO%LFL+NO%ZRO+FLD(2,NO%COL)] ;FORMAT FOR 2-COL, NO SIGN, LEFT FILL WITH ZEROS
HRRI T3,^D10 ;RADIX TEN
NOUT%
EJSHLT ; IF ERROR
HRRZI T2,"\"
BOUT
POP P,T3 ;RETRIEVE DOM-1,,DOW-1
HLRZ T2,T3 ;DOM-1 IN T2 NOW
ADDI T2,1 ;DAY OF MONTH IN T2
MOVX T3,[NO%MAG+NO%LFL+NO%ZRO+FLD(2,NO%COL)] ;FORMAT FOR 2-COL, NO SIGN, LEFT FILL WITH ZEROS
HRRI T3,^D10 ;RADIX TEN
NOUT%
EJSHLT
DMOVE T1,DS ;GET TWO-WORD ASCII DATE
DMOVEM T1,@0(L) ;STORE INTO TARGET
POP P,T4
POP P,T3
POP P,T2
POP P,T1
RET ;RETURN CONTROL TO CALLING ROUTINE
DS: BLOCK 3 ;HAVE TO STORE HERE BECAUSE LAST NOUT DOES ASCIZ, WOULD OVERWRITE DOUBLEWORD
END

Rich Alderson

unread,
Apr 26, 2012, 2:51:52 PM4/26/12
to
David Todd <hdt...@gmail.com> writes:

> TITLE MDATE - FORTRAN Subroutine to return date in 2nd millenium

You mean "third millenium", don't you? :-)

--
Rich Alderson ne...@alderson.users.panix.com
the russet leaves of an autumn oak/inspire once again the failed poet/
to take up his pen/and essay to place his meagre words upon the page...

Robert Bonomi

unread,
Apr 27, 2012, 3:14:56 AM4/27/12
to
In article <mddr4va...@panix5.panix.com>,
Rich Alderson <ne...@alderson.users.panix.com> wrote:
>David Todd <hdt...@gmail.com> writes:
>
>> TITLE MDATE - FORTRAN Subroutine to return date in 2nd millenium
>
>You mean "third millenium", don't you? :-)


I *seriously* doubt that either the author, the hardware involved, *or*
the programming environment existed in the 'zeroth' millennium. <snicker>

Somewhat less facetiously -- the original code was written in one millennium
and being used in a second one -- necessitating the change.

Johnny Billquist

unread,
Apr 27, 2012, 9:15:13 AM4/27/12
to
On 2012-04-27 09.14, Robert Bonomi wrote:
> In article<mddr4va...@panix5.panix.com>,
> Rich Alderson<ne...@alderson.users.panix.com> wrote:
>> David Todd<hdt...@gmail.com> writes:
>>
>>> TITLE MDATE - FORTRAN Subroutine to return date in 2nd millenium
>>
>> You mean "third millenium", don't you? :-)
>
>
> I *seriously* doubt that either the author, the hardware involved, *or*
> the programming environment existed in the 'zeroth' millennium.<snicker>

Not sure there ever was a zeroth millennium.

Years 1-1000 was the first millennium. 1001-2000 was the second
millennium. 2001-3000 is the third millennium.
When would the zeroth millennium have been?

> Somewhat less facetiously -- the original code was written in one millennium
> and being used in a second one -- necessitating the change.

Indeed. But that does not mean it is *the* second millennium. :-)

Johnny

David Todd

unread,
Apr 28, 2012, 7:23:51 AM4/28/12
to
On Thursday, April 26, 2012 2:51:52 PM UTC-4, Rich Alderson wrote:
> David Todd <hdtodd at gmail.com> writes:
>
> > TITLE MDATE - FORTRAN Subroutine to return date in 2nd millenium
>
> You mean "third millenium", don't you? :-)
>
> --
> Rich Alderson news at alderson.users.panix.com
> the russet leaves of an autumn oak/inspire once again the failed poet/
> to take up his pen/and essay to place his meagre words upon the page...

Rich,

Absolutely right! Thanks.

I wasn't around for the zeroth millenium, but wow!, the problems around Y1K were a heck of a lot more difficult than the Y2K problems. You'd think I'd learn to count by now.

As Digital used to say in response to bug reports, "Fixed in the next release". Which is now up on the Dropbox site.

Thanks, all. Hope the code ends up being useful to someone.

David

David Meyer

unread,
Mar 15, 2022, 10:48:51 PM3/15/22
to
I would like to do some date arithmetic programming in Fortran on TOPS-20 and have been trying to get the Fortran DATE() bug work-arounds posted above to work, but without success.

1. Charles Richmond's DATE4Y.MAC (posted on 2011/12/25) will compile on LCM+L's TOAD-2 (creates DATE4Y.REL), but with the following errors:

[NOKNOW] LS:<~>@ comp date4y
MACRO: FORDAT
+10 PAGE 1
RU 000000' 000000 000000* SEGMENT CODE
+32
RU 000013' 000000 000000* SEGMENT DATA
DATA Unassigned, defined as if external
CODE Unassigned, defined as if external
SEGMENT Unassigned, defined as if external

?4 ERRORS DETECTED

EXIT

(DATE4Y.MAC won't compile on other TOPS-20 systems I have access to (including twenex.org) due to not being able to find MTHPRM.)

Charles's TSM.FOR demo program compiles, but produces the following errors when I try linking it with DATE4Y.REL (mostly understandable from the DATE4Y compile errors):

[NOKNOW] LS:<~>@ link
*date4y
*/start=tsm
*/go
?LNKUGS 7 undefined global symbols
TMDATE 437
SEGMENT 0
DATA 153
PARSER 463
CODE 140
CHANNL 421
CLEARC 423

2. David Todd's MDATE.MAC (posted 2012/4/26) compiles without errors on all TOPS-20 systems I have tried. I created the following Fortran program to test MDATE, which also compiles without errors:

C TMDATE.FOR - Test MDATE subroutine

PROGRAM TMDATE
CHARACTER*10 DATSTR
CALL MDATE (DATSTR)
TYPE *, DATSTR
STOP
END

Link also terminated normally:

[NOKNOW] LS:<~>@ comp tmdate
FORTRAN: TMDATE
TMDATE
[NOKNOW] LS:<~>@ link
*mdate
*/start=tmdate
*/go
[NOKNOW] LS:<~>@ save
TMDATE.EXE.1 Saved

However, running TMDATE seems to produce an endless loop of pages of blank output.

Any insights will be appreciated.



David Meyer

unread,
Mar 15, 2022, 11:00:05 PM3/15/22
to
On Wednesday, March 16, 2022 at 11:48:51 AM UTC+9, David Meyer wrote:
> 2. David Todd's MDATE.MAC (posted 2012/4/26) compiles without errors on all TOPS-20 systems I have tried. I created the following Fortran program to test MDATE, which also compiles without errors:
>
> C TMDATE.FOR - Test MDATE subroutine
>
> PROGRAM TMDATE
> CHARACTER*10 DATSTR
> CALL MDATE (DATSTR)
> TYPE *, DATSTR
> STOP
> END

My test programs appears to work if I change the data declaration from "CHARACTER*10 DATSTR" to "DOUBLE PRECISION DATSTR" or "INTEGER DATSTR (2)" as David's documentation instructs.

David Meyer

unread,
Mar 16, 2022, 12:21:55 AM3/16/22
to
On Wednesday, March 16, 2022 at 12:00:05 PM UTC+9, David Meyer wrote:
> My test programs appears to work if I change the data declaration from "CHARACTER*10 DATSTR" to "DOUBLE PRECISION DATSTR" or "INTEGER DATSTR (2)" as David's documentation instructs.

For the benefit of other Fortran novices, here's an improved version of my MDATE test program that calls David's subroutine then prints the date string:

C TMDATE.FOR - Test MDATE subroutine

PROGRAM TMDATE
INTEGER DATARY (2)
CALL MDATE (DATARY)
TYPE 10, DATARY (1), DATARY (2)
10 FORMAT (' ', A, A)
STOP
END

gah4

unread,
Mar 16, 2022, 1:45:41 AM3/16/22
to
On Tuesday, March 15, 2022 at 9:21:55 PM UTC-7, papa...@gmail.com wrote:

(snip)

> PROGRAM TMDATE
> INTEGER DATARY (2)
> CALL MDATE (DATARY)
> TYPE 10, DATARY (1), DATARY (2)
> 10 FORMAT (' ', A, A)
> STOP
> END

I might have thought those would be A5 format. Is the default 5?

David Meyer

unread,
Mar 16, 2022, 3:52:40 AM3/16/22
to
On Wednesday, March 16, 2022 at 2:45:41 PM UTC+9, gah4 wrote:
> I might have thought those would be A5 format. Is the default 5?

Yes, for single-precision values. Default is A10 for double-precision.

(The program works because I was lucky, not because I knew that. ;)

David Todd

unread,
Mar 20, 2022, 6:14:17 PM3/20/22
to
On Tuesday, March 15, 2022 at 10:48:51 PM UTC-4, papa... wrote:
> I would like to do some date arithmetic programming in Fortran on TOPS-20 and have been trying to get the Fortran DATE() bug work-arounds posted above to work, but without success.

As a result of smj's upgrade to KANKAN and associated boot camps, I've started fiddling with my Mac-hosted Panda DEC-20 (thinking of MRC every time I fire it up). I saw your note and was amused and pleased that my 10-year-old MACRO routine for a long-dead hardware platform was useful to someone. Thanks for that.

But as I thought about it, if you're doing date arithmetic processing, you'd probably really want the date in numeric form. And that seemed like a fun exercise. So here it is. Hope it's useful, or at least interesting. Much easier getting the numbers than the strings.

Apologies for the formatting below ... no "code" formatting in Google Groups conversations, apparently. I can drop these somewhere if you think they're useful but have trouble with the formatting.

David

C NDTEST.FOR - Test NDATE subroutine

PROGRAM NDTEST
INTEGER DATSTR(3)
CALL MDATE (DATSTR)
TYPE 10, DATSTR(1), DATSTR(2), DATSTR(3)
10 FORMAT(' Today''s date is: ', I4, '\', i2, '\', i2)
STOP
END

cat ndate.mac
TITLE NDATE - FORTRAN Subroutine to return date in 3rd millenium
SEARCH MONSYM,MACSYM
.REQUIRE SYS:MACREL
;
; Replaces FORTRAN library DATE subroutine, which was not Y2K compatible
;
; Calling sequence
; CALL MDATE(A)
; where A is a 3-word array
; Returns the date as 3 integers, YYYY, MM, DD in that array
; MM = 1..12 and dd 1..{28, 30, 31}
;
; Written by H D Todd, Williston, VT, March, 2022
;
T0==0
T1==1
T2==2
T3==3
T4==4
L==16
P==17
;
ENTRY MDATE
SIXBIT /MDATE/
MDATE: PUSH P,T1 ;SAVE REGS WE USE
PUSH P,T2
PUSH P,T3
PUSH P,T4
MOVX T2,-1 ;GET TODAY'S DATE AS COMPONENTS
SETZ T4,
ODCNV%
;RESULTS COME BACK AS
;T2: YEAR,,MONTH-1
;T3: DAY-OF-MONTH-1,,DAY-OF-WEEK-1
;T4: FLAGS FROM CONVERSION
HRRZ T1,0(L) ;GET THE ADDRESS OF THE OUTPUT ARRAY
HLRZM T2,0(T1) ;STORE THE YEAR
ADDI T2,1 ;GET MON IN T2 RIGHT HAND SIDE
HRRZM T2,1(T1) ;STORE THE MONTH
HLRZ T2,T3 ;GET DOW-1 INTO T2
ADDI T2,1 ;DOW NOW IN T2
HRRZM T2,2(T1) ;STORE THE DAY OF MONTH
POP P,T4
POP P,T3
POP P,T2
POP P,T1
RET ;RETURN CONTROL TO CALLING ROUTINE
END

Rich Alderson

unread,
Mar 21, 2022, 2:48:59 PM3/21/22
to
Removing the "quoted printable" "formatting"...
--
Rich Alderson ne...@alderson.users.panix.com
Audendum est, et veritas investiganda; quam etiamsi non assequamur,
omnino tamen proprius, quam nunc sumus, ad eam perveniemus.
--Galen
0 new messages