Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29369 Discussions

The maximum length of processor collating sequence

DataScientist
Valued Contributor I
1,600 Views

The Fortran standard `char (i [,kind] )` returns the character in position i in the processor collating sequence associated with the relevant kind parameter. The value of i must be in the range `0 < i < n - 1`, where n is the number of characters in the processor’s collating sequence. Is there a way to infer the value of `n` in a portable way within the programming environment?

0 Kudos
1 Solution
Steve_Lionel
Honored Contributor III
1,565 Views

@DataScientist wrote:

What would `char(i)` behavior be if the collating sequence can be discontiguous?


Undefined.

I'll admit that I was not familiar with the behavior of MAXVAL/MINVAL when ARRAY is size zero. It would seem that:

ichar(minval(c))

where c is a zero-sized array of characters, does what you want.

View solution in original post

0 Kudos
5 Replies
Steve_Lionel
Honored Contributor III
1,581 Views

Interesting question. I can't think of a reasonable way, offhand. What's your use case? I think some character sets have discontiguous ranges, which could complicate matters.

DataScientist
Valued Contributor I
1,573 Views

The goal is to replicate `minval`/`maxval` and similar functionalities for scalar character sequences.

These two intrinsics return the maximum/minimum of the corresponding type and kind if the input array has zero size.

For characters, the result of the comparison is determined by the positions in the processor collating sequence.

Therefore, the last character in the collating sequence is required to fully mimic `minval`/`maxval` behavior.

What would `char(i)` behavior be if the collating sequence can be discontiguous?

 

0 Kudos
Steve_Lionel
Honored Contributor III
1,566 Views

@DataScientist wrote:

What would `char(i)` behavior be if the collating sequence can be discontiguous?


Undefined.

I'll admit that I was not familiar with the behavior of MAXVAL/MINVAL when ARRAY is size zero. It would seem that:

ichar(minval(c))

where c is a zero-sized array of characters, does what you want.

0 Kudos
DataScientist
Valued Contributor I
1,558 Views
0 Kudos
DataScientist
Valued Contributor I
1,556 Views

I also have to admit that I did not know `minval` and `maxval` work with character arrays.

0 Kudos
Reply