Re: Proper way to return a string



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
.



Relevant Pages

  • Re: module
    ... implicit none ... !gcc$ ATTRIBUTES STDCALL:: GetLastError ... realsimpson ...
    (comp.lang.fortran)
  • Re: module
    ... implicit none ... !gcc$ ATTRIBUTES STDCALL:: GetLastError ... end interface ...
    (comp.lang.fortran)
  • Re: Procedures as arguments - set dummy arguments
    ... implicit none ... lpCurrentDirectory, lpStartupInfo, lpProcessInformation & ... end interface ... public GetLastError ...
    (comp.lang.fortran)
  • Re: Fortran templates
    ... end module mykinds ... implicit real ... end interface initr1_int ... Maybe that's due to an old version of ifort: allowing intrinsics ...
    (comp.lang.fortran)
  • Re: module
    ... implicit none ... integerGetLastError ... realsimpson ...
    (comp.lang.fortran)