|
| View previous topic :: View next topic |
| Author |
Message |
escj
Joined: 30 Sep 2009 Posts: 37 Location: Laboratoire d'Aérologie, Toulouse, FRANCE
|
Posted: Tue Nov 16, 2010 4:05 am Post subject: string segmentation problem : upcase_trim_adjustl |
|
|
:-) 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 |
|
 |
jtull
Joined: 30 Jun 2004 Posts: 233
|
Posted: Tue Nov 16, 2010 5:03 pm Post subject: Seg fault from YSTATU = UPCASE(TRIM(ADJUSTL(HSTATU))) |
|
|
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 |
|
 |
escj
Joined: 30 Sep 2009 Posts: 37 Location: Laboratoire d'Aérologie, Toulouse, FRANCE
|
Posted: Fri Nov 19, 2010 8:09 am Post subject: |
|
|
:-) Thank you Dave .
Bye |
|
| Back to top |
|
 |
jtull
Joined: 30 Jun 2004 Posts: 233
|
Posted: Thu Dec 02, 2010 2:40 pm Post subject: Re: A workaround for TPR 17413 |
|
|
A work-around is to rearrange the upcase call,e .g.,
TRIM(UPCASE(ADJUSTL(HSTATU)))
regards,
dave |
|
| Back to top |
|
 |
jtull
Joined: 30 Jun 2004 Posts: 233
|
Posted: Sun May 19, 2013 2:40 pm Post subject: TPR 17413 has been fixed as of the 12.10 release. |
|
|
TPR 17413 has been fixed as of the 12.10 release.
thanks,
dave |
|
| Back to top |
|
 |
|
|
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 © 2001, 2002 phpBB Group
|