Ignore:
Timestamp:
12/22/21 10:39:44 (3 years ago)
Author:
Mathieu Morlighem
Message:

merged trunk-jpl and trunk for revision 26742

Location:
issm/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk

  • issm/trunk/src

  • TabularUnified issm/trunk/src/m/classes/clusters/maui.m

    r25836 r26744  
    1 %MAUI class definition
     1%MAUI cluster class definition
    22%
    33%   Usage:
     
    77
    88classdef maui
    9     properties (SetAccess=public) 
    10                  % {{{
    11                  name           = 'maui'
    12                  login          = '';
    13                  numnodes       = 1;
    14                  cpuspernode    = 8;
    15                  port           = 0;
    16                  projectaccount = '';
    17                  partition      = 'nesi_research';
    18                  codepath       = '';
    19                  executionpath  = '';
    20                  interactive    = 0;
    21                  time           = 24*60;
    22                  memory         = 2;
    23          end
    24          %}}}
    25          methods
    26                  function cluster=maui(varargin) % {{{
     9        properties (SetAccess=public)
     10                % {{{
     11                name           = 'maui'
     12                login          = '';
     13                numnodes       = 1;
     14                cpuspernode    = 8;
     15                port           = 0;
     16                projectaccount = '';
     17                partition      = 'nesi_research';
     18                codepath       = '';
     19                executionpath  = '';
     20                interactive    = 0;
     21                time           = 24*60;
     22                memory         = 2;
     23        end
     24        %}}}
     25        methods
     26                function cluster=maui(varargin) % {{{
    2727
    28                          %initialize cluster using default settings if provided
    29                          if (exist('maui_settings')==2), maui_settings; end
     28                        %initialize cluster using default settings if provided
     29                        if (exist('maui_settings')==2), maui_settings; end
    3030
    31                          %use provided options to change fields
    32                          cluster=AssignObjectFields(pairoptions(varargin{:}),cluster);
    33                  end
    34                  %}}}
    35                  function disp(cluster) % {{{
    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('    port: %i',cluster.port));
    41                          disp(sprintf('    numnodes: %i',cluster.numnodes));
    42                          disp(sprintf('    cpuspernode: %i',cluster.cpuspernode));
    43                          disp(sprintf('    np: %i',cluster.cpuspernode*cluster.numnodes));
    44                          disp(sprintf('    projectaccount: %s',cluster.projectaccount));
    45                          disp(sprintf('    partition: %s',cluster.partition));
    46                          disp(sprintf('    codepath: %s',cluster.codepath));
    47                          disp(sprintf('    executionpath: %s',cluster.executionpath));
    48                          disp(sprintf('    interactive: %i',cluster.interactive));
    49                          disp(sprintf('    time: %i',cluster.time));
    50                          disp(sprintf('    memory: %i',cluster.memory));
    51                  end
    52                  %}}}
    53                  function numprocs=np(cluster) % {{{
    54                          %compute number of processors
    55                          numprocs=cluster.numnodes*cluster.cpuspernode;
    56                  end
    57                  %}}}
    58                  function md = checkconsistency(cluster,md,solution,analyses) % {{{
     31                        %use provided options to change fields
     32                        cluster=AssignObjectFields(pairoptions(varargin{:}),cluster);
     33                end
     34                %}}}
     35                function disp(cluster) % {{{
     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('    numnodes: %i',cluster.numnodes));
     41                        disp(sprintf('    cpuspernode: %i',cluster.cpuspernode));
     42                        disp(sprintf('    np: %i',cluster.nprocs()));
     43                        disp(sprintf('    port: %i',cluster.port));
     44                        disp(sprintf('    projectaccount: %s',cluster.projectaccount));
     45                        disp(sprintf('    partition: %s',cluster.partition));
     46                        disp(sprintf('    codepath: %s',cluster.codepath));
     47                        disp(sprintf('    executionpath: %s',cluster.executionpath));
     48                        disp(sprintf('    interactive: %i',cluster.interactive));
     49                        disp(sprintf('    time: %i',cluster.time));
     50                        disp(sprintf('    memory: %i',cluster.memory));
     51                end
     52                %}}}
     53                function numprocs=nprocs(cluster) % {{{
     54                        %compute number of processors
     55                        numprocs=cluster.numnodes*cluster.cpuspernode;
     56                end
     57                %}}}
     58                function md = checkconsistency(cluster,md,solution,analyses) % {{{
    5959
    60                          available_partitions={'nesi_research'}
    61                          partition_requirements_time=[24*60];
    62                          partition_requirements_np=[80];
     60                        available_partitions={'nesi_research'}
     61                        partition_requirements_time=[24*60];
     62                        partition_requirements_np=[80];
    6363
    64                          QueueRequirements(available_partitions,partition_requirements_time,partition_requirements_np,cluster.partition,cluster.np,1)
     64                        QueueRequirements(available_partitions,partition_requirements_time,partition_requirements_np,cluster.partition,cluster.nprocs(),1)
    6565
    66                          %Miscelaneous
    67                          if isempty(cluster.login), md = checkmessage(md,'login empty'); end
    68                          if isempty(cluster.codepath), md = checkmessage(md,'codepath empty'); end
    69                          if isempty(cluster.executionpath), md = checkmessage(md,'executionpath empty'); end
    70                  end
    71                  %}}}
    72                  function BuildKrigingQueueScript(cluster,dirname,modelname,solution,io_gather,isvalgrind,isgprof,isdakota,isoceancoupling) % {{{
    73                          error('not implemented yet');
    74                  end
    75                  %}}}
    76                  function BuildQueueScript(cluster,dirname,modelname,solution,io_gather,isvalgrind,isgprof,isdakota,isoceancoupling) % {{{
     66                        %Miscellaneous
     67                        if isempty(cluster.login), md = checkmessage(md,'login empty'); end
     68                        if isempty(cluster.codepath), md = checkmessage(md,'codepath empty'); end
     69                        if isempty(cluster.executionpath), md = checkmessage(md,'executionpath empty'); end
     70                end
     71                %}}}
     72                function BuildKrigingQueueScript(cluster,dirname,modelname,solution,io_gather,isvalgrind,isgprof,isdakota,isoceancoupling) % {{{
     73                        error('not implemented yet');
     74                end
     75                %}}}
     76                function BuildQueueScript(cluster,dirname,modelname,solution,io_gather,isvalgrind,isgprof,isdakota,isoceancoupling) % {{{
    7777
    78                          if(isvalgrind), disp('valgrind not supported by cluster, ignoring...'); end
    79                          if(isgprof),    disp('gprof not supported by cluster, ignoring...'); end
     78                        if(isvalgrind), disp('valgrind not supported by cluster, ignoring...'); end
     79                        if(isgprof),    disp('gprof not supported by cluster, ignoring...'); end
    8080
    81                          %write queuing script
    82                          fid=fopen([modelname '.queue'],'w');
    83                          fprintf(fid,'#!/bin/bash\n');
    84                          fprintf(fid,'#SBATCH --job-name=%s\n',modelname);
    85                          fprintf(fid,'#SBATCH --account=%s \n',cluster.projectaccount);
    86                          fprintf(fid,'#SBATCH --partition=%s \n',cluster.partition);
    87                          fprintf(fid,'#SBATCH --ntasks=%i  \n',cluster.numnodes);
    88                          fprintf(fid,'#SBATCH --cpus-per-task=%i\n',cluster.cpuspernode);
    89                          fprintf(fid,'#SBATCH --time=%i\n',cluster.time); %walltime is in minutes
    90                          fprintf(fid,'#SBATCH --mem-per-cpu=%igb\n',cluster.memory);
    91                          fprintf(fid,'#SBATCH -o %s.outlog \n',modelname);
    92                          fprintf(fid,'#SBATCH -e %s.errlog \n\n',modelname);
    93                          fprintf(fid,'export ISSM_DIR="%s/../"\n',cluster.codepath); %FIXME
    94                          fprintf(fid,'source $ISSM_DIR/etc/environment.sh\n');       %FIXME
    95                          fprintf(fid,'module swap PrgEnv-cray PrgEnv-intel\n');
    96                          fprintf(fid,'cd %s/%s\n\n',cluster.executionpath,dirname);
    97                          fprintf(fid,'srun -n %i %s/issm.exe %s %s %s\n',cluster.np,cluster.codepath,solution,[cluster.executionpath '/' dirname],modelname);
    98                          if ~io_gather, %concatenate the output files:
    99                                  fprintf(fid,'cat %s.outbin.* > %s.outbin',modelname,modelname);
    100                          end
    101                          fclose(fid);
     81                        %write queuing script
     82                        fid=fopen([modelname '.queue'],'w');
     83                        fprintf(fid,'#!/bin/bash\n');
     84                        fprintf(fid,'#SBATCH --job-name=%s\n',modelname);
     85                        fprintf(fid,'#SBATCH --account=%s \n',cluster.projectaccount);
     86                        fprintf(fid,'#SBATCH --partition=%s \n',cluster.partition);
     87                        fprintf(fid,'#SBATCH --ntasks=%i  \n',cluster.numnodes);
     88                        fprintf(fid,'#SBATCH --cpus-per-task=%i\n',cluster.cpuspernode);
     89                        fprintf(fid,'#SBATCH --time=%i\n',cluster.time); %walltime is in minutes
     90                        fprintf(fid,'#SBATCH --mem-per-cpu=%igb\n',cluster.memory);
     91                        fprintf(fid,'#SBATCH -o %s.outlog \n',modelname);
     92                        fprintf(fid,'#SBATCH -e %s.errlog \n\n',modelname);
     93                        fprintf(fid,'export ISSM_DIR="%s/../"\n',cluster.codepath); %FIXME
     94                        fprintf(fid,'source $ISSM_DIR/etc/environment.sh\n');       %FIXME
     95                        fprintf(fid,'module swap PrgEnv-cray PrgEnv-intel\n');
     96                        fprintf(fid,'cd %s/%s\n\n',cluster.executionpath,dirname);
     97                        fprintf(fid,'srun -n %i %s/issm.exe %s %s %s\n',cluster.nprocs(),cluster.codepath,solution,[cluster.executionpath '/' dirname],modelname);
     98                        if ~io_gather, %concatenate the output files:
     99                                fprintf(fid,'cat %s.outbin.* > %s.outbin',modelname,modelname);
     100                        end
     101                        fclose(fid);
    102102
    103                          %in interactive mode, create a run file, and errlog and outlog file
    104                          if cluster.interactive,
    105                                  fid=fopen([modelname '.run'],'w');
    106                                  fprintf(fid,'mpiexec -n %i %s/issm.exe %s %s %s\n',cluster.np,cluster.codepath,solution,[cluster.executionpath '/' dirname],modelname);
    107                                  if ~io_gather, %concatenate the output files:
    108                                          fprintf(fid,'cat %s.outbin.* > %s.outbin',modelname,modelname);
    109                                  end
    110                                  fclose(fid);
    111                                  fid=fopen([modelname '.errlog'],'w');
    112                                  fclose(fid);
    113                                  fid=fopen([modelname '.outlog'],'w');
    114                                  fclose(fid);
    115                          end
    116                  end %}}}
    117                  function UploadQueueJob(cluster,modelname,dirname,filelist)% {{{
     103                        %in interactive mode, create a run file, and errlog and outlog file
     104                        if cluster.interactive,
     105                                fid=fopen([modelname '.run'],'w');
     106                                fprintf(fid,'mpiexec -n %i %s/issm.exe %s %s %s\n',cluster.nprocs(),cluster.codepath,solution,[cluster.executionpath '/' dirname],modelname);
     107                                if ~io_gather, %concatenate the output files:
     108                                        fprintf(fid,'cat %s.outbin.* > %s.outbin',modelname,modelname);
     109                                end
     110                                fclose(fid);
     111                                fid=fopen([modelname '.errlog'],'w');
     112                                fclose(fid);
     113                                fid=fopen([modelname '.outlog'],'w');
     114                                fclose(fid);
     115                        end
     116                end %}}}
     117                function UploadQueueJob(cluster,modelname,dirname,filelist) % {{{
    118118
    119                          %compress the files into one zip.
    120                          compressstring=['tar -zcf ' dirname '.tar.gz '];
    121                          for i=1:numel(filelist),
    122                                  compressstring = [compressstring ' ' filelist{i}];
    123                          end
    124                          if cluster.interactive,
    125                                  compressstring = [compressstring ' ' modelname '.errlog ' modelname '.outlog '];
    126                          end
    127                          system(compressstring);
     119                        %compress the files into one zip.
     120                        compressstring=['tar -zcf ' dirname '.tar.gz '];
     121                        for i=1:numel(filelist),
     122                                compressstring = [compressstring ' ' filelist{i}];
     123                        end
     124                        if cluster.interactive,
     125                                compressstring = [compressstring ' ' modelname '.errlog ' modelname '.outlog '];
     126                        end
     127                        system(compressstring);
    128128
    129                          disp('uploading input file and queueing script');
    130                          issmscpout(cluster.name,cluster.executionpath,cluster.login,cluster.port,{[dirname '.tar.gz']});
     129                        disp('uploading input file and queueing script');
     130                        issmscpout(cluster.name,cluster.executionpath,cluster.login,cluster.port,{[dirname '.tar.gz']});
    131131
    132                  end %}}}
    133                  function LaunchQueueJob(cluster,modelname,dirname,filelist,restart,batch)% {{{
     132                end %}}}
     133                function LaunchQueueJob(cluster,modelname,dirname,filelist,restart,batch) % {{{
    134134
    135                          disp('launching solution sequence on remote cluster');
    136                          if ~isempty(restart)
    137                                  launchcommand=['cd ' cluster.executionpath ' && cd ' dirname ' && hostname && sbatch ' modelname '.queue '];
    138                          else
    139                                  launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' dirname ' && mkdir ' dirname ...
    140                                          ' && cd ' dirname ' && mv ../' dirname '.tar.gz ./ && tar -zxf ' dirname '.tar.gz  && hostname && sbatch ' modelname '.queue '];
    141                          end
    142                          issmssh(cluster.name,cluster.login,cluster.port,launchcommand);
    143                  end %}}}
    144                  function Download(cluster,dirname,filelist)% {{{
     135                        disp('launching solution sequence on remote cluster');
     136                        if ~isempty(restart)
     137                                launchcommand=['cd ' cluster.executionpath ' && cd ' dirname ' && hostname && sbatch ' modelname '.queue '];
     138                        else
     139                                launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' dirname ' && mkdir ' dirname ...
     140                                        ' && cd ' dirname ' && mv ../' dirname '.tar.gz ./ && tar -zxf ' dirname '.tar.gz  && hostname && sbatch ' modelname '.queue '];
     141                        end
     142                        issmssh(cluster.name,cluster.login,cluster.port,launchcommand);
     143                end %}}}
     144                function Download(cluster,dirname,filelist) % {{{
    145145
    146                          %copy files from cluster to current directory
    147                          directory=[cluster.executionpath '/' dirname '/'];
    148                          issmscpin(cluster.name,cluster.login,cluster.port,directory,filelist);
     146                        %copy files from cluster to current directory
     147                        directory=[cluster.executionpath '/' dirname '/'];
     148                        issmscpin(cluster.name,cluster.login,cluster.port,directory,filelist);
    149149
    150                  end %}}}
     150                end %}}}
    151151        end
    152152end
Note: See TracChangeset for help on using the changeset viewer.