Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29343 Discussions

intrinsic function names in type-bound procedures

John4
Valued Contributor I
609 Views

In the code below I get some errors regarding the use of the name "TRIM" as a type-bound procedure, since it's also used as a specification function:

[fortran]module mod1

    implicit none
    private
    save

    type, public :: t1
        character(20) :: label
    contains
        procedure :: TRIM => TRIM_t1
    end type

contains

    pure function TRIM_t1(string) result(trimmed)
        class(t1), allocatable :: trimmed
        class(t1), intent(IN) :: string
        allocate (trimmed, mold = string)
        trimmed%label = TRIM(string%label)
    end function

    pure function blank(string) result(new)
        character(*), intent(IN) :: string
        character(LEN = LEN_TRIM(ADJUSTL(string)) - &
                        mycount(TRIM(ADJUSTL(string)), ' ')) :: new
        new = ''
    end function

    pure function mycount(string, substring) result(many)
        integer :: many
        character(*), intent(IN) :: string
        character(*), intent(IN) :: substring
        integer :: i
        many = 0
        do i = 1, LEN(string)
            many = many + (-1) ** i
        enddo
    end function
end module mod1
[/fortran]
Am I doing something wrong here or is it just a bug in the compiler? When I compile with gfortran (v4.5, with source= instead of mold=) I don't get any error.

0 Kudos
1 Reply
Steven_L_Intel1
Employee
609 Views
I'm looking at this now.
0 Kudos
Reply