Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29276 Discussions

Compiler option for assumed array sizes in subroutines

pneumann
Beginner
519 Views
An old practice in Fortran would pass arrays in a call to a Fortran subroutine. Within the subroutine the array size would be defined just as x(1), for an array x. The subroutine array x would assume the size of the array in the subroutine call.

I believe there was an option back in Compaq Visual Fortran v.6.x and in earlier versions of Intel Fortran but I can't locate the compiler option in the latest Intel Visual Fortran. Can anyone help me locate this compiler option?

Thanks,
Peter
0 Kudos
3 Replies
TimP
Honored Contributor III
519 Views
Up to 30 years ago, what became x(*) in f77, and was named assumed size in f90, was typically written as x(1), for want of a standard way. Do you mean an option to enable subscript range checking without complaining about the obsolete practice? Early ifort versions required the option /WB to turn some of those from fatal error to warning. That option is still available to allow some strange legacy practices.
0 Kudos
mecej4
Honored Contributor III
519 Views
The subroutine array x would assume the size of the array in the subroutine call

Not quite. The caller did not pass the size of the argument array to the subroutine at all. The declaration x(1) simply told the compiler that the argument x was an array, and that x(1) was an array element rather than an invocation of a function named x with argument=1. With most compilers, you could put some other number in place of 1, and it would make no difference. Perhaps because of that, the more meaningful notation x(*) was introduced later, as TimP stated.

Unless you ask the compiler (CVF or Intel) to check subscripts, you need no compiler options to process code with such declarations.

Some compilers (I think that the obsolete G77 was one such) would refuse to compile code that contained expressions such as x(2) when x had been declared with the dummy dimension (1). With such a compiler, replacing the "(1) " by "(*)" had to be done throughout the code.
0 Kudos
Steven_L_Intel1
Employee
519 Views
There was no option in CVF to allow (1) to be treated as (*) - it did it automatically. So does Intel Fortran.
0 Kudos
Reply