source: issm/trunk/src/m/classes/clusters/generic.m@ 9571

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

Simplified solutioncore calling structure. Took out control_core
from issm.m and issm.cpp.
New AnalysisConfiguration routine and new call to CorePointerFromSolutionEnum in issm.m and issm.cpp
Qmu could not be folded, had to put it back into issm.m and issm.cpp

Renamed Qmu to Dakota.

File size: 6.2 KB
RevLine 
[8586]1%GENERIC cluster class definition
[8578]2%
3% Usage:
[8586]4% cluster=generic('name','astrid',);
5% cluster=generic('name','astrid','np',3);
6% cluster=generic('name',oshostname(),'np',3,'login','username');
[8578]7
8classdef generic
9 properties (SetAccess=public)
10 % {{{1
[8586]11 name='';
[8578]12 login='';
[8586]13 np=1;
[8578]14 port=0;
15 interactive=1;
16 codepath=[issmtier() '/bin'];
17 executionpath=[issmdir() '/execution'];
18 valgrind=[issmtier() '/externalpackages/valgrind/install/bin/valgrind'];
19 valgrindlib=[issmtier() '/externalpackages/valgrind/install/lib/libmpidebug.so'];
20 valgrindsup=[issmtier() '/externalpackages/valgrind/issm.supp'];
21 %}}}
22 end
23 methods
24 function cluster=generic(varargin) % {{{1
[8586]25
26 %use provided options to change fields
27 options=pairoptions(varargin{:});
28
29 %get name
30 if ~exist(options,'name'), error('option ''name'' has not been provided'); end
31 cluster.name=getfieldvalue(options,'name');
32
[8578]33 %initialize cluster using user settings if provided
[8583]34 if (exist([cluster.name '_settings'])==2), eval([cluster.name '_settings']); end
[8578]35
[8586]36 %OK get other fields
[8578]37 for i=1:size(options.list,1),
38 fieldname=options.list{i,1};
39 fieldvalue=options.list{i,2};
[8587]40 if ismember(fieldname,properties('generic')),
[8578]41 cluster.(fieldname)=fieldvalue;
42 else
43 disp(['''' fieldname ''' is not a property of cluster generic']);
44 end
45 end
46 end
47 %}}}
48 function disp(cluster) % {{{1
49 % display the object
50 disp(sprintf('class ''%s'' object ''%s'' = ',class(cluster),inputname(1)));
51 disp(sprintf(' name: %s',cluster.name));
52 disp(sprintf(' login: %s',cluster.login));
53 disp(sprintf(' np: %i',cluster.np));
54 disp(sprintf(' port: %i',cluster.port));
55 disp(sprintf(' codepath: %s',cluster.codepath));
56 disp(sprintf(' executionpath: %s',cluster.executionpath));
57 disp(sprintf(' valgrind: %s',cluster.valgrind));
58 disp(sprintf(' valgrindlib: %s',cluster.valgrindlib));
59 disp(sprintf(' valgrindsup: %s',cluster.valgrindsup));
60 end
61 %}}}
62 function IsConsistent(cluster) % {{{1
[8586]63 if cluster.np<1
64 error(['number of processors should be at least 1']);
[8578]65 end
66 if isnan(cluster.np),
67 error('number of processors should not be NaN!');
68 end
69 end
70 %}}}
71 function BuildQueueScript(cluster,md) % {{{1
72
73 %retrieve parameters
74 modelname=md.name;
75 solution_type=md.solution_type;
[9565]76 isvalgrind=md.debug.valgrind;
77 isgprof=md.debug.gprof;
[8578]78
79 %open file for writing:
80 fid=fopen([modelname '.queue'],'w');
81
82 %write instructions for launching a job on the cluster
83 fprintf(fid,'#!/bin/sh\n');
[9565]84 if ~isvalgrind,
[8578]85 if cluster.interactive
[9561]86 fprintf(fid,'mpiexec -np %i %s/issm.exe %s %s %s ',...
87 cluster.np,cluster.codepath,EnumToString(solution_type),cluster.executionpath,modelname);
[8578]88 else
[9561]89 fprintf(fid,'mpiexec -np %i %s/issm.exe %s %s %s 2> %s.errlog >%s.outlog ',...
90 cluster.np,cluster.codepath,EnumToString(solution_type),cluster.executionpath,modelname,modelname,modelname);
[8578]91 end
92 else
[9561]93 %fprintf(fid,'LD_PRELOAD=%s mpiexec -np %i %s --leak-check=full --gen-suppressions=all --suppressions=%s %s/issm.exe %s %s %s 2> %s.errlog >%s.outlog ',cluster.valgrindlib,cluster.np,cluster.valgrind,cluster.valgrindsup,cluster.codepath,EnumToString(solution_type),cluster.executionpath,modelname,modelname,modelname);
94 fprintf(fid,'LD_PRELOAD=%s mpiexec -np %i %s --leak-check=full --suppressions=%s %s/issm.exe %s %s %s 2> %s.errlog >%s.outlog ',...
95 cluster.valgrindlib,cluster.np,cluster.valgrind,cluster.valgrindsup, cluster.codepath,EnumToString(solution_type),cluster.executionpath,modelname,modelname,modelname);
[8578]96 end
97
[9565]98 if isgprof,
[8578]99 fprintf(fid,'\n gprof %s/issm.exe gmon.out > %s.performance',cluster.codepath,modelname);
100 end
101
102 if ~md.io_gather,
103 %concatenate the output files:
104 fprintf(fid,'\ncat %s.outbin.* > %s.outbin',modelname,modelname);
105 end
106
107 %in interactive mode, create a run file, and errlog and outlog file
108 if cluster.interactive,
109 fid=fopen([modelname '.errlog'],'w'); fclose(fid);
110 fid=fopen([modelname '.outlog'],'w'); fclose(fid);
111 end
112
113 end
114 %}}}
115 function LaunchQueueJob(cluster,md,options)% {{{1
116
117 %lauch command, to be executed via ssh
118 launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' md.runtimename ' && mkdir ' md.runtimename ...
119 ' && cd ' md.runtimename ' && mv ../' md.runtimename '.tar.gz ./ && tar -zxf ' md.runtimename '.tar.gz && source ' md.name '.queue '];
120
121 if ~strcmpi(options.batch,'yes'),
122
123 %compress the files into one zip.
124 compressstring=['tar -zcf ' md.runtimename '.tar.gz ' md.name '.bin ' md.name '.queue ' md.name '.petsc '];
[9571]125 if md.dakota_analysis,
[8578]126 compressstring=[compressstring md.name '.qmu.in'];
127 end
128 if cluster.interactive,
129 compressstring=[compressstring ' ' md.name '.errlog ' md.name '.outlog '];
130 end
131 system(compressstring);
132
133 disp('uploading input file and queueing script');
134 issmscpout(cluster.name,cluster.executionpath,cluster.login,cluster.port,{[md.runtimename '.tar.gz']});
135
136 disp('launching solution sequence on remote cluster');
137 issmssh(cluster.name,cluster.login,cluster.port,launchcommand);
138 else
139 disp('batch mode requested: not launching job interactively');
140 disp('launch solution sequence on remote cluster by hand');
141 end
142
143 end %}}}
144 function Download(cluster,md)% {{{1
145
146 %some check
147 if isempty(md.runtimename),
148 error('supply runtime name for results to be loaded!');
149 end
150
151 %Figure out the directory where all the files are in:
152 directory=[cluster.executionpath '/' md.runtimename '/'];
153
154 %What packages are we picking up from remote cluster
155 packages={[md.name '.outlog'],[md.name '.errlog']};
[9571]156 if md.dakota_analysis,
[8578]157 packages{end+1}=[md.name '.qmu.err'];
158 packages{end+1}=[md.name '.qmu.out'];
159 if isfield(md.qmu_params,'tabular_graphics_data'),
160 if md.qmu_params.tabular_graphics_data==true,
161 packages{end+1}='dakota_tabular.dat';
162 end
163 end
164 else
165 packages{end+1}=[md.name '.outbin'];
166 end
167
168 %copy files from cluster to present directory
169 issmscpin(cluster.name, cluster.login, cluster.port, directory, packages);
170 end %}}}
171 end
172end
Note: See TracBrowser for help on using the repository browser.