namelist array objects in subprograms

Paul Thomas paulthomas2@wanadoo.fr
Sat Jan 15 10:35:00 GMT 2005


I cannot decide if the following indicates a lack of understanding on my 
part or some problem with association of array variables.

program test_sub_nml
  real  :: x = 99.0
  real,dimension(2)  :: z = (/1.0,2.0/)
  call foo(x , z)
contains
  subroutine foo(x , z )
    real,dimension(2)  :: z
    real,dimension(2)  :: y = (/3.0,4.0/)
    real :: x
    namelist /a/ x , y , z
    write(*,nml=a)
    write(*,*) z
  end subroutine foo
end program test_sub_nml

Runs fine with the Digital compiler.  With the cvs gfortran, which treats 
arrays as scalars, it gives

&a
x=  99.00000    ,y=  3.000000    ,z= 5.9520881E-39,/
   1.000000       2.000000

and my development version gives

&A
 X=  99.00000    ,
 Y=  3.000000    ,  4.000000    ,
 Z= 5.9578278E-39, 3.2086484E-39,  /

   1.000000       2.000000

Apparently the

gfc_conv_expr_reference (&se, nmlvar);      /*line 1026 of trans-io.c */

transfers the pointer to the data in the local scope (ie. y above)  but not 
when array data is transferred as a subroutine argument(ie. z above). 
Scalars, such as x, ARE correctly transferred, however.

Is there something I should be adding to build up the reference correctly or 
has the association not occurred fully before the NAMELIST statement?

Paul T 




More information about the Fortran mailing list