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__3
I=3
WRITE(6,100) I
100 FORMAT (I3)
will create:_3
In fact, that is not what we ordered!
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.