Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

problem comparing character strings

elainethale
Beginner
915 Views
I have the variable:
character*50 :: TableType

From the debugger, I can see that

TableType == 'SYSTEM TABLE ',

However, in an if-statement the relation
(TableType /= 'SYSTEM TABLE')
returns .TRUE. as does
(TRIM(TableType) /= 'SYSTEM TABLE')

But, if I declare another variable variable
character*12 :: temp
and set
temp = TRIM(TableType)
and then execute the if-statement with
(temp /= 'SYSTEM TABLE')
it returns .FALSE. as expected...

Does anyone have any ideas as to why using the variable temp works, but directly comparing does not? The manual leads me to believe that the trailing blanks shouldn't be a problem...

Thank you,
Elaine Hale
0 Kudos
3 Replies
elainethale
Beginner
915 Views
There is a typo in the original message -- TableType is equal to 'SYSTEM TABLE'//38 Blanks.
0 Kudos
Steven_L_Intel1
Employee
915 Views
My guess is that there are non-blanks in the "trailing" space - possibly NULs. What does LEN_TRIM give you?

Steve
0 Kudos
Jugoslav_Dujic
Valued Contributor II
915 Views
Tip: you can see exact contents of a string variable by typing variable name in "Memory" Debugger window.

Jugoslav
0 Kudos
Reply