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

Annotation of /MITgcm_contrib/gael/matlab_class/gcmfaces_diags/diags_pre_process.m

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


Revision 1.4 - (hide annotations) (download)
Tue Jan 28 17:07:13 2014 UTC (11 years, 6 months ago) by gforget
Branch: MAIN
Changes since 1.3: +1 -1 lines
- diags_display.m : omit annual running mean when diagsNbRec<=12
- diags_pre_process.m and diags_set_E.m : fix typos
- diags_set_D.m and diags_set_E.m : alow for 'mat/' subdirectories
- added : diags_set_SEAICE.m dedicated to seaice and snow diagnostics

1 gforget 1.1 function [myswitch]=diags_pre_process(dirModel,dirMat);
2     %object : pre-processing for grid, model parameters, budgets,
3     % profiles, cost and control, etc.
4     % To be called at the the start of diags_driver
5     %inputs : dirModel is the model run directory name
6     % dirMat is the directory where diagnozed .mat files will be saved
7     % -> set it to '' to use the default [dirModel 'mat/']
8     %output : myswitch is the set of switches (doBudget, doProfiles, doCost, doCtrl)
9     % that are set here depending on the model output available
10    
11     gcmfaces_global; global myparms;
12    
13     dirModel=[dirModel '/'];
14     if isempty(dirMat); dirMat=[dirModel 'mat/']; else; dirMat=[dirMat '/']; end;
15    
16     doBudget=~isempty(dir([dirModel 'diags/BUDG/']))
17     doProfiles=~isempty(dir([dirModel 'profiles/']))
18     doCost=~isempty(dir([dirModel 'barfiles/']))
19     doCtrl=~isempty(dir([dirModel 'ADXXfiles/']))
20    
21     %output switches
22     myswitch.doBudget=doBudget;
23     myswitch.doProfiles=doProfiles;
24     myswitch.doCost=doCost;
25     myswitch.doCtrl=doCtrl;
26    
27     %0) create dirMat if needed:
28     if isempty(dir(dirMat)); eval(['!mkdir ' dirMat ';']); end;
29    
30     %1) pre-processing diags_grid_parms.mat
31     test0=isempty(dir([dirMat 'diags_grid_parms.mat']));
32     test1=isempty(dir([dirMat 'lock_mygrid']));
33    
34     if test0&test1;%this process will do the pre-processing
35     fprintf(['pre-processing : started for mygrid \n']);
36     write2file([dirMat 'lock_mygrid'],1);
37     %set the list of diags times
38     listSubdirs={[dirMat 'BUDG/' ],[dirModel 'diags/BUDG/' ],[dirModel 'diags/OTHER/' ],...
39     [dirModel 'diags/STATE/' ],[dirModel 'diags/TRSP/'],[dirModel 'diags/' ]};
40     listFiles={'state_2d_set1','diags_2d_set1','monthly_2d_set1'};
41     [listTimes]=diags_list_times(listSubdirs,listFiles);
42     %set grid and model parameters:
43     diags_grid_parms(listTimes);
44     %save to disk:
45     eval(['save ' dirMat 'diags_grid_parms.mat mygrid myparms;']);
46     eval(['!\rm ' dirMat 'lock_mygrid']);
47     test1=1;
48     fprintf(['pre-processing : completed for mygrid \n\n']);
49     end;
50    
51     while ~test1;%this process will wait for pre-processing to complete
52     fprintf(['waiting 30s for removal of ' dirMat 'lock_mygrid \n']);
53 gforget 1.2 fprintf(['- That should happen automatically after pre-processing is complete \n']);
54     fprintf(['- But if a previous session was interupted, you may need to stop this one, \n ']);
55     fprintf([' remove ' dirMat 'lock_grid manually, and start over. \n\n']);
56 gforget 1.1 test1=isempty(dir([dirMat 'lock_mygrid']));
57     pause(30);
58     end;
59    
60     %here we always reload the grid from dirMat to make sure the same one is used throughout
61     eval(['load ' dirMat 'diags_grid_parms.mat;']);
62    
63     %2) pre-processing profiles
64     test0=isempty(dir([dirMat 'profiles/']));
65     test1=isempty(dir([dirMat 'lock_profiles']));
66    
67     if test0&test1&doProfiles;%this process will do the pre-processing
68     fprintf(['pre-processing : started for profiles \n']);
69     write2file([dirMat 'lock_profiles'],1);
70     eval(['!mkdir ' dirMat 'profiles/;']);
71     eval(['!ln -s /net/nares/raid11/ecco-shared/ecco-version-4/input/input_insitu ' dirMat 'profiles/input']);
72     eval(['!mkdir ' dirMat 'profiles/output']);
73     if dirModel(1)~='/'; dirModelFull=[pwd '/' dirModel]; else; dirModelFull=dirModel; end;
74     eval(['!ln -s ' dirModelFull 'profiles/*equi.data ' dirMat 'profiles/.']);
75 gforget 1.4 listModel={'argo_feb2013_1992_to_2007*','argo_feb2013_2008_to_2010*',...
76 gforget 1.3 'argo_feb2013_2011_to_2012*','ctd_feb2013*','itp_feb2013*',...
77     'seals_feb2013*','xbt_feb2013*','climode_feb2013*'};
78 gforget 1.1 MITprof_gcm2nc([dirMat 'profiles/'],listModel);
79     eval(['!\rm ' dirMat 'lock_profiles']);
80     test1=1;
81     fprintf(['pre-processing : completed for profiles \n\n']);
82     end;
83    
84     while ~test1&doProfiles;%this process will wait for pre-processing to complete
85     fprintf(['waiting 30s for removal of ' dirMat 'lock_profiles \n']);
86 gforget 1.2 fprintf(['- That should happen automatically after pre-processing is complete \n']);
87     fprintf(['- But if a previous session was interupted, you may need to stop this one, \n ']);
88     fprintf([' remove ' dirMat 'lock_profiles manually, and start over. \n\n']);
89 gforget 1.1 test1=isempty(dir([dirMat 'lock_profiles']));
90     pause(30);
91     end;
92    
93     %3) budget pre-processing
94     test0=isempty(dir([dirMat 'BUDG/']));
95     test1=isempty(dir([dirMat 'lock_budg']));%this aims at having only one process do the
96    
97     if (test0&test1&doBudget);
98     fprintf(['pre-processing : started for budget \n']);
99     write2file([dirMat 'lock_budg'],1);
100     eval(['!mkdir ' dirMat 'BUDG/;']);
101     %compute time derivatives between snwpshots that will be
102     %compared in budgets with the time mean flux terms
103     v4_diff_snapshots(dirModel,dirMat,'budg2d_snap_set1');
104     v4_diff_snapshots(dirModel,dirMat,'budg2d_snap_set2');
105     v4_diff_snapshots(dirModel,dirMat,'budg2d_snap_set3');
106     %v4_diff_snapshots(dirModel,dirMat,'budg3d_snap_set1');
107     budget_list=1;
108     for kk=1:length(mygrid.RC);
109     tmp1=sprintf('%s/diags/BUDG/budg2d_snap_set3_%02i*',dirModel,kk);
110     tmp2=~isempty(dir(tmp1));
111     if tmp2;
112     budget_list=[budget_list kk];
113     tmp1=sprintf('budg2d_snap_set3_%02i',kk);
114     v4_diff_snapshots(dirModel,dirMat,tmp1);
115     end;
116     end;
117     eval(['save ' dirMat 'diags_select_budget_list.mat budget_list;']);
118     eval(['!\rm ' dirMat 'lock_budg']);
119     test1=1;
120     fprintf(['pre-processing : completed for budget \n\n']);
121     end;
122    
123     while ~test1&doBudget;%this process will wait for pre-processing to complete
124     fprintf(['waiting 30s more for removal of ' dirMat 'lock_budg \n']);
125 gforget 1.2 fprintf(['- That should happen automatically after pre-processing is complete \n']);
126     fprintf(['- But if a previous session was interupted, you may need to stop this one, \n ']);
127     fprintf([' remove ' dirMat 'lock_budg manually, and start over. \n\n']);
128 gforget 1.1 test1=isempty(dir([dirMat 'lock_budg']));
129     pause(30);
130     end;
131    

  ViewVC Help
Powered by ViewVC 1.1.22