- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
&MY_NAMELIST
A(:,2) = /1,2/
A(1,1:5:2) = /3,4,5/
/
The idea is to input efficiently sections of the array, or maybe even specify non-unity strides. Obviously the example above will not work - but maybe there is a way to achieve this?
Thanks!
Olivier
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You might want to construct a state machine and reader to read-in your sparse arrays (or sparse updates to previously loaded data).
This will provide for extended capabilities over NAMELIST (you add the extended capabilities).
The state machine works off a data file to be read sequentially. The mechanics of the state machine is to work somewhat like a binary loader. The data contains an identifier for next entity (or end of file). In your case the entity would be an array identifier (A), the next input data might be an offset (index), then count of data, then data for insert. You might configure the state table such that you can have multiple read-in formats
array id, offset, n, { n elements }
array id, stride fill, stride, offset, n, {n elements at stride seperation }
array id, wipe, offset, n
...
A technique that I found useful was for the read-in code to expect numeric values (easy to code hard to read) but then use the Fortran Preprocessor to preprocess the "human readable text" file for input into numeric format for program reading.
Use the #define ARRAYnameHere nnnn
And other mnemonic names for the numeric values/codes.
The preprocessor additionaly supports
#include aFileNameHere.xx
And then you can then construct your master data tables out of pre-build components.
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Maybe I don't understand the question... Or maybe the previous answer is way too much for a simple question, but:
In Fortran, slash ( / ) is used to skip or end input. Try changing the data file to something like:
&MY_NAMELISTA(:,2) = 1,2
A(1,1:5:2) = 3,4,5
/
The following example works just fine with it:
!--------------------------------------------------------------------------------------------------
program nml_test
implicit none
integer :: a(2,5), ios, i, j
namelist /my_namelist/ a
continue
a = 0
open (unit = 100, file = 'nml.dat', status = 'old', action = 'read', iostat = ios)
print '("open ios = ", i0)', ios
read (100, my_namelist, iostat = ios)
print '("read ios = ", i0)', ios
close (100, iostat = ios)
print '("A(", i0, ",", i0, ") = ", i0)', ((i, j, a(i, j), i = 1, 2), j = 1, 5)
end program nml_test
!--------------------------------------------------------------------------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks again!
Olivier

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