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

Last change on this file since 8587 was 8587, checked in by Mathieu Morlighem, 14 years ago

call properties('objectname') instead of properties(object) that calls the constructor

File size: 6.4 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;
76 mem_debug=md.mem_debug;
77
78 %open file for writing:
79 fid=fopen([modelname '.queue'],'w');
80
81 %write instructions for launching a job on the cluster
82 fprintf(fid,'#!/bin/sh\n');
83 if mem_debug==0,
84 if cluster.interactive
85 fprintf(fid,'mpiexec -np %i %s/issm.exe %s %s %s.bin %s.petsc %s.outbin %s.lock ',...
86 cluster.np,cluster.codepath,EnumToString(solution_type),cluster.executionpath,modelname,modelname,modelname,modelname);
87 else
88 fprintf(fid,'mpiexec -np %i %s/issm.exe %s %s %s.bin %s.petsc %s.outbin %s.lock 2> %s.errlog >%s.outlog ',...
89 cluster.np,cluster.codepath,EnumToString(solution_type),cluster.executionpath,modelname,modelname,modelname,modelname,modelname,modelname);
90 end
91 else
92 %fprintf(fid,'LD_PRELOAD=%s mpiexec -np %i %s --leak-check=full --gen-suppressions=all --suppressions=%s %s/issm.exe %s %s %s.bin %s.petsc %s.outbin %s.lock 2> %s.errlog >%s.outlog ',cluster.valgrindlib,cluster.np,cluster.valgrind,cluster.valgrindsup,cluster.codepath,EnumToString(solution_type),cluster.executionpath,modelname,modelname,modelname,modelname,modelname,modelname);
93 fprintf(fid,'LD_PRELOAD=%s mpiexec -np %i %s --leak-check=full --suppressions=%s %s/issm.exe %s %s %s.bin %s.petsc %s.outbin %s.lock 2> %s.errlog >%s.outlog ',...
94 cluster.valgrindlib,cluster.np,cluster.valgrind,cluster.valgrindsup, cluster.codepath,EnumToString(solution_type),cluster.executionpath,modelname,modelname,modelname,modelname,modelname,modelname);
95 end
96
97 if md.gprof,
98 fprintf(fid,'\n gprof %s/issm.exe gmon.out > %s.performance',cluster.codepath,modelname);
99 end
100
101 if ~md.io_gather,
102 %concatenate the output files:
103 fprintf(fid,'\ncat %s.outbin.* > %s.outbin',modelname,modelname);
104 end
105
106 %in interactive mode, create a run file, and errlog and outlog file
107 if cluster.interactive,
108 fid=fopen([modelname '.errlog'],'w'); fclose(fid);
109 fid=fopen([modelname '.outlog'],'w'); fclose(fid);
110 end
111
112 end
113 %}}}
114 function LaunchQueueJob(cluster,md,options)% {{{1
115
116 %lauch command, to be executed via ssh
117 launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' md.runtimename ' && mkdir ' md.runtimename ...
118 ' && cd ' md.runtimename ' && mv ../' md.runtimename '.tar.gz ./ && tar -zxf ' md.runtimename '.tar.gz && source ' md.name '.queue '];
119
120 if ~strcmpi(options.batch,'yes'),
121
122 %compress the files into one zip.
123 compressstring=['tar -zcf ' md.runtimename '.tar.gz ' md.name '.bin ' md.name '.queue ' md.name '.petsc '];
124 if md.qmu_analysis,
125 compressstring=[compressstring md.name '.qmu.in'];
126 end
127 if cluster.interactive,
128 compressstring=[compressstring ' ' md.name '.errlog ' md.name '.outlog '];
129 end
130 system(compressstring);
131
132 disp('uploading input file and queueing script');
133 issmscpout(cluster.name,cluster.executionpath,cluster.login,cluster.port,{[md.runtimename '.tar.gz']});
134
135 disp('launching solution sequence on remote cluster');
136 issmssh(cluster.name,cluster.login,cluster.port,launchcommand);
137 else
138 disp('batch mode requested: not launching job interactively');
139 disp('launch solution sequence on remote cluster by hand');
140 end
141
142 end %}}}
143 function Download(cluster,md)% {{{1
144
145 %some check
146 if isempty(md.runtimename),
147 error('supply runtime name for results to be loaded!');
148 end
149
150 %Figure out the directory where all the files are in:
151 directory=[cluster.executionpath '/' md.runtimename '/'];
152
153 %What packages are we picking up from remote cluster
154 packages={[md.name '.outlog'],[md.name '.errlog']};
155 if md.qmu_analysis,
156 packages{end+1}=[md.name '.qmu.err'];
157 packages{end+1}=[md.name '.qmu.out'];
158 if isfield(md.qmu_params,'tabular_graphics_data'),
159 if md.qmu_params.tabular_graphics_data==true,
160 packages{end+1}='dakota_tabular.dat';
161 end
162 end
163 else
164 packages{end+1}=[md.name '.outbin'];
165 end
166
167 %copy files from cluster to present directory
168 issmscpin(cluster.name, cluster.login, cluster.port, directory, packages);
169 end %}}}
170 end
171end
Note: See TracBrowser for help on using the repository browser.