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

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

Checkmodelconsistency passes solution and analyses to the objects for further checks

File size: 6.5 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 %}}}
[9853]62 function checkconsistency(cluster,md,solution,analyses) % {{{1
[8586]63 if cluster.np<1
[9751]64 checkmessage(['number of processors should be at least 1']);
[8578]65 end
66 if isnan(cluster.np),
[9751]67 checkessage('number of processors should not be NaN!');
[8578]68 end
69 end
70 %}}}
71 function BuildQueueScript(cluster,md) % {{{1
72
73 %retrieve parameters
[9625]74 modelname=md.miscellaneous.name;
[9853]75 solution=md.private.solution;
[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 ',...
[9853]87 cluster.np,cluster.codepath,EnumToString(solution),cluster.executionpath,modelname);
[8578]88 else
[9561]89 fprintf(fid,'mpiexec -np %i %s/issm.exe %s %s %s 2> %s.errlog >%s.outlog ',...
[9853]90 cluster.np,cluster.codepath,EnumToString(solution),cluster.executionpath,modelname,modelname,modelname);
[8578]91 end
92 else
[9853]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),cluster.executionpath,modelname,modelname,modelname);
[9561]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 ',...
[9853]95 cluster.valgrindlib,cluster.np,cluster.valgrind,cluster.valgrindsup, cluster.codepath,EnumToString(solution),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
[9622]102 if ~md.settings.io_gather,
[8578]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
[9614]118 launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' md.private.runtimename ' && mkdir ' md.private.runtimename ...
[9625]119 ' && cd ' md.private.runtimename ' && mv ../' md.private.runtimename '.tar.gz ./ && tar -zxf ' md.private.runtimename '.tar.gz && source ' md.miscellaneous.name '.queue '];
[8578]120
121 if ~strcmpi(options.batch,'yes'),
122
123 %compress the files into one zip.
[9625]124 compressstring=['tar -zcf ' md.private.runtimename '.tar.gz ' md.miscellaneous.name '.bin ' md.miscellaneous.name '.queue ' md.miscellaneous.name '.petsc '];
[9650]125 if md.qmu.isdakota,
[9625]126 compressstring=[compressstring md.miscellaneous.name '.qmu.in'];
[8578]127 end
128 if cluster.interactive,
[9625]129 compressstring=[compressstring ' ' md.miscellaneous.name '.errlog ' md.miscellaneous.name '.outlog '];
[8578]130 end
131 system(compressstring);
132
133 disp('uploading input file and queueing script');
[9614]134 issmscpout(cluster.name,cluster.executionpath,cluster.login,cluster.port,{[md.private.runtimename '.tar.gz']});
[8578]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
[9614]147 if isempty(md.private.runtimename),
[8578]148 error('supply runtime name for results to be loaded!');
149 end
150
151 %Figure out the directory where all the files are in:
[9614]152 directory=[cluster.executionpath '/' md.private.runtimename '/'];
[8578]153
154 %What packages are we picking up from remote cluster
[9625]155 packages={[md.miscellaneous.name '.outlog'],[md.miscellaneous.name '.errlog']};
[9650]156 if md.qmu.isdakota,
[9625]157 packages{end+1}=[md.miscellaneous.name '.qmu.err'];
158 packages{end+1}=[md.miscellaneous.name '.qmu.out'];
[9650]159 if isfield(md.qmu.params,'tabular_graphics_data'),
160 if md.qmu.params.tabular_graphics_data==true,
[8578]161 packages{end+1}='dakota_tabular.dat';
162 end
163 end
164 else
[9625]165 packages{end+1}=[md.miscellaneous.name '.outbin'];
[8578]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.