/[MITgcm]/MITgcm_contrib/gael/matlab_class/gcmfaces_diags/diags_grid_parms.m
ViewVC logotype

Contents of /MITgcm_contrib/gael/matlab_class/gcmfaces_diags/diags_grid_parms.m

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


Revision 1.18 - (show annotations) (download)
Fri Dec 30 19:34:32 2016 UTC (8 years, 6 months ago) by gforget
Branch: MAIN
CVS Tags: checkpoint66f, checkpoint66e, checkpoint66d, checkpoint66c, checkpoint66b, checkpoint66o, HEAD
Changes since 1.17: +10 -2 lines
- gcmfaces_diags/diags_select.m: set missing variables to 0 (e.g., for seaice fields in ocean only run)
- gcmfaces_diags/diags_grid_parms.m: allow parms.iceModel==0 case for ocean only run

1 function []=diags_grid_parms(dirModel,listTimes,doInteractive);
2 %object : load grid, set params, and save myparms to dirMat
3 %input : dirModel is the model output directory
4 % listTimes is the time list obtained from diags_list_times
5 % doInteractive=1 allows users to specify parameters interactively
6 % whereas doInteractive=0 tries to specify them automatically
7
8 %global variables
9 gcmfaces_global;
10 global myparms;
11
12 %load grid
13 diags_grid(dirModel,doInteractive);
14
15 %set default for model run parameters
16 if doInteractive;
17 choiceParams=input(['choice of default parameters? (1=ecco v4, ' ...
18 '2=core, 3=ecco2 adjoint, 4=ecco v3, 5=core-Jeff)\n']);
19 else;
20 choiceParams=1;
21 end;
22 myparms=default_parms(myparms,choiceParams);
23
24 %allow user to change model params if necessary
25 myparms=review_parms(myparms,listTimes,doInteractive);
26
27 function [parms]=default_parms(parms,choiceParams);
28 %set model parameters to default (ecco_v4)
29
30 if choiceParams==1|choiceParams==2|choiceParams==4|choiceParams==5;
31 parms.yearFirst=1992; %first year covered by model integration
32 parms.yearLast =2011; %last year covered by model integration
33 parms.yearInAve=[parms.yearFirst parms.yearLast]; %period for time averages and variance computations
34 parms.timeStep =3600; %model time step for tracers
35 parms.iceModel =1;%0=use freezing point 1=use pkg/seaice 2=use pkg/thsice (not implemented)
36 parms.useRFWF =1;%1=real fresh water flux 0=virtual salt flux
37 parms.useNLFS =2;%2=rstar 1=nlfs 0=linear free surface
38 parms.rhoconst =1029; %sea water density
39 parms.rcp =3994*parms.rhoconst; % sea water rho X heat capacity
40 parms.rhoi = 910; %sea ice density
41 parms.rhosn = 330; %snow density
42 parms.flami = 3.34e05; % latent heat of fusion of ice/snow (J/kg)
43 parms.flamb = 2.50e06; % latent heat of evaporation (J/kg)
44 parms.SIsal0 =4;
45 if choiceParams==2;
46 parms.yearFirst=1948; %first year covered by model integration
47 parms.yearLast =2007; %last year covered by model integration
48 parms.yearInAve = [1948 2007];
49 end;
50 if choiceParams==4;
51 parms.useRFWF =0;%1=real fresh water flux 0=virtual salt flux
52 parms.useNLFS =0;%2=rstar 1=nlfs 0=linear free surface
53 end;
54 if choiceParams==5;
55 parms.yearFirst=2006; %first year covered by model integration
56 parms.yearLast =2305; %last year covered by model integration
57 parms.yearInAve = [2006 2305];
58 end;
59 end;
60
61 if choiceParams==3;
62 parms.yearFirst=2004; %first year covered by model integration
63 parms.yearLast =2005; %last year covered by model integration
64 parms.yearInAve=[parms.yearFirst parms.yearLast]; %period for time averages and variance computations
65 parms.timeStep =1200; %model time step for tracers
66 parms.iceModel =1;%0=use freezing point 1=use pkg/seaice 2=use pkg/thsice
67 parms.useRFWF =0;%1=real fresh water flux 0=virtual salt flux
68 parms.useNLFS =0;%2=rstar 1=nlfs 0=linear free surface
69 parms.rhoconst =1027.5; %sea water density
70 parms.rcp =3994*parms.rhoconst; % sea water rho X heat capacity
71 parms.rhoi = 910; %sea ice density
72 parms.rhosn = 330; %snow density
73 parms.flami = 3.34e05; % latent heat of fusion of ice/snow (J/kg)
74 parms.flamb = 2.50e06; % latent heat of evaporation (J/kg)
75 parms.SIsal0 = 0;
76 end;
77
78 if parms.iceModel==0;
79 parms.rhoi = 0; %sea ice density
80 parms.rhosn = 0; %snow density
81 parms.flami = 0; % latent heat of fusion of ice/snow (J/kg)
82 parms.flamb = 0; % latent heat of evaporation (J/kg)
83 parms.SIsal0 = 0;
84 end;
85
86 function [parms]=review_parms(parms,listTimes,doInteractive);
87 %review model parameters, correct them if needed, and check a couple more things
88
89 test1=1;%so that we print params at least once
90 while test1;
91 fprintf('\n\n');
92 gcmfaces_msg('model parameters summary','==== ');
93
94 tmp1=sprintf('parms.yearFirst = %i (first year covered by model integration)',parms.yearFirst); gcmfaces_msg(tmp1,'== ');
95 tmp1=sprintf('parms.yearLast = %i (first year covered by model integration)',parms.yearLast); gcmfaces_msg(tmp1,'== ');
96 tmp1=sprintf('parms.yearInAve = [%i %i] (time mean and variance years)',parms.yearInAve); gcmfaces_msg(tmp1,'== ');
97 tmp1=sprintf('parms.timeStep = %i (model time step for tracers)',parms.timeStep); gcmfaces_msg(tmp1,'== ');
98 tmp1=sprintf('parms.iceModel = %i (0=freezing point 1=pkg/seaice 2=pkg/thsice)',parms.iceModel); gcmfaces_msg(tmp1,'== ');
99 tmp1=sprintf('parms.useRFWF = %i (1=real fresh water flux 0=virtual salt flux)',parms.useRFWF); gcmfaces_msg(tmp1,'== ');
100 tmp1=sprintf('parms.useNLFS = %i; (2=rstar 1=nlfs 0=linear free surface)',parms.useNLFS); gcmfaces_msg(tmp1,'== ');
101 tmp1=sprintf('parms.rhoconst = %0.6g (sea water density)',parms.rhoconst); gcmfaces_msg(tmp1,'== ');
102 tmp1=sprintf('parms.rcp = %0.6g (sea water density X heat capacity)',parms.rcp); gcmfaces_msg(tmp1,'== ');
103 if parms.iceModel<=1;
104 tmp1=sprintf('parms.rhoi = %0.6g (sea ice density)',parms.rhoi); gcmfaces_msg(tmp1,'== ');
105 tmp1=sprintf('parms.rhosn = %0.6g (snow density)',parms.rhosn); gcmfaces_msg(tmp1,'== ');
106 tmp1=sprintf('parms.flami = %0.6g (latent heat of fusion of ice/snow in J/kg)',parms.flami); gcmfaces_msg(tmp1,'== ');
107 tmp1=sprintf('parms.flamb = %0.6g (latent heat of evaporation in J/kg)',parms.flamb); gcmfaces_msg(tmp1,'== ');
108 tmp1=sprintf('parms.SIsal0 = %0.6g (sea ice constant salinity)',parms.SIsal0); gcmfaces_msg(tmp1,'== ');
109 %tmp1=sprintf('',); gcmfaces_msg(tmp1,'== ');
110 else;
111 error('only parms.iceModel=1 is currently treated\n');
112 end;
113
114 if doInteractive;
115 gcmfaces_msg('to change a param type e.g. ''parms.yearFirst=1;'' or hit return if all params are ok. Change a param?','==== ');
116 tmp1=input('');
117 test1=~isempty(tmp1); %so that we change param and iterate process
118 if test1; eval(tmp1); end;
119 else;
120 test1=[];
121 end;
122 end;
123
124 %determine a few more things about the diagnostic time axis
125 fprintf('\n\n');
126 parms.diagsNbRec=length(listTimes);
127 test1=median(diff(listTimes)*parms.timeStep/86400);
128 if abs(test1-30.5)<1; parms.diagsAreMonthly=1; else; parms.diagsAreMonthly=0; end;
129 if abs(test1-365.25)<1; parms.diagsAreAnnual=1; else; parms.diagsAreAnnual=0; end;
130 if doInteractive;
131 tmp1=sprintf('parms.diagsNbRec = %i (number of records, based on model output files)',parms.diagsNbRec); gcmfaces_msg(tmp1,'== ');
132 tmp1=sprintf('parms.diagsAreMonthly = %i (0/1 = false/true; based on output frequency)',parms.diagsAreMonthly); gcmfaces_msg(tmp1,'== ');
133 tmp1=sprintf('parms.diagsAreAnnual = %i (0/1 = false/true; based on output frequency)',parms.diagsAreAnnual); gcmfaces_msg(tmp1,'== ');
134 gcmfaces_msg('hit return if this seems correct otherwise stop here','== '); test0=input(''); if ~isempty(test0); error('likely dir problem'); end;
135 end;
136
137 listTimes2=parms.yearFirst+listTimes*parms.timeStep/86400/365.25;%this approximation of course makes things simpler
138 tmp1=-0.5*diff(listTimes,1,1)*parms.timeStep/86400/365.25; tmp1=[median(tmp1);tmp1];
139 listTimes2=listTimes2+tmp1;%this converts the enddate to the middate of pkg/diags
140 ii=find(listTimes2>=parms.yearInAve(1)&listTimes2<=parms.yearInAve(2)+1);
141 if parms.diagsAreMonthly;%then restrict to full years
142 ni=floor(length(ii)/12)*12;
143 if ni>0;
144 parms.recInAve=[ii(1) ii(floor(ni))];
145 else;
146 parms.recInAve=[ii(1) ii(end)];
147 end;
148 elseif ~isempty(ii);
149 parms.recInAve=[ii(1) ii(end)];
150 else;
151 parms.recInAve=[1 1];
152 end;
153 if doInteractive;
154 tmp1=sprintf('parms.recInAve = [%i %i] (time mean and variance records)',parms.recInAve); gcmfaces_msg(tmp1,'== ');
155 end;
156
157 fprintf('\n\n');
158

  ViewVC Help
Powered by ViewVC 1.1.22