[5954] | 1 | %COSMOS class definition
|
---|
| 2 | %
|
---|
| 3 | % Usage:
|
---|
[5985] | 4 | % cluster=cosmos();
|
---|
| 5 | % cluster=cosmos('np',3);
|
---|
| 6 | % cluster=cosmos('np',3,'login','username');
|
---|
| 7 |
|
---|
[5954] | 8 | classdef cosmos
|
---|
| 9 | properties (SetAccess=public)
|
---|
[5980] | 10 | % {{{1
|
---|
| 11 | name='cosmos'
|
---|
[11417] | 12 | login='username';
|
---|
[5980] | 13 | np=128;
|
---|
| 14 | port=0;
|
---|
| 15 | queue='shortq';
|
---|
| 16 | time=3*60;
|
---|
[11417] | 17 | codepath='/work00/edw/issm-2.0/bin';
|
---|
| 18 | executionpath='/work00/edw/Execution';
|
---|
[5980] | 19 | %}}}
|
---|
| 20 | end
|
---|
| 21 | methods
|
---|
| 22 | function cluster=cosmos(varargin) % {{{1
|
---|
| 23 | options=pairoptions(varargin{:});
|
---|
| 24 | for i=1:size(options.list,1),
|
---|
| 25 | fieldname=options.list{i,1};
|
---|
| 26 | fieldvalue=options.list{i,2};
|
---|
[8587] | 27 | if ismember(fieldname,properties('cosmos')),
|
---|
[5980] | 28 | cluster.(fieldname)=fieldvalue;
|
---|
| 29 | else
|
---|
| 30 | disp(['''' fieldname ''' is not a property of cluster cosmos']);
|
---|
| 31 | end
|
---|
| 32 | end
|
---|
| 33 | end
|
---|
| 34 | %}}}
|
---|
| 35 | function disp(cluster) % {{{1
|
---|
| 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(' np: %i',cluster.np));
|
---|
| 41 | disp(sprintf(' port: %i',cluster.port));
|
---|
| 42 | disp(sprintf(' queue: %s',cluster.queue));
|
---|
| 43 | disp(sprintf(' time: %i',cluster.time));
|
---|
| 44 | disp(sprintf(' codepath: %s',cluster.codepath));
|
---|
| 45 | disp(sprintf(' executionpath: %s',cluster.executionpath));
|
---|
| 46 | end
|
---|
| 47 | %}}}
|
---|
[9853] | 48 | function checkconsistency(cluster,md,solution,analyses) % {{{1
|
---|
[5954] | 49 |
|
---|
[5980] | 50 | available_queues={'debug','shortq','longq'};
|
---|
| 51 | queue_requirements_time=[60*1 60*3 60*17];
|
---|
| 52 | queue_requirements_np=[32 128 256];
|
---|
[5954] | 53 |
|
---|
[5980] | 54 | QueueRequirements(available_queues,queue_requirements_time,queue_requirements_np,cluster.queue,cluster.np,cluster.time)
|
---|
| 55 | end
|
---|
| 56 | %}}}
|
---|
[6219] | 57 | function BuildQueueScript(cluster,md) % {{{1
|
---|
[5954] | 58 |
|
---|
[6219] | 59 | %retrieve parameters
|
---|
[9625] | 60 | modelname=md.miscellaneous.name;
|
---|
[9853] | 61 | solution=md.private.solution;
|
---|
[6219] | 62 |
|
---|
[5980] | 63 | %open file for writing:
|
---|
| 64 | fid=fopen([modelname '.queue'],'w');
|
---|
[5954] | 65 |
|
---|
[5980] | 66 | fprintf(fid,'#!/bin/bash\n');
|
---|
| 67 | fprintf(fid,'#PBS -l select=%i:ncpus=1\n',cluster.np);
|
---|
| 68 | fprintf(fid,'#PBS -N %s\n',modelname);
|
---|
| 69 | fprintf(fid,'#PBS -l walltime=%i\n',time*60); %walltime is in seconds.
|
---|
| 70 | fprintf(fid,'#PBS -q %s\n',queue);
|
---|
| 71 | fprintf(fid,'#PBS -o %s.outlog \n',modelname);
|
---|
| 72 | fprintf(fid,'#PBS -e %s.errlog \n',modelname);
|
---|
| 73 | fprintf(fid,'export PBS_O_WORKDIR=%s\n',cluster.executionpath);
|
---|
| 74 | fprintf(fid,'cd $PBS_O_WORKDIR\n');
|
---|
| 75 | fprintf(fid,'export OMP_NUM_THREADS=1\n');
|
---|
| 76 | fprintf(fid,'ulimit -s unlimited\n');
|
---|
| 77 | fprintf(fid,'ulimit -c 0\n');
|
---|
[9853] | 78 | fprintf(fid,'/opt/mpich/gm/intel10.1/bin/mpiexec -np %i %s/issm.exe %s %s %s',cluster.np,cluster.codepath,EnumToString(solution),cluster.executionpath,modelname);
|
---|
[5954] | 79 |
|
---|
[5980] | 80 | %close file
|
---|
| 81 | fclose(fid);
|
---|
| 82 |
|
---|
| 83 | end
|
---|
| 84 | %}}}
|
---|
[6043] | 85 | function LaunchQueueJob(cluster,md,options)% {{{1
|
---|
[6038] | 86 |
|
---|
| 87 | %lauch command, to be executed via ssh
|
---|
[9614] | 88 | launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' md.private.runtimename ' && mkdir ' md.private.runtimename ...
|
---|
| 89 | ' && cd ' md.private.runtimename ' && mv ../' md.private.runtimename '.tar.gz ./ && tar -zxf ' md.private.runtimename '.tar.gz && qsub -S/bin/sh ' modelname '.queue '];
|
---|
[6038] | 90 |
|
---|
| 91 | if ~strcmpi(options.batch,'yes'),
|
---|
| 92 |
|
---|
| 93 | %compress the files into one zip.
|
---|
[9625] | 94 | compressstring=['tar -zcf ' md.private.runtimename '.tar.gz ' md.miscellaneous.name '.bin ' md.miscellaneous.name '.queue ' md.miscellaneous.name '.petsc '];
|
---|
[9650] | 95 | if md.qmu.isdakota,
|
---|
[9625] | 96 | compressstring=[compressstring md.miscellaneous.name '.qmu.in'];
|
---|
[6038] | 97 | end
|
---|
| 98 | system(compressstring);
|
---|
| 99 |
|
---|
| 100 | disp('uploading input file and queueing script');
|
---|
[9614] | 101 | issmscpout(md.cluster.name,md.cluster.executionpath,md.cluster.login,md.cluster.port,{[md.private.runtimename '.tar.gz']});
|
---|
[6039] | 102 |
|
---|
| 103 | disp('launching solution sequence on remote cluster');
|
---|
| 104 | issmssh(md.cluster.name,md.cluster.login,md.cluster.port,launchcommand);
|
---|
| 105 |
|
---|
[6038] | 106 | else
|
---|
| 107 | disp('batch mode requested: not launching job interactively');
|
---|
| 108 | disp('launch solution sequence on remote cluster by hand');
|
---|
| 109 | end
|
---|
| 110 |
|
---|
[5980] | 111 | end
|
---|
| 112 | %}}}
|
---|
[6043] | 113 | function Download(cluster,md)% {{{1
|
---|
[6039] | 114 |
|
---|
| 115 | %some check
|
---|
[9614] | 116 | if isempty(md.private.runtimename),
|
---|
[6039] | 117 | error('pfe Download error message: supply runtime name for results to be loaded!');
|
---|
| 118 | end
|
---|
| 119 |
|
---|
| 120 | %Figure out the directory where all the files are in:
|
---|
[9614] | 121 | directory=[cluster.executionpath '/' md.private.runtimename '/'];
|
---|
[6039] | 122 |
|
---|
| 123 | %What packages are we picking up from remote cluster
|
---|
[9625] | 124 | packages={[md.miscellaneous.name '.outlog'],[md.miscellaneous.name '.errlog']};
|
---|
[9650] | 125 | if md.qmu.isdakota,
|
---|
[9625] | 126 | packages{end+1}=[md.miscellaneous.name '.qmu.err'];
|
---|
| 127 | packages{end+1}=[md.miscellaneous.name '.qmu.out'];
|
---|
[9650] | 128 | if isfield(md.qmu.params,'tabular_graphics_data'),
|
---|
| 129 | if md.qmu.params.tabular_graphics_data==true,
|
---|
[6039] | 130 | packages{end+1}='dakota_tabular.dat';
|
---|
| 131 | end
|
---|
| 132 | end
|
---|
| 133 | else
|
---|
[9625] | 134 | packages{end+1}=[md.miscellaneous.name '.outbin'];
|
---|
[6039] | 135 | end
|
---|
| 136 |
|
---|
| 137 | %copy files from cluster to present directory
|
---|
[6040] | 138 | issmscpin(cluster.name, cluster.login, cluster.port, directory, packages);
|
---|
[6039] | 139 | end %}}}
|
---|
[5954] | 140 | end
|
---|
| 141 | end
|
---|