Re: Proper way to return a string



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/
.



Relevant Pages

  • Re: ide-cd problems
    ... >> interface it uses is not worth the lines of code it occupies. ... > Warning: Open by 'devname' is unintentional and not supported. ... Kernel and cdrecord disagreement, news at 11. ... Look at the errors as well - one is about the transport used: ...
    (Linux-Kernel)
  • Re: 2.6.18-rc1-mm2: process `showconsole used the removed sysctl system call
    ... warning: process `touch' used the removed sysctl system call ... binary sysctl interface for some time time now". ... It is the glibc pthread library testing to see if you have an SMP ... kernel by greping for SMP in the UTS_VERSION string. ...
    (Linux-Kernel)
  • Re: The best computer for running Windows...
    ... display a warning that it needed taking into a garage. ... I like to know if I'm getting low on oil or the engine ... But the car is still running fine, no odd noises, no smoky ... those with no technical experience if its interface is improved. ...
    (uk.comp.sys.mac)
  • Configuring Hard Drive SCSI Bus
    ... I have recently been working on a Solaris 7 system, on an Ultra 10, ... installed and the SCSI bus that I connect to the work station. ... WARNING <interface> ...
    (comp.unix.solaris)
  • Problem installing a Com+ Application via Regsvcs
    ... has worked perfectly but today when I tried to use regsvcs to register ... WARNING: The class 'OnLine.EKR.DAL.Store.CustomerStore' has no class ... interface, which means that unmanaged late bound calls cannot take ... advantage of AutoComplete methods. ...
    (microsoft.public.dotnet.framework.component_services)