Wednesday, July 15, 2020

Microsoft Fortran quirks

F0RTRAN is the one language closest to me, apparently. Hence, my attention to get compilers going.
In a previous post, I covered how to install Watcom F0RTRAN on FreeDOS. Eventually, this might be my compiler of choice anyway.

However, this post is dedicated to Microsoft Fortran and the bad memories about it returning.
Fist of all, there are some abandoned DOS versions of the compiler on the internet. I wont provide any links, since I am not aware of Microsoft officially abandoning this compiler.

I tested the following version on my genuine FreeDOS netbook
MS Fortran 2.0
MS Fortran 3.2
MS Fortran 5.0

First of all, have a look at this F0RTRAN77 code:
      I=3
      WRITE(6,100) I
 100  FORMAT (I3.3)
This should be pretty straight forward, in terms of F0RTRAN77, you might think... not according to Microsoft though.
This code should produce an output like this:
003

All compilers had the same fault, which drive me crazy 30 years ago.
If you code:
      I=3
      WRITE(6,100) I
 100  FORMAT (I3.3)
You would expect the compiler to print on the STDOUT an integer of 3 ciphers filled with 0. Something like:
003
Microsoft thinks differently!

MS Fortran 2.0 does not recognize this format at all. While the compiler in passes 1 and 2 wont create any errors, nor will the linker, the executable wont run.
You need to code:
      I=3
      WRITE(6,100) I
 100  FORMAT (1X,I3)
which will create:
__3

coding
      I=3
      WRITE(6,100) I
 100  FORMAT (I3)
will create:
_3

In fact,  that is not what we ordered!

MS Fortran 3.2 will compile and execute the code,
      I=3
      WRITE(6,100) I
 100  FORMAT (I3.3)
The above code will not produce any reasonable output. This drove me nuts, a few decades ago!
This is what Microsoft thinks the output should look like, when compiling with MS Fortran 5.0:
03
I am not joking. decades ago, it took me days to understand that Microsoft starts counting at 0, while the rest of the F0RTRAN world uses 1 for the first character in a line.
So, contrary to all other F0RTRAN compilers, for MS, one needs to code
      I=3
      WRITE(6,100) I
 100  FORMAT (1X,I3.3)
in order to obtain
003

Of course, this makes no sense at all, and it did not many years ago!


MS Fortran 2.0 does not accept this type of F0RTRAN77 FORMAT.
MS Fortran 3.2 does accept it... and so does MS Fortran 5.0.





The old router to the rescue

This is an interesting one, in my mind.
Some years ago, many actually, I got a router of the brand Sweex. This brand is/was lower end gear for the Dutch market. The router did OK-ish, however, I was not so convinced, so, at some stage, a got another one. No, I wont mention the brand here, since this was the real disappointment.
Anyway, the Sweex LW310V2 did serve a few years, and ended up in storage for a few years.
Finally, lately, I remembered that there was something concerning a "bridge" in this very inexpensive router. I checked my expensive (not to be named) present device, and there was no bridge option. Bummer! Some further giveaway, the company of said more expensive device recently removed the feature of a free dynamic DNS.
So, what was keeping me using the device? Nothing!
Back to the Sweex. It turned out that, while there is a bridge mode present, this is not what I need/ The big deal on this WiFi router is that has a WAN medium option which allows for wireless LAN.
Hence, I had to set my cable modem to allow bridge mode on WiFi and the Sweex WLAN router to wireless WAN mode. Both had to be set on the same channel And there we go.
The Sweex now offers its own WiFi and Ethernet LAN bridged from my cable modem.
Yep, that's what we want.
My old Sweex LW310V2 is back in service, after a break of many years. Glad I did not through it in the garbage, which I intended before.