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

  • Thread starter Thread starter Giammy85
  • Start date Start date
  • Tags Tags
    Argument
AI Thread Summary
The discussion revolves around a Fortran programming issue related to array allocation and type mismatches when passing arrays to a subroutine. The user encounters a "Type/rank mismatch in argument 'a'" error after allocating arrays for time, a, and e based on calculated steps. The user initially considers whether the subroutine 'calc' needs to declare these arrays as allocatable and of the same type as in the main program. They realize that the problem was due to a mismatch in data types between the main program and the subroutine, specifically between real and double precision declarations. The issue is resolved when the types are aligned correctly, eliminating the error messages related to allocatable attributes and syntax errors in the allocate statement.
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
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I have a quick questions. I am going through a book on C programming on my own. Afterwards, I plan to go through something call data structures and algorithms on my own also in C. I also need to learn C++, Matlab and for personal interest Haskell. For the two topic of data structures and algorithms, I understand there are standard ones across all programming languages. After learning it through C, what would be the biggest issue when trying to implement the same data...

Similar threads

Replies
12
Views
3K
Replies
2
Views
1K
Replies
1
Views
7K
Replies
8
Views
3K
Replies
7
Views
14K
Back
Top