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

A dummy argument with the INTENT(IN) attribute shall not appear in a variable definition context

milenko1976
Beginner
4,568 Views
Why is this illegal?

module modelpet

implicit none

contains
subroutine rm(xn,res,icd,ivar)
real,dimension(57,3),intent(in) :: xn
real,dimension(57) :: a,b,c
real,dimension(57),intent(out) :: res,icd,ivar
xn(:,1)=a
a=res
xn(:,2)=b
b=icd
xn(:,3)=c
c=ivar

end subroutine
end module
milenko@milenkons:~/ircg$ ifort -c modelpet.for
modelpet.for(10): error #6780: A dummy argument with the INTENT(IN) attribute shall not appear in a variable definition context [XN]
xn(:,1)=a
------^
modelpet.for(12): error #6780: A dummy argument with the INTENT(IN) attribute shall not appear in a variable definition context [XN]
xn(:,2)=b
------^
modelpet.for(14): error #6780: A dummy argument with the INTENT(IN) attribute shall not appear in a variable definition context [XN]
xn(:,3)=c
------^
modelpet.for(6): warning #6843: A dummy argument with an explicit INTENT(OUT) declaration is not given an explicit value. [RES]
subroutine rm(xn,res,icd,ivar)
-----------------------^
modelpet.for(6): warning #6843: A dummy argument with an explicit INTENT(OUT) declaration is not given an explicit value. [ICD]
subroutine rm(xn,res,icd,ivar)
---------------------------^
modelpet.for(6): warning #6843: A dummy argument with an explicit INTENT(OUT) declaration is not given an explicit value. [IVAR]
subroutine rm(xn,res,icd,ivar)
-------------------------------^
compilation aborted for modelpet.for (code 1)

0 Kudos
4 Replies
Steven_L_Intel1
Employee
4,568 Views
Perhaps you misunderstand the meaning of the INTENT attribute? With INTENT(IN), you are promising to the compiler that argument XN is not modified nor its definition status changed, but you assign to it. This is an error the compiler is required to detect.

Similarly, INTENT(OUT) says that variables res, icd and var are always assigned a value in the routine, but yoiu don't do so, Again, the compiler detects this.

Does this help?
0 Kudos
milenko1976
Beginner
4,568 Views
Yes, I have to do it other way
Thanks.
0 Kudos
Steven_L_Intel1
Employee
4,568 Views
What do you want to do?
0 Kudos
TimP
Honored Contributor III
4,568 Views
I've found the compiler's diagnostics for INTENT extremely useful in building a full list of argument usage.
0 Kudos
Reply