Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Type mismatch when converting from 77 to 90

Status
Not open for further replies.

mojomother

Programmer
Apr 20, 2010
9
DE
I've converted a program from f77 to f90 syntax and am now getting errors of the type "The type of the actual argument differs from the type of the dummy argument" with Intel Visual Fortran 10.


The code from where the errors originate has the following structure:

Code:
SUBROUTINE routine1(w)
   ...
   REAL*8 w(length)
   ...
>  CALL routine2(w(pos1), w(pos2), w(pos3), w(pos4))
END SUBROUTINE routine1

SUBROUTINE routine2(w1, w2, w3, w4)
   ...
   REAL*8 w1(l1,l2), w2(l3), w3(l4,l5,l6), w4(l7)
   ...
END SUBROUTINE routine2

The line marked with ">" gives the errors. I do see what the general problem is, the call passes elements of an array which are then re-interpreted as multi-dimensional arrays by the receiving routine. However, the same piece of code compiles without issues using Fortran77 compilation.

I need f90 for my project, though. Any ideas on how to solve that particular problem? The array "w" needs to be flat, so simply defining the same substructure as used by routine2 is not an option.

Thank you in advance,
Matt
 
The parameters to routine2 are arrays. You are passing single elements to it.

Can't see how it can possibly compile on F77. It is semantically incorrect. You may be able to get around it using EQUIVALENCE statements but not all F90s support EQUIVALENCE on parameters. The alternative is to declare the same sized arrays in routine1 and transfer the contents of w before calling routine2. Then transfer the contents back to w after calling routine2.

The other problem is whether any of the arrays overlap.
 
I found the problem, there was a simple type mismatch (REAL/INTEGER) which I had not noticed before.

In fact, the behavior described (passing array elements and have them reinterpreted as array markers) works without problems in both f77 and f90.

Have a good day,
Matt
 
Interesting feature. As I mentioned earlier: make sure your arrays do not overlap.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top