To dreamcoder:
The error could have many causes, most likely the disparity between 64-bit NASM compilation and not insisting that gfortran use 64-bit integers and reals, which was fixed by adding those flags to the gfortran compilation. Not insisting leaves those sizing decisions to gfortran's optimizer, which might leave garbage in the high-order 32-bits of a 64-bit word. Who knows...
Moving on. Earlier in the year, I believe I found value, and maybe behavioral, differences, between addresses acquired via Fortran's "loc" function and a machine address function written in assembly, "madov," which I used seven years ago. I'll be reviewing my notes about that and see what conclusion I reached, if any.
If you've downloaded gfortran you could write your own madov.asm function and test it with same gfortran main program. The "madov" function must leave the address in RAX, and must have those same ending underscores in its name. And gfortran main program must include.
integer, external :: madov
You could also keep Fortran's "loc" to see if they match.
Infer how to add it to the gfortran compilation by looking at how "set" was added. Don't forget the three Fortran flags.
Michael