Re: LEN() of unallocated array
From: Rich Townsend (rhdt_at_XXXXX.udel.edu)
Date: 11/06/03
- Next message: Jim Patterson: "Re: renaming file"
- Previous message: John C. Bollinger: "Re: LEN() of unallocated array"
- In reply to: David Frank: "Re: LEN() of unallocated array"
- Next in thread: David Frank: "Re: LEN() of unallocated array"
- Reply: David Frank: "Re: LEN() of unallocated array"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 06 Nov 2003 09:41:44 -0500
David Frank wrote:
> "Rich Townsend" <rhdt@XXXXX.udel.edu> wrote in message
<snip>
>
> It has nothing to do with LEN,
> I dont believe your intention to directly output a string "hello
> world"
> into a allocatable string array is going to work..
>
> CVF compiles above ok, but has a runtime access error on execution.
> To illustrate what you are doing wrong, I rewrote your subroutine
> (see below) which DOES run ok under CVF and illustrates what you
> are doing wrong
> ( outputting a 15char string into the wrong array index.
>
> ! ---------------------------------
> program test
> character, allocatable :: a(:,:)
> call my_sub(a)
> write (*,*) a ! outputs Hello Hello Hello
>
> contains
> subroutine my_sub(a)
> character, allocatable :: a(:,:)
> character :: b(6) = ['H','e','l','l','o',' ']
> allocate ( a(6,3) )
>
> do i = 1,3
> a(:,i) = b ! note storing into left index
> end do
> end subroutine my_sub
> end program test
>
>
I can't see how this illustrates what I'm doing wrong. You've replaced
my array of character strings with a 2-D array of length-1 strings, but
beyond that I'm not sure what you are trying to demonstrate. Are you
arguing that the assignments in my original code:
b = 'Hello'
a = b
...are causing the problem? Surely the latter is handled by the rules
for broadcasting a scalar to an array?
Could you try running my original program again with CVF, but change the
declaration of b to:
character(15) :: b
This should establish whether the LEN() is causing the problem or not.
cheers,
Rich
- Next message: Jim Patterson: "Re: renaming file"
- Previous message: John C. Bollinger: "Re: LEN() of unallocated array"
- In reply to: David Frank: "Re: LEN() of unallocated array"
- Next in thread: David Frank: "Re: LEN() of unallocated array"
- Reply: David Frank: "Re: LEN() of unallocated array"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|