source: issm/branches/trunk-larour-NatGeoScience2016/src/m/classes/clusters/cosmos.m

Last change on this file was 21759, checked in by Eric.Larour, 8 years ago

CHG: merged branch back to trunk-jpl 21754.

File size: 3.9 KB
RevLine 
[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]8classdef cosmos
9 properties (SetAccess=public)
[12351]10 % {{{
[5980]11 name='cosmos'
[11365]12 login='username';
[5980]13 np=128;
14 port=0;
15 queue='shortq';
16 time=3*60;
[11365]17 codepath='/work00/edw/issm-2.0/bin';
18 executionpath='/work00/edw/Execution';
[5980]19 %}}}
20 end
21 methods
[12351]22 function cluster=cosmos(varargin) % {{{
[11867]23 cluster=AssignObjectFields(pairoptions(varargin{:}),cluster);
[5980]24 end
25 %}}}
[12351]26 function disp(cluster) % {{{
[5980]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 %}}}
[12663]39 function md = checkconsistency(cluster,md,solution,analyses) % {{{
[5954]40
[5980]41 available_queues={'debug','shortq','longq'};
42 queue_requirements_time=[60*1 60*3 60*17];
43 queue_requirements_np=[32 128 256];
[5954]44
[5980]45 QueueRequirements(available_queues,queue_requirements_time,queue_requirements_np,cluster.queue,cluster.np,cluster.time)
46 end
47 %}}}
[21759]48 function BuildQueueScript(cluster,dirname,modelname,solution,io_gather,isvalgrind,isgprof,isdakota,isoceancoupling) % {{{
[5954]49
[12351]50 if(isvalgrind), disp('valgrind not supported by cluster, ignoring...'); end
51 if(isgprof), disp('gprof not supported by cluster, ignoring...'); end
[6219]52
[12351]53 %write queuing script
[5980]54 fid=fopen([modelname '.queue'],'w');
55 fprintf(fid,'#!/bin/bash\n');
56 fprintf(fid,'#PBS -l select=%i:ncpus=1\n',cluster.np);
57 fprintf(fid,'#PBS -N %s\n',modelname);
58 fprintf(fid,'#PBS -l walltime=%i\n',time*60); %walltime is in seconds.
59 fprintf(fid,'#PBS -q %s\n',queue);
60 fprintf(fid,'#PBS -o %s.outlog \n',modelname);
61 fprintf(fid,'#PBS -e %s.errlog \n',modelname);
[13278]62 fprintf(fid,'export PBS_O_WORKDIR=%s\n',[cluster.executionpath '/' dirname]);
[5980]63 fprintf(fid,'cd $PBS_O_WORKDIR\n');
64 fprintf(fid,'export OMP_NUM_THREADS=1\n');
65 fprintf(fid,'ulimit -s unlimited\n');
66 fprintf(fid,'ulimit -c 0\n');
[21050]67 fprintf(fid,'/opt/mpich/gm/intel10.1/bin/mpiexec -np %i %s/issm.exe %s %s %s',cluster.np,cluster.codepath,solution,[cluster.executionpath '/' dirname],modelname);
[5980]68 fclose(fid);
69
70 end
71 %}}}
[19328]72 function UploadQueueJob(cluster,modelname,dirname,filelist)% {{{
[6038]73
[12371]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);
[6039]83
[12371]84 disp('uploading input file and queueing script');
85 issmscpout(cluster.name,cluster.executionpath,cluster.login,cluster.port,{[dirname '.tar.gz']});
[6038]86
[19328]87 end %}}}
[19335]88 function LaunchQueueJob(cluster,modelname,dirname,filelist,restart)% {{{
[19328]89
[12371]90 disp('launching solution sequence on remote cluster');
[19335]91 if ~isempty(restart)
92 launchcommand=['cd ' cluster.executionpath ' && cd ' dirname ' && qsub ' modelname '.queue '];
93 else
94 launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' dirname ' && mkdir ' dirname ...
95 ' && cd ' dirname ' && mv ../' dirname '.tar.gz ./ && tar -zxf ' dirname '.tar.gz && qsub ' modelname '.queue '];
96 end
[12371]97 issmssh(cluster.name,cluster.login,cluster.port,launchcommand);
98 end %}}}
[12363]99 function Download(cluster,dirname,filelist)% {{{
[6039]100
[12363]101 %copy files from cluster to current directory
102 directory=[cluster.executionpath '/' dirname '/'];
103 issmscpin(cluster.name,cluster.login,cluster.port,directory,filelist);
[6039]104
[12363]105 end %}}}
[5954]106 end
107end
Note: See TracBrowser for help on using the repository browser.