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

Last change on this file since 12706 was 12706, checked in by Mathieu Morlighem, 13 years ago

merged trunk-jpl and trunk for revision 12703

File size: 7.0 KB
Line 
1%GENERIC cluster class definition
2%
3% Usage:
4% cluster=generic('name','astrid','np',3);
5% cluster=generic('name',oshostname(),'np',3,'login','username');
6
7classdef generic
8 properties (SetAccess=public)
9 % {{{
10 name='';
11 login='';
12 np=1;
13 port=0;
14 interactive=1;
15 codepath=[issmdir() '/bin'];
16 executionpath=[issmdir() '/execution'];
17 valgrind=[issmdir() '/externalpackages/valgrind/install/bin/valgrind'];
18 valgrindlib=[issmdir() '/externalpackages/valgrind/install/lib/libmpidebug.so'];
19 valgrindsup=[issmdir() '/externalpackages/valgrind/issm.supp'];
20 %}}}
21 end
22 methods
23 function cluster=generic(varargin) % {{{
24
25 %use provided options to change fields
26 options=pairoptions(varargin{:});
27
28 %get name
29 cluster.name=getfieldvalue(options,'name',oshostname());
30
31 %initialize cluster using user settings if provided
32 if (exist([cluster.name '_settings'])==2), eval([cluster.name '_settings']); end
33
34 %OK get other fields
35 cluster=AssignObjectFields(pairoptions(varargin{:}),cluster);
36 end
37 %}}}
38 function disp(cluster) % {{{
39 % display the object
40 disp(sprintf('class ''%s'' object ''%s'' = ',class(cluster),inputname(1)));
41 disp(sprintf(' name: %s',cluster.name));
42 disp(sprintf(' login: %s',cluster.login));
43 disp(sprintf(' np: %i',cluster.np));
44 disp(sprintf(' port: %i',cluster.port));
45 disp(sprintf(' codepath: %s',cluster.codepath));
46 disp(sprintf(' executionpath: %s',cluster.executionpath));
47 disp(sprintf(' valgrind: %s',cluster.valgrind));
48 disp(sprintf(' valgrindlib: %s',cluster.valgrindlib));
49 disp(sprintf(' valgrindsup: %s',cluster.valgrindsup));
50 end
51 %}}}
52 function md = checkconsistency(cluster,md,solution,analyses) % {{{
53 if cluster.np<1
54 md = checkmessage(md,['number of processors should be at least 1']);
55 end
56 if isnan(cluster.np),
57 checkessage('number of processors should not be NaN!');
58 end
59 end
60 %}}}
61 function BuildQueueScript(cluster,modelname,solution,io_gather,isvalgrind,isgprof) % {{{
62
63 %write queuing script
64 if ~ispc,
65
66 fid=fopen([modelname '.queue'],'w');
67 fprintf(fid,'#!/bin/sh\n');
68 if ~isvalgrind,
69 if cluster.interactive
70 fprintf(fid,'mpiexec -np %i %s/issm.exe %s %s %s ',cluster.np,cluster.codepath,EnumToString(solution),cluster.executionpath,modelname);
71 else
72 fprintf(fid,'mpiexec -np %i %s/issm.exe %s %s %s 2> %s.errlog >%s.outlog ',cluster.np,cluster.codepath,EnumToString(solution),cluster.executionpath,modelname,modelname,modelname);
73 end
74 elseif isgprof,
75 fprintf(fid,'\n gprof %s/issm.exe gmon.out > %s.performance',cluster.codepath,modelname);
76 else
77 %Add --gen-suppressions=all to get suppression lines
78 fprintf(fid,'LD_PRELOAD=%s \\\n',cluster.valgrindlib);
79 fprintf(fid,'mpiexec -np %i %s --leak-check=full --suppressions=%s %s/issm.exe %s %s %s 2> %s.errlog >%s.outlog ',...
80 cluster.np,cluster.valgrind,cluster.valgrindsup,cluster.codepath,EnumToString(solution),cluster.executionpath,modelname,modelname,modelname);
81 end
82 if ~io_gather, %concatenate the output files:
83 fprintf(fid,'\ncat %s.outbin.* > %s.outbin',modelname,modelname);
84 end
85 fclose(fid);
86
87 else % Windows
88
89 fid=fopen([modelname '.bat'],'w');
90 fprintf(fid,'@echo off\n');
91 if cluster.interactive
92 fprintf(fid,'"%s/issm.exe" %s "%s" %s ',cluster.codepath,EnumToString(solution),cluster.executionpath,modelname);
93 else
94 fprintf(fid,'"%s/issm.exe" %s "%s" %s 2> %s.errlog >%s.outlog',...
95 cluster.codepath,EnumToString(solution),cluster.executionpath,modelname,modelname,modelname);
96 end
97 fclose(fid);
98 end
99
100 %in interactive mode, create a run file, and errlog and outlog file
101 if cluster.interactive,
102 fid=fopen([modelname '.errlog'],'w'); fclose(fid);
103 fid=fopen([modelname '.outlog'],'w'); fclose(fid);
104 end
105 end
106 %}}}
107 function BuildKrigingQueueScript(cluster,modelname,solution,io_gather,isvalgrind,isgprof) % {{{
108
109 %write queuing script
110 if ~ispc,
111
112 fid=fopen([modelname '.queue'],'w');
113 fprintf(fid,'#!/bin/sh\n');
114 if ~isvalgrind,
115 if cluster.interactive
116 fprintf(fid,'mpiexec -np %i %s/kriging.exe %s %s ',cluster.np,cluster.codepath,cluster.executionpath,modelname);
117 else
118 fprintf(fid,'mpiexec -np %i %s/kriging.exe %s %s 2> %s.errlog >%s.outlog ',cluster.np,cluster.codepath,cluster.executionpath,modelname,modelname,modelname);
119 end
120 elseif isgprof,
121 fprintf(fid,'\n gprof %s/kriging.exe gmon.out > %s.performance',cluster.codepath,modelname);
122 else
123 %Add --gen-suppressions=all to get suppression lines
124 fprintf(fid,'LD_PRELOAD=%s \\\n',cluster.valgrindlib);
125 fprintf(fid,'mpiexec -np %i %s --leak-check=full --suppressions=%s %s/kriging.exe %s %s 2> %s.errlog >%s.outlog ',...
126 cluster.np,cluster.valgrind,cluster.valgrindsup,cluster.codepath,cluster.executionpath,modelname,modelname,modelname);
127 end
128 if ~io_gather, %concatenate the output files:
129 fprintf(fid,'\ncat %s.outbin.* > %s.outbin',modelname,modelname);
130 end
131 fclose(fid);
132
133 else % Windows
134
135 fid=fopen([modelname '.bat'],'w');
136 fprintf(fid,'@echo off\n');
137 if cluster.interactive
138 fprintf(fid,'"%s/issm.exe" %s "%s" %s ',cluster.codepath,EnumToString(solution),cluster.executionpath,modelname);
139 else
140 fprintf(fid,'"%s/issm.exe" %s "%s" %s 2> %s.errlog >%s.outlog',...
141 cluster.codepath,EnumToString(solution),cluster.executionpath,modelname,modelname,modelname);
142 end
143 fclose(fid);
144 end
145
146 %in interactive mode, create a run file, and errlog and outlog file
147 if cluster.interactive,
148 fid=fopen([modelname '.errlog'],'w'); fclose(fid);
149 fid=fopen([modelname '.outlog'],'w'); fclose(fid);
150 end
151 end
152 %}}}
153 function LaunchQueueJob(cluster,modelname,dirname,filelist)% {{{
154
155 %compress the files into one zip.
156 compressstring=['tar -zcf ' dirname '.tar.gz '];
157 for i=1:numel(filelist),
158 compressstring = [compressstring ' ' filelist{i}];
159 end
160 if cluster.interactive,
161 compressstring = [compressstring ' ' modelname '.errlog ' modelname '.outlog '];
162 end
163 system(compressstring);
164
165 disp('uploading input file and queueing script');
166 issmscpout(cluster.name,cluster.executionpath,cluster.login,cluster.port,{[dirname '.tar.gz']});
167
168 disp('launching solution sequence on remote cluster');
169 launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' dirname ' && mkdir ' dirname ...
170 ' && cd ' dirname ' && mv ../' dirname '.tar.gz ./ && tar -zxf ' dirname '.tar.gz && source ' modelname '.queue '];
171 issmssh(cluster.name,cluster.login,cluster.port,launchcommand);
172 end %}}}
173 function Download(cluster,dirname,filelist)% {{{
174
175 if ispc,
176 %do nothing
177 return;
178 end
179
180 %copy files from cluster to current directory
181 directory=[cluster.executionpath '/' dirname '/'];
182 issmscpin(cluster.name,cluster.login,cluster.port,directory,filelist);
183 end %}}}
184 end
185end
Note: See TracBrowser for help on using the repository browser.