- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
One fast question.
How can I declare a charater string as ALLOCATABLE
e.g
character :: string*5000
I want to have
character, ALLOCATABLE :: string(:)
How to allocate this string for e.g 5000 characters ?
Using ALLOCATE (string(*5000)) does not work.
Using ALLOCATE (string(5000)) works but the I get error messages when compiling with code using this string.
How can I declare a charater string as ALLOCATABLE
e.g
character :: string*5000
I want to have
character, ALLOCATABLE :: string(:)
How to allocate this string for e.g 5000 characters ?
Using ALLOCATE (string(*5000)) does not work.
Using ALLOCATE (string(5000)) works but the I get error messages when compiling with code using this string.
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
you undoubtedly are trying to use the string array
ie. allocate ( string(5000) )
as a string.
but its NOT a string despite you calling it one.
you cant allocate a character string in F95,
but you can in F2003..
what you can do is switch gears by using your "string"
as a subroutine argument and use the array as a string in the subroutine..
ie. allocate ( string(5000) )
as a string.
but its NOT a string despite you calling it one.
you cant allocate a character string in F95,
but you can in F2003..
what you can do is switch gears by using your "string"
as a subroutine argument and use the array as a string in the subroutine..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Erm, you can't, at least not in F95 standard. It will be possible in next F2000 standard, but you'll have to wait for that loooong.
Second form, as you discovered, is usable in some contexts, but cannot be used everywhere where normal strings are required.
Also, you can google for ISO_VARYING_STRING module. This is an extension to standard which defines operations on a user-defined TYPE. One incarnation (allegedly without memory leaks, which are a pain with POINTERs within derived types) can be found here. (Didn't try it myself).
Jugoslav
Second form, as you discovered, is usable in some contexts, but cannot be used everywhere where normal strings are required.
Also, you can google for ISO_VARYING_STRING module. This is an extension to standard which defines operations on a user-defined TYPE. One incarnation (allegedly without memory leaks, which are a pain with POINTERs within derived types) can be found here. (Didn't try it myself).
Jugoslav

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