/[MITgcm]/MITgcm/verification/global_ocean.90x40x15/diags_matlab/mit_getparm.m
ViewVC logotype

Contents of /MITgcm/verification/global_ocean.90x40x15/diags_matlab/mit_getparm.m

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1.2.1 - (show annotations) (download)
Wed Oct 23 18:26:35 2002 UTC (21 years, 8 months ago) by mlosch
Branch: release1
CVS Tags: release1_p12, release1_p10, release1_p16, release1_p15, release1_p11, release1_p14, release1_p13, release1_p17, release1_p8, release1_p9, release1_p6, release1_p7, release1_p13_pre, release1_p12_pre
Branch point for: release1_50yr
Changes since 1.1: +0 -0 lines
o fixed the verification/global_ocean.90x40x15 experiment:
 - new bathymetry (the world according to A., JMC, and M.)
 - new initial fields and forcing fields (*.bin files)
 - new POLY3.COEFFS (for the next release one should switch to a full
   equation of state)
 - fixed several errors and redundancies in the data file
 - experiment uses looped cells
 - added matlab directory with diagnostic scripts for plotting of output

1 function y = mit_getparm(fname,pname);
2 %function y = mit_getparm(fname,pname);
3
4 y = [];
5 [fp, msg] = fopen(fname,'r');
6 if fp > 0
7 str{1} = [];
8 notfound = 0;
9 while isempty(mystrfind(str{1},pname))
10 str{1} = fgetl(fp);
11 if ~ischar(str{1}); % this catches the end of file (not very clean)
12 notfound = 1;
13 break;
14 end
15 % clear again if commented
16 if ~isempty(mystrfind(str{1},'#'))
17 str{1} = [];
18 end
19 end
20 if notfound
21 disp(['Warning: ' pname ' not found in ' fname])
22 y=[];
23 % disp([' setting ' pname ' to zero'])
24 % y = 0;
25 else
26 teststr = [];
27 % find the termination of parameter pname
28 % (next line with an '=' sign
29 % or with a namelist termination character '&' or '/')
30 n = 1;
31 while ( isempty(mystrfind(teststr,'=')) & ...
32 isempty(mystrfind(teststr,'&')) & ...
33 isempty(mystrfind(teststr,'/')) )
34 n = n + 1;
35 teststr = fgetl(fp);
36 str{n} = teststr;
37 if ~ischar(teststr); break; end
38 end
39 eqind = findstr(str{1},'=');
40 y = str{1}(eqind+1:end-1);
41 % check whether it is a string in quotes or something else
42 quotes = findstr(y,'''');
43 if ~isempty(quotes)
44 y(quotes(2):end) = [];
45 y(1:quotes(1)) = [];
46 else
47 if ~( strcmpi(y,'.TRUE.') | strcmpi(y,'.FALSE.') )
48 y = convert_str2num(str{1}(eqind+1:end-1));
49 for k=2:n-1
50 y = [y; convert_str2num(str{k}(eqind+1:end-1))];
51 end
52 % $$$ y = str2num(str{1}(eqind+1:end-1))';
53 % $$$ for k=2:n-1
54 % $$$ y = [y; str2num(str{k}(eqind+1:end-1))'];
55 % $$$ end
56 end
57 end
58 end
59 fclose(fp);
60 else
61 error([fname ' could not be opened: ' msg])
62 end
63
64 return
65
66 function y = convert_str2num(str)
67
68 % take care of the n*value format
69 stars = findstr(str,'*');
70 if isempty(stars)
71 y = str2num(str)';
72 else
73 if length(stars)==1
74 y=repmat(str2num(str(stars+1:end)),[str2num(str(1:stars-1)) 1]);
75 else
76 warning('The format n*x1,m*x2, ... cannot be handled')
77 % $$$ for k=1:length(stars)
78 % $$$ % find the beginnin and termination of the set
79 % $$$ end
80 end
81 end
82
83 return
84
85 function [ind] = mystrfind(str,pattern)
86
87 if length(pattern) > length(str)
88 ind = [];
89 return
90 else
91 ind = findstr(str,pattern);
92 end

  ViewVC Help
Powered by ViewVC 1.1.22