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

The number of actual arguments cannot be greater than the number of dummy arguments

milenko1976
Beginner
4,245 Views
ifort -c ircg.for
ircg.for(124): error #6784: The number of actual arguments cannot be greater than the number of dummy arguments. [NEWCALC1]
call newcalc1(iter,l)
module lstep1
use params
use mt2ddat
contains
subroutine newcalc1(iter,l)

implicit none

integer,intent(in) :: iter
integer:: i,j,x
real, dimension(80,21) :: sens
real, dimension(21,80) :: ist,ftw
integer,dimension(80,80) :: wd1,wd2
real,dimension(80,1):: d,p1
real,dimension(21,1):: p,q,dlm,a
integer,dimension(21,21) :: wm1,wm2,wm3
real :: norm20,norm21

allocate(l(iter))

do j=1,21
do i=1,80
read(114,*)sens(i,j)
end do
end do

ist=transpose(sens)
write(88,1001)ist
1001 format(80e12.5)

do j=1,80
do i=1,80
read(117,*)wd1(i,j)
end do
end do

wd2=matmul(wd1,wd1)
ftw=matmul(ist,wd2)

read(116,*)d
1002 format(e12.5)
p=matmul(ftw,d)


c calculate *Wm^2*(m-mapr)
c ovde alfa mora da se racuna drugacije
c po formuli iz zhdanova
x=iter-1
alpha=300*(0.92)**x

do i=1,21
read(118,*)(wm1(i,j),j=1,21)
end do
wm2=matmul(wm1,wm1)
wm3=alpha*wm2

read(122,1006)dlm
1006 format(e10.3)
q=matmul(wm3,dlm)

a=p+q
l=reshape(a,shape=shape(l))
write(*,*)l
deallocate(l)
end subroutine

end module
Actual arguments greater?What should I change?
0 Kudos
10 Replies
jimdempseyatthecove
Honored Contributor III
4,245 Views
In

subroutine newcalc1(iter,l)

The second argument "l" is not declared.
(implicit none should have caught this)

Is "l" also declared inside params or lt2ddat?

Jim Dempsey
0 Kudos
milenko1976
Beginner
4,245 Views
Yes.
real,allocatable,dimension(:) :: l
0 Kudos
jimdempseyatthecove
Honored Contributor III
4,245 Views
If array l(:) is in the use module (included in a subroutine or function)then it cannot also be used as a dummy argument named l(:). This creates an ambiguity. An error message should report this, it is likely that the wrong error message is being reported for this error.

In your subroutine, change the dummy argument name, and all references to that dummy argument

from "l"
to "Llocal"

and declare "real, allocatable, dimension(:)::Llocal" in the dummy and local variable section of the subroutine.

Note, if your subroutine is always using a global array then do not also use it as a dummy argument.

Jim Dempsey
0 Kudos
mecej4
Honored Contributor III
4,245 Views
> Actual arguments greater?What should I change?

You have not provided enough information. The error message indicates that the compiler sees a mismatch with respect to arguments to subroutine newcalc1 . To see why, you need to show us the complete interface declaration for the subroutine and the declarations of the actual arguments at the point of call. Since you did not do so, and there are many possible ways of calling the subroutine incorrectly, there is no point in attempting to answer your question.

As Jim already pointed out, you probably have missing or mismatched declarations. I note in addition that when you call a subroutine with allocatable array arguments the caller must have an explicit interface available to it.

0 Kudos
milenko1976
Beginner
4,245 Views
Thanks both of you.I am attaching the main code where the interface is.Regarding dummy argument I want to pass l to the main program,I need this for further calculations.
0 Kudos
mecej4
Honored Contributor III
4,245 Views
Quoting milenko1976
Thanks both of you.I am attaching the main code where the interface is.Regarding dummy argument I want to pass l to the main program,I need this for further calculations.

Not enough. The declaration of l(:) is not given in ircg.for, which depends on 10 modules in addition to lstep1. These modules have not been shown.

0 Kudos
milenko1976
Beginner
4,245 Views
I am adding them.
0 Kudos
milenko1976
Beginner
4,245 Views
I have compiled lstep1.for by deleting l as dummy argument.I think Jim was right when he mentioned global arrays.
0 Kudos
mecej4
Honored Contributor III
4,245 Views
The second argument in the declaration of newcalc1 supersedes the USE allociated variable of the same name, and version 12.0.2 of the Intel compiler says:

Intel Visual Fortran Compiler XE for applications running on IA-32, Version 12.0.2.154 Build 20110112
Copyright (C) 1985-2011 Intel Corporation. All rights reserved.

lstep1.f(20): error #6404: This name does not have a type, and must have an explicit type.
allocate(l(iter))

The fix is to add

real, allocatable, dimension(:), intent(in out) :: l

in Subroutine newcalc1.

Whether to go this way, or to pass the array l as a USE-associated variable rather than as an argument, depends on other considerations than just silencing the compiler.
0 Kudos
milenko1976
Beginner
4,245 Views
I get it now.Thanks mecej4.
0 Kudos
Reply