source: issm/trunk/src/m/solve/solve.m@ 13975

Last change on this file since 13975 was 13975, checked in by Mathieu Morlighem, 12 years ago

merged trunk-jpl and trunk for revision 13974

File size: 3.4 KB
RevLine 
[8296]1function md=solve(md,solutionenum,varargin)
[1]2%SOLVE - apply solution sequence for this model
3%
4% Usage:
[8296]5% md=solve(md,solutionenum,varargin)
[3923]6% where varargin is a lit of paired arguments of string OR enums
[1]7%
[9218]8% solution types available comprise:
[9401]9% - DiagnosticSolutionEnum
10% - PrognosticSolutionEnum
11% - ThermalSolutionEnum
12% - SteadystateSolutionEnum
13% - TransientSolutionEnum...
14% - BalancethicknessSolutionEnum
15% - BedSlopeSolutionEnum
16% - SurfaceSlopeSolutionEnum
17% - HydrologySolutionEnum
18% - FlaimSolutionEnum
[8343]19%
[9428]20% extra options:
21% - loadonly : does not solve. only load results
22%
[1]23% Examples:
[8296]24% md=solve(md,DiagnosticSolutionEnum);
[1]25
[12351]26%recover and process solve options
[8296]27options=pairoptions(varargin{:},'solution_type',solutionenum);
[465]28options=process_solve_options(options);
[1]29
[465]30%recover some fields
[9614]31md.private.solution=options.solution_type;
[12363]32cluster=md.cluster;
[1]33
[2326]34%check model consistency
[6304]35disp('checking model consistency');
[13043]36if (solutionenum == FlaimSolutionEnum())
[12673]37 md.private.isconsistent=true;
38 md=checkconsistency(md.mesh,md,solutionenum);
39 md=checkconsistency(md.flaim,md,solutionenum);
40 if md.private.isconsistent==false,
41 error('Model not consistent, see messages above');
[9882]42 end
43else
44 ismodelselfconsistent(md),
45end
[132]46
[12363]47%First, build a runtime name that is unique
48c=clock;
49md.private.runtimename=sprintf('%s-%02i-%02i-%04i-%02i-%02i-%02i-%i',md.miscellaneous.name,c(2),c(3),c(1),c(4),c(5),floor(c(6)),feature('GetPid'));
50
[12351]51%if running qmu analysis, some preprocessing of dakota files using models
52%fields needs to be carried out.
[9650]53if md.qmu.isdakota,
[961]54 md=preqmu(md,options);
55end
[2540]56
[7686]57%flaim analysis
[13043]58if (options.solution_type == FlaimSolutionEnum())
[9882]59 md=flaim_sol(md,options);
[9614]60 md.private.solution=EnumToString(options.solution_type);
[7686]61 return;
62end
63
[12351]64%Do we load results only?
65if options.loadonly,
66 md=loadresultsfromcluster(md);
67 return;
68end
[8330]69
[12351]70%we need to make sure we have PETSC support, otherwise, we run with only one cpu:
[13043]71if ~ispetsc(),
[13383]72 disp('PETSc support not included, running on 1 cpu only!');
[12351]73 cluster.np=1;
[1]74end
[1030]75
[13043]76%Write all input files
[12988]77marshall(md); % bin file
78PetscFile(md.solver,[md.miscellaneous.name '.petsc']); % petsc file
79BuildQueueScript(cluster,md.private.runtimename,md.miscellaneous.name,md.private.solution,md.settings.io_gather,md.debug.valgrind,md.debug.gprof); % queue file
80
[12363]81%Stop here if batch mode
82if strcmpi(options.batch,'yes')
83 disp('batch mode requested: not launching job interactively');
84 disp('launch solution sequence on remote cluster by hand');
85 return;
86end
[1]87
[12363]88%Launch job
89modelname = md.miscellaneous.name;
90filelist = {[modelname '.bin '] [modelname '.petsc '] [modelname '.queue ']};
91if md.qmu.isdakota,
92 filelist{end+1} = [modelname '.qmu.in'];
93end
94LaunchQueueJob(cluster,md.miscellaneous.name,md.private.runtimename,filelist);
[12351]95
[12363]96%did we even try to run? if so, wait on lock
97if strcmpi(options.upload,'on'),
98 disp('solve done uploading test decks');
99 return;
100end
[12351]101
[12363]102%wait on lock
103if md.settings.waitonlock>0,
104 %we wait for the done file
105 islock=waitonlock(md);
106 if islock==0, %no results to be loaded
107 disp('The results must be loaded manually with md=loadresultsfromcluster(md).');
108 else %load results
109 disp('loading results from cluster');
110 md=loadresultsfromcluster(md);
[6569]111 end
[12363]112end
[12351]113
[12363]114%post processes qmu results if necessary
115if md.qmu.isdakota,
116 if ~strncmpi(options.keep,'y',1)
117 system(['rm -rf qmu' num2str(feature('GetPid'))]);
[12351]118 end
[961]119end
Note: See TracBrowser for help on using the repository browser.