source: issm/oecreview/Archive/23390-24306/ISSM-24159-24160.diff

Last change on this file was 24307, checked in by Mathieu Morlighem, 5 years ago

NEW: adding Archive/23390-24306

File size: 6.9 KB
  • ../trunk-jpl/src/m/classes/clusters/sherlock.m

     
     1%PFE class definition
     2%
     3%   Usage:
     4%      cluster=sherlock();
     5%      cluster=sherlock('np',3);
     6%      cluster=sherlock('np',3,'login','username');
     7
     8classdef sherlock
     9    properties (SetAccess=public) 
     10                 % {{{
     11                 name          = 'sherlock'
     12                 login         = '';
     13                 numnodes      = 1;
     14                 cpuspernode   = 24;
     15                 port          = 0;
     16                 codepath      = '';
     17                 executionpath = '';
     18                 interactive   = 0;
     19                 time          = 30;
     20                 memory        = 2;
     21         end
     22         %}}}
     23         methods
     24                 function cluster=sherlock(varargin) % {{{
     25
     26                         %initialize cluster using default settings if provided
     27                         if (exist('sherlock_settings')==2), sherlock_settings; end
     28
     29                         %use provided options to change fields
     30                         cluster=AssignObjectFields(pairoptions(varargin{:}),cluster);
     31                 end
     32                 %}}}
     33                 function disp(cluster) % {{{
     34                         %  display the object
     35                         disp(sprintf('class ''%s'' object ''%s'' = ',class(cluster),inputname(1)));
     36                         disp(sprintf('    name: %s',cluster.name));
     37                         disp(sprintf('    login: %s',cluster.login));
     38                         disp(sprintf('    port: %i',cluster.port));
     39                         disp(sprintf('    numnodes: %i',cluster.numnodes));
     40                         disp(sprintf('    cpuspernode: %i',cluster.cpuspernode));
     41                         disp(sprintf('    np: %i',cluster.cpuspernode*cluster.numnodes));
     42                         disp(sprintf('    codepath: %s',cluster.codepath));
     43                         disp(sprintf('    executionpath: %s',cluster.executionpath));
     44                         disp(sprintf('    interactive: %i',cluster.interactive));
     45                         disp(sprintf('    time: %i',cluster.time));
     46                         disp(sprintf('    memory: %i',cluster.memory));
     47                 end
     48                 %}}}
     49                 function numprocs=np(cluster) % {{{
     50                         %compute number of processors
     51                         numprocs=cluster.numnodes*cluster.cpuspernode;
     52                 end
     53                 %}}}
     54                 function md = checkconsistency(cluster,md,solution,analyses) % {{{
     55
     56                         %Miscelaneous
     57                         if isempty(cluster.login), md = checkmessage(md,'login empty'); end
     58                         if isempty(cluster.codepath), md = checkmessage(md,'codepath empty'); end
     59                         if isempty(cluster.executionpath), md = checkmessage(md,'executionpath empty'); end
     60
     61                 end
     62                 %}}}
     63                 function BuildKrigingQueueScript(cluster,dirname,modelname,solution,io_gather,isvalgrind,isgprof,isdakota,isoceancoupling) % {{{
     64
     65                         if(isvalgrind), disp('valgrind not supported by cluster, ignoring...'); end
     66                         if(isgprof),    disp('gprof not supported by cluster, ignoring...'); end
     67
     68                         %write queuing script
     69                         fid=fopen([modelname '.queue'],'w');
     70                         fprintf(fid,'#!/bin/bash\n');
     71                         fprintf(fid,'#SBATCH --job-name=%s\n',mdelname);
     72                         fprintf(fid,'#SBATCH -p %s \n',cluster.queue);
     73                         fprintf(fid,'#SBATCH -N %i -n %i\n',cluster.numnodes,cluster.cpuspernode);
     74                         fprintf(fid,'#SBATCH --time=%i\n',cluster.time*60); %walltime is in seconds.
     75                         fprintf(fid,'#SBATCH --mem-per-cpu=%igb\n',cluster.memory);
     76                         fprintf(fid,'#SBATCH -o %s.outlog \n',modelname);
     77                         fprintf(fid,'#SBATCH -e %s.errlog \n\n',modelname);
     78                         fprintf(fid,'export ISSM_DIR="%s/../"\n',cluster.codepath); %FIXME
     79                         fprintf(fid,'source $ISSM_DIR/etc/environment.sh\n');       %FIXME
     80                         fprintf(fid,'cd %s/%s\n\n',cluster.executionpath,dirname);
     81                         fprintf(fid,'mpiexec -np %i %s/kriging.exe %s %s\n',cluster.np,cluster.codepath,[cluster.executionpath '/' modelname],modelname);
     82                         if ~io_gather, %concatenate the output files:
     83                                 fprintf(fid,'cat %s.outbin.* > %s.outbin',modelname,modelname);
     84                         end
     85                         fclose(fid);
     86                 end
     87                 %}}}
     88                 function BuildQueueScript(cluster,dirname,modelname,solution,io_gather,isvalgrind,isgprof,isdakota,isoceancoupling) % {{{
     89
     90                         if(isvalgrind), disp('valgrind not supported by cluster, ignoring...'); end
     91                         if(isgprof),    disp('gprof not supported by cluster, ignoring...'); end
     92
     93                         %write queuing script
     94                         fid=fopen([modelname '.queue'],'w');
     95                         fprintf(fid,'#!/bin/bash\n');
     96                         fprintf(fid,'#SBATCH --job-name=%s\n',modelname);
     97                         fprintf(fid,'#SBATCH -N %i -n %i\n',cluster.numnodes,cluster.cpuspernode);
     98                         fprintf(fid,'#SBATCH --time=%i\n',cluster.time*60); %walltime is in seconds.
     99                         fprintf(fid,'#SBATCH --mem-per-cpu=%igb\n',cluster.memory);
     100                         fprintf(fid,'#SBATCH -o %s.outlog \n',modelname);
     101                         fprintf(fid,'#SBATCH -e %s.errlog \n\n',modelname);
     102                         fprintf(fid,'export ISSM_DIR="%s/../"\n',cluster.codepath); %FIXME
     103                         fprintf(fid,'source $ISSM_DIR/etc/environment.sh\n');       %FIXME
     104                         fprintf(fid,'cd %s/%s\n\n',cluster.executionpath,dirname);
     105                         fprintf(fid,'mpiexec -n %i %s/issm.exe %s %s %s\n',cluster.np,cluster.codepath,solution,[cluster.executionpath '/' dirname],modelname);
     106                         if ~io_gather, %concatenate the output files:
     107                                 fprintf(fid,'cat %s.outbin.* > %s.outbin',modelname,modelname);
     108                         end
     109                         fclose(fid);
     110
     111                         %in interactive mode, create a run file, and errlog and outlog file
     112                         if cluster.interactive,
     113                                 fid=fopen([modelname '.run'],'w');
     114                                 fprintf(fid,'mpiexec -n %i %s/issm.exe %s %s %s\n',cluster.np,cluster.codepath,solution,[cluster.executionpath '/' dirname],modelname);
     115                                 if ~io_gather, %concatenate the output files:
     116                                         fprintf(fid,'cat %s.outbin.* > %s.outbin',modelname,modelname);
     117                                 end
     118                                 fclose(fid);
     119                                 fid=fopen([modelname '.errlog'],'w');
     120                                 fclose(fid);
     121                                 fid=fopen([modelname '.outlog'],'w');
     122                                 fclose(fid);
     123                         end
     124                 end %}}}
     125                 function UploadQueueJob(cluster,modelname,dirname,filelist)% {{{
     126
     127                         %compress the files into one zip.
     128                         compressstring=['tar -zcf ' dirname '.tar.gz '];
     129                         for i=1:numel(filelist),
     130                                 compressstring = [compressstring ' ' filelist{i}];
     131                         end
     132                         if cluster.interactive,
     133                                 compressstring = [compressstring ' ' modelname '.errlog ' modelname '.outlog '];
     134                         end
     135                         system(compressstring);
     136
     137                         disp('uploading input file and queueing script');
     138                         issmscpout(cluster.name,cluster.executionpath,cluster.login,cluster.port,{[dirname '.tar.gz']});
     139
     140                 end %}}}
     141                 function LaunchQueueJob(cluster,modelname,dirname,filelist,restart,batch)% {{{
     142
     143                         disp('launching solution sequence on remote cluster');
     144                         if ~isempty(restart)
     145                                 launchcommand=['cd ' cluster.executionpath ' && cd ' dirname ' && hostname && sbatch ' modelname '.queue '];
     146                         else
     147                                 launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' dirname ' && mkdir ' dirname ...
     148                                         ' && cd ' dirname ' && mv ../' dirname '.tar.gz ./ && tar -zxf ' dirname '.tar.gz  && hostname && sbatch ' modelname '.queue '];
     149                         end
     150                         issmssh(cluster.name,cluster.login,cluster.port,launchcommand);
     151                 end %}}}
     152                 function Download(cluster,dirname,filelist)% {{{
     153
     154                         %copy files from cluster to current directory
     155                         directory=[cluster.executionpath '/' dirname '/'];
     156                         issmscpin(cluster.name,cluster.login,cluster.port,directory,filelist);
     157
     158                 end %}}}
     159        end
     160end
Note: See TracBrowser for help on using the repository browser.