Question about elemental functions 
Author Message
 Question about elemental functions

Hello,

I'm testing m_strings.f95 from " http://www.*-*-*.com/ ;. It
compiles fine using IFORT 9.1 and CVF 6.6b. However on SGI, compiler
complains about the following (and many more similar) elemental
functions:

      elemental function len_s(s)
      implicit none
      type(string), intent(in)  :: s
      integer                   :: len_s

      len_s = s%len

      end function len_s

where string type is defined in the same module as:

      type string
          private
          integer                 :: len = 0
          integer                 :: size = 0
          character, pointer      :: chars(:) => null()
      end type string

Compiler complains on the ONLY executable line "len_s = s%len". Error
message says:

"S" must not be defined inside of a elemental subprogram. It is in
common, a dummy argument or host or use associated.

Huh ?!?

Can someone please decipher this error message, and possibly suggest a
work around?

Thanks.



Wed, 26 Nov 2008 03:09:16 GMT  
 Question about elemental functions


Quote:

> Compiler complains on the ONLY executable line "len_s = s%len". Error
> message says:

> "S" must not be defined inside of a elemental subprogram. It is in
> common, a dummy argument or host or use associated.

> Huh ?!?

> Can someone please decipher this error message, and possibly suggest a
> work around?

The code looks fine and compiles with CVF 6.6C and g95. Suspect a compiler
error.

Regards,

Mike Metcalf



Wed, 26 Nov 2008 03:20:56 GMT  
 Question about elemental functions
Quote:

> Hello,

> I'm testing m_strings.f95 from "http://nn-online.org/code/strings/". It
> compiles fine using IFORT 9.1 and CVF 6.6b. However on SGI, compiler
> complains about the following (and many more similar) elemental
> functions:

>       elemental function len_s(s)
>       implicit none
>       type(string), intent(in)  :: s
>       integer                   :: len_s

>       len_s = s%len

>       end function len_s

> where string type is defined in the same module as:

>       type string
>           private
>           integer                 :: len = 0
>           integer                 :: size = 0
>           character, pointer      :: chars(:) => null()
>       end type string

> Compiler complains on the ONLY executable line "len_s = s%len". Error
> message says:

> "S" must not be defined inside of a elemental subprogram. It is in
> common, a dummy argument or host or use associated.

> Huh ?!?

> Can someone please decipher this error message, and possibly suggest a
> work around?

> Thanks.

Yes, it does seem an error as Michael Metcalf says. But why don't you
try this:

      elemental function len_s(s) result (ReturnValue)
        implicit none
        type(string), intent(in)  :: s
        integer                   :: ReturnValue

        ReturnValue = s%len

      end function len_s

Perhaps this form will work.

Norm



Wed, 26 Nov 2008 03:46:03 GMT  
 Question about elemental functions
Made the suggested changes, still nogo. Got the same error message. We
have (I think) the latest version of SGI fortran compiler. I also
verified that code compiles on Solaris and HP, so it's very likely a
compiler problem.
Quote:

> Yes, it does seem an error as Michael Metcalf says. But why don't you
> try this:

>       elemental function len_s(s) result (ReturnValue)
>         implicit none
>         type(string), intent(in)  :: s
>         integer                   :: ReturnValue

>         ReturnValue = s%len

>       end function len_s

> Perhaps this form will work.

> Norm



Wed, 26 Nov 2008 04:21:14 GMT  
 Question about elemental functions

Quote:

>Compiler complains on the ONLY executable line "len_s = s%len". Error
>message says:

>"S" must not be defined inside of a elemental subprogram. It is in
>common, a dummy argument or host or use associated.

You're talking about the SGI MIPS compiler, yes? If so this is a bug
which was already in the compiler when Open64 was released, and we've
fixed it on Opteron, but I'm not surprised that it wasn't found by the
maintainers at SGI...

-- greg



Wed, 26 Nov 2008 05:24:50 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. elemental function versus loop over function

2. CVF, Absoft bug involving ELEMENTAL character functions

3. PURE and ELEMENTAL Functions

4. elemental functions and arrays within derived types

5. elemental functions

6. Example of Elemental function

7. elemental function

8. Elemental functions in PARAMETER statements

9. ELEMENTAL functions and performance

10. optional argument of elemental function

11. need help making function elemental

12. intrinsic elemental math functions

 

 
Powered by phpBB® Forum Software