PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

Free OpenACC Course

Unmatched quote and type mismatch errors

 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling
View previous topic :: View next topic  
Author Message
bgeneto



Joined: 03 Jul 2006
Posts: 2

PostPosted: Mon Sep 03, 2007 8:43 am    Post subject: Unmatched quote and type mismatch errors Reply with quote

The code below compiles with g95 and Intel Fortran but not with PVF 7.0.7. I've noticed that exchanging the order of the following declaration lines inside realToChar function:
Code:

real(rp), intent(in)          :: num
character(getRealLength(num)) :: char

resolves the first error (type mismatch), but the second remains. A (not so) minimal test case follows:
Code:

module printUtils

    implicit none

    private
   
    integer, parameter :: rp = selected_real_kind(p=15);

    interface strLen
        module procedure getRealLength
    end interface strLen

    interface toChar
        module procedure realToChar
    end interface toChar

contains

    pure function getRealLength(num) result(len)
        integer              :: len
        real(rp), intent(in) :: num
        character(50)        :: tmp

        write(tmp, *) num
        len = len_trim(tmp)

    end function getRealLength


    pure function realToChar(num) result(char)
        character(getRealLength(num)) :: char
        real(rp), intent(in)          :: num

        write(char, *) num

    end function realToChar
   
    pure function len_nopath(fname) result(len)
        character(*), intent(in) :: fname
        integer :: len, fin

        fin = len_trim(fname)
        len = fin - index(trim(fname), '/', back=.true.)
        if (len == fin) len = fin - index(trim(fname), '\', back=.true.)
        if (len == fin) len = fin

    end function len_nopath

end module printUtils
Back to top
View user's profile
mkcolg



Joined: 30 Jun 2004
Posts: 6660
Location: The Portland Group Inc.

PostPosted: Tue Sep 04, 2007 10:41 am    Post subject: Reply with quote

Hi Bernhard,

The error is caused by the use of the escape character in a string. To fix, escape the escape character:
Code:
if (len == fin) len = fin - index(trim(fname), '\\', back=.true.)


Hope this helps,
Mat
Back to top
View user's profile
bgeneto



Joined: 03 Jul 2006
Posts: 2

PostPosted: Wed Sep 05, 2007 1:40 pm    Post subject: Reply with quote

mkcolg wrote:
Hi Bernhard,

The error is caused by the use of the escape character in a string. To fix, escape the escape character:
Code:
if (len == fin) len = fin - index(trim(fname), '\\', back=.true.)


Hope this helps,
Mat


Got it. But what is the cause of the first error?

Thanks again,

Bernhard Enders
Back to top
View user's profile
brentl



Joined: 20 Jul 2004
Posts: 140

PostPosted: Thu Sep 13, 2007 10:36 am    Post subject: Reply with quote

In this code:

pure function realToChar(num) result(char)
character(getRealLength(num)) :: char
real(rp), intent(in) :: num

You are using num as an argument (at runtime) to getRealLength() before it
is explicitly defined as having type real(rp). It defaults to type integer. This is sort of a gray area of the spec, sort of a bug. We are working on fixing these types of problems, since as you point out other compilers can handle it
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © phpBB Group