| 1 | %CASTOR class definition
|
|---|
| 2 | %
|
|---|
| 3 | % Usage:
|
|---|
| 4 | % cluster=castor();
|
|---|
| 5 | % cluster=castor('np',3);
|
|---|
| 6 | % cluster=castor('np',3,'login','username');
|
|---|
| 7 |
|
|---|
| 8 | classdef castor
|
|---|
| 9 | properties (SetAccess=public)
|
|---|
| 10 | % {{{1
|
|---|
| 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) % {{{1
|
|---|
| 23 | cluster=AssignObjectFields(pairoptions(varargin{:}),cluster);
|
|---|
| 24 | end
|
|---|
| 25 | %}}}
|
|---|
| 26 | function disp(cluster) % {{{1
|
|---|
| 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) % {{{1
|
|---|
| 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,md) % {{{1
|
|---|
| 49 |
|
|---|
| 50 | %retrieve parameters
|
|---|
| 51 | modelname=md.miscellaneous.name;
|
|---|
| 52 | solution=md.private.solution;
|
|---|
| 53 |
|
|---|
| 54 | %open file for writing:
|
|---|
| 55 | fid=fopen([modelname '.queue'],'w');
|
|---|
| 56 |
|
|---|
| 57 | fprintf(fid,'#!/bin/sh\n');
|
|---|
| 58 | fprintf(fid,'#PBS -l walltime=%i\n',cluster.time*60); %walltime is in seconds.
|
|---|
| 59 | fprintf(fid,'#PBS -N %s\n',modelname);
|
|---|
| 60 | fprintf(fid,'#PBS -l ncpus=%i\n',cluster.np);
|
|---|
| 61 | if ~isempty(queue),
|
|---|
| 62 | fprintf(fid,'#PBS -q %s\n',cluster.queue);
|
|---|
| 63 | end
|
|---|
| 64 | fprintf(fid,'#PBS -o %s.outlog \n',modelname);
|
|---|
| 65 | fprintf(fid,'#PBS -e %s.errlog \n',modelname);
|
|---|
| 66 |
|
|---|
| 67 | fprintf(fid,'export PBS_O_WORKDIR=%s\n',cluster.executionpath);
|
|---|
| 68 | fprintf(fid,'cd $PBS_O_WORKDIR\n');
|
|---|
| 69 | fprintf(fid,'export OMP_NUM_THREADS=1\n');
|
|---|
| 70 | 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);
|
|---|
| 71 |
|
|---|
| 72 | %close file
|
|---|
| 73 | fclose(fid);
|
|---|
| 74 |
|
|---|
| 75 | end
|
|---|
| 76 | %}}}
|
|---|
| 77 | function LaunchQueueJob(cluster,md,options)% {{{1
|
|---|
| 78 |
|
|---|
| 79 | %lauch command, to be executed via ssh
|
|---|
| 80 | launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' md.private.runtimename ' && mkdir ' md.private.runtimename ...
|
|---|
| 81 | ' && cd ' md.private.runtimename ' && mv ../' md.private.runtimename '.tar.gz ./ && tar -zxf ' md.private.runtimename '.tar.gz && qsub ' modelname '.queue '];
|
|---|
| 82 |
|
|---|
| 83 | if ~strcmpi(options.batch,'yes'),
|
|---|
| 84 |
|
|---|
| 85 | %compress the files into one zip.
|
|---|
| 86 | compressstring=['tar -zcf ' md.private.runtimename '.tar.gz ' md.miscellaneous.name '.bin ' md.miscellaneous.name '.queue ' md.miscellaneous.name '.petsc '];
|
|---|
| 87 | if md.qmu.isdakota,
|
|---|
| 88 | compressstring=[compressstring md.miscellaneous.name '.qmu.in'];
|
|---|
| 89 | end
|
|---|
| 90 | system(compressstring);
|
|---|
| 91 |
|
|---|
| 92 | disp('uploading input file and queueing script');
|
|---|
| 93 | issmscpout(md.cluster.name,md.cluster.executionpath,md.cluster.login,md.cluster.port,{[md.private.runtimename '.tar.gz']});
|
|---|
| 94 |
|
|---|
| 95 | disp('launching solution sequence on remote cluster');
|
|---|
| 96 | issmssh(md.cluster.name,md.cluster.login,md.cluster.port,launchcommand);
|
|---|
| 97 |
|
|---|
| 98 | else
|
|---|
| 99 | disp('batch mode requested: not launching job interactively');
|
|---|
| 100 | disp('launch solution sequence on remote cluster by hand');
|
|---|
| 101 | end
|
|---|
| 102 |
|
|---|
| 103 | end
|
|---|
| 104 | %}}}
|
|---|
| 105 | function Download(cluster,md)% {{{1
|
|---|
| 106 |
|
|---|
| 107 | %some check
|
|---|
| 108 | if isempty(md.private.runtimename),
|
|---|
| 109 | error('pfe Download error message: supply runtime name for results to be loaded!');
|
|---|
| 110 | end
|
|---|
| 111 |
|
|---|
| 112 | %Figure out the directory where all the files are in:
|
|---|
| 113 | directory=[cluster.executionpath '/' md.private.runtimename '/'];
|
|---|
| 114 |
|
|---|
| 115 | %What packages are we picking up from remote cluster
|
|---|
| 116 | packages={[md.miscellaneous.name '.outlog'],[md.miscellaneous.name '.errlog']};
|
|---|
| 117 | if md.qmu.isdakota,
|
|---|
| 118 | packages{end+1}=[md.miscellaneous.name '.qmu.err'];
|
|---|
| 119 | packages{end+1}=[md.miscellaneous.name '.qmu.out'];
|
|---|
| 120 | if isfield(md.qmu.params,'tabular_graphics_data'),
|
|---|
| 121 | if md.qmu.params.tabular_graphics_data==true,
|
|---|
| 122 | packages{end+1}='dakota_tabular.dat';
|
|---|
| 123 | end
|
|---|
| 124 | end
|
|---|
| 125 | else
|
|---|
| 126 | packages{end+1}=[md.miscellaneous.name '.outbin'];
|
|---|
| 127 | end
|
|---|
| 128 |
|
|---|
| 129 | %copy files from cluster to present directory
|
|---|
| 130 | issmscpin(cluster.name, cluster.login, cluster.port, directory, packages);
|
|---|
| 131 | end %}}}
|
|---|
| 132 | end
|
|---|
| 133 | end
|
|---|