What Causes Type/Rank Mismatch in Argument 'a'?

  • Thread starter Thread starter Giammy85
  • Start date Start date
  • Tags Tags
    Argument
Click For Summary

Discussion Overview

The discussion revolves around a programming error encountered in Fortran related to a type/rank mismatch in an argument passed to a subroutine. Participants explore the implications of data types and array allocation in the context of a numerical computation involving arrays.

Discussion Character

  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant describes an error message related to type/rank mismatch when passing arrays to a subroutine.
  • Another participant questions whether the subroutine needs to declare the arrays as allocatable and of the same type as in the main program.
  • A participant reports that declaring the arrays as allocatable in the subroutine leads to further error messages regarding attribute conflicts.
  • There is a suggestion that the issue may stem from a mismatch in data types between the main program and the subroutine parameters.
  • A later reply indicates that the issue has been resolved, although the specifics of the resolution are not detailed.

Areas of Agreement / Disagreement

Participants generally agree that the type mismatch was the source of the error, but the specific nature of the resolution is not elaborated upon, leaving some uncertainty about the details of the fix.

Contextual Notes

Limitations include the lack of clarity on the specific changes made to resolve the issue and the potential implications of data type mismatches in Fortran programming.

Giammy85
Messages
19
Reaction score
0
Hi,

I'm allocating the dimension of some arrays once I have calculated steps, then I send the allocated arrays to a function but I have the error Type/rank mismatch in argument 'a'.

What am I doing wrong?

Cheers


integer i, steps, noutput, savestep

double integrationtime, outputstep, timestep, deltat, ain, ein

real, dimension(:), allocatable :: a, e, time

steps=int(integrationtime/timestep)



allocate(time(steps), a(steps), e(steps))
time(0)=0.0d0
a(0)=ain*1.49597870691d11
e(0)=ein



call calc (steps, a, e, time)



stop



contains



subroutine calc (steps, a, e, time)

integer i, steps

double precision time(steps), a(steps), e(steps)


do i=1, steps
time(i)=


a(i)=...

e(i)=...


end subroutine calc
 
Technology news on Phys.org
I'm not that familiar with modern fortran, but would the subroutine calc also need to delcare a , e, and time as real allocatable (versus double)?
 
Unfortunately by doing so I have ever more error messages:
In file tidalevolution.f90:84

real, dimension(:), allocatable :: a, e, time
1
Error: ALLOCATABLE attribute conflicts with DUMMY attribute at (1)
In file tidalevolution.f90:86

allocate(time(steps), a(steps), e(steps))
1
Error: Syntax error in ALLOCATE statement at (1)
 
OK, then could it just be a problem with the parameters from the main program being decleared as real while the subroutine parameters are declared as double?
 
Yes, solved
 

Similar threads

  • · Replies 12 ·
Replies
12
Views
4K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 11 ·
Replies
11
Views
5K
  • · Replies 1 ·
Replies
1
Views
7K
  • · Replies 8 ·
Replies
8
Views
4K
  • · Replies 7 ·
Replies
7
Views
14K
  • · Replies 5 ·
Replies
5
Views
6K
  • · Replies 1 ·
Replies
1
Views
3K
Replies
11
Views
16K