From: glen herrmannsfeldt on
Richard Maine <nospam(a)see.signature> wrote:
(snip, I wrote)

>> It seems that for F2003 (10.10.1.1) that subscripts, strides,
>> and substring expressions are allowed.

> Oh, I had forgotten about that. (I pretty much stopped using namelist
> myself at about the time it was standardized). Thanks for the
> correction.

> I was probably thinking about how you can't do things like x(k)=12345
> because the k isn't available.

OS/360 NAMELIST allows either the X= form or the X(3)= form.
Stides didn't exist yet, but are an interesting addition
to NAMESLIST.

-- glen
From: Paul Thomas on
On Jan 20, 7:06 pm, jshine <jtomsh...(a)gmail.com> wrote:
> I'm curious if anyone has some example code of how to input a 2-D (or,
> in principle, n-D) array via a namelist file in Fortran 95 (I'm using
> a reasonably current "gfortran" compiler)?  I can load a 1-D array (a
> vector) easily enough and have tried a number of permutations on that
> syntax, but I haven't been successful yet.  ...nor have I found any
> good examples of this via Google or in any of my Fortran books.

Dear Jon,

The gfortran testsuite, which you can download separately from gcc
mirror sites, contains lots of namelist examples; eg. namelist_24.f90
- uses 2D arrays:

! Tests namelist read when more data is provided then specified by
! array qualifier in list.
! Contributed by Jerry DeLisle.
program pr24459
implicit none
integer nd, ier, i, j
parameter ( nd = 5 )
character*(8) names(nd,nd)
character*(8) names2(nd,nd)
character*(8) names3(nd,nd)
namelist / mynml / names, names2, names3
open(unit=20,status='scratch', delim='apostrophe')
write (20, '(a)') "&MYNML"
write (20, '(a)') "NAMES = 25*'0'"
write (20, '(a)') "NAMES2 = 25*'0'"
write (20, '(a)') "NAMES3 = 25*'0'"
write (20, '(a)') "NAMES(2,2) = 'frogger'"
write (20, '(a)') "NAMES(1,1) = 'E123' 'E456' 'D789' 'P135'
'P246'"
write (20, '(a)') "NAMES2(1:5:2,2) = 'abcde' 'fghij' 'klmno'"
write (20, '(a)') "NAMES3 = 'E123' 'E456' 'D789' 'P135' 'P246'
'0' 'frogger'"
write (20, '(a)') "/"
rewind(20)
read(20,nml=mynml, iostat=ier)
if (ier.ne.0) call abort()
if (any(names(:,3:5).ne."0")) call abort()
if (names(2,2).ne."frogger") call abort()
if (names(1,1).ne."E123") call abort()
if (names(2,1).ne."E456") call abort()
if (names(3,1).ne."D789") call abort()
if (names(4,1).ne."P135") call abort()
if (names(5,1).ne."P246") call abort()
if (any(names2(:,1).ne."0")) call abort()
if (any(names2(:,3:5).ne."0")) call abort()
if (names2(1,2).ne."abcde") call abort()
if (names2(2,2).ne."0") call abort()
if (names2(3,2).ne."fghij") call abort()
if (names2(4,2).ne."0") call abort()
if (names2(5,2).ne."klmno") call abort()
if (any(names3.ne.names)) call abort()
end

Others use strides and so on.

Cheers

Paul
From: robin on
"jshine" <jtomshine(a)gmail.com> wrote in message news:622d7e24-9400-4aa9-93a1-090a39ca79db(a)h2g2000yqj.googlegroups.com...
| I'm curious if anyone has some example code of how to input a 2-D (or,
| in principle, n-D) array via a namelist file in Fortran 95 (I'm using
| a reasonably current "gfortran" compiler)? I can load a 1-D array (a
| vector) easily enough and have tried a number of permutations on that
| syntax, but I haven't been successful yet. ...nor have I found any
| good examples of this via Google or in any of my Fortran books.
|
| Any help will be appreciated!

The easiest way for you to check that out is to
output the array using NAMELIST.


From: jshine on
Thanks for all the pointers; this has definitely cleared up my issue
and I've now got the whole array loading in nicely.

Thanks again!
-Jon


On Jan 20, 10:06 am, jshine <jtomsh...(a)gmail.com> wrote:
> I'm curious if anyone has some example code of how to input a 2-D (or,
> in principle, n-D) array via a namelist file in Fortran 95 (I'm using
> a reasonably current "gfortran" compiler)?  I can load a 1-D array (a
> vector) easily enough and have tried a number of permutations on that
> syntax, but I haven't been successful yet.  ...nor have I found any
> good examples of this via Google or in any of my Fortran books.
>
> Any help will be appreciated!
>
> Thanks,
> -Jon

First  |  Prev  | 
Pages: 1 2
Prev: Data Plotting Library DISLIN 10.0
Next: errata list