Disclaimer: I have little experience with fortran, but recently I need to read a very old routine mirkdc for a project, so for now my goal is simply getting this code run locally.
MIRKDC is a solver for BVP and there are also a driver on netlib.
I try to compile mirkdc.f90 and mirkdc_driver.f90 locally but always got a lot of errors.
gfortran mirkdc_driver.f90 -o mirkdc_driver
Besides, when I opened mirkdc.f90 file using vscode, the extension seems doesn’t recognize the comment?
The first thing to note is that the code is in so-called fixed form. This is the original layout for Fortran source code. Ever since Fortran 90 there has been a second form, called free form, that is more flexible and preferred by many (most?) programmers. The two forms are commonly distinguished via the file extension: .f for fixed form and .f90 for free form. This is not chiseled in stone, but it does help to use this convention.
The first thing to do then is to rename the two files to .f. That should help the compiler to compile it correclty.
I downloaded the two files and used gfortran to compile them. With the default options I got messages about rank mismatches. That is a consequence of an ancient idiom. Use -std=legacy to get rid of them. (They are then turned into warnings).
You will need BLAS routines to actually build the program.
Expanding on this: the original file seemed to have different indentation from the screenshot shown here. The keyword subroutine is indented 6 spaces in the original file, and the + continuation character is in the sixth column.
Fixed form requires the the first six characters to be blank, unless a continuation is used. It also assumes lines are ended unless explicitly continued. Here, on line 1 we see an error at the end highlighted because the line should be continued but is not.
Thanks a lot!!! Now I know why I can’t compile them.
@Arjen I followed your instruction but the code still seems weird(the indentation are all wrong here) Could you help me by telling the detailed flow of how you successfully ran the code? , e.g. the detailed commands and operations. It would help me a lot!
Well, I copied the code from netlib, as per the links you showed. By simply copying from the webpage, which preserved the indentation in my case, I got the source files I required. My command-line read:
As there are a number of routines (from the BLAS library) that were not included in that build command, I got a list of unresolved externals, but the compile errors were all gone - turned into warnings.