Changeset 450
- Timestamp:
- 05/15/09 14:16:13 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/m/solutions/dakota/qmu.m
r356 r450 7 7 % qmudir =['qmu_' datestr(now,'yyyymmdd_HHMMSS')]; 8 8 qmudir ='qmu'; 9 % qmufile can not be changed unless cielo_ice_script.sh is 9 % qmufile can not be changed unless cielo_ice_script.sh is also changed 10 10 qmufile='qmu'; 11 11 ivar =1; … … 13 13 imethod=1; 14 14 iparams=1; 15 runmpi =false; 15 16 16 17 % process any extra input arguments … … 30 31 case 'iparams' 31 32 iparams=varargin{i+1}; 33 case 'overwrite' 34 overwrite=varargin{i+1}; 35 case 'outfiles' 36 outfiles =varargin{i+1}; 37 case 'rstfile' 38 rstfile =varargin{i+1}; 39 case 'rundakota' 40 rundakota=varargin{i+1}; 41 case 'runmpi' 42 runmpi =varargin{i+1}; 43 disp(sprintf('runmpi=%d',runmpi)); 32 44 end 33 45 end … … 35 47 %first create temporary directory in which we will work 36 48 if exist(qmudir,'dir') 37 overwrite=input(['Overwrite existing ''' qmudir ''' directory? Y/N [N]: '], 's'); 49 if ~exist('overwrite','var') 50 overwrite=input(['Overwrite existing ''' qmudir ''' directory? Y/N [N]: '], 's'); 51 end 38 52 if strncmpi(overwrite,'y',1) 39 53 system(['rm -rf ' qmudir]); 40 else41 error('Existing ''%s'' directory not overwritten.',qmudir);54 % else 55 % error('Existing ''%s'' directory not overwritten.',qmudir); 42 56 end 43 57 end … … 56 70 md.qmu_params(iparams).analysis_driver=[ISSM_DIR '/src/m/solutions/dakota/cielo_ice_script.sh']; 57 71 end 72 dakota_in_data(md.qmu_method(imethod),md.variables(ivar),md.responses(iresp),md.qmu_params(iparams),qmufile,package,md); 58 73 59 dakota_in_data(md.qmu_method(imethod),md.variables(ivar),md.responses(iresp),md.qmu_params(iparams),qmufile,package,md); 60 rundak=input(['Run Dakota analysis ''' qmufile '''? Y/N [N]: '], 's'); 61 if ~strncmpi(rundak,'y',1) 74 % check for existence of results.out files to use 75 if exist('results.out.1','file') || exist('results.out.zip','file') 76 if ~exist('outfiles','var') 77 outfiles=input(['Use existing ''results.out'' files? Y/N [N]: '], 's'); 78 end 79 if ~strncmpi(outfiles,'y',1) 80 system('rm -f results.out.[1-9]*'); 81 else 82 if exist('results.out.zip','file') && ~exist('results.out.1','file') 83 display('Inflating ''results.out.zip'' file.'); 84 system('unzip -q results.out.zip'); 85 end 86 end 87 end 88 89 % check for existence of dakota.rst file to use 90 rstflag=''; 91 if (~exist('outfiles','var') || ~strncmpi(outfiles,'y',1)) && ... 92 exist('dakota.rst','file') 93 if ~exist('rstfile','var') 94 rstfiles=input(['Use existing ''dakota.rst'' file? Y/N [N]: '], 's'); 95 end 96 if strncmpi(rstfiles,'y',1) 97 system('rm -f results.out.[1-9]*'); 98 system('dakota_restart_util print dakota.rst | grep completed'); 99 rstflag=' -read_restart dakota.rst'; 100 end 101 end 102 103 %call dakota 104 if ~exist('rundakota','var') 105 rundakota=input(['Run Dakota analysis ''' qmufile '''? Y/N [N]: '], 's'); 106 end 107 if ~strncmpi(rundakota,'y',1) 62 108 cd .. 63 109 return 64 110 end 65 111 66 %call dakota 67 system(['dakota -i ' qmufile '.in -o ' qmufile '.out -e ' qmufile '.err']); 68 % system(['export MPIRUN_NPROCS=8;mpirun -np 4 dakota -i ' qmufile '.in -o ' qmufile '.out -e ' qmufile '.err']); 112 if ~runmpi 113 system(['dakota -i ' qmufile '.in -o ' qmufile '.out -e ' qmufile '.err' rstflag]); 114 else 115 % use 'mpd --ncpus=8 &' to initialize mpi and 'mpdringtest' to verify. 116 % exporting MPIRUN_NPROCS sets mpi in dakota. 117 % system('mpd --ncpus=8 &'); 118 % system('mpdringtest'); 119 system(['export MPIRUN_NPROCS=8;mpirun -np 4 dakota -i ' qmufile '.in -o ' qmufile '.out -e ' qmufile '.err' rstflag]); 120 end 121 122 % check to see if dakota returned errors in the err file 123 fide=fopen([qmufile '.err'],'r'); 124 fline=fgetl(fide); 125 if ischar(fline) 126 while ischar(fline) 127 disp(sprintf('%s',fline)); 128 fline=fgetl(fide); 129 end 130 status=fclose(fide); 131 cd ../ 132 error(['Dakota returned error in ''' qmufile '.err'' file. ''' qmudir ''' directory retained.']) 133 end 134 status=fclose(fide); 69 135 70 136 %parse inputs and results from dakota … … 93 159 %end 94 160 161 % move all the individual function evalutations into zip files 95 162 system('zip -mq params.in.zip params.in.[1-9]*'); 96 163 system('zip -mq results.out.zip results.out.[1-9]*');
Note:
See TracChangeset
for help on using the changeset viewer.