source: issm/trunk-jpl-damage/src/m/classes/clusters/cosmos.m@ 11330

Last change on this file since 11330 was 9853, checked in by Mathieu Morlighem, 14 years ago

Checkmodelconsistency passes solution and analyses to the objects for further checks

File size: 4.9 KB
Line 
1%COSMOS class definition
2%
3% Usage:
4% cluster=cosmos();
5% cluster=cosmos('np',3);
6% cluster=cosmos('np',3,'login','username');
7
8classdef cosmos
9 properties (SetAccess=public)
10 % {{{1
11 name='cosmos'
12 login='larour';
13 np=128;
14 port=0;
15 queue='shortq';
16 time=3*60;
17 codepath='/work00/edw/larour/issm-2.0/bin';
18 executionpath='/work00/edw/larour/Execution';
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};
27 if ismember(fieldname,properties('cosmos')),
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 %}}}
48 function checkconsistency(cluster,md,solution,analyses) % {{{1
49
50 available_queues={'debug','shortq','longq'};
51 queue_requirements_time=[60*1 60*3 60*17];
52 queue_requirements_np=[32 128 256];
53
54 QueueRequirements(available_queues,queue_requirements_time,queue_requirements_np,cluster.queue,cluster.np,cluster.time)
55 end
56 %}}}
57 function BuildQueueScript(cluster,md) % {{{1
58
59 %retrieve parameters
60 modelname=md.miscellaneous.name;
61 solution=md.private.solution;
62
63 %open file for writing:
64 fid=fopen([modelname '.queue'],'w');
65
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');
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);
79
80 %close file
81 fclose(fid);
82
83 end
84 %}}}
85 function LaunchQueueJob(cluster,md,options)% {{{1
86
87 %lauch command, to be executed via ssh
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 '];
90
91 if ~strcmpi(options.batch,'yes'),
92
93 %compress the files into one zip.
94 compressstring=['tar -zcf ' md.private.runtimename '.tar.gz ' md.miscellaneous.name '.bin ' md.miscellaneous.name '.queue ' md.miscellaneous.name '.petsc '];
95 if md.qmu.isdakota,
96 compressstring=[compressstring md.miscellaneous.name '.qmu.in'];
97 end
98 system(compressstring);
99
100 disp('uploading input file and queueing script');
101 issmscpout(md.cluster.name,md.cluster.executionpath,md.cluster.login,md.cluster.port,{[md.private.runtimename '.tar.gz']});
102
103 disp('launching solution sequence on remote cluster');
104 issmssh(md.cluster.name,md.cluster.login,md.cluster.port,launchcommand);
105
106 else
107 disp('batch mode requested: not launching job interactively');
108 disp('launch solution sequence on remote cluster by hand');
109 end
110
111 end
112 %}}}
113 function Download(cluster,md)% {{{1
114
115 %some check
116 if isempty(md.private.runtimename),
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:
121 directory=[cluster.executionpath '/' md.private.runtimename '/'];
122
123 %What packages are we picking up from remote cluster
124 packages={[md.miscellaneous.name '.outlog'],[md.miscellaneous.name '.errlog']};
125 if md.qmu.isdakota,
126 packages{end+1}=[md.miscellaneous.name '.qmu.err'];
127 packages{end+1}=[md.miscellaneous.name '.qmu.out'];
128 if isfield(md.qmu.params,'tabular_graphics_data'),
129 if md.qmu.params.tabular_graphics_data==true,
130 packages{end+1}='dakota_tabular.dat';
131 end
132 end
133 else
134 packages{end+1}=[md.miscellaneous.name '.outbin'];
135 end
136
137 %copy files from cluster to present directory
138 issmscpin(cluster.name, cluster.login, cluster.port, directory, packages);
139 end %}}}
140 end
141end
Note: See TracBrowser for help on using the repository browser.