- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I would like to initialize the contents of some character arrays in a data structure, but can't figure out how. Advice is welcome!!
Here is the data structure:
TYPE LMRT_STR
INTEGER :: SPP
CHARACTER (LEN=15) :: PRETTYNAME(10)
REAL :: COEF(8)
END TYPE
and here is an example of how one of these structures is initialized in a DATA statement.
TYPE (LMRT_STR) LMRT(32)
DATA (LMRT(I), I=1,32) /
> LMRT_STR (
> 3,
> (/'ICHmk1/03', 'ICHmk1/04', 'ICHmk2/01', 'ICHmk2/03',
> 'ICHmw3/03' /),
> (/-4.906955, -2.476706, -0.257206, 0.004187, 1.081121,
> 0.144035, -0.341321, -0.000008 /)),
// etc.
The second component of the structure, 'PRETTYNAME', is a set of up to 10 character strings, each of length 15. What I want to do is to initialize the unused character strings (with a blank and not nulls). There are 5 unused character arrays in the example above. I can't find any help about the syntax that would allow this. The integer example would be
5*0
to set 5 integers to 0; is there something like this for the character arrays?
Here is the data structure:
TYPE LMRT_STR
INTEGER :: SPP
CHARACTER (LEN=15) :: PRETTYNAME(10)
REAL :: COEF(8)
END TYPE
and here is an example of how one of these structures is initialized in a DATA statement.
TYPE (LMRT_STR) LMRT(32)
DATA (LMRT(I), I=1,32) /
> LMRT_STR (
> 3,
> (/'ICHmk1/03', 'ICHmk1/04', 'ICHmk2/01', 'ICHmk2/03',
> 'ICHmw3/03' /),
> (/-4.906955, -2.476706, -0.257206, 0.004187, 1.081121,
> 0.144035, -0.341321, -0.000008 /)),
// etc.
The second component of the structure, 'PRETTYNAME', is a set of up to 10 character strings, each of length 15. What I want to do is to initialize the unused character strings (with a blank and not nulls). There are 5 unused character arrays in the example above. I can't find any help about the syntax that would allow this. The integer example would be
5*0
to set 5 integers to 0; is there something like this for the character arrays?
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
An example of an array with LEN=15 and SHAPE = (/10/) is:
spread(repeat(achar(32),15),1,10)
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page