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

Annotation 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.1 - (hide annotations) (download)
Thu Nov 1 19:07:16 2012 UTC (12 years, 8 months ago) by gforget
Branch: MAIN
- more modular, and suposedly more user-friendly, version
  of ecco_v4/comp_driver.m and basic_diags_ecco.m

1 gforget 1.1 function []=diags_grid_parms(listTimes);
2     %object : load grid, set params, and save both to dirMat
3     %input : listTimes is the time list obtained from diags_list_times
4    
5     %global variables
6     gcmfaces_global;
7     global myparms;
8    
9     %load grid
10     if isempty(dir('GRID'));
11     dirGrid=input('grid directory?\n');
12     else;
13     dirGrid='GRID/'
14     end;
15     grid_load(dirGrid,5,'compact');
16    
17     %set default for model run parameters
18     myparms=default_parms;
19    
20     %allow user to change model params if necessary
21     myparms=review_parms(myparms,listTimes);
22    
23    
24    
25     function [parms]=default_parms();
26     %set model parameters to default (ecco_v4)
27    
28     %parms.yearFirst=1948; %first year covered by model integration
29     %parms.yearLast =2007; %last year covered by model integration
30     parms.yearFirst=1992; %first year covered by model integration
31     parms.yearLast =2010; %last year covered by model integration
32     parms.yearInAve=[parms.yearFirst parms.yearLast]; %period for time averages and variance computations
33     parms.timeStep =3600; %model time step for tracers
34     parms.iceModel =1;%0=use freezing point 1=use pkg/seaice 2=use pkg/thsice
35     parms.useRFWF =1;%1=real fresh water flux 0=virtual salt flux
36     parms.useNLFS =2;%2=rstar 1=nlfs 0=linear free surface
37     parms.rhoconst =1029; %sea water density
38     parms.rcp =3994*parms.rhoconst; % sea water rho X heat capacity
39     parms.rhoi = 910; %sea ice density
40     parms.rhosn = 330; %snow density
41     parms.flami = 3.34e05; % latent heat of fusion of ice/snow (J/kg)
42     parms.flamb = 2.50e06; % latent heat of evaporation (J/kg)
43     parms.SIsal0 =4;
44    
45     function [parms]=review_parms(parms,listTimes);
46     %review model parameters, correct them if needed, and check a couple more things
47    
48     test1=1;%so that we print params at least once
49     while test1;
50     fprintf('\n\n');
51     gcmfaces_msg('model parameters summary','==== ');
52    
53     tmp1=sprintf('parms.yearFirst = %i (first year covered by model integration)',parms.yearFirst); gcmfaces_msg(tmp1,'== ');
54     tmp1=sprintf('parms.yearLast = %i (first year covered by model integration)',parms.yearLast); gcmfaces_msg(tmp1,'== ');
55     tmp1=sprintf('parms.yearInAve = [%i %i] (time mean and variance years)',parms.yearInAve); gcmfaces_msg(tmp1,'== ');
56     tmp1=sprintf('parms.timeStep = %i (model time step for tracers)',parms.timeStep); gcmfaces_msg(tmp1,'== ');
57     tmp1=sprintf('parms.iceModel = %i (0=freezing point 1=pkg/seaice 2=pkg/thsice)',parms.iceModel); gcmfaces_msg(tmp1,'== ');
58     tmp1=sprintf('parms.useRFWF = %i (1=real fresh water flux 0=virtual salt flux)',parms.useRFWF); gcmfaces_msg(tmp1,'== ');
59     tmp1=sprintf('parms.useNLFS = %i; (2=rstar 1=nlfs 0=linear free surface)',parms.useNLFS); gcmfaces_msg(tmp1,'== ');
60     tmp1=sprintf('parms.rhoconst = %0.6g (sea water density)',parms.rhoconst); gcmfaces_msg(tmp1,'== ');
61     tmp1=sprintf('parms.rcp = %0.6g (sea water density X heat capacity)',parms.rcp); gcmfaces_msg(tmp1,'== ');
62     if parms.iceModel==1;
63     tmp1=sprintf('parms.rhoi = %0.6g (sea ice density)',parms.rhoi); gcmfaces_msg(tmp1,'== ');
64     tmp1=sprintf('parms.rhosn = %0.6g (snow density)',parms.rhosn); gcmfaces_msg(tmp1,'== ');
65     tmp1=sprintf('parms.flami = %0.6g (latent heat of fusion of ice/snow in J/kg)',parms.flami); gcmfaces_msg(tmp1,'== ');
66     tmp1=sprintf('parms.flamb = %0.6g (latent heat of evaporation in J/kg)',parms.flamb); gcmfaces_msg(tmp1,'== ');
67     tmp1=sprintf('parms.SIsal0 = %0.6g (sea ice constant salinity)',parms.SIsal0); gcmfaces_msg(tmp1,'== ');
68     %tmp1=sprintf('',); gcmfaces_msg(tmp1,'== ');
69     else;
70     error('only parms.iceModel=1 is currently treated\n');
71     end;
72    
73     gcmfaces_msg('to change a param type e.g. ''parms.yearFirst=1;'' or hit return if all params are ok. Change a param?','==== ');
74     tmp1=input('');
75     test1=~isempty(tmp1); %so that we change param and iterate process
76     if test1; eval(tmp1); end;
77    
78     end;
79    
80     %determine a few more things about the diagnostic time axis
81     fprintf('\n\n');
82     parms.diagsNbRec=length(listTimes);
83     test1=median(diff(listTimes)*parms.timeStep/86400);
84     if abs(test1-30.5)<1; parms.diagsAreMonthly=1; else; parms.diagsAreMonthly=0; end;
85     if abs(test1-365.25)<1; parms.diagsAreAnnual=1; else; parms.diagsAreAnnual=0; end;
86     tmp1=sprintf('parms.diagsNbRec = %i (number of records, based on model output files)',parms.diagsNbRec); gcmfaces_msg(tmp1,'== ');
87     tmp1=sprintf('parms.diagsAreMonthly = %i (0/1 = false/true; based on output frequency)',parms.diagsAreMonthly); gcmfaces_msg(tmp1,'== ');
88     tmp1=sprintf('parms.diagsAreAnnual = %i (0/1 = false/true; based on output frequency)',parms.diagsAreAnnual); gcmfaces_msg(tmp1,'== ');
89     gcmfaces_msg('hit return if this seems correct otherwise stop here','== '); test0=input(''); if ~isempty(test0); error('likely dir problem'); end;
90    
91     listTimes2=parms.yearFirst+listTimes*parms.timeStep/86400/365.25;%this approximation of course makes things simpler
92     tmp1=-0.5*diff(listTimes,1,1)*parms.timeStep/86400/365.25; tmp1=[median(tmp1);tmp1];
93     listTimes2=listTimes2+tmp1;%this converts the enddate to the middate of pkg/diags
94     ii=find(listTimes2>=parms.yearInAve(1)&listTimes2<=parms.yearInAve(2)+1);
95     if parms.diagsAreMonthly;%then restrict to full years
96     ni=floor(length(ii)/12)*12; parms.recInAve=[ii(1) ii(floor(ni))];
97     elseif ~isempty(ii);
98     parms.recInAve=[ii(1) ii(end)];
99     else;
100     parms.recInAve=[1 1];
101     end;
102     tmp1=sprintf('parms.recInAve = [%i %i] (time mean and variance records)',parms.recInAve); gcmfaces_msg(tmp1,'== ');
103    
104     fprintf('\n\n');
105    

  ViewVC Help
Powered by ViewVC 1.1.22