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

Differing types error

omnia666
Beginner
664 Views
Hi Everyone,

I'm new to this forum, I hope I'm keeping up all the guidelines...
I've been working with a proprietary code, and tried to make a copy of one of the subroutines so that it will receive and return double precision variables instead of real ones. For that purpose, I copied the subroutine itself, a suroutine it calls, and the interface, and changed all the relevant variables and numbers within them to double precision. I've been getting "error #6633: The type of the actual argument differs from the type of the dummy argument", but I have checked and triple-checked that all the variables are declared as double precision. I'm not using any new types, either, only the internal double precision declarations.
Since the code is proprietary, I can't post it here, and I can't think of a simple way to reproduce the problem. I know that it's impossible to give a solution under such restrictions, and I don't expect one - but I'd really appreciate any ideas that could direct me in the right direction...

Thanks in advance.
0 Kudos
1 Reply
JVanB
Valued Contributor II
664 Views
Since you haven't posted any code, we are forced to compose our own examples.

[bash]module mod implicit none interface subroutine sub(x) double precision x end subroutine sub end interface end module mod program prog use mod implicit none real x x = 1 call sub(x) end program prog recursive subroutine sub(x) use mod, other => sub implicit none real x procedure(other), pointer :: fpp fpp => sub end subroutine sub [/bash]
Here the handwritten interface disagrees with both the actual external subroutine and the calling context. I tried this code with gfortran and got some very nice error messages:

[bash]wrong_type.f90:15.12: call sub(x) 1 Error: Type mismatch in argument 'x' at (1); passed REAL(4) to REAL(8) wrong_type.f90:23.10: fpp => sub 1 Error: Interface mismatch in procedure pointer assignment at (1): Type/rank mism atch in argument 'x'[/bash]
We can see that for the incorrect invocation in program prog gfortran tells us exactly which argument is mismatched and the nature of the mismatch. Inside subroutine sub we have added the Fortran procedure pointer fpp for the explicit purpose of comparing the interface body to the declarations in sub. Although the error message isn't quite as nice as the one received from program prog it still seems to narrow the possibilities down significantly.

I suggest you try tests like this with ifort or gfortran to see if you can stigmatize some syntax as an error. This may enable you to create a very small example which gives no hint as to the nature of the actual code so that you can post it safely.
0 Kudos
Reply