I am porting our 850,000 lines of F77 code to the latest Intel Fortran..
The hidden verification of all the subroutine arguments is causing me a
lot of work. Plus this little code change got me when I back ported to
our Open Watcom F77 compiler:
double precision factor (1)
...
factor = qaunit / 5.44444d0
The calculation of factor is legal for the Intel Fortran compiler but
not on the Open Watcom F77 compiler. Is this part of the array changes
in the F90 and above compilers ?
I am porting our 850,000 lines of F77 code to the latest Intel Fortran.
The hidden verification of all the subroutine arguments is causing me a
lot of work.
Plus this little code change got me when I back ported to
our Open Watcom F77 compiler:
double precision factor (1)
...
factor = qaunit / 5.44444d0
The calculation of factor is legal for the Intel Fortran compiler but
not on the Open Watcom F77 compiler. Is this part of the array changes
in the F90 and above compilers ?
I am porting our 850,000 lines of F77 code to the latest Intel Fortran..
The hidden verification of all the subroutine arguments is causing me a
lot of work. Plus this little code change got me when I back ported to
our Open Watcom F77 compiler:
double precision factor (1)
...
factor = qaunit / 5.44444d0
The calculation of factor is legal for the Intel Fortran compiler but
not on the Open Watcom F77 compiler. Is this part of the array changes
in the F90 and above compilers ?
Since dimensioning an array to a size of zero or one was not defined in F77.
it is likely that the dimension of 1 was using an old extension for what became the asterisk; so FACTOR is a parameter on a procedure? And since this was before array syntax was supported if FACTOR was an array then the statement FACTOR = ... makes nosense; so probably need to see more than just the QAUNIT declaration;
but what the code looked like originally as well; but it looks like you were using some really old extensions or some other information is missing.
I am porting our 850,000 lines of F77 code to the latest Intel Fortran.
The hidden verification of all the subroutine arguments is causing me a
lot of work. Plus this little code change got me when I back ported to
our Open Watcom F77 compiler:
double precision factor (1)
...
factor = qaunit / 5.44444d0
The calculation of factor is legal for the Intel Fortran compiler but
not on the Open Watcom F77 compiler. Is this part of the array changes
in the F90 and above compilers ?
I am porting our 850,000 lines of F77 code to the latest Intel Fortran.
The hidden verification of all the subroutine arguments is causing me a
lot of work. Plus this little code change got me when I back ported to
our Open Watcom F77 compiler:
double precision factor (1)
...
factor = qaunit / 5.44444d0
The calculation of factor is legal for the Intel Fortran compiler but
not on the Open Watcom F77 compiler. Is this part of the array changes
in the F90 and above compilers ?
Thanks,
Lynn
The question at hand is assignment of a scalar to an array. This is
legal in F90, but I can't find any words in F77 to either allow or
reject it. My guess is that this was not valid in F77. (I am assuming
that qaunit is a scalar.)
By the way, we have seen standard-conforming FORTRAN 77 which will not compile under Fortran 90 and later, though these are very rare. Before someone asks, for example:
REAL NU, LAMBDA
DIMENSION NU(1000)
LAMBDA(NU) = C(ALT) / NU ! Statement function for wavelength, NU remains scalar.
I don't think this works in Fortran 2018!
By the way, we have seen standard-conforming FORTRAN 77 which will not compile
under Fortran 90 and later, though these are very rare. Before someone asks, for example:
REAL NU, LAMBDA
DIMENSION NU(1000)
LAMBDA(NU) = C(ALT) / NU ! Statement function for wavelength, NU remains scalar.
I don't think this works in Fortran 2018!
On Saturday, December 11, 2021 at 11:08:47 AM UTC+11, Lynn McGuire wrote:
I am porting our 850,000 lines of F77 code to the latest Intel Fortran..
The hidden verification of all the subroutine arguments is causing me a
lot of work. Plus this little code change got me when I back ported to
our Open Watcom F77 compiler:
double precision factor (1)
...
factor = qaunit / 5.44444d0
The calculation of factor is legal for the Intel Fortran compiler but
not on the Open Watcom F77 compiler. Is this part of the array changes
in the F90 and above compilers ?
You have not stated what the declaration of qaunit is.
We have migrated a great deal of legacy Fortran code to modern compilers, usually gfortran or ifort. We always carry out a back-port of any modifications to the original compiler. This is sometimes essential in verifying that changes in the code havenot changed the behaviour.
I agree with @mecej4 that it is desirable to migrate to a standard and not to a compiler. But sometimes legacy codes may contain language extensions which affect a large number of statements. The Intel and gfortran authors have taken great care topreserve these features. There is sometimes a strong argument to migrate to a specific compiler, at least as a first step. We recently migrated over a million lines of VMS Fortran to ifort. The VMS code used STRUCTURE, MAP and UNION. A systematic
By the way, we have seen standard-conforming FORTRAN 77 which will not compile under Fortran 90 and later, though these are very rare. Before someone asks, for example:
REAL NU, LAMBDA
DIMENSION NU(1000)
LAMBDA(NU) = C(ALT) / NU ! Statement function for wavelength, NU remains scalar.
I don't think this works in Fortran 2018!
John
Lynn McGuire <lynnmcguire5@gmail.com> schrieb:
I am porting our 850,000 lines of F77 code to the latest Intel Fortran.
The hidden verification of all the subroutine arguments is causing me a
lot of work.
As it should :-)
It is usually advisable to use several compilers, and heed the
warnings from all of them. gfortran would be an obvious choice
(it's free). NAG is excellent with checking and run-time checks.
Plus this little code change got me when I back ported to
our Open Watcom F77 compiler:
double precision factor (1)
...
factor = qaunit / 5.44444d0
The calculation of factor is legal for the Intel Fortran compiler but
not on the Open Watcom F77 compiler. Is this part of the array changes
in the F90 and above compilers ?
Assuming that quaunit is a scalar, what you write there is an
assignment statement for the whole array factor with a scalar right-hand-side. All elements (one, in this case) of "factor"
get assigned the same value.
Perfectly legal, and this may or may not be what you intended.
...
map
double precision d
end map
map
integer i
integer i_low
end map
On 12/13/2021 4:40 PM, Lynn McGuire wrote:
...
map
double precision d
end map
map
integer i
integer i_low
end map
There is something odd about i_low coming after i. Does your software
run on big-endian hardware? Or are you solving something similar to the
"nUxi problem"?
Lynn McGuire <lynnmcguire5@gmail.com> schrieb:
I am porting our 850,000 lines of F77 code to the latest Intel Fortran.
The hidden verification of all the subroutine arguments is causing me a
lot of work.
As it should :-)
It is usually advisable to use several compilers, and heed the
warnings from all of them. gfortran would be an obvious choice
(it's free). NAG is excellent with checking and run-time checks.
Plus this little code change got me when I back ported to
our Open Watcom F77 compiler:
double precision factor (1)
...
factor = qaunit / 5.44444d0
The calculation of factor is legal for the Intel Fortran compiler but
not on the Open Watcom F77 compiler. Is this part of the array changes
in the F90 and above compilers ?
Assuming that quaunit is a scalar, what you write there is an
assignment statement for the whole array factor with a scalar right-hand-side. All elements (one, in this case) of "factor"
get assigned the same value.
Perfectly legal, and this may or may not be what you intended.
On Saturday, December 11, 2021 at 11:08:47 AM UTC+11, Lynn McGuire wrote:
I am porting our 850,000 lines of F77 code to the latest Intel Fortran..
The hidden verification of all the subroutine arguments is causing me a
lot of work. Plus this little code change got me when I back ported to
our Open Watcom F77 compiler:
double precision factor (1)
...
factor = qaunit / 5.44444d0
The calculation of factor is legal for the Intel Fortran compiler but
not on the Open Watcom F77 compiler. Is this part of the array changes
in the F90 and above compilers ?
You said that you were porting to the latest Intel compiler.
So, why are you trying to port to F77?
That assignment is not a statement that was legal in F77.
So why did you change it from F77?
On 12/10/2021 7:08 PM, Lynn McGuire wrote:
I am porting our 850,000 lines of F77 code to the latest Intel
Fortran. The hidden verification of all the subroutine arguments is
causing me a lot of work. Plus this little code change got me when I
back ported to our Open Watcom F77 compiler:
double precision factor (1)
...
factor = qaunit / 5.44444d0
The calculation of factor is legal for the Intel Fortran compiler but
not on the Open Watcom F77 compiler. Is this part of the array
changes in the F90 and above compilers ?
The question at hand is assignment of a scalar to an array. This is
legal in F90, but I can't find any words in F77 to either allow or
reject it. My guess is that this was not valid in F77. (I am assuming
that qaunit is a scalar.)
You did mention "subroutine arguments", so I think John was on the right track when he mentioned the use of (1) as a way around bounds violations
in F66. F77 added assumed-size arrays (*), but many compilers allowed
(1) as a substitute.
Since dimensioning an array to a size of zero or one was not defined in F77 it is likely that the dimension of 1 was using an old extension for what became the asterisk; so FACTOR is a parameter on a procedure? And since this was before array syntaxwas supported if FACTOR was an array then the statement FACTOR = ... makes no sense; so probably need to see more than just the QAUNIT declaration;
but what the code looked like originally as well; but it looks like you were using some really old extensions or some other information is missing..
F66 allowed (1) also. At least the IBM CMS and MVS compilers allowed that.
On 12/11/2021 4:02 AM, Robin Vowels wrote:
On Saturday, December 11, 2021 at 11:08:47 AM UTC+11, Lynn McGuire wrote: >>> I am porting our 850,000 lines of F77 code to the latest Intel Fortran.
The hidden verification of all the subroutine arguments is causing me a.
lot of work. Plus this little code change got me when I back ported to
our Open Watcom F77 compiler:
double precision factor (1)
...
factor = qaunit / 5.44444d0
The calculation of factor is legal for the Intel Fortran compiler but
not on the Open Watcom F77 compiler. Is this part of the array changes
in the F90 and above compilers ?
You said that you were porting to the latest Intel compiler.
So, why are you trying to port to F77?
That assignment is not a statement that was legal in F77.
So why did you change it from F77?
Because Watcom does not care if you send a scalar to a subroutine for a vector of (1) whereas Intel Fortran cares very much.
Lynn
On 12/13/2021 10:12 PM, Lynn McGuire wrote:.
On 12/11/2021 4:02 AM, Robin Vowels wrote:
On Saturday, December 11, 2021 at 11:08:47 AM UTC+11, Lynn McGuire wrote: >>> I am porting our 850,000 lines of F77 code to the latest Intel Fortran. >>> The hidden verification of all the subroutine arguments is causing me a >>> lot of work. Plus this little code change got me when I back ported to >>> our Open Watcom F77 compiler:
.
double precision factor (1)
...
factor = qaunit / 5.44444d0
The calculation of factor is legal for the Intel Fortran compiler but
not on the Open Watcom F77 compiler. Is this part of the array changes >>> in the F90 and above compilers ?
You said that you were porting to the latest Intel compiler.
So, why are you trying to port to F77?
That assignment is not a statement that was legal in F77.
So why did you change it from F77?
Because Watcom does not care if you send a scalar to a subroutine for a vector of (1) whereas Intel Fortran cares very much.
Lynn
The statement that "... Watcom does not care whereas Intel does"
requires qualification. Perhaps, you can give an example and state the compiler options that you used. For the following example, neither
Watcom 1.9 nor Intel 2021 cares; the options I used are -BO -TR for
Watcom and /check:all for Intel.
program LMG
implicit none
integer iv(5),i
do 10 i = 1,5
iv(i) = 2*i-1
10 continue
call sub(iv,5)
print *,iv
end
subroutine sub(kv,n)
implicit none
integer i,n,kv(1) !The '(1)' is taken to be '(*)'
do 10 i=1,n
kv(i) = kv(i)/2+1
10 continue
return
end
On 12/13/2021 10:12 PM, Lynn McGuire wrote:
On 12/11/2021 4:02 AM, Robin Vowels wrote:
On Saturday, December 11, 2021 at 11:08:47 AM UTC+11, Lynn McGuire
wrote:
I am porting our 850,000 lines of F77 code to the latest Intel Fortran. >>>> The hidden verification of all the subroutine arguments is causing me a >>>> lot of work. Plus this little code change got me when I back ported to >>>> our Open Watcom F77 compiler:.
double precision factor (1)
...
factor = qaunit / 5.44444d0
The calculation of factor is legal for the Intel Fortran compiler but
not on the Open Watcom F77 compiler. Is this part of the array changes >>>> in the F90 and above compilers ?
You said that you were porting to the latest Intel compiler.
So, why are you trying to port to F77?
That assignment is not a statement that was legal in F77.
So why did you change it from F77?
Because Watcom does not care if you send a scalar to a subroutine for
a vector of (1) whereas Intel Fortran cares very much.
Lynn
The statement that "... Watcom does not care whereas Intel does"
requires qualification. Perhaps, you can give an example and state the compiler options that you used. For the following example, neither
Watcom 1.9 nor Intel 2021 cares; the options I used are -BO -TR for
Watcom and /check:all for Intel.
program LMG
implicit none
integer iv(5),i
do 10 i = 1,5
iv(i) = 2*i-1
10 continue
call sub(iv,5)
print *,iv
end
subroutine sub(kv,n)
implicit none
integer i,n,kv(1) !The '(1)' is taken to be '(*)'
do 10 i=1,n
kv(i) = kv(i)/2+1
10 continue
return
end
I really have no idea what Intel Fortran compile options that I am using
are. I am just using the defaults at this time. For instance, I am
getting this error concerning this call:
double precision ddummy
...
CALL UNIVOL (DDUMMY,1,DUNIT,VOLKEY(1),VOLKEY(3),2)
Severity Code Description Project File Line Suppression State
Error error #8284: If the actual argument is scalar, the dummy argument
shall be scalar unless the actual argument is of type character or is an element of an array that is not assumed shape, pointer, or
polymorphic. [VAL] C:\dii\CHM\PURCOM\tabpur.f 176
I load univol.f and find that the first argument is VAL which is defined as:
SUBROUTINE UNIVOL (VAL,N,NAMES,KEY,KSP,IGO)
integer N
double precision VAL (N)
So I will have to convert the definition of DDUMMY in tabpur.f to:
double precision ddummy (1)
On 12/14/2021 8:24 AM, mecej4 wrote:.
On 12/13/2021 10:12 PM, Lynn McGuire wrote:
On 12/11/2021 4:02 AM, Robin Vowels wrote:
On Saturday, December 11, 2021 at 11:08:47 AM UTC+11, Lynn McGuire
wrote:
I am porting our 850,000 lines of F77 code to the latest Intel Fortran. >>>> The hidden verification of all the subroutine arguments is causing me a >>>> lot of work. Plus this little code change got me when I back ported to >>>> our Open Watcom F77 compiler:.
double precision factor (1)
...
factor = qaunit / 5.44444d0
The calculation of factor is legal for the Intel Fortran compiler but >>>> not on the Open Watcom F77 compiler. Is this part of the array changes >>>> in the F90 and above compilers ?
You said that you were porting to the latest Intel compiler.
So, why are you trying to port to F77?
That assignment is not a statement that was legal in F77.
So why did you change it from F77?
Because Watcom does not care if you send a scalar to a subroutine for
a vector of (1) whereas Intel Fortran cares very much.
Lynn
The statement that "... Watcom does not care whereas Intel does"
requires qualification. Perhaps, you can give an example and state the compiler options that you used. For the following example, neither
Watcom 1.9 nor Intel 2021 cares; the options I used are -BO -TR for
Watcom and /check:all for Intel.
program LMG
implicit none
integer iv(5),i
do 10 i = 1,5
iv(i) = 2*i-1
10 continue
call sub(iv,5)
print *,iv
end
subroutine sub(kv,n)I really have no idea what Intel Fortran compile options that I am using
implicit none
integer i,n,kv(1) !The '(1)' is taken to be '(*)'
do 10 i=1,n
kv(i) = kv(i)/2+1
10 continue
return
end
are. I am just using the defaults at this time. For instance, I am
getting this error concerning this call:
double precision ddummy
...
CALL UNIVOL (DDUMMY,1,DUNIT,VOLKEY(1),VOLKEY(3),2)
Severity Code Description Project File Line Suppression State
Error error #8284: If the actual argument is scalar, the dummy argument
shall be scalar unless the actual argument is of type character or is an element of an array that is not assumed shape, pointer, or
polymorphic. [VAL] C:\dii\CHM\PURCOM\tabpur.f 176
I load univol.f and find that the first argument is VAL which is defined as:
SUBROUTINE UNIVOL (VAL,N,NAMES,KEY,KSP,IGO)
integer N
double precision VAL (N)
So I will have to convert the definition of DDUMMY in tabpur.f to:
double precision ddummy (1)
Lynn McGuire <lynnmc...@gmail.com> schrieb:
2 | CALL UNIVOL (DDUMMY,1,DUNIT,VOLKEY(1),VOLKEY(3),2)
| 1
Error: Rank mismatch in argument 'val' at (1) (rank-1 and scalar)
but they amount to the same thing.
So I will have to convert the definition of DDUMMY in tabpur.f to:
double precision ddummy (1)Yes. If an array is expected, you have to pass an array or
(in this case) an array element.
This is touching on the biggest porting issue going from
older code to modern code with interfaces, at least in my
experience. Modern fortran really wants the rule to be "array to
array and scalar to scalar", but because every compiler I know of pre-fortran90 allowed the same behavior as C every large code I
ever modernized had this as an issue, and the exceptions like in
the example are more a minimal bow to this history than a feature;
so I would recommend passing a(2:) instead of a(2) above.
Note that many (all that I know of) F77 compilers
would have allowed
program show
real a(10)
data a /1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0/
a=[(real(i),i=1,size(a))]
call foo(a(2),9)
call foo(10.0,1)
end
subroutine foo (b,n)
integer n
real b(n)
write(*,*)b
return
end
This is touching on the biggest porting issue going from older code to modern code with interfaces, at least in my experience. Modern fortran really wants the
rule to be "array to array and scalar to scalar", but because every compiler I know of pre-fortran90 allowed the same behavior as C every large code
I ever modernized had this as an issue, and the exceptions like in the example
are more a minimal bow to this history than a feature;
so I would recommend passing a(2:) instead of a(2) above.
Note that many (all that I know of) F77 compilers
would have allowed
On Tuesday, December 14, 2021 at 10:04:39 PM UTC-8, John wrote:You can also generate beautiful little bugs with using (1) instead of (*). If I remember correctly, I once had to use a rather large library, where a lot of arrays were declared like that. I replaced the ones that were subroutine arguments with (*), but
This is touching on the biggest porting issue going from older code to modernIt has been standard since Fortran 66, and still is for assumed size dummy arrays, that you can pass an array element, and reference element from that one to the end of the array. (You are not supposed to use negative subscripts
code with interfaces, at least in my experience. Modern fortran really wants the
rule to be "array to array and scalar to scalar", but because every compiler
I know of pre-fortran90 allowed the same behavior as C every large code
I ever modernized had this as an issue, and the exceptions like in the example
are more a minimal bow to this history than a feature;
and reference earlier elements.)
It won't work for assumed shape, which is recommended by many
for new code.
Assumed size also allows for passing to a different rank array, commonly used to process a matrix, with a 1D dummy array. Many matrix routines
from the Fortran 66 days do that.
so I would recommend passing a(2:) instead of a(2) above.You want a(2:) for assumed shape, which will generate a descriptor
Note that many (all that I know of) F77 compilers
would have allowed
with the appropriate bounds, and pass those bounds.
You can also generate beautiful little bugs with using (1) instead of (*).
If I remember correctly, I once had to use a rather large library, where a lot of
arrays were declared like that. I replaced the ones that were subroutine arguments with (*), but they also used (1) in common blocks (last variable), and gfortran used that information for optimizing loops:
program whatever
! size of x depends on the problem to be solved
common /workarray/ i(100), x(2500)
...
call sub(...some arguments...)
end program
! library code
subroutine sub(....)
common /workarray/ i(100), x(1)
do j = 1, n
x(i) = ...
end do
end subroutine
and gfortran optimized away the loop. Compiler option -funconstrained-commons solved the problem, but a proper modernization of the code would have been much nicer. I do not know if the same happens with subroutine arguments.
I am familiar with that, I still recommend using a(2:)
unless a compiler is bad enough to make a copy because of the
array syntax, as the need for upward compatibility has created
a lot of inconsistencies; like requiring kind=real64 on REAL((10.0d,20.0d),kind=real64) and so on.
The risk the compiler will go a gather-scatter is real, but probably
means you need a better compiler.
Upward compatibility can go to
far. Taking the example back a few years ....
A little more like some old Fortran code.
Works fine with nvfortran and ifort, only
gfortran required splitting it into two
files to run.
* main
1000 0real*8 a(5),b(5),c(10)
2000 0data a /1.0, 2.0, 3.0, 4.0, 5.0/
3000 0data b /6.0, 7.0, 8.0, 9.0, 10.0/
4000 0equivalence
1 (a,c(1)),
2 (b,c(6))
5000 0calls 00 (c(2),9)
This arrives here as
"5000 0calls 00 (c(2),9)"
which makes little sense.
On 12/15/2021 3:22 PM, Thomas Koenig wrote:
This arrives here as
"5000 0calls 00 (c(2),9)"
which makes little sense.John's fixed form source code has unnecessary statement numbers, '0's in column 6, and has non-significant blanks added in some places and
removed in other places. These features may bother humans, but the
compiler should be able to handle them.
The above statement could be written
call s00(c(2),9)
--
mecej...@nospam.invalid
(Replace four by 4, nospam by gmail, invalid by com,
and remove all underscores)
I think it works with gfortran too. It does give a *warning*, not an error, and the output is what you sent.
gfortran -s -O2 -std=legacy clf_john.f -o clf_john
clf_john.f:10:16:
10 | call s01 (10.0d0,1)
| 1
Warning: Rank mismatch in argument ‘b’ at (1) (rank-1 and scalar) [-Wargument-mismatch]
I am using gfortran 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04).
I am familiar with that, I still recommend using a(2:) unless a compiler is bad enough to make a copy because of the array syntax, as the need for upward compatibility has created a lot of inconsistencies; like requiring kind=real64 on REAL((10.0d,20.0d),kind=real64) and so
on. The risk the compiler will go a gather-scatter is real, but probably means you need a better compiler. Upward compatibility can go toI think it works with gfortran too. It does give a *warning*, not an error, and the output is what you sent.
far. Taking the example back a few years ....
A little more like some old Fortran code.
Works fine with nvfortran and ifort, only
gfortran required splitting it into two
files to run.
* main
1000 0real*8 a(5),b(5),c(10)
2000 0data a /1.0, 2.0, 3.0, 4.0, 5.0/
3000 0data b /6.0, 7.0, 8.0, 9.0, 10.0/
4000 0equivalence
1 (a,c(1)),
2 (b,c(6))
5000 0calls 00 (c(2),9)
6000 0calls 01 (10.0d0,1)
6500 0calls 01 (c(2),9)
7000 0end
* subroutines
8000 0subroutines 00 (b,n)
9000 0integer n
1000 0real*8 b(1)
1 0continue
1100 0do 2i=1,n
2 0write(6,'(2HB=999F8.4,1X)')b(i)
1200 0return
1300 0entrys 01(b,n)
1400 0write(6,'(2HN=I9)')n
0goto 1
1500 0return
1600 0end
#!/bin/bash
set -x
rm -f ./a.out
#gfortran tmp.f -Wargument-mismatch
gfortran tmp1.f tmp2.f && ./a.out
rm -f ./a.out
ifort tmp.f && ./a.out
rm -f ./a.out
nvfortran tmp.f && ./a.out
B= 2.0000
B= 3.0000
B= 4.0000
B= 5.0000
B= 6.0000
B= 7.0000
B= 8.0000
B= 9.0000
B= 10.0000
N= 1
B= 10.0000
N= 9
B= 2.0000
B= 3.0000
B= 4.0000
B= 5.0000
B= 6.0000
B= 7.0000
B= 8.0000
B= 9.0000
B= 10.0000
The non-standard example was actually a back-port of the original example highlighting that.
compilers often not only support previous standards but non-standard usage as well,
which is understandable given the long history of Fortran and how in the past it was often highly extended, particularly before C and Unix emerged that makes it even harder to reliably upgrade old code without being aware of
what the history of the code is (what platforms did it ever work on);
which was meant to highlight why it can be important to port code to standard-conforming F77 code first
(which because F77 is a subset of F90+.
also means the code becomes much more portable);.
and lets you develop unit tests in the original environment more reliably before starting a more
extensive upgrade. Even gfortran, which has become much more NAG-like in strictly applying
standard conformance by default in recent releases, the code will compile without warning if the
subroutine and main program are placed in separate files. I often find placing all the source in a
single file as a test useful partly for this reason (especially in the past that could also give a
big performance guide primarily because it allowed for more inlining and other optimizations when
the compiler could "see everything"; but modern compilers are often much better about optimizing
multi-file builds than in the past). Several of the features like the asterisk comment and
dimensioning and real*8 were never standard as I remember it; but very very common extensions;
but dimensioning to one now has a standard-conforming meaning so you really have to be careful
with that one; some of the other syntax was not only a bit of a try at humor but shows how tooling
you might make to automate some migration can easily run into issues if it looks for certain words
like subroutine or procedure names like s00 shows in the example. I do not know if more recent
compilers will ever even consider supporting some of that old syntax, but if they do some of the
works in progress could give access to automatic migration tools. I think NAG has a tool that
will rewrite the code; and I think that the LFortran project plans to be able to read your Fortran
code in and rewrite it as standard-conforming (although it is unlikely it would automatically
convert a COMMON to a MODULE) which sounds like it could be very useful in a circumstance like
this. But the example was just a few mods to the original to illustrate (I thought somewhat
humourously, but perhaps not) how even such a horrible little code snippet would compile with
three newer-facing compilers; which is create for code longevity but horrible in other respects.
At least I did not add computed GOTOs.
I am porting our 850,000 lines of F77 code to the latest Intel Fortran.If you still have access to the Watcom compiler, there is a great advantage to doing the conversion on it. You can then test as you do the conversion, step by step. One you think it is compatible with the Intel compiler, you can test that. If it fails,
The hidden verification of all the subroutine arguments is causing me a
lot of work. Plus this little code change got me when I back ported to
our Open Watcom F77 compiler:
double precision factor (1)
...
factor = qaunit / 5.44444d0
The calculation of factor is legal for the Intel Fortran compiler but
not on the Open Watcom F77 compiler. Is this part of the array changes
in the F90 and above compilers ?
Thanks,
Lynn
On Friday, December 10, 2021 at 7:08:47 PM UTC-5, Lynn McGuire wrote:
I am porting our 850,000 lines of F77 code to the latest Intel Fortran.
The hidden verification of all the subroutine arguments is causing me a
lot of work. Plus this little code change got me when I back ported to
our Open Watcom F77 compiler:
double precision factor (1)
...
factor = qaunit / 5.44444d0
The calculation of factor is legal for the Intel Fortran compiler but
not on the Open Watcom F77 compiler. Is this part of the array changes
in the F90 and above compilers ?
There is a separate issue with associating a scalar actual argument with
the dummy array, factor(1). That is not legal anywhere. It works on some compilers because they happen to pass all arguments by address. But historically, compilers have used various ways to associate actual and
dummy arguments, and not all of those are consistent with the rank
mismatch. For example, some compilers pass the first few scalar
arguments through registers rather than by address. In that case the
actual scalar argument value would have been loaded into a register,
used directly in the register within the subprogram, and then eventually copied back from that register into its memory location by the calling program. The dummy declaration would have looked for an address on the
stack for that argument instead of its value in the register, so the
compiler would not have made the correct association between actual and
dummy argument. If the compiler could not detect such errors, then
syntax tools such as FTNCHEK could detect them. Contrary to some
previous statements in this thead, this was a fairly common error in
fortran codes in the 70s and 80s, and I think most programmers were
aware of the problem, they just did not have or use the tools available
to detect and correct the code. In the above case, as I understand it,
it was a recently introduced error, not a legacy error.
On Friday, December 10, 2021 at 7:08:47 PM UTC-5, Lynn McGuire wrote:back to Watcom for some revision and testing. Of course this means you can't start using F90+ features until you have standard F77 code and can then move the testing to Intel, but I don't think that is a big disadvantage compared to working from the
I am porting our 850,000 lines of F77 code to the latest Intel Fortran.If you still have access to the Watcom compiler, there is a great advantage to doing the conversion on it. You can then test as you do the conversion, step by step. One you think it is compatible with the Intel compiler, you can test that. If it fails,
The hidden verification of all the subroutine arguments is causing me a
lot of work. Plus this little code change got me when I back ported to
our Open Watcom F77 compiler:
double precision factor (1)
...
factor = qaunit / 5.44444d0
The calculation of factor is legal for the Intel Fortran compiler but
not on the Open Watcom F77 compiler. Is this part of the array changes
in the F90 and above compilers ?
Thanks,
Lynn
You can get the Open Watcom C, C++, and F77 compiler at: http://www.openwatcom.org/
Have you tried using either fpt or PlusFort in the migration? Either should find the problems and may fix them automatically.
We would very much like to know which issues cause the most difficulty.
Best wishes,
John
Ben Barrowes <benbarrowes@gmail.com> schrieb:
On Friday, January 28, 2022 at 2:14:27 PM UTC-5, john.c...@simconglobal.com wrote:
Have you tried using either fpt or PlusFort in the migration? Either should find the problems and may fix them automatically.
We would very much like to know which issues cause the most difficulty.
Best wishes,
John
I would like to echo John Appleyard's recommendation above. PlusFort does a good job of cleaning up code and modernizing it to more modern standards, gives good diagnostics as well.
If you want to do a source to source conversion of your fortran
code into matlab/octave or python, I could help with that kind of
project.
Before doing this kind of thing, consider that
- With Matlab, you are committing to the vendor lock from hell
- With Python, you are committing to a highly unstable, moving
target, see
http://blog.khinsen.net/posts/2017/11/16/a-plea-for-stability-in-the-scipy-ecosystem/
All three of these versions have the drawback of abysmally slow
execution (factor of 10000 or so)
On Friday, January 28, 2022 at 2:14:27 PM UTC-5, john.c...@simconglobal.com wrote:
Have you tried using either fpt or PlusFort in the migration? Either should find the problems and may fix them automatically.
We would very much like to know which issues cause the most difficulty.
Best wishes,
John
I would like to echo John Appleyard's recommendation above. PlusFort does a good job of cleaning up code and modernizing it to more modern standards, gives good diagnostics as well.
If you want to do a source to source conversion of your fortran
code into matlab/octave or python, I could help with that kind of
project.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 159 |
Nodes: | 16 (0 / 16) |
Uptime: | 99:55:25 |
Calls: | 3,209 |
Files: | 10,563 |
Messages: | 3,009,979 |