- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
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.
- Marcas:
- Intel® Fortran Compiler
Link copiado
2 Respostas
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
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..
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
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

Responder
Opções do tópico
- Subscrever fonte RSS
- Marcar tópico como novo
- Marcar tópico como lido
- Flutuar este Tópico para o utilizador atual
- Marcador
- Subscrever
- Página amigável para impressora