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

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

Simplifying cluster

File size: 3.9 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,md,options)% {{{
73
74 %lauch command, to be executed via ssh
75 launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' md.private.runtimename ' && mkdir ' md.private.runtimename ...
76 ' && cd ' md.private.runtimename ' && mv ../' md.private.runtimename '.tar.gz ./ && tar -zxf ' md.private.runtimename '.tar.gz && qsub ' modelname '.queue '];
77
78 if ~strcmpi(options.batch,'yes'),
79
80 %compress the files into one zip.
81 compressstring=['tar -zcf ' md.private.runtimename '.tar.gz ' md.miscellaneous.name '.bin ' md.miscellaneous.name '.queue ' md.miscellaneous.name '.petsc '];
82 if md.qmu.isdakota,
83 compressstring=[compressstring md.miscellaneous.name '.qmu.in'];
84 end
85 system(compressstring);
86
87 disp('uploading input file and queueing script');
88 issmscpout(md.cluster.name,md.cluster.executionpath,md.cluster.login,md.cluster.port,{[md.private.runtimename '.tar.gz']});
89
90 disp('launching solution sequence on remote cluster');
91 issmssh(md.cluster.name,md.cluster.login,md.cluster.port,launchcommand);
92
93 else
94 disp('batch mode requested: not launching job interactively');
95 disp('launch solution sequence on remote cluster by hand');
96 end
97
98 end
99 %}}}
100 function Download(cluster,dirname,filelist)% {{{
101
102 %copy files from cluster to current directory
103 directory=[cluster.executionpath '/' dirname '/'];
104 issmscpin(cluster.name,cluster.login,cluster.port,directory,filelist);
105
106 end %}}}
107 end
108end
Note: See TracBrowser for help on using the repository browser.