As I indicated with my last post, I wanted to tackle the random number generator first. This seemed to be the biggest remaining hurdle, as I figured the rest of the coding would be pretty straightforward, but I really didn't expect it to take long. After doing a little research, I found that a linear congruent generator was probably my best bet. Mathematically, it's pretty simple.
Shamelessly stolen from Wikipedia entry for Linear Congruent Generator, entry linked above |
When I tried to use it, I kept getting USER ERROR MAIN 0004 error. Obviously this isn't the most obvious error message ever, and I couldn't find specific information on that error, but I did finally track it down to the MOD function. Apparently it couldn't find the MOD function. Somewhat annoyingly, this doesn't occur in the compilation phase.
To understand, you have to appreciate how any but the most simple of computer applications are compiled. Whether you're dealing with a 50-year old PDP-8 or the latest computer, the basic steps are still the same. There are three basic phases: Compilation, linking/loading, and execution. For OS/8's Fortran IV system, they have F4 as their compiler, a utility called LOAD for loading, and then the FRTS (Fortran Run-Time System) program for linking and execution. Based on what I was seeing, I think they're using what we would today call Late Binding, because I got the error from the last phase, the FRTS utility. I don't recall seeing this term used in the Handbook, so I'm not sure what they would have called it in 1974 when it was written, but it basically means that external functions and subroutines are linked together at execution time rather than compile time (which would be called, not surprisingly, Early Binding).
So even though linking is done in the third phase, actual loading is done in the second phase with the LOAD utility. When doing so, you actually specify your output program, and then specify all the modules that go into it. Looking at a sample LOAD session in the Handbook, one of the modules that you include is the standard library. In the book, it says the standard library is contained in a file named FORLIB.RL, but in the example session they use LIB.RL instead. They have a comment explaining that they're using this name instead of FORLIB.RL, but give no indication why. In any case, after a quick search, neither file appears on the OS/8 hard disk image that I'm using. So I guess this is a slightly misconfigured installation of Fortran.
This leaves me with two options. First, I could try and locate FORLIB.RL and copy it to my system. Or, second, I could just write my own version of mod. Obviously, this isn't difficult, but I would like to be able to use the standard library. I don't really anticipate using it in any of the rest of my program, but it annoys me that I can't so I will at least take a stab at fixing the problem. But I don't really have that much time left, so if I don't fix it soon, I'll just write it myself.
No comments:
Post a Comment