source: issm/trunk-jpl/src/m/classes/clusters/castor.m@ 12372

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

double LaunchQueueJob

File size: 3.6 KB
Line 
1%CASTOR class definition
2%
3% Usage:
4% cluster=castor();
5% cluster=castor('np',3);
6% cluster=castor('np',3,'login','username');
7
8classdef castor
9 properties (SetAccess=public)
10 % {{{
11 name='castor'
12 login='username';
13 np =128;
14 port=0;
15 queue='shortc';
16 time=180;
17 codepath='/workp/edw/issm-2.0/bin'
18 executionpath='/workp/edw/Testing/Execution'
19 %}}}
20 end
21 methods
22 function cluster=castor(varargin) % {{{
23 cluster=AssignObjectFields(pairoptions(varargin{:}),cluster);
24 end
25 %}}}
26 function disp(cluster) % {{{
27 % display the object
28 disp(sprintf('class ''%s'' object ''%s'' = ',class(cluster),inputname(1)));
29 disp(sprintf(' name: %s',cluster.name));
30 disp(sprintf(' login: %s',cluster.login));
31 disp(sprintf(' np: %i',cluster.np));
32 disp(sprintf(' port: %i',cluster.port));
33 disp(sprintf(' queue: %s',cluster.queue));
34 disp(sprintf(' time: %i',cluster.time));
35 disp(sprintf(' codepath: %s',cluster.codepath));
36 disp(sprintf(' executionpath: %s',cluster.executionpath));
37 end
38 %}}}
39 function checkconsistency(cluster,md,solution,analyses) % {{{
40
41 available_queues={'shortc','longc'};
42 queue_requirements_time=[180 720];
43 queue_requirements_np=[128 128];
44
45 QueueRequirements(available_queues,queue_requirements_time,queue_requirements_np,cluster.queue,cluster.np,cluster.time)
46 end
47 %}}}
48 function BuildQueueScript(cluster,modelname,solution,io_gather,isvalgrind,isgprof) % {{{
49
50 if(isvalgrind), disp('valgrind not supported by cluster, ignoring...'); end
51 if(isgprof), disp('gprof not supported by cluster, ignoring...'); end
52
53 %write queuing script
54 fid=fopen([modelname '.queue'],'w');
55 fprintf(fid,'#!/bin/sh\n');
56 fprintf(fid,'#PBS -l walltime=%i\n',cluster.time*60); %walltime is in seconds.
57 fprintf(fid,'#PBS -N %s\n',modelname);
58 fprintf(fid,'#PBS -l ncpus=%i\n',cluster.np);
59 if ~isempty(queue),
60 fprintf(fid,'#PBS -q %s\n',cluster.queue);
61 end
62 fprintf(fid,'#PBS -o %s.outlog \n',modelname);
63 fprintf(fid,'#PBS -e %s.errlog \n',modelname);
64 fprintf(fid,'export PBS_O_WORKDIR=%s\n',cluster.executionpath);
65 fprintf(fid,'cd $PBS_O_WORKDIR\n');
66 fprintf(fid,'export OMP_NUM_THREADS=1\n');
67 fprintf(fid,'dplace -s1 -c0-%i mpiexec -np %i %s/issm.exe %s %s %s',cluster.np-1,cluster.np,cluster.codepath,EnumToString(solution),cluster.executionpath,modelname);
68 fclose(fid);
69
70 end
71 %}}}
72 function LaunchQueueJob(cluster,modelname,dirname,filelist)% {{{
73
74 %compress the files into one zip.
75 compressstring=['tar -zcf ' dirname '.tar.gz '];
76 for i=1:numel(filelist),
77 compressstring = [compressstring ' ' filelist{i}];
78 end
79 if cluster.interactive,
80 compressstring = [compressstring ' ' modelname '.errlog ' modelname '.outlog '];
81 end
82 system(compressstring);
83
84 disp('uploading input file and queueing script');
85 issmscpout(cluster.name,cluster.executionpath,cluster.login,cluster.port,{[dirname '.tar.gz']});
86
87 disp('launching solution sequence on remote cluster');
88 launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' dirname ' && mkdir ' dirname ...
89 ' && cd ' dirname ' && mv ../' dirname '.tar.gz ./ && tar -zxf ' dirname '.tar.gz && qsub ' modelname '.queue '];
90 issmssh(cluster.name,cluster.login,cluster.port,launchcommand);
91 end %}}}
92 function Download(cluster,dirname,filelist)% {{{
93
94 %copy files from cluster to current directory
95 directory=[cluster.executionpath '/' dirname '/'];
96 issmscpin(cluster.name,cluster.login,cluster.port,directory,filelist);
97
98 end %}}}
99 end
100end
Note: See TracBrowser for help on using the repository browser.