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
새로운 기여자 I
1,807 조회수

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 포인트
6 응답
andrew_4619
명예로운 기여자 III
1,807 조회수

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 포인트
Steve_Lionel
명예로운 기여자 III
1,807 조회수

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 포인트
kolber__Michael
새로운 기여자 I
1,807 조회수

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 포인트
Steve_Lionel
명예로운 기여자 III
1,807 조회수

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 포인트
andrew_4619
명예로운 기여자 III
1,807 조회수

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 포인트
kolber__Michael
새로운 기여자 I
1,807 조회수

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 포인트
응답