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

Interface checking

kolber__Michael
New Contributor I
1,114 Views

I am working on an application that is written in Fortran 77, but was upgraded to use structures based on Compaq f90.  I am trying to get it as compliant as possible.  I have run into cases where in a subroutine call a scalar is passed to an array.  That worked with interface checking turned off, but does not with interface checking turned on.  I would think a scalar would just get assigned to element one of the array.

The more problematic issue I found is when an array is passed to a subroutine that expects a scalar.  No specific element is being passed. it is the entire array.  In Fortran 77 this seemed to not throw any kind of error.

What are the best ways to deal with these issues.

 

Thaks.

Michael

 

 

0 Kudos
6 Replies
andrew_4619
Honored Contributor III
1,114 Views

On the call you can put square brackets around the scalar  e.g. [scalar_var] which constructs an array of 1 element to pass. The interface checking will then be happy. The other way you need to pass array(1) or array(1,1) to pass just the first element as a scalar.

 

0 Kudos
Steve_Lionel
Honored Contributor III
1,114 Views

Passing an array to a scalar, or a scalar to an array, has always been an error in the Fortran language, but, in the absence of explicit interfaces, a compiler had no way to detect the mismatch. 

I discuss this in the section on Sequence Association in Doctor Fortran in "I've Come Here For An Argument"

0 Kudos
kolber__Michael
New Contributor I
1,114 Views

One issue I am trying to fix is when the prior programmers passed a 0 into a subroutine expecting an integer.  I defined a parameter zero and gave it the value 0.  I am still getting a mis-match with that combination.

0 Kudos
Steve_Lionel
Honored Contributor III
1,114 Views

First, are you sure that the corresponding argument is integer? Is there a non-default kind of integer, such as INTEGER*2 specified? Show us the subroutine argument list and all the argument declarations, as well as the call you are making. What is the exact error message?

0 Kudos
andrew_4619
Honored Contributor III
1,114 Views

kolber, Michael wrote:

One issue I am trying to fix is when the prior programmers passed a 0 into a subroutine expecting an integer.  I defined a parameter zero and gave it the value 0.  I am still getting a mis-match with that combination.

I don't get that? Is the integer in the subprogram not declared with default kind? E.G 0 will be a default (4 byte) integer with default compiler settings. Is there any intent specified? Maybe you should show a simple example that has the call and the declarations.

0 Kudos
kolber__Michael
New Contributor I
1,114 Views

I solved the problem.  It was not one of the hard coded 0's that was causing the issue.  It was a parameter that was defined as 0 being passed to a logical variable in the subroutine.

Thanks all for the help.

 

0 Kudos
Reply