source: issm/oecreview/Archive/26740-27031/ISSM-26850-26851.diff@ 27032

Last change on this file since 27032 was 27032, checked in by Mathieu Morlighem, 3 years ago

CHG: added 26740-27031

File size: 6.1 KB
RevLine 
[27032]1Index: ../trunk-jpl/src/m/classes/clusters/computecanada.m
2===================================================================
3--- ../trunk-jpl/src/m/classes/clusters/computecanada.m (nonexistent)
4+++ ../trunk-jpl/src/m/classes/clusters/computecanada.m (revision 26851)
5@@ -0,0 +1,133 @@
6+%COMPUTECANADA class definition
7+%
8+% Usage:
9+% cluster=computecanada();
10+% cluster=computecanada('np',3);
11+% cluster=computecanada('np',3,'login','username');
12+
13+classdef computecanada
14+ properties (SetAccess=public)
15+ % {{{
16+ name = ''
17+ login = '';
18+ numtasks = 1;
19+ cpuspertask = 8;
20+ port = 0;
21+ projectaccount = '';
22+ codepath = '';
23+ executionpath = '';
24+ time = 24*60;
25+ memory = 2;
26+ email = '';
27+ mailtype = '';
28+ end
29+ %}}}
30+ methods
31+ function cluster=computecanada(varargin) % {{{
32+
33+ %initialize cluster using default settings if provided
34+ if (exist('computecanada_settings')==2), computecanada_settings; end
35+
36+ %use provided options to change fields
37+ cluster=AssignObjectFields(pairoptions(varargin{:}),cluster);
38+ end
39+ %}}}
40+ function disp(cluster) % {{{
41+ % display the object
42+ disp(sprintf('class ''%s'' object ''%s'' = ',class(cluster),inputname(1)));
43+ disp(sprintf(' name: %s',cluster.name));
44+ disp(sprintf(' login: %s',cluster.login));
45+ disp(sprintf(' port: %i',cluster.port));
46+ disp(sprintf(' numtasks: %i',cluster.numtasks));
47+ disp(sprintf(' cpuspertask: %i',cluster.cpuspertask));
48+ disp(sprintf(' projectaccount: %s',cluster.projectaccount));
49+ disp(sprintf(' codepath: %s',cluster.codepath));
50+ disp(sprintf(' executionpath: %s',cluster.executionpath));
51+ disp(sprintf(' time: %i',cluster.time));
52+ disp(sprintf(' memory: %i',cluster.memory));
53+ disp(sprintf(' email: %s', cluster.email));
54+ disp(sprintf(' mailtype: %s', cluster.mailtype));
55+
56+ end
57+ %}}}
58+ function numprocs=np(cluster) % {{{
59+ %compute number of processors
60+ numprocs=cluster.numtasks*cluster.cpuspertask;
61+ end
62+ %}}}
63+ function md = checkconsistency(cluster,md,solution,analyses) % {{{
64+ if isempty(cluster.name), md = checkmessage(md,'name empty'); end
65+ if isempty(cluster.login), md = checkmessage(md,'login empty'); end
66+ if ~(cluster.numtasks > 0), md = checkmessage(md,'numtasks must be > 0'); end
67+ if ~(cluster.cpuspertask > 0), md = checkmessage(md,'cpuspertask must be > 0'); end
68+ if ~(cluster.port >= 0), md = checkmessage(md,'port must be >= 0'); end
69+ if isempty(cluster.projectaccount), md = checkmessage(md,'projectaccount empty'); end
70+ if isempty(cluster.codepath), md = checkmessage(md,'codepath empty'); end
71+ if isempty(cluster.executionpath), md = checkmessage(md,'executionpath empty'); end
72+ if ~(cluster.time > 0), md = checkmessage(md,'time must be > 0'); end
73+ if ~(cluster.memory > 0), md = checkmessage(md,'memory must be > 0'); end
74+ end
75+ %}}}
76+ function BuildKrigingQueueScript(cluster,dirname,modelname,solution,io_gather,isvalgrind,isgprof,isdakota,isoceancoupling) % {{{
77+ error('not implemented yet');
78+ end
79+ %}}}
80+ function BuildQueueScript(cluster,dirname,modelname,solution,io_gather,isvalgrind,isgprof,isdakota,isoceancoupling) % {{{
81+
82+ if(isvalgrind), disp('valgrind not supported by cluster, ignoring...'); end
83+ if(isgprof), disp('gprof not supported by cluster, ignoring...'); end
84+
85+ %write queuing script
86+ fid=fopen([modelname '.queue'],'w');
87+ fprintf(fid,'#!/bin/bash\n');
88+ fprintf(fid,'#SBATCH --job-name=%s\n',modelname);
89+ fprintf(fid,'#SBATCH --account=%s \n',cluster.projectaccount);
90+ fprintf(fid,'#SBATCH --ntasks=%i \n',cluster.numtasks);
91+ fprintf(fid,'#SBATCH --cpus-per-task=%i\n',cluster.cpuspertask);
92+ fprintf(fid,'#SBATCH --time=%i\n',cluster.time); %walltime is in minutes
93+ fprintf(fid,'#SBATCH --mem-per-cpu=%igb\n',cluster.memory); %memory in in gigabytes
94+ fprintf(fid,'#SBATCH --mail-user=%s\n',cluster.email); %email
95+ fprintf(fid,'#SBATCH --mail-type=%s',cluster.mailtype);
96+ fprintf(fid,'#SBATCH --output=%s.outlog \n',modelname);
97+ fprintf(fid,'#SBATCH --error=%s.errlog \n\n',modelname);
98+ fprintf(fid,'export ISSM_DIR="%s/../"\n',cluster.codepath); %FIXME
99+ fprintf(fid,'cd %s/%s\n\n',cluster.executionpath,dirname);
100+ fprintf(fid,'srun %s/issm.exe %s %s %s\n',cluster.codepath,solution,[cluster.executionpath '/' dirname],modelname);
101+ if ~io_gather, %concatenate the output files:
102+ fprintf(fid,'cat %s.outbin.* > %s.outbin',modelname,modelname);
103+ end
104+ fclose(fid);
105+ end %}}}
106+ function UploadQueueJob(cluster,modelname,dirname,filelist)% {{{
107+
108+ %compress the files into one zip.
109+ compressstring=['tar -zcf ' dirname '.tar.gz '];
110+ for i=1:numel(filelist),
111+ compressstring = [compressstring ' ' filelist{i}];
112+ end
113+ system(compressstring);
114+
115+ disp('uploading input file and queueing script');
116+ issmscpout(cluster.name,cluster.executionpath,cluster.login,cluster.port,{[dirname '.tar.gz']});
117+
118+ end %}}}
119+ function LaunchQueueJob(cluster,modelname,dirname,filelist,restart,batch)% {{{
120+
121+ disp('launching solution sequence on remote cluster');
122+ if ~isempty(restart)
123+ launchcommand=['cd ' cluster.executionpath ' && cd ' dirname ' && hostname && sbatch ' modelname '.queue '];
124+ else
125+ launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' dirname ' && mkdir ' dirname ...
126+ ' && cd ' dirname ' && mv ../' dirname '.tar.gz ./ && tar -zxf ' dirname '.tar.gz && hostname && sbatch ' modelname '.queue '];
127+ end
128+ issmssh(cluster.name,cluster.login,cluster.port,launchcommand);
129+ end %}}}
130+ function Download(cluster,dirname,filelist)% {{{
131+
132+ %copy files from cluster to current directory
133+ directory=[cluster.executionpath '/' dirname '/'];
134+ issmscpin(cluster.name,cluster.login,cluster.port,directory,filelist);
135+
136+ end %}}}
137+ end
138+end
Note: See TracBrowser for help on using the repository browser.