source: issm/trunk/src/m/qmu/preqmu.m@ 5029

Last change on this file since 5029 was 5029, checked in by Eric.Larour, 15 years ago

Append PID number of qmu directory, for nightly runs.

File size: 3.6 KB
Line 
1function md=preqmu(md,options)
2%QMU - apply Quantification of Margins and Uncertainties techniques
3% to a solution sequence (like diagnostic.m, progonstic.m, etc ...),
4% using the Dakota software from Sandia.
5%
6% options come from the solve.m routine. They can include Dakota options:
7%
8% qmudir: any directory where to run the qmu analysis
9% qmufile: input file for Dakota
10% ivar: selection number for variables input (if several are specified in variables)
11% iresp: same thing for response functions
12% imethod: same thing for methods
13% iparams: same thing for params
14% overwrite: overwrite qmudir
15% outfiles: (John?)
16% rstfile: backup file name
17% rundakota: (John?)
18% runmpi: (John?)
19
20global ISSM_DIR;
21
22displaystring(md.verbose,'\n%s\n','preprocessing dakota inputs');
23
24%first create temporary directory in which we will work
25if strncmpi(options.overwrite,'y',1)
26 system(['rm -rf ' options.qmudir '/*']);
27else
28 %does the directory exist? if so, then error out
29 if exist(options.qmudir)==7,
30 error('Existing ''%s'' directory, cannot overwrite. Specify ''overwrite'',''y'' option in solve arguments.',options.qmudir);
31 end
32end
33mkdir(options.qmudir)
34cd(options.qmudir)
35
36%when running in library mode, the in file needs to be called md.name.qmu.in
37options.qmufile=[md.name ];
38
39%retrieve variables and resposnes for this particular analysis.
40variables=md.variables(options.ivar);
41responses=md.responses(options.iresp);
42
43%create m and in files for dakota
44dakota_in_data(md.qmu_method(options.imethod),variables,md.responses,md.qmu_params(options.iparams),options.qmufile,md);
45
46%in library mode, we only need the dakota in file
47system(['rm -rf ' md.name '.m']);
48
49%figure out number of variables and responses, it's not straightforwared
50numvariables=0;
51variable_fieldnames=fieldnames(variables);
52for i=1:length(variable_fieldnames),
53 field_name=variable_fieldnames{i};
54 fieldvariables=variables.(field_name);
55 numvariables=numvariables+numel(variables.(field_name));
56end
57
58numresponses=0;
59response_fieldnames=fieldnames(responses);
60for i=1:length(response_fieldnames),
61 field_name=response_fieldnames{i};
62 fieldresponses=responses.(field_name);
63 numresponses=numresponses+numel(responses.(field_name));
64end
65
66%ok, now, for this particular qmu analysis, iresp and ivar specifiy the variables and responses.
67%The Qmu module will need a list of variable descriptors and response descriptors.
68%For ease of use, we gather this list here.
69
70count=0;
71variable_fieldnames=fieldnames(variables);
72variabledescriptors={};
73for i=1:length(variable_fieldnames),
74 field_name=variable_fieldnames{i};
75 fieldvariables=variables.(field_name);
76 for j=1:length(fieldvariables),
77 descriptor=fieldvariables(j).descriptor;
78 variabledescriptors{end+1}=descriptor;
79 count=count+1;
80 end
81end
82
83count=0;
84response_fieldnames=fieldnames(responses);
85responsedescriptors={};
86for i=1:length(response_fieldnames),
87 field_name=response_fieldnames{i};
88 fieldresponses=responses.(field_name);
89 for j=1:length(fieldresponses),
90 descriptor=fieldresponses(j).descriptor;
91 responsedescriptors{end+1}=descriptor;
92 count=count+1;
93 end
94end
95
96%register the fields that will be needed by the Qmu model.
97md.numberofvariables=numvariables;
98md.numberofresponses=numresponses;
99md.variabledescriptors=variabledescriptors;
100md.responsedescriptors=responsedescriptors;
101
102%now, we have to provide all the info necessary for the solutions to compute the responses. For ex, if mass_flux
103%is a response, we need a profile of points. For a misfit, we need the observed velocity, etc ...
104md=process_qmu_response_data(md);
Note: See TracBrowser for help on using the repository browser.