Changeset 780
- Timestamp:
- 06/04/09 16:36:32 (16 years ago)
- Location:
- issm/trunk/src/m/solutions/dakota
- Files:
-
- 1 added
- 1 edited
- 3 copied
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/m/solutions/dakota/process_qmu_options.m
r762 r780 1 function outoptions=process_ solve_options(options)2 % DEFAULT_SOLVE_OPTIONS - set up default options for solvephase1 function outoptions=process_qmu_options(options) 2 %PROCESS_QMU_OPTIONS - set up default options for qmu phase 3 3 % 4 4 % Usage: 5 % options=process_ solve_options(options)5 % options=process_qmu_options(options) 6 6 % 7 % See also: SOLVE,RECOVER_SOLVE_OPTIONS7 % See also: QMU,RECOVER_QMU_OPTIONS 8 8 9 9 %analysis_type: check on this option, error out otherwise … … 16 16 end 17 17 if ~found, 18 error('recover_ solve_options error message: no ''analysis_type'' was provided');18 error('recover_qmu_options error message: no ''analysis_type'' was provided'); 19 19 end 20 20 21 %package: is there one? checkto ''cielo''21 %package: is there one? default to ''cielo'' 22 22 found=0; 23 23 for i=1:size(options,1), … … 28 28 end 29 29 if ~found, 30 disp('recover_ solve_options info message: no ''package'' was provided, defaulting to ''cielo''');30 disp('recover_qmu_options info message: no ''package'' was provided, defaulting to ''cielo'''); 31 31 options(end+1,:)={'package' 'cielo'}; 32 32 package='cielo'; … … 34 34 35 35 if ~ischar(package), 36 error(['process_ solve_options error message: package ' package ' not supported yet']);36 error(['process_qmu_options error message: package ' package ' not supported yet']); 37 37 end 38 38 … … 49 49 sub_analysis_type='none'; 50 50 else 51 disp('recover_ solve_options info message: no ''sub_analysis_type'' was provided, defaulting to ''steady''');51 disp('recover_qmu_options info message: no ''sub_analysis_type'' was provided, defaulting to ''steady'''); 52 52 sub_analysis_type='steady'; 53 53 end … … 63 63 strcmpi(analysis_type,'mesh2grid') | ... 64 64 strcmpi(analysis_type,'transient') ), 65 error(['process_ solve_options error message: analysis_type ' analysis_type ' not supported yet!']);65 error(['process_qmu_options error message: analysis_type ' analysis_type ' not supported yet!']); 66 66 end 67 67 if ~(strcmpi(sub_analysis_type,'none') | ... … … 71 71 strcmpi(sub_analysis_type,'') | ... 72 72 strcmpi(sub_analysis_type,'transient') ), 73 error(['process_ solve_options error message: sub_analysis_type ' sub_analysis_type ' not supported yet!']);73 error(['process_qmu_options error message: sub_analysis_type ' sub_analysis_type ' not supported yet!']); 74 74 end 75 75 if ~(strcmpi(package,'cielo') | ... 76 76 strcmpi(package,'ice') | ... 77 77 strcmpi(package,'macayeal') ), 78 error(['process_solve_options error message: package ' package ' not supported yet!']); 78 error(['process_qmu_options error message: package ' package ' not supported yet!']); 79 end 80 81 82 83 84 % process qmu arguments 85 86 %first, the defaults 87 qmudir ='qmu';% qmudir =['qmu_' datestr(now,'yyyymmdd_HHMMSS')]; 88 qmufile='qmu';% qmufile can not be changed unless cielo_ice_script.sh is also changed 89 ivar =1; 90 iresp =1; 91 imethod=1; 92 iparams=1; 93 runmpi =false; 94 95 for i=1:size(options,1), 96 switch options{i,1}, 97 case 'qmudir' 98 qmudir=options{i,2}; 99 case 'qmufile' 100 qmufile=options{i,2}; 101 case 'ivar' 102 ivar=options{i,2}; 103 case 'iresp' 104 iresp=options{i,2}; 105 case 'imethod' 106 imethod=options{i,2}; 107 case 'iparams' 108 iparams=options{i,2}; 109 case 'overwrite' 110 outoptions.overwrite=options{i,2}; 111 case 'outfiles' 112 outoptions.outfiles=options{i,2}; 113 case 'rstfile' 114 outoptions.rstfile=options{i,2}; 115 case 'rundakota' 116 outoptions.rundakota=options{i,2}; 117 case 'runmpi' 118 runmpi=options{i,2}; 119 otherwise 120 %nothing 121 end 79 122 end 80 123 … … 83 126 outoptions.package=package; 84 127 outoptions.sub_analysis_type=sub_analysis_type; 128 outoptions.qmudir=qmudir; 129 outoptions.qmufile=qmufile; 130 outoptions.ivar=ivar; 131 outoptions.iresp=iresp; 132 outoptions.imethod=imethod; 133 outoptions.iparams=iparams; 134 outoptions.runmpi=runmpi; 135 -
issm/trunk/src/m/solutions/dakota/qmu.m
r672 r780 37 37 38 38 %recover options 39 options=recover_ solve_options(md,varargin{:});39 options=recover_qmu_options(md,varargin{:}); 40 40 41 41 %add default options 42 options=process_ solve_options(options);42 options=process_qmu_options(options); 43 43 44 44 %recover some fields … … 56 56 displaystring(md.debug,'\n%s\n','launching solution sequence'); 57 57 58 %Ok, are we running serially or in parallel? 59 if ~strcmpi(md.cluster,'none'), 60 %ok, we are running parallel. 61 md=qmuparallel(md,varargin{:}); 58 59 %first create temporary directory in which we will work 60 if exist(options.qmudir,'dir') 61 if ~isfield(options,'overwrite') 62 options.overwrite=input(['Overwrite existing ''' options.qmudir ''' directory? Y/N [N]: '], 's'); 63 end 64 if strncmpi(options.overwrite,'y',1) 65 system(['rm -rf ' options.qmudir]); 66 % else 67 % error('Existing ''%s'' directory not overwritten.',qmudir); 68 end 69 end 70 mkdir(options.qmudir) 71 cd(options.qmudir) 72 73 %some data needs to be copied in qmudir when not running in library mode 74 if ~md.dakotaplugin, 75 system('cp $ISSM_DIR/startup.m .'); 76 77 %save our model in qmu so that it can be repeatedly used by Dakota. 78 save('Qmu.model','md') 79 end 80 81 %when running in library mode, the in file needs to be called md.name.qmu.in 82 if md.dakotaplugin, 83 options.qmufile=[md.name ]; 84 end 85 86 %create m and in files for dakota 87 if (~isfield(md.qmu_params(options.iparams),'direct') || ... 88 ~md.qmu_params(options.iparams).direct) && ... 89 (~isfield(md.qmu_params(options.iparams),'analysis_driver') || ... 90 isempty(md.qmu_params(options.iparams).analysis_driver)) 91 md.qmu_params(options.iparams).analysis_driver=[ISSM_DIR '/src/m/solutions/dakota/cielo_ice_script.sh']; 92 end 93 94 %create m and in files for dakota 95 dakota_in_data(md.qmu_method(options.imethod),md.variables(options.ivar),md.responses(options.iresp),md.qmu_params(options.iparams),options.qmufile,package,md); 96 97 98 %in library mode, we only need the dakota in file 99 if md.dakotaplugin, 100 system(['rm -rf ' md.name '.m']); 101 end 102 103 %Dakota can be run in library mode in parallel, or using the 104 %standard Dakota (scripted or direct) interface. Those two 105 %modes of running are very different, and call for different 106 %solution sequences. We branch here. 107 108 if md.dakotaplugin, 109 110 %Check we are running in parallel. 111 if strcmpi(md.cluster,'none'), 112 error('qmu error message: cannot run in library mode serially! set dakotaplugin to 0'); 113 end 114 115 %Get cluster.rc location 116 cluster_rc_location=which('cluster.rc'); 117 118 %let solution sequences know that we are running in qmu mode 119 md.qmu_analysis=1; 120 121 %Figure out parameters for this particular cluster 122 [codepath,executionpath]=ClusterParameters(md.cluster,cluster_rc_location); 123 124 %Marshall model data into a binary file. 125 marshall(md); 126 127 %add qmu fields to binary file 128 qmumarshall(md,md.variables(options.ivar),md.responses(options.iresp)); 129 130 %Now, we need to build the queuing script, used by the cluster to launch the job. 131 BuildQueueingScript(md,executionpath,codepath); 132 133 %Now, launch the queueing script 134 LaunchQueueJob(md,executionpath); 135 136 %Do we return, or just wait for results? 137 if md.waitonlock, 138 %we wait for the done file 139 waitonlock([executionpath '/' md.name '.lock']); 140 %load results 141 md=loadresultsfromcluster(md); 142 else 143 return; 144 end 145 62 146 else 63 %we are running serially. 64 md=qmuserial(md,varargin{:}); 65 end 147 % check for existence of results.out files to use 148 if exist('results.out.1','file') || exist('results.out.zip','file') 149 if ~isfield(options,'outfiles') 150 options.outfiles=input(['Use existing ''results.out'' files? Y/N [N]: '], 's'); 151 end 152 if ~strncmpi(options.outfiles,'y',1) 153 system('rm -f results.out.[1-9]*'); 154 else 155 if exist('results.out.zip','file') && ~exist('results.out.1','file') 156 display('Inflating ''results.out.zip'' file.'); 157 system('unzip -q results.out.zip'); 158 end 159 end 160 end 161 162 % check for existence of dakota.rst file to use 163 rstflag=''; 164 if (~isfield(options,'outfiles') || ~strncmpi(options.outfiles,'y',1)) && ... 165 exist('dakota.rst','file') 166 if ~isfield(options,'rstfile') 167 options.rstfiles=input(['Use existing ''dakota.rst'' file? Y/N [N]: '], 's'); 168 end 169 if strncmpi(options.rstfiles,'y',1) 170 system('rm -f results.out.[1-9]*'); 171 system('dakota_restart_util print dakota.rst | grep completed'); 172 rstflag=' -read_restart dakota.rst'; 173 end 174 end 175 176 %call dakota 177 if ~isfield(options,'rundakota') 178 options.rundakota=input(['Run Dakota analysis ''' qmufile '''? Y/N [N]: '], 's'); 179 end 180 if ~strncmpi(options.rundakota,'y',1) 181 cd .. 182 return 183 end 184 185 if ~options.runmpi 186 system(['dakota -i ' qmufile '.in -o ' qmufile '.out -e ' qmufile '.err' rstflag]); 187 else 188 % use 'mpd --ncpus=8 &' to initialize mpi and 'mpdringtest' to verify. 189 % exporting MPIRUN_NPROCS sets mpi in dakota. 190 % system('mpd --ncpus=8 &'); 191 % system('mpdringtest'); 192 system(['export MPIRUN_NPROCS=8;mpirun -np 4 dakota -i ' qmufile '.in -o ' qmufile '.out -e ' qmufile '.err' rstflag]); 193 end 194 195 end 196 197 198 199 %Now load the results from dakota output files. 200 qmuoutput(md,options.qmufile,options.qmudir); 201 202 %Get out of qmu directory 203 cd .. 204 -
issm/trunk/src/m/solutions/dakota/qmuserial.m
r586 r780 14 14 iparams=1; 15 15 runmpi =false; 16 16 17 17 18 % process any extra input arguments -
issm/trunk/src/m/solutions/dakota/recover_qmu_options.m
r672 r780 1 function options=recover_ solve_options(md,varargin)2 %RECOVER_SOLVE_OPTIONS - recover solution options 1 function options=recover_qmu_options(md,varargin) 2 %RECOVER_SOLVE_OPTIONS - recover solution options for qmu runs. 3 3 % 4 4 % Usage: 5 % options=recover_ solve_options(md,varargin);5 % options=recover_qmu_options(md,varargin); 6 6 % 7 7 % See also: SOLVE … … 12 12 %make sure length(varargin) is even, ie options come in pairs. 13 13 if mod(length(varargin),2), 14 error('recover_ solve_options error message: an even number of options is necessary');14 error('recover_qmu_options error message: an even number of options is necessary'); 15 15 end 16 16
Note:
See TracChangeset
for help on using the changeset viewer.