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
 
Thread 'Star maps using Blender'
Blender just recently dropped a new version, 4.5(with 5.0 on the horizon), and within it was a new feature for which I immediately thought of a use for. The new feature was a .csv importer for Geometry nodes. Geometry nodes are a method of modelling that uses a node tree to create 3D models which offers more flexibility than straight modeling does. The .csv importer node allows you to bring in a .csv file and use the data in it to control aspects of your model. So for example, if you...
I tried a web search "the loss of programming ", and found an article saying that all aspects of writing, developing, and testing software programs will one day all be handled through artificial intelligence. One must wonder then, who is responsible. WHO is responsible for any problems, bugs, deficiencies, or whatever malfunctions which the programs make their users endure? Things may work wrong however the "wrong" happens. AI needs to fix the problems for the users. Any way to...

Similar threads

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