On 4/8/12 1:44 PM, Aleksandar Donev wrote:
> Hello,
>
> A question. If you have an array of size 3 in a namelist, in the
> namelist you can do:
>
> array(1)=5
>
> to set just the first value. But if I do
>
> array=5
Not enough values provided. Try array = 3*5. Here's an example
program aleks
implicit none
integer array(3)
namelist /nm/ array
array = 1
print *, array
open (unit=10,file="nm.dat")
read (10,nml=nm)
print *, array
read (10,nml=nm)
print *, array
end program aleks
> cat nm.dat
&nm array(:) = 3*5/
&nm array(1) = 3/
> ./a.out
3*1
3*5
3, 2*5
Cheers,
Bill
>
> it seems the compilers I use accept this but also only change the first
> value of array. Is this a bug or feature? If the above syntax is at all
> allowed (missing values for the array elements), then I would have
> thought it should either be read as "array syntax" and assign all 3
> elements the value of 5, or give some I/O error about incomplete field.
> I cannot figure out where these rules are in the standard however.
>
> Thanks,
> Aleks
>
--
Bill Long [log in to unmask]
Fortran Technical Support & voice: 651-605-9024
Bioinformatics Software Development fax: 651-605-9142
Cray Inc./Cray Plaza, Suite 210/380 Jackson St./St. Paul, MN 55101
|