mm2...@scarletmail.rutgers.edu <
mm2...@scarletmail.rutgers.edu> schrieb:
> The code that I am working with was originally written in
> FORTRAN 77. I am hesitant to update all of the files to a more
> modern standard since there are multiple files thousands of lines
> long that rely on obsolete functions.
Often, there is no need to do a full conversion, getting rid of
a few bugs is often good enough.
What exactly are these "obsolete functions"? Are they non-standard
compiler-supplied intrinsics? If, on the other hand, they are
still in the standard (such as DCOS), I would not worry about them.
Do you know what the original compiler was, and do you have
documentation for it?
> During compilation, I get a few type mismatch arguments, most
> of which are taken care of with -freal-4-real-8, but I am unsure
> if that is a permanent solution.
That can be dangerous, depending on the reason for these mismatches.
If it is just storage allocation (some old Fortran programs have
then), then this may actually work. If it is mismatches... well,
you probably need to look into that.
> I currently use the following flags to compile all of the object
> files which are then compiled into the final executable: -ff2c
> -std=legacy -freal-4-real-8
-ff2c changes the ABI to what f2c did. Is there a particular
reason why you need to do this? I am rather careful about
ABI-altering flags.
> The file in which the error occurs is compiled without the -freal
> flag because it uses a function that requires a real(4) variable.
If you compile one file with one ABI and the other with another ABI,
then you are indeed asking for trouble. It is better not to use
things like -freal-4-real-8 then.
> The current error I am getting upon running the executable is:
> At line 2680 of file twopt.f Fortran runtime error: Assigned label
> is not a target label
So, your program has a bug there.
> The subroutine in which the error occurs takes in REENT as a
> logical parameter. ROUTE is later declared as an integer but is
> not assigned any value which I think might be the reason behind
> the problem. I used print statements to check its value before
> the error occurs, and REENT is true, and ROUTE is 0.
Quesions: Is there any ASSIGN statement in the subroutine?
Are the arguments OK (they very well might not be, due to
flag use)?
>
> Code at lines 2678-2681:
>
> IF (REENT) THEN REENT = .FALSE. GO TO ROUTE END IF
> In the subroutine there is no statement label with the value of
> 0 which also might contribute to the error.
That is not what this is.
An assigned GOTO is a statement like
ASSIGN 100 TO ROUTE
and then later
GOTO ROUTE
which would then jump to
100 CONTINUE
This will not assign the numeric value of 100 to ROUTE. Historically,
this probably put the address of the staement with the number 100
into the variable; gfortran does this a bit differently (using
a shadow variable).
> Again, I am hesitant
> to edit the code too much since it supposedly worked as intended
> back in the ‘90s. Any help would be greatly appreciated.
You should probably understand the code to a degree, at least
where you make changes. You should also try to use all warnings.
Refactoring old code with gfortran, it often (not aways) makes
sense to use -Wall -Werror (and later, -fcheck=all) and then fix
anything that comes up.