Re: Proper way to return a string
- From: kargl@xxxxxxxxxxxxxxxxxxxxxxxxxxxx (Steven G. Kargl)
- Date: Sat, 30 Dec 2006 19:05:03 +0000 (UTC)
In article <4596A133.95297D31@xxxxxxxxxxxxx>,
Walter Spector <w6ws_xthisoutx@xxxxxxxxxxxxx> writes:
Richard Maine wrote:
...
Error: Internal function 'str_func' at (1) cannot be an assumed-length
CHARACTER
I'm too tired to check right now, but an internal function with a len=*
result would be at least ... strange. Might be disallowed...
In F95 §12.3.1.1(2)(e) addresses this case. It prohibits a character function
with an assumed length result from having an explicit interface.
Interestingly it also says the same about 'non-constant length results'.
This seems like a bug in the Standard.
In F2003 §12.3.1.1 the sentence above has been reworded to cover
'nonassumed type parameter value that is not an initialization
expression' - which seems much more reasonable.
Hmm. I can't see how the calling routine could declare the length of a
char(len=*) internal function. That would be two different declarations
in the same scope. That probably effectively disallows them...
Yup.
Likewise is creating an INTERFACE block for such a routine legal?
module bel2
implicit none
interface
function str_junk (a)
implicit none
character(*), intent(in) :: a
character(*) :: str_junk
end function
end interface
end module
The g95, gfortran, and Salford compilers compile it without complaint.
However IRIX f90 gives a big warning - basically saying the routine
would be uncallable. And Intel considers it a fatal error.
Walt
NAG's compiler [version 4.2(513,515-543)] gives
laptop:kargl[209] f95 -c u.f90
Obsolescent: u.f90, line 12: Assumed-length CHARACTER function
gfortran (version 4.3.0 20061216) gives
laptop:kargl[210] gfc4x -c u.f90
u.f90:5.21:
function str_junk (a)
1
Warning: CHARACTER(*) function 'str_junk' at (1) is obsolescent in fortran 95
u.f90:5.21:
function str_junk (a)
1
Warning: CHARACTER(*) function 'str_junk' at (1) is obsolescent in fortran 95
Is there some other warning you want?
--
Steve
http://troutmask.apl.washington.edu/~kargl/
.
- Follow-Ups:
- Re: Proper way to return a string
- From: Walter Spector
- Re: Proper way to return a string
- References:
- Proper way to return a string
- From: Jeremy
- Re: Proper way to return a string
- From: Steven G. Kargl
- Re: Proper way to return a string
- From: Gordon Sande
- Re: Proper way to return a string
- From: Ron Shepard
- Re: Proper way to return a string
- From: Beliavsky
- Re: Proper way to return a string
- From: Richard Maine
- Re: Proper way to return a string
- From: Walter Spector
- Proper way to return a string
- Prev by Date: Re: Proper way to return a string
- Next by Date: Re: Proper way to return a string
- Previous by thread: Re: Proper way to return a string
- Next by thread: Re: Proper way to return a string
- Index(es):
Relevant Pages
|