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