fortran g77, we got a source code from 1979 pdf .So now we are trying to execute the code but there are multiple errors that are occuring during its execution so i am posting the code it would be quite helpful if anybody could help
Dear @Scientist007, welcome to the forum!
Can you post the code, the exact compiler version and command that you use and the error you are getting?
P.S. Instead of g77
, do you mean F77
?
Welcome, @Scientist007.
The PDF document format was introduced in 1993. G77 is a particular Fortran compiler that compiles Fortran 77 (and earlier versions) with a few extensions and exclusions. Gfortran is a modern successor to G77, but there are other compilers available in addition.
Chances are high that your “1979 pdf” is a scanned version of a printed paper, report or book. Fortran source code derived from such sources using OCR is likely to contain many errors.
In the 1970s, most people used mainframes or minicomputers, and had to use the compiler that was installed on their specific machine, so your scanned code is probably Fortran 66.
Please post your source files as well as the PDF document(s).
https://drive.google.com/drive/folders/1z9X_o17WDGHfDZ2jE_SteR7qSCkQ3ofY?usp=drive_link
the code and errors are in this hope u could help
Please don’t open multiple threads on the same topic, and don’t create multiple user names. I deleted the other threads. Paste code and error messages here. Often looking at just the first few error messages will be enough to identify the problem.
As expected, the source file has plenty of OCR errors. You must supply a readable PDF file; without it, it is nearly impossible to correct those OCR errors.
As remarked upthread, OCR scanning errors may get in the way, please try to solve these first. The errors that result from the corrected source code are likely due to local extensions in the FORTRAN code. I saw one or two in the page that you provided. We will be glad to help out with these, but correcting OCR errors is not a pastime you can ask from us ;).
Is there such a thing as programming-language-aware OCR? Knowing that an image contains code in programming language X ought to help one infer what the characters in the image are. I wonder if ChatGPT or other LLMs are already better at inferring code than previous OCR programs. One could also try a two-step method where OCR is used to infer characters and an LLM is asked to edit the output to make it compilable Fortran code. A human will need to verify the result.
A slightly more legible PDF is available. Fortunately, the report contains sample input and output listings that can be used to verify that the program, when the OCR errors have been corrected and the program can be run, is working correctly.
I estimate that the program will take many hours, possibly days, to repair and debug. You will have to do the work yourself, or get a qualified person to do so on your behalf. The person who does that will need to know Fortran 66 quite well.
This kind of work is quite unpleasant to do, and is to be avoided if possible. Look for a more recent version of the program, or contact ORNL for similar programs for which they are willing to provide source code.
OCR errors can be classified into several groups. Those that result from the wrong number of blanks in sequence, including continuation marks other than in col-6, are fairly easy to fix. Characters that have been lost are quite difficult to find and fix. Incorrectly spelled keywords, such as IP for IF, etc., can be spotted by a language-aware tool as @Beliavsky suggests. The most troublesome are incorrect variable names, incorrectly scanned 0 in place of O, incorrect choice among ‘1’, ‘l’, ‘i’, ‘/’, and so on.
Please confirm that compiler mentioned in the below link is suitable for using for the code
http://www.cs.yorku.ca/~roumani/fortran/ftnOld.htm
we are using DOS command prompt under WIn98 under VMplayer and f77, g77 installed from above site. it is compiling however many errors,
If you are directly compiling the file “FORTRAN CODE”, then it has formatting issues. This is old fixed form Fortran source, with the statements that must be in the columns 7 to 72. A character in the column 6 means this is a continuation line.
New lets look at the lines 16-17:
123456789012345678901234567890123456789012345678901234567890123456789012
DIMENSION AOUT(100), OOUT(100), STVOL(100), DF(4), SOLIN(3), SOLOU 60
1T(3), AQOUT(100), ORGOUT(100) 65
On line 16, the statement is in the columns 8-73 instead of 7-72. It’s OK to start beyond column 7, but not to go beyond column 72.
On line 17, the leading “1
” is obviously the continuation character, but it misplaced in column 7 instead of column 6.
It looks like your entire file is wrongly shifted right by 1 column. The comment lines (the ones starting with a “C
” in the column 1) are OK, though. There are other errors of course, but a lot of them come from this problem when compiling when gfortran.
My recommandation:
- do not bother with an old compiler and a W98 virtual machine, the up-to-date gfortran compiler is fine to compile old FORTRAN 77 codes.
- Reformat you source file by shifting left by one character all lines that do not start with a “
C
” - Retry compiling with gfortran
- Now you will have the errors that come from OCR errors. There’s no choice other than manually editing all the lines that give such errors, by refering to the “original” PDF file and see what was really written
Exemple of OCR error: a zero (“0
”) that is interpreted as the letter “O
” (or vice versa).
No compiler, no matter how old, should be expected to compile scanned program source that contains OCR errors. Even after enough OCR errors are fixed to get the code to compile, the likelihood is zero for the resulting program to produce correct results.
Indeed… There can be many OCR errors that do not result in compilation errors. Such errors can be dramatically reduced if the implicit typing is turned off (implicit none
), but this requires a significant amount of work, as all the variables that were implicitly typed have to be declared.