- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
[cpp]REAL (KIND=8), ALLOCATABLE :: A(:) REAL (KIND=8), ALLOCATABLE :: B(:) NAMELIST /vars/ A, B [/cpp]
I'm trying to read a file with A and B, but when I read a get the folowing message:
forrtl: severe (18): too many values for NAMELIST variable, unit 11, file /test,
How can I use NAMELIST to read allocatable arrays?
1 Solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
My guess is that you did not allocate the arrays first. If you are expecting a NAMELIST read to do the allocation, you are mistaken.
C:Projects>type t.f90
REAL(8), ALLOCATABLE, DIMENSION(:) :: A,B
NAMELIST /vars/ A,B
ALLOCATE (A(2), B(3))
A = 1.0
B = 2.0
READ (*,vars)
WRITE (*, vars)
END
C:Projects> ifort /nologo t.f90
C:Projects t.exe
&vars A = 4,B = 5,6 /
&VARS
A = 4.00000000000000 , 1.00000000000000 ,
B = 5.00000000000000 , 6.00000000000000 , 2.00000000000000
/
You will need the latest 11.1 for this, as some earlier versions did not allow ALLOCATABLE arrays in NAMELIST at all.
C:Projects>type t.f90
REAL(8), ALLOCATABLE, DIMENSION(:) :: A,B
NAMELIST /vars/ A,B
ALLOCATE (A(2), B(3))
A = 1.0
B = 2.0
READ (*,vars)
WRITE (*, vars)
END
C:Projects> ifort /nologo t.f90
C:Projects t.exe
&vars A = 4,B = 5,6 /
&VARS
A = 4.00000000000000 , 1.00000000000000 ,
B = 5.00000000000000 , 6.00000000000000 , 2.00000000000000
/
You will need the latest 11.1 for this, as some earlier versions did not allow ALLOCATABLE arrays in NAMELIST at all.
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
With no example of your source code or data file, it is nearly pointless to attempt an answer. From the fragment you have shown, I would say don't try non-standard extensions until you have it working with a standard-compliant example.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
My guess is that you did not allocate the arrays first. If you are expecting a NAMELIST read to do the allocation, you are mistaken.
C:Projects>type t.f90
REAL(8), ALLOCATABLE, DIMENSION(:) :: A,B
NAMELIST /vars/ A,B
ALLOCATE (A(2), B(3))
A = 1.0
B = 2.0
READ (*,vars)
WRITE (*, vars)
END
C:Projects> ifort /nologo t.f90
C:Projects t.exe
&vars A = 4,B = 5,6 /
&VARS
A = 4.00000000000000 , 1.00000000000000 ,
B = 5.00000000000000 , 6.00000000000000 , 2.00000000000000
/
You will need the latest 11.1 for this, as some earlier versions did not allow ALLOCATABLE arrays in NAMELIST at all.
C:Projects>type t.f90
REAL(8), ALLOCATABLE, DIMENSION(:) :: A,B
NAMELIST /vars/ A,B
ALLOCATE (A(2), B(3))
A = 1.0
B = 2.0
READ (*,vars)
WRITE (*, vars)
END
C:Projects> ifort /nologo t.f90
C:Projects t.exe
&vars A = 4,B = 5,6 /
&VARS
A = 4.00000000000000 , 1.00000000000000 ,
B = 5.00000000000000 , 6.00000000000000 , 2.00000000000000
/
You will need the latest 11.1 for this, as some earlier versions did not allow ALLOCATABLE arrays in NAMELIST at all.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page