- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I would like to define a parameter structure array, that is, an array of derived type components which would be a parameter. Thiswould look like something like this:
INTEGER,PARAMETER :: MAX_SYMBOL_NAME_LENGTH = 63
TYPE T_ID
INTEGER :: ID
CHARACTER(LEN=MAX_SYMBOL_NAME_LENGTH) :: NAME
END TYPE T_ID
TYPE(T_ID),PARAMETER :: IDS(1) = [ (1,'test') ]
This triggers a compiler error - the syntax is not valid. Obviously I want more than one element in my array - this is just for illustration purposes. I am wondering if this is possible, and if yes what is the proper syntax.
Thanks!
Olivier
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You're close. You need the type name in the structure constructor. For example:
[fortran]TYPE(T_ID),PARAMETER :: IDS(2) = [T_ID(1,'test'),T_ID(2,'moretest')][/fortran]
(Hmm - that should all be on one line...)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ah, that works beautifully. Thanks Steve!
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page