From martin@anduin.ocf.llnl.gov  Wed Jul  3 22:56:14 1996
Received: from anduin.ocf.llnl.gov (anduin.ocf.llnl.gov [134.9.49.1]) by dkuug.dk (8.6.12/8.6.12) with SMTP id WAA08419 for <sc22wg5@dkuug.dk>; Wed, 3 Jul 1996 22:56:12 +0200
Received: by anduin.ocf.llnl.gov (4.1/SMI-4.0)
	id AA24674; Wed, 3 Jul 96 13:42:00 PDT
Date: Wed, 3 Jul 96 13:42:00 PDT
From: martin@anduin.ocf.llnl.gov (Jeanne T Martin)
Message-Id: <9607032042.AA24674@anduin.ocf.llnl.gov>
To: sc22wg5@dkuug.dk
Subject: Allocatable Components - User Input


Here is a message I received from some "real" Fortran 90 users at LLNL.
______________________________________________________________________________
> From: "Gayle Sugiyama" <sugiyama@anvil.llnl.gov>
> Date: Wed, 3 Jul 1996 09:06:42 -0700
> To: jtm@llnl.gov
> Subject: F90 standards : pointers inside derived type
> Cc: jleone@anvil.llnl.gov
> 
>    I know that officially LLNL has no representative on the F90 standards
> board/committee, but I am hoping that you will be able to pass on
> this input from the ARAC F90 users (we took a course from you last
> year).
>    We have been working with derived types containing allocatable
> pointers. In some cases the ONLY reason we are using pointers is that
> allocatable arrays are not permitted in a derived type. This leads
> to what we consider inconsistent behavior of the = versus the =>
> assignments. As stated in the Fortran Handbook p276, rule 14
> "If a structure has a component with the POINTER attribute and the
> structure is assigned a value using an instrinsic derived-type assignment,
> POINTER ASSIGNMENT is used for each component with the POINTER
> attibute." From our perspective this means that when you do a
>    derived_type1 = derived_type2
> assignment the pointer array inside the derived type is not
> copied but acts like a => assignment instead. This has been very
> confusing to us since if we wanted that we would have used
>    derived_type1 => derived_type2
> instead. To get a copy of derived_type2, we must go in by hand and
> assign each of the elements of the derived type by hand
>    derived_type1%pointer_array = derived_type2%pointer_array
>    derived_type1%real_var      = derived_type2%real_var
> and so on.
>    In fact overall we think that it would have been nicer if
> allocatable arrays and pointers would more clearly distinct -
> i.e. arrays could be allocatable/deallocatable and pointers
> associated/nullified. There are probably good reasons why this
> wasn't done and to insure backwards compatability we presume
> this won't be changed, so our suggestion is to add allocatable
> arrays as an allowed element in derived types for which
> derived type assignments would work like = and not =>.
> 
> --- Gayle Sugiyama and John Leone
> 
> A simple test code example of the above written by JL :
> 
> module met_definition
> 
>    implicit none
> 
>    type met_data
>       real, pointer, dimension(:,:,:) :: val
>       real                            :: time
>       character(len = 20)             :: met_str
>    end type met_data
> 
> end module met_definition
> 
> 
> program test_ta
> 
>    use met_definition
> 
>    implicit none
> 
>    type (met_data),  allocatable, dimension(:, :) :: u
> 
>    integer           :: imax = 3, jmax = 1, kmax = 1, num_data = 2, &
>                         i,        j,        k,        nd
> 
>    allocate(u(1, num_data))
> 
>    do nd = 1, num_data
>       allocate(u(1, nd)%val(imax, jmax, kmax))
>       u(1, nd)%val = nd
>       u(1, nd)%time = nd * 100.
>       write(u(1, nd)%met_str, '(a, i2.2)') 'u data set ', nd
>    end do
> 
>    write (*, *) 'PART I'
>    write (*, *) 'u data types after allocation and initial assignment'
>    do nd = 1, num_data
>       write (*, '(/, a, i2.2)') 'data set ', nd
>       write (*, *) u(1, nd)%met_str, u(1, nd)%time
>       write (*, *) u(1, nd)%val
>    enddo
> 
>    u(1, 1) = u(1, 2)
> 
>    write (*, '(///,a)') 'PART II'
>    write (*, *) 'u data types after setting u(1, 1) = u(1, 2)'
>    do nd = 1, num_data
>       write (*, '(/, a, i2.2)') 'data set ', nd
>       write (*, *) u(1, nd)%met_str, u(1, nd)%time
>       write (*, *) u(1, nd)%val
>    enddo
> 
>    u(1, 2)%val = 3
>    u(1, 2)%time = 3 * 100.
>    write(u(1, 2)%met_str, '(a, i2.2)') 'u data set ', 3
> 
>    write (*, '(///,a)') 'PART III'
>    write (*, *) 'u data types after reassigning u(1, 2) but not u(1, 1)'
>    do nd = 1, num_data
>       write (*, '(/, a, i2.2)') 'data set ', nd
>       write (*, *) u(1, nd)%met_str, u(1, nd)%time
>       write (*, *) u(1, nd)%val
>    enddo
> 
> end program
> 
> -- 
> ------------------------------------------------------------------------------
> Gayle Sugiyama
> sugiyama@llnl.gov
> L-103
> Lawrence Livermore National Lab
> Livermore, CA 94550
> (510)422-7266
> ------------------------------------------------------------------------------
> 
Jeanne Martin
email: jtm@llnl.gov                     phone: (510) 422-3753
postal code: L-561                      fax: (510) 423-8704
Lawrence Livermore National Laboratory
Livermore, CA 94550
