/[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.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 [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     fprintf(['that should happen automatically after pre-processing is complete \n\n']);
54     test1=isempty(dir([dirMat 'lock_mygrid']));
55     pause(30);
56     end;
57    
58     %here we always reload the grid from dirMat to make sure the same one is used throughout
59     eval(['load ' dirMat 'diags_grid_parms.mat;']);
60    
61     %2) pre-processing profiles
62     test0=isempty(dir([dirMat 'profiles/']));
63     test1=isempty(dir([dirMat 'lock_profiles']));
64    
65     if test0&test1&doProfiles;%this process will do the pre-processing
66     fprintf(['pre-processing : started for profiles \n']);
67     write2file([dirMat 'lock_profiles'],1);
68     eval(['!mkdir ' dirMat 'profiles/;']);
69     eval(['!ln -s /net/nares/raid11/ecco-shared/ecco-version-4/input/input_insitu ' dirMat 'profiles/input']);
70     eval(['!mkdir ' dirMat 'profiles/output']);
71     if dirModel(1)~='/'; dirModelFull=[pwd '/' dirModel]; else; dirModelFull=dirModel; end;
72     eval(['!ln -s ' dirModelFull 'profiles/*equi.data ' dirMat 'profiles/.']);
73     listModel={'argo_june2012_1992_to_2007**','argo_june2012_2008_to_2010*',...
74     'argo_june2012_2011_to_2012*','ctd_june2012*','itp_june2012*',...
75     'seals_june2012*','xbt_june2012*','climode_june2012*'};
76     MITprof_gcm2nc([dirMat 'profiles/'],listModel);
77     eval(['!\rm ' dirMat 'lock_profiles']);
78     test1=1;
79     fprintf(['pre-processing : completed for profiles \n\n']);
80     end;
81    
82     while ~test1&doProfiles;%this process will wait for pre-processing to complete
83     fprintf(['waiting 30s for removal of ' dirMat 'lock_profiles \n']);
84     fprintf(['that should happen automatically after pre-processing is complete \n\n']);
85     test1=isempty(dir([dirMat 'lock_profiles']));
86     pause(30);
87     end;
88    
89     %3) budget pre-processing
90     test0=isempty(dir([dirMat 'BUDG/']));
91     test1=isempty(dir([dirMat 'lock_budg']));%this aims at having only one process do the
92    
93     if (test0&test1&doBudget);
94     fprintf(['pre-processing : started for budget \n']);
95     write2file([dirMat 'lock_budg'],1);
96     eval(['!mkdir ' dirMat 'BUDG/;']);
97     %compute time derivatives between snwpshots that will be
98     %compared in budgets with the time mean flux terms
99     v4_diff_snapshots(dirModel,dirMat,'budg2d_snap_set1');
100     v4_diff_snapshots(dirModel,dirMat,'budg2d_snap_set2');
101     v4_diff_snapshots(dirModel,dirMat,'budg2d_snap_set3');
102     %v4_diff_snapshots(dirModel,dirMat,'budg3d_snap_set1');
103     budget_list=1;
104     for kk=1:length(mygrid.RC);
105     tmp1=sprintf('%s/diags/BUDG/budg2d_snap_set3_%02i*',dirModel,kk);
106     tmp2=~isempty(dir(tmp1));
107     if tmp2;
108     budget_list=[budget_list kk];
109     tmp1=sprintf('budg2d_snap_set3_%02i',kk);
110     v4_diff_snapshots(dirModel,dirMat,tmp1);
111     end;
112     end;
113     eval(['save ' dirMat 'diags_select_budget_list.mat budget_list;']);
114     eval(['!\rm ' dirMat 'lock_budg']);
115     test1=1;
116     fprintf(['pre-processing : completed for budget \n\n']);
117     end;
118    
119     while ~test1&doBudget;%this process will wait for pre-processing to complete
120     fprintf(['waiting 30s more for removal of ' dirMat 'lock_budg \n']);
121     fprintf(['- That should happen automatically after pre-processing is complete \n\n']);
122     fprintf(['- But if a previous session was interupted, you may need to stop this one, \n\n ']);
123     fprintf([' remove lock_budg manually, and start over. ']);
124     test1=isempty(dir([dirMat 'lock_budg']));
125     pause(30);
126     end;
127    

  ViewVC Help
Powered by ViewVC 1.1.22