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

Character array reference

rss001
Beginner
696 Views
Hi,

I'm having a little difficulty. Here's how I started:

Character * 32 test(100), test_hld


now if I want to reference just the first 10 fields of test_hld I can write:

test_hld(1:10) = 'abcdefghij'


here's my problem:

How do I reference the first 10 characters of test?

test(1:10)(5)='1234567890'

did not complie. I've checked everywhere and I can't findout whether or not this is possible. Any help would be appreciated. Thanks.
0 Kudos
5 Replies
ipattielgc
Beginner
696 Views
Try test_xxx(5)(1:10). If the char is an array, the first paranthesis is the array element, the second is the char substring.
Ian
0 Kudos
rss001
Beginner
696 Views
worked like a charm. Thanks. I'm using MSDEV and could not find the reference for character array access. Thanks.
0 Kudos
Steven_L_Intel1
Employee
696 Views
The Language Reference Manual (on-disk) would have this.
0 Kudos
rss001
Beginner
696 Views
It may, but when I looked I couldn't find it. I checked under character and found very little. Nothing listed under ARRAY and the STRING dialog covered other issues. I know you're right I just couldn't find it. What would you look under?
0 Kudos
Steven_L_Intel1
Employee
696 Views
It's under Character Substrings in chapter 3. Perhaps not blindingly obvious, but it says:

A character substring is a contiguous segment of a character string. It takes one of the following forms:

v ([e1]:[e2])
a (s [,s] ... ) ([e1]:[e2])

The second is the form you are looking for.
0 Kudos
Reply