File organization in really old COBOL code.

May 7, 2020 Mainframe , , , , , , , , , , , , ,

I encountered customer COBOL code today with a file declaration of the following form:

000038   SELECT AUSGABE ASSIGN TO UR-S-AUSGABE            
000039    ACCESS IS SEQUENTIAL.                   
...
000056 FD  AUSGABE                                                     
000057     RECORDING F                                                  
000058     BLOCK 0 RECORDS                                              
000059     LABEL RECORDS OMITTED.                                       

where the program’s JCL used an AUSGABE (German “output”) DDNAME of the following form:

//AUSGABE   DD    DUMMY

The SELECT looked completely wrong to me, as I thought that SELECT is supposed to have the form:

SELECT cobol-file-variable-name ASSIGN TO ddname

That’s the syntax that my Murach’s Mainframe COBOL uses, and also what I’d seen in big-blue’s documentation.

However, in this customer’s code, the identifier UR-S-AUSGABE is longer than 8 characters, so it sure didn’t look like a DDNAME. I preprocessed the code looking to see if UR-S-AUSGABE was hiding in a copybook (mainframe lingo for an include file), but it wasn’t. How on Earth did this work when it was compiled and run on the original mainframe?

It turns out that [LABEL-]S- or [LABEL]-AS- are ways that really old COBOL code used to specify file organization (something like PL/I’s ENV(ORGANIZATION) clauses for FILEs). This works on the mainframe because a “modern” mainframe COBOL compiler strips off the LABEL- prefix if specified and the organization prefix S- as well, essentially treating those identifier fragments as “comments”.

For anybody reading this who has only programmed in a sane programming language, on sane operating systems, this all probably sounds like verbal diarrhea.  What on earth is a file organization and ddname?  Do I really have to care about those just to access a file?  Well, on the mainframe, yes, you do.

These mysterious dependencies highlight a number of reasons why COBOL code is hard to migrate. It isn’t just a programming language, but it is tied to the mainframe with lots of historic baggage in ways that are very difficult to extricate.  Even just to understand how to open a file in mainframe COBOL you have a whole pile of obstacles along the learning curve:

  • You don’t just run the program in a shell, passing in arguments, but you have to construct a JCL job step to do so.  This specifies parameters, environment variables, file handles, and other junk.
  • You have to know what a DDNAME is.  This is like a HANDLE in the JCL code that refers to a file.  The file has a filename (DSNAME), but you don’t typically use that.  Instead the JCL’s job step declares an arbitrary DDNAME to refer to that handle, and the program that is run in that job step has to always refer to the file using that abstract handle.
  • The file has all sorts of esoteric attributes that you have to know about to access it properly (fixed, variable, blocked, record length, block size, …).  The program that accesses the file typically has to make sure that these attributes are all encoded with the equivalent language specific syntax.
  • Files are not typically just byte streams on the mainframe but can have internal structure that can be as complicated as a simple database (keyed records, with special modes to access them to initialize vs access/modify.)
  • To make life extra “fun”, files are found in a variety of EBCDIC code pages.  In some cases these can’t be converted to single byte iso-8859-X code pages, so you have to use utf-8, and can get into trouble if you want to do round trip conversions.
  • Because of the internal structure of a mainframe file, you may not be able to transfer it to a sane operating system unless special steps are taken.  For example, a variable format file with binary data would typically have to be converted to a fixed format representation so that it’s possible to seek from record to record.
  • Within the (COBOL) code you have three sets of attributes that you have to specify to “declare” a file, before you can even attempt to open it: the DDNAME to COBOL-file-name mapping (SELECT), the FD clause (file properties), and finally record declarations (global variables that mirror the file data record structure that you have to use to read and write the file.)

You can’t just learn to program COBOL, like you would any sane programming language, but also have to learn all the mainframe concepts that the COBOL code is dependent on.  Make sure you are close enough to your eyewash station before you start!

Finding the cheapest copy of my geometric algebra book on amazon

May 3, 2020 Geometric Algebra for Electrical Engineers , , ,

My book, “Geometric Algebra for Electrical Engineers” is available as a free PDF here on my website, but also available in color ($40) and black-and-white ($12) formats on amazon.  Both versions are basically offered close to cost, should the reader be like me, preferring a print copy that can be marked up.  In fact, I made it available initially just so that I could get a cheap bound copy for my own use that I could mark up myself.

I noticed today that amazon now hides the cheapest version of my book, and seems shows the price of a reseller first.  For example, if you click the link to the $12 black-and-white version, it now appears that the book is selling for $13.01

but if you click on “Other Sellers”, the kindle-direct (print on demand) version that amazon offers itself hides further down in the list of sellers.  The version that I’m selling directly through amazon.com is third on the list, despite it being the cheapest:

I guess that I’ve priced the black-and-white version of the book so low, that there are resellers that are willing to try to make some profit selling their own copies.  Do they depend on amazon giving them preferential listing order to make those sales?  I wonder how many of the people who have bought my book have ended up accidentally paying a higher price, using one of these resellers?

It does not appear that any resellers have played this game with the color version of the book, which has a higher price point.  I’m curious now to look at the sales stats for the two variations of the book to see how many of each version are selling (hardly any in either case, as the subject matter is too esoteric, but it was actually enough over the whole year that I did include the revenue on my income taxes.)

splitting the last git commit into two

April 23, 2020 C/C++ development and debugging. , ,

In the blog post, Split a commit in two with Git, Emmanuel provides a super clear explanation of how to split an old commit into multiple commits, separating that commit into different commits, each with a subset of the files initially committed.

It took me a while before I could figure out how to apply this to the very last commit.  Here’s the required git magic:

git log -n 1 > m
git reset HEAD^
git add ...
git commit -m "First part"
git add ...
git commit -m "Second part"

The differences are really to just skip the first and last rebase steps (don’t do an interactive rebase, and don’t continue that rebase when done.) This was probably obvious to the author of the more general instructions.

Note that before resetting HEAD to the previous commit, I collect the current commit message, under the assumption that portions of it will be used in either of the two (or more) new commit messages.  If you don’t do that, you can fish it out of your history by looking at ‘git reflog’ to see what the message was before mucking around with HEAD.

How absurd: facebook marketplace has promoted me to arms-dealer.

April 7, 2020 Incoherent ramblings , ,

I tried giving away some of Lance’s old model rocket stuff, but facebook has determined, even after appeal, that I am an arms dealer:

My listing description was:

Rocket launching base and trigger, a few engines (2x B6-6 and 2x 1/2A3-T4) and igniters, and some recovery wadding. The metal post that was originally on the launching base got lost somewhere along the way, but any straight conductive rod of the same diameter should do the job.

Available for porch pickup (M4X1C2, cabbagetown: Parliament and Wellesley)

The message from them, after my appeal, specifically says that this has been determined to be a weapon:

It’s been a long time since I’ve been in trouble with the law for weapons sales (there was that time back in grade 3 when I made the best ninja stars in my school and opened a little business for myself.)  I used to call myself a drug pusher when I worked for Bowles pharamacy, making sure that all the little old ladies (and that super stinky guy at 59 Edgewood) got their fixes.  Now I can add arms dealer to my resume along with drug dealer.

Incidentally, if you want some old model rocket stuff, including 4 weapons grade engines, please send me a message, and you can have it.

Shon Hopwood’s “Law Man” book.

March 22, 2020 Uncategorized , , ,

I’d heard Shon Hopwood interviewed on the Rubin report quite a while ago.  Now that I’m living in Toronto, I have the Toronto Public Library at my disposal (which has a far superior selection to the Markham Public Library).  They had Hopwood’s book, which I’d been meaning to read for a while, and luckily was able to pick it up before the current coronavirus mass hysteria shut down the library and most of the world:

The story in this book is really amazing.

Part of the book describes life in prison.  What I know of prison comes from a couple sources.  The first of those sources is the most unreliable (movies), the second is an old childhood friend who I saw after he’d served some time (*), and the last is a family member who is now a guard in the US prison system.  This book added a bit more color to my understanding of that very different world.  There are probably lots of prison memoirs, but this is one that is exceptionally well written.  I really loved the way it starts by telling a story right off the bat.

The improbability of Shon’s story is truly phenomenal and inspiring.  The subset of Shon’s life that is described in this book ends with him starting as a law student, but I knew from the Rubin interview and Wikipedia others that he completed that schooling and went on to work as both a lawyer and a law professor!  In his book Shon ends up, somewhat reluctantly, attributing some of his miraculous story to a higher power.  Perhaps a higher power was at work, but so was a lot of very hard work.

I’d highly recommend this book.  It provides a glimpse of prison life, some peeks of aspects of injustice of the US justice system (which is probably mirrored by Canadian law), and shows how Shon managed to avoid the trap of perpetually cycling through iterations of prison and crime with a with a combination of hard work and luck.  Along the way, it tells a very entertaining and inspiring story.

Footnotes:

(*) I had a friend who had the misfortune to end up dating the daughter of one the Toronto Chinese mafia kingpins when we were both in high school.  Things didn’t go well for him after that dating selection, to say the least, and it’s been over 25 years since I heard from him.  He did tell me all about guards on the take, butt smuggling of drugs and cigarettes into prison, and the absurdity of airport security theater given how many airport staff were effectively paid mafia employees.  I’m sure that airport mafia payroll is still essentially the same, despite airport security theater now being far worse than it was in the 90s — criminals can still get the guns and drugs through the system easily, but we have to throw away our toothpaste and finger nail clippers, and dangerous too-big water bottles.