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

Scalar arguments passed to dummy array arguments

nssmith
Beginner
406 Views
I have recently upgraded to the Version 11 compiler under Visual Studio 2005. I am working on several large legacy F77 Fortran projects, and when I turn on the Interface Checking option I run into the following problem involving scalar arguments passed to dummy array arguments. As a typical example I have a 1-D interpolation subroutine INTERP1 that performs local quadratic interpolation to provide both an interpolated function value and its first derivative.

SUBROUTINE INTERP1(Nintp, Xintp, Yintp, Ypintp, Ntbl, Xtbl, Ytbl)
....
INTEGER :: Nintp, Ntbl
REAL :: Xintp(*), Yintp(*), Ypintp(*), Xtbl(*), Ytbl(*)
.....
END

In my legacy F77 project this subroutine gets called numerous times with both with 1-D vector arguments for multiple interpolated output points and with scalar arguments for a single interpolated output point.

INTEGER :: Nvec, Ntbl, Nscl
REAL :: Xvec(Nvec), Yvec(Nvec), Ypvec(Nvec)
REAL :: Xtbl(Ntbl), Ytbl(Ntbl)
REAL :: Xscl, Yscl, Ypscl
...............
CALL INTERP1(Nvec, Xvec, Yvec, Ypvec, Ntbl, Xtbl, Ytbl)
Nscl = 1
CALL INTERP1(Nscl, Xscl, Yscl, Ypscl, Ntbl, Xtbl, Ytbl)

With interface checking turned off this vector/scalar argument usage compiles and runs. With interface checking turned on I get the following typical three error messages per scalar call usage of the subroutine INTERP1.

error #7836: If the actual argument is scalar, the corresponding dummy argument shall be scalar unless the actual argument is an element of an array that is not an assumed-shape or pointer array, or a substring of such an element. [Xscl] C:\\NSS_Office\\Intel Fortran Projects\\HydroV6\\trunk\\HydroV_Lib\\EBHYDRO.FOR 373

error #7836: If the actual argument is scalar, the corresponding dummy argument shall be scalar unless the actual argument is an element of an array that is not an assumed-shape or pointer array, or a substring of such an element. [Yscl] C:\\NSS_Office\\Intel Fortran Projects\\HydroV6\\trunk\\HydroV_Lib\\EBHYDRO.FOR 373

error #7836: If the actual argument is scalar, the corresponding dummy argument shall be scalar unless the actual argument is an element of an array that is not an assumed-shape or pointer array, or a substring of such an element. [Ypscl] C:\\NSS_Office\\Intel Fortran Projects\\HydroV6\\trunk\\HydroV_Lib\\EBHYDRO.FOR 373

How do I fix this type of problem for actual arguments vs dummy arguments? It is leading to a "ton" of error messages with my F77 projects.

Thanks,

Neill Smith
0 Kudos
2 Replies
Steven_L_Intel1
Employee
406 Views
Your program is not legal Fortran 77 in that it passes a scalar to an array. Most older compilers do not catch this error. You can either turn off interface checking, or turn the scalar argument(s) into an array like this:

CALL INTERP1(Nscl, [Xscl], [Yscl], [Ypscl], Ntbl, Xtbl, Ytbl)

For further reading, see the section on Sequence Association here.
0 Kudos
nssmith
Beginner
406 Views
Thanks Steve! That little trick has just saved me a heap of recoding -- it works like a charm.

Neill Smith
0 Kudos
Reply