- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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)
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)
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, I have to do it other way
Thanks.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
What do you want to do?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I've found the compiler's diagnostics for INTENT extremely useful in building a full list of argument usage.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page