Software Archive
Read-only legacy content
17060 Discussions

initializing character arrays in a structure

Robinson__Donald
Beginner
1,579 Views
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?
0 Kudos
1 Reply
Intel_C_Intel
Employee
1,579 Views
An example of an array with LEN=15 and SHAPE = (/10/) is:
 
spread(repeat(achar(32),15),1,10) 
0 Kudos
Reply