read_namelist.m
SYNTAX:
FUNCTION CALL:
[nlnames,nlstr,nlall]= read_namelist(filename,to_upper);
SCRIPT CALL (compatable with old script)
read_namelist; SCRIPT FORM reads & writes to caller area
PURPOSE: Read a FORTRAN namelist file and create variables in the
matlab workspace defined by variables in the namelist.
INPUT: [default]
filename = name of namelist file to read
to_upper = 1; makes variables UPPER case; -1= LOWER case;s [0]
NOTE: if any input variable missing it looks 1st in "caller" then in "base"
OUTPUT:
nlnames= Name of all namelists found in file
nlstr= Structure of namelist and variables
nlall= total list of all namelists and variable (for write_namelist)
NOTE: if output variable "nlstr" is not present, routine puts all
namelist variables in "caller" routine. Same for "nlall"
(duplicate variable names in "caller" routine are overwritten)
NOTE: To get all structure namelist variables into environment:
[names, isstruc]= struct_to_ws(nlstr); Do 1st level
if any(isstruc) Loop to do 2nd level
id= find(isstruc);
for ii= 1:length(id)
str= ['[names1,isstruc1]= struct_to_ws(' char(names(id(ii))) ');'];
eval(str)
end for
end if any
clear nlstr
RESTRICTIONS:
won't work if '=' signs in quotes in any of string data
won't work for multiple (*) string variables
Dependencies