Hello,
NAMELIST variables cannot have a variable length/size, ever...I like
NAMELIST input because I do not have to worry about parsing things and
it is simple. But I do every now and then need to input small arrays of
variable size. A typical example: If I am working with a binary
molecular mixture, I need 2 numbers to tell me how many molecules of
each kind to have, but I may only need 1 number, or maybe more. Any
ideas how to handle this? Here is my try:
INTEGER, DIMENSION(n_molecule_types) :: n_molecules ! Automatic array
CHARACTER(LEN=100) :: n_molecules_buffer=""
NAMELIST /system_size/ n_molecules_buffer
READ(unit,NML=system_size)
IF(n_molecules_buffer!="") THEN
READ(n_molecules_buffer,*) n_molecules
ELSE
n_molecules=1
END IF
Any better ideas?
Thanks,
Aleksandar
--
__________________________________
Aleksandar Donev
Complex Materials Theory Group (http://cherrypit.princeton.edu/)
Princeton Materials Institute & Program in Applied and Computational Mathematics
@ Princeton University
Address:
419 Bowen Hall, 70 Prospect Avenue
Princeton University
Princeton, NJ 08540-5211
E-mail: [log in to unmask]
WWW: http://atom.princeton.edu/donev
Phone: (609) 258-2775
Fax: (609) 258-6878
__________________________________
|