NCEP CCS Conversion Guide
Issues Converting FORTRAN and C/C++ Programs
Back to Main Page
Topic: Intrinsic Function ICHAR
Posted by: Stephen Gilbert
Updated by: David Michaud
Post Date: 12/16/1998
Last Updated: 08/14/2002
Problem: 

ORIGINAL PROBLEM GOING FROM CRAY TO IBMSP (ncosp):

We found that Fortran Intrinsic Function ICHAR returns different values when compiled with the -qhot compiler option than without it.  ( Note that -qhot is turned on automatically if the -qsmp option is used. )

CURRENT PROBLEM GOING FROM IBMSP (asp) to CCS (frost/snow):

We found ichar does not return the same values as the asp/bsp on frost/snow compiled in any configuration.

ICHAR(A):  On the Crays the character A can be any character in the collating sequence with the range 0 <= ICHAR(A) <= 255.  IBM supports only the range 0 <= ICHAR(A) <= 127.  The ICHAR function no longer returns the expected integer values between 128 and 255.  Negative values are returned instead.

Solution:  Function MOVA2I in the w3lib can be used in place of the ICHAR function to allow for collating sequence values greater than 127.  That is, MOVA2I will return the expected values in the range 0 <= MOVA2I(A) <= 255.

Example:

Change

        character*1 a
        ...
        i = ichar(a)

To

        character*1 a
        ...
        i = mova2i(a)

 

Back to Main Page