-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathread_ini.m
More file actions
87 lines (66 loc) · 2.12 KB
/
Copy pathread_ini.m
File metadata and controls
87 lines (66 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
function params = read_ini(filename)
narginchk(1,1)
assert(is_file(filename), ['config file ', filename, ' not found.'])
fid=fopen(filename);
%DATE
datatrim = strtok(fgetl(fid),' ');
[day,remainder]=strtok(datatrim,',');
[month,remainder]=strtok(remainder,',');
year =strtok(remainder,','); %should not find delimiter..
params.ymd=[str2double(year),str2double(month),str2double(day)];
%UT seconds
datatrim =strtok(fgetl(fid),' ');
params.UTsec0=str2double(datatrim);
%Sim duration
datatrim =strtok(fgetl(fid),' ');
params.tdur=str2double(datatrim);
%Output dt
datatrim =strtok(fgetl(fid),' ');
params.dtout=str2double(datatrim);
%f10.7 and geomag indices (used in msis)
datatrim =strtok(fgetl(fid),' ');
[f107a,remainder]=strtok(datatrim,',');
[f107,remainder]=strtok(remainder,',');
ap =strtok(remainder,','); %should not find delimiter..
params.activ=[str2double(f107a),str2double(f107),str2double(ap)];
%CFL number
datatrim =strtok(fgetl(fid),' ');
params.tcfl=str2double(datatrim);
%Exospheric temp.
datatrim =strtok(fgetl(fid),' ');
params.Teinf=str2double(datatrim);
%Strip out the junk
% data=fgetl(fid);
%Type of potential solution
datatrim = strtok(fgetl(fid),' ');
params.flagpot=str2double(datatrim);
%Grid periodic flag
datatrim =strtok(fgetl(fid),' ');
params.flagperiodic=str2double(datatrim);
%OUTPUT type flag
datatrim = strtok(fgetl(fid),' ');
params.flagoutput=str2double(datatrim);
%capacitance flag
datatrim = strtok(fgetl(fid),' ');
params.flagcap=str2double(datatrim);
%Strip out the junk
fgetl(fid);
fgetl(fid);
fgetl(fid);
%Neutral perturbation info
datatrim = strtok(fgetl(fid),' ');
params.flagdneu = str2double(datatrim);
%Type of neutral interpolation done (not used)
fgetl(fid);
params.mloc=[];
if params.flagdneu
datatrim = strtok(fgetl(fid),' ');
[mlat,remainder]=strtok(datatrim,',');
mlon = strtok(remainder,',');
% NOTE: str2num necessary here in case input formatted like 1.3d0 which
% str2double returns NaN for while str2num works
params.mloc=[str2num(mlat), str2num(mlon)]; %#ok<ST2NM>
end
fclose(fid);
%There's more in the input file, but we don't use it in the data processing
end % function