PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

CUDA-x86.

string segmentation problem : upcase_trim_adjustl

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



Joined: 30 Sep 2009
Posts: 63
Location: Laboratoire d'Aérologie, Toulouse, FRANCE

PostPosted: Tue Nov 16, 2010 4:05 am    Post subject: string segmentation problem : upcase_trim_adjustl Reply with quote

:-) Hello .
;-) This time a problem ( extracted form Meso-NH ) with strings routines .

We try to manage the string read in NAMELIST in a reproducible form, so we use this kind or routine/statement :
Quote:

UPCASE(TRIM(ADJUSTL(HSTATU)))


No problem with g95/gfortran/ifort
Quote:

bug_pgi> g95 test_upcase_trim_adjustl.f90 -o test_upcase_trim_adjustl
bug_pgi> test_upcase_trim_adjustl
TEST :: sub_upcase_trim_adjustl
HSTATU >>>> keep <<<<
YSTATU = UPCASE(TRIM(ADJUSTL(HSTATU))) >>>>KEEP###<<<<
PASSED :: sub_upcase_trim_adjustl


With pgf90 ( 10.9 ) Segmentation Violation ( ;-) in French in the text )
Quote:

bug_pgi> pgf90 test_upcase_trim_adjustl.f90 -o test_upcase_trim_adjustl
bug_pgi> test_upcase_trim_adjustl
TEST :: sub_upcase_trim_adjustl
Erreur de segmentation


Here is the test code "test_upcase_trim_adjustl.f90"

Bye Juan

Code:

MODULE mode_sub                                                                         

CONTAINS
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  FUNCTION UPCASE(HSTRING)                                                                                 

    IMPLICIT NONE
    CHARACTER(LEN=*)            :: HSTRING
    CHARACTER(LEN=LEN(HSTRING)) :: UPCASE

    INTEGER :: JC
    INTEGER, PARAMETER :: IAMIN = IACHAR("a")
    INTEGER, PARAMETER :: IAMAJ = IACHAR("A")

    DO JC=1,LEN(HSTRING)
       IF (HSTRING(JC:JC) >= "a" .AND. HSTRING(JC:JC) <= "z") THEN
          UPCASE(JC:JC) = ACHAR(IACHAR(HSTRING(JC:JC)) - IAMIN + IAMAJ)
       ELSE                                                           
          UPCASE(JC:JC) = HSTRING(JC:JC)                               
       END IF                                                         
    END DO                                                             

  END FUNCTION UPCASE

  SUBROUTINE sub_upcase_trim_adjustl(HSTATU)

    IMPLICIT NONE
    CHARACTER(LEN=*),  INTENT(IN)  :: HSTATU  ! status for the closed file

    ! local variable
    CHARACTER(LEN=LEN(HSTATU))     :: YSTATU

    YSTATU = UPCASE(TRIM(ADJUSTL(HSTATU))) // "######"
    print*,"  HSTATU                                 >>>>" , HSTATU ,"<<<<"
    print*,"  YSTATU = UPCASE(TRIM(ADJUSTL(HSTATU))) >>>>" , YSTATU ,"<<<<"


  END SUBROUTINE sub_upcase_trim_adjustl

END MODULE mode_sub
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
PROGRAM test_upcase_trim_adjustl

  USE mode_sub

  IMPLICIT NONE

  CHARACTER(LEN=7)     :: CSTATU

  CSTATU = " keep "

  print*," TEST   :: sub_upcase_trim_adjustl  "
  CALL sub_upcase_trim_adjustl(CSTATU)
  print*," PASSED :: sub_upcase_trim_adjustl  " ; print*

END PROGRAM test_upcase_trim_adjustl
Back to top
View user's profile
jtull



Joined: 30 Jun 2004
Posts: 441

PostPosted: Tue Nov 16, 2010 5:03 pm    Post subject: Seg fault from YSTATU = UPCASE(TRIM(ADJUSTL(HSTATU))) Reply with quote

Hello,

we recreated your behavior with the current compilers, and we have
logged it as TPR 17413. The line it fails on is

YSTATU = UPCASE(TRIM(ADJUSTL(HSTATU)))

regards,
dave
Back to top
View user's profile
escj



Joined: 30 Sep 2009
Posts: 63
Location: Laboratoire d'Aérologie, Toulouse, FRANCE

PostPosted: Fri Nov 19, 2010 8:09 am    Post subject: Reply with quote

:-) Thank you Dave .

Bye
Back to top
View user's profile
jtull



Joined: 30 Jun 2004
Posts: 441

PostPosted: Thu Dec 02, 2010 2:40 pm    Post subject: Re: A workaround for TPR 17413 Reply with quote

A work-around is to rearrange the upcase call,e .g.,

TRIM(UPCASE(ADJUSTL(HSTATU)))


regards,
dave
Back to top
View user's profile
jtull



Joined: 30 Jun 2004
Posts: 441

PostPosted: Sun May 19, 2013 2:40 pm    Post subject: TPR 17413 has been fixed as of the 12.10 release. Reply with quote

TPR 17413 has been fixed as of the 12.10 release.

thanks,
dave
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