Changeset 26330


Ignore:
Timestamp:
06/23/21 13:51:11 (4 years ago)
Author:
jdquinn
Message:

CHG: Bringing pfe.py up to date (will ping Basile about this); clean up

Location:
issm/trunk-jpl/src/m/classes/clusters
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/m/classes/clusters/aurora.m

    r23624 r26330  
    1 %AURORA class definition
     1%AURORA cluster class definition
    22%
    33%   Usage:
     
    77
    88classdef aurora
    9     properties (SetAccess=public)
    10                  % {{{
    11                  name='aurora.jpl.nasa.gov'
    12                  login='username';
    13                  numnodes = 1;
    14                  cpuspernode = 24;
    15                  modules = {'intel/cluster-toolkit-2013.5.192'};
    16                  port=1070;
    17                  queue='shortq';
    18                  time=3*60;
    19                  codepath='~/issm/trunk/';
    20                  executionpath='~/issm/trunk/execution/';
    21                  mpipath='/opt/intel/impi/4.1.3/intel64/bin/';
    22                  %}}}
    23          end
    24          methods
    25                  function cluster=aurora(varargin) % {{{
     9        properties (SetAccess=public)
     10                % {{{
     11                name='aurora.jpl.nasa.gov'
     12                login='username';
     13                numnodes = 1;
     14                cpuspernode = 24;
     15                modules = {'intel/cluster-toolkit-2013.5.192'};
     16                port=1070;
     17                queue='shortq';
     18                time=3*60;
     19                codepath='~/issm/trunk/';
     20                executionpath='~/issm/trunk/execution/';
     21                mpipath='/opt/intel/impi/4.1.3/intel64/bin/';
     22                %}}}
     23        end
     24        methods
     25                function cluster=aurora(varargin) % {{{
    2626
    27                          %initialize cluster using default settings if provided
    28                          if (exist('aurora_settings')==2), aurora_settings; end
     27                        %initialize cluster using default settings if provided
     28                        if (exist('aurora_settings')==2), aurora_settings; end
    2929
    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('    numnodes: %i',cluster.numnodes));
    39                          disp(sprintf('    cpuspernode: %i',cluster.cpuspernode));
    40                          disp(sprintf('    port: %i',cluster.port));
    41                          disp(sprintf('    queue: %s',cluster.queue));
    42                          disp(sprintf('    time: %i',cluster.time));
    43                          disp(sprintf('    codepath: %s',cluster.codepath));
    44                          disp(sprintf('    executionpath: %s',cluster.executionpath));
    45                  end
    46                  %}}}
    47                  function numprocs=np(cluster) % {{{
    48                          %compute number of processors
    49                          numprocs=cluster.numnodes*cluster.cpuspernode;
    50                  end
    51                  %}}}
    52                  function md = checkconsistency(cluster,md,solution,analyses) % {{{
     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('    numnodes: %i',cluster.numnodes));
     39                        disp(sprintf('    cpuspernode: %i',cluster.cpuspernode));
     40                        disp(sprintf('    port: %i',cluster.port));
     41                        disp(sprintf('    queue: %s',cluster.queue));
     42                        disp(sprintf('    time: %i',cluster.time));
     43                        disp(sprintf('    codepath: %s',cluster.codepath));
     44                        disp(sprintf('    executionpath: %s',cluster.executionpath));
     45                end
     46                %}}}
     47                function numprocs=nprocs(cluster) % {{{
     48                        %compute number of processors
     49                        numprocs=cluster.numnodes*cluster.cpuspernode;
     50                end
     51                %}}}
     52                function md = checkconsistency(cluster,md,solution,analyses) % {{{
    5353
    54                          available_queues={'debugq','shortq','mediumq','longq','verylongq'};
    55                          queue_requirements_time=[60*1 60*3 60*12 60*48 60*192];
    56                          queue_requirements_np=[16 256 256 128 128];
     54                        available_queues={'debugq','shortq','mediumq','longq','verylongq'};
     55                        queue_requirements_time=[60*1 60*3 60*12 60*48 60*192];
     56                        queue_requirements_np=[16 256 256 128 128];
    5757
    58                          QueueRequirements(available_queues,queue_requirements_time,queue_requirements_np,cluster.queue,cluster.numnodes.*cluster.cpuspernode,cluster.time)
    59                  end
    60                  %}}}
    61                  function BuildQueueScript(cluster,dirname,modelname,solution,io_gather,isvalgrind,isgprof,isdakota,isoceancoupling) % {{{
     58                        QueueRequirements(available_queues,queue_requirements_time,queue_requirements_np,cluster.queue,cluster.numnodes.*cluster.cpuspernode,cluster.time)
     59                end
     60                %}}}
     61                function BuildQueueScript(cluster,dirname,modelname,solution,io_gather,isvalgrind,isgprof,isdakota,isoceancoupling) % {{{
    6262
    63                          if(isvalgrind), disp('valgrind not supported by cluster, ignoring...'); end
    64                          if(isgprof),    disp('gprof not supported by cluster, ignoring...'); end
    65                          executable='issm.exe';
    66                          if isdakota,
    67                                  version=IssmConfig('_DAKOTA_VERSION_'); version=str2num(version(1:3));
    68                                  if (version>=6),
    69                                          executable='issm_dakota.exe';
    70                                  end
    71                          end
    72                          if isoceancoupling,
    73                                  executable='issm_ocean.exe';
    74                          end
     63                        if(isvalgrind), disp('valgrind not supported by cluster, ignoring...'); end
     64                        if(isgprof),    disp('gprof not supported by cluster, ignoring...'); end
     65                        executable='issm.exe';
     66                        if isdakota,
     67                                version=IssmConfig('_DAKOTA_VERSION_'); version=str2num(version(1:3));
     68                                if (version>=6),
     69                                        executable='issm_dakota.exe';
     70                                end
     71                        end
     72                        if isoceancoupling,
     73                                executable='issm_ocean.exe';
     74                        end
    7575
    76                          %write queuing script
    77                          fid=fopen([modelname '.queue'],'w');
    78                          fprintf(fid,'#!/bin/bash\n');
    79                          fprintf(fid,'#PBS -l select=%i:ncpus=%i\n',cluster.numnodes,cluster.cpuspernode);
    80                          fprintf(fid,'#PBS -N %s\n',modelname);
    81                          fprintf(fid,'#PBS -l walltime=%i\n',cluster.time*60); %walltime is in seconds.
    82                          fprintf(fid,'#PBS -q %s\n',cluster.queue);
    83                          fprintf(fid,'#PBS -o %s.outlog \n',modelname);
    84                          fprintf(fid,'#PBS -e %s.errlog \n',modelname);
    85                          fprintf(fid,'source /usr/share/Modules/init/bash\n');
    86                          for i=1:numel(cluster.modules), fprintf(fid,['module load ' cluster.modules{i} '\n\n']); end
    87                          fprintf(fid,'export PATH="$PATH:."\n\n');
    88                          fprintf(fid,'export MPI_GROUP_MAX=64\n\n');
    89                          fprintf(fid,'export MPI_UNBUFFERED_STDIO=true\n\n');
    90                          fprintf(fid,'export ISSM_DIR="%s/../"\n',cluster.codepath);
    91                          fprintf(fid,'source $ISSM_DIR/etc/environment.sh\n');     
    92                          fprintf(fid,'export PATH="$PATH:.:%s"\n',cluster.mpipath);
    93                          fprintf(fid,'export PBS_O_WORKDIR=%s\n',[cluster.executionpath '/' dirname]);
    94                          fprintf(fid,'cd $PBS_O_WORKDIR\n');
    95                          fprintf(fid,'mpirun -n %i %s/%s %s %s %s',cluster.np(),cluster.codepath,executable,solution,[cluster.executionpath '/' dirname],modelname);
    96                          fclose(fid);
     76                        %write queuing script
     77                        fid=fopen([modelname '.queue'],'w');
     78                        fprintf(fid,'#!/bin/bash\n');
     79                        fprintf(fid,'#PBS -l select=%i:ncpus=%i\n',cluster.numnodes,cluster.cpuspernode);
     80                        fprintf(fid,'#PBS -N %s\n',modelname);
     81                        fprintf(fid,'#PBS -l walltime=%i\n',cluster.time*60); %walltime is in seconds.
     82                        fprintf(fid,'#PBS -q %s\n',cluster.queue);
     83                        fprintf(fid,'#PBS -o %s.outlog \n',modelname);
     84                        fprintf(fid,'#PBS -e %s.errlog \n',modelname);
     85                        fprintf(fid,'source /usr/share/Modules/init/bash\n');
     86                        for i=1:numel(cluster.modules), fprintf(fid,['module load ' cluster.modules{i} '\n\n']); end
     87                        fprintf(fid,'export PATH="$PATH:."\n\n');
     88                        fprintf(fid,'export MPI_GROUP_MAX=64\n\n');
     89                        fprintf(fid,'export MPI_UNBUFFERED_STDIO=true\n\n');
     90                        fprintf(fid,'export ISSM_DIR="%s/../"\n',cluster.codepath);
     91                        fprintf(fid,'source $ISSM_DIR/etc/environment.sh\n');     
     92                        fprintf(fid,'export PATH="$PATH:.:%s"\n',cluster.mpipath);
     93                        fprintf(fid,'export PBS_O_WORKDIR=%s\n',[cluster.executionpath '/' dirname]);
     94                        fprintf(fid,'cd $PBS_O_WORKDIR\n');
     95                        fprintf(fid,'mpirun -n %i %s/%s %s %s %s',cluster.nprocs(),cluster.codepath,executable,solution,[cluster.executionpath '/' dirname],modelname);
     96                        fclose(fid);
    9797
    98                  end
    99                  %}}}
    100                  function UploadQueueJob(cluster,modelname,dirname,filelist)% {{{
     98                end
     99                %}}}
     100                function UploadQueueJob(cluster,modelname,dirname,filelist) % {{{
    101101
    102                          %compress the files into one zip.
    103                          compressstring=['tar -zcf ' dirname '.tar.gz '];
    104                          for i=1:numel(filelist),
    105                                  compressstring = [compressstring ' ' filelist{i}];
    106                          end
    107                          system(compressstring);
     102                        %compress the files into one zip.
     103                        compressstring=['tar -zcf ' dirname '.tar.gz '];
     104                        for i=1:numel(filelist),
     105                                compressstring = [compressstring ' ' filelist{i}];
     106                        end
     107                        system(compressstring);
    108108
    109                          disp('uploading input file and queueing script');
    110                          issmscpout(cluster.name,cluster.executionpath,cluster.login,cluster.port,{[dirname '.tar.gz']});
     109                        disp('uploading input file and queueing script');
     110                        issmscpout(cluster.name,cluster.executionpath,cluster.login,cluster.port,{[dirname '.tar.gz']});
    111111
    112                  end %}}}
    113                  function LaunchQueueJob(cluster,modelname,dirname,filelist,restart,batch)% {{{
     112                end %}}}
     113                function LaunchQueueJob(cluster,modelname,dirname,filelist,restart,batch) % {{{
    114114
    115                          if ~isempty(restart)
    116                                  launchcommand=['cd ' cluster.executionpath ' && cd ' dirname ' && qsub ' modelname '.queue '];
    117                          else
    118                                  launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' dirname ' && mkdir ' dirname ...
    119                                          ' && cd ' dirname ' && mv ../' dirname '.tar.gz ./ && tar -zxf ' dirname '.tar.gz  && qsub ' modelname '.queue '];
    120                          end
     115                        if ~isempty(restart)
     116                                launchcommand=['cd ' cluster.executionpath ' && cd ' dirname ' && qsub ' modelname '.queue '];
     117                        else
     118                                launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' dirname ' && mkdir ' dirname ...
     119                                        ' && cd ' dirname ' && mv ../' dirname '.tar.gz ./ && tar -zxf ' dirname '.tar.gz  && qsub ' modelname '.queue '];
     120                        end
    121121
    122                          disp('launching solution sequence on remote cluster');
    123                          issmssh(cluster.name,cluster.login,cluster.port,launchcommand);
     122                        disp('launching solution sequence on remote cluster');
     123                        issmssh(cluster.name,cluster.login,cluster.port,launchcommand);
    124124
    125                  end %}}}
    126                  function Download(cluster,dirname,filelist)% {{{
     125                end %}}}
     126                function Download(cluster,dirname,filelist) % {{{
    127127
    128                          %copy files from cluster to current directory
    129                          directory=[cluster.executionpath '/' dirname '/'];
    130                          issmscpin(cluster.name,cluster.login,cluster.port,directory,filelist);
     128                        %copy files from cluster to current directory
     129                        directory=[cluster.executionpath '/' dirname '/'];
     130                        issmscpin(cluster.name,cluster.login,cluster.port,directory,filelist);
    131131
    132                  end %}}}
     132                end %}}}
    133133        end
    134134end
  • issm/trunk-jpl/src/m/classes/clusters/camhpc.m

    r22641 r26330  
    1 %PFE class definition
     1%CAMHPC cluster class definition
    22%
    33%   Usage:
     
    77
    88classdef camhpc
    9     properties (SetAccess=public) 
    10                  % {{{
    11                  name          = 'camhpc'
    12                  login         = '';
    13                  numnodes      = 20;
    14                  cpuspernode   = 8;
    15                  port          = 8000;
    16                  project       = '';
    17                  partition     = '';
    18                  codepath      = '';
    19                  executionpath = '';
    20                  interactive   = 0;
    21                  time          = 24*60;
    22                  memory        = 2;
    23          end
    24          %}}}
    25          methods
    26                  function cluster=camhpc(varargin) % {{{
     9        properties (SetAccess=public)
     10                % {{{
     11                name          = 'camhpc'
     12                login         = '';
     13                numnodes      = 20;
     14                cpuspernode   = 8;
     15                port          = 8000;
     16                project       = '';
     17                partition     = '';
     18                codepath      = '';
     19                executionpath = '';
     20                interactive   = 0;
     21                time          = 24*60;
     22                memory        = 2;
     23        end
     24        %}}}
     25        methods
     26                function cluster=camhpc(varargin) % {{{
    2727
    28                          %initialize cluster using default settings if provided
    29                          if (exist('camhpc_settings')==2), camhpc_settings; end
     28                        %initialize cluster using default settings if provided
     29                        if (exist('camhpc_settings')==2), camhpc_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('    project: %s',cluster.project));
    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('    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('    project: %s',cluster.project));
     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_queues={'ARNOLD-SL3-CPU'}; % Updated for csd3 NSA 28/3/18
    61                          queue_requirements_time=[Inf Inf];
    62                          queue_requirements_np=[80 80];
     60                        available_queues={'ARNOLD-SL3-CPU'}; % Updated for csd3 NSA 28/3/18
     61                        queue_requirements_time=[Inf Inf];
     62                        queue_requirements_np=[80 80];
    6363
    64                          QueueRequirements(available_queues,queue_requirements_time,queue_requirements_np,cluster.project,cluster.np,1)
     64                        QueueRequirements(available_queues,queue_requirements_time,queue_requirements_np,cluster.project,cluster.np,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
     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
    7070
    71                  end
    72                  %}}}
    73                  function BuildQueueScript(cluster,dirname,modelname,solution,io_gather,isvalgrind,isgprof,isdakota,isoceancoupling) % {{{
     71                end
     72                %}}}
     73                function BuildQueueScript(cluster,dirname,modelname,solution,io_gather,isvalgrind,isgprof,isdakota,isoceancoupling) % {{{
    7474
    75                          if(isvalgrind), disp('valgrind not supported by cluster, ignoring...'); end
    76                          if(isgprof),    disp('gprof not supported by cluster, ignoring...'); end
     75                        if(isvalgrind), disp('valgrind not supported by cluster, ignoring...'); end
     76                        if(isgprof),    disp('gprof not supported by cluster, ignoring...'); end
    7777
    78                          %write queuing script
    79              disp(modelname)
    80                          fid=fopen([modelname '.queue'],'w');
    81                          fprintf(fid,'#!/bin/bash\n');
    82                          fprintf(fid,'#SBATCH --job-name=%s\n',modelname);
    83                          fprintf(fid,'#SBATCH -p %s \n',cluster.partition);
    84                          fprintf(fid,'#SBATCH -A %s \n',cluster.project);
    85                          fprintf(fid,'#SBATCH --mail-type=ALL\n');
    86                          fprintf(fid,'#SBATCH -N %i -n %i\n',cluster.numnodes,cluster.cpuspernode);
    87                          fprintf(fid,'#SBATCH --time=%i\n',cluster.time*60) %walltime is in seconds.
    88                          fprintf(fid,'#SBATCH --mem-per-cpu=%igb\n',cluster.memory);
    89                          fprintf(fid,'#SBATCH -o %s.outlog \n',modelname);
    90                          fprintf(fid,'#SBATCH -e %s.errlog \n\n',modelname);
    91                          fprintf(fid,'export ISSM_DIR="%s/../"\n',cluster.codepath); %FIXME
    92                          fprintf(fid,'source $ISSM_DIR/etc/environment.sh\n');       %FIXME
    93                          fprintf(fid,'cd %s/%s\n\n',cluster.executionpath,dirname);
    94                          fprintf(fid,'mpirun -np %i %s/issm.exe %s %s %s\n',cluster.np,cluster.codepath,solution,[cluster.executionpath '/' dirname],modelname);
    95                          if ~io_gather, %concatenate the output files:
    96                                  fprintf(fid,'cat %s.outbin.* > %s.outbin',modelname,modelname);
    97                          end
    98                          fclose(fid);
     78                        %write queuing script
     79                        disp(modelname)
     80                        fid=fopen([modelname '.queue'],'w');
     81                        fprintf(fid,'#!/bin/bash\n');
     82                        fprintf(fid,'#SBATCH --job-name=%s\n',modelname);
     83                        fprintf(fid,'#SBATCH -p %s \n',cluster.partition);
     84                        fprintf(fid,'#SBATCH -A %s \n',cluster.project);
     85                        fprintf(fid,'#SBATCH --mail-type=ALL\n');
     86                        fprintf(fid,'#SBATCH -N %i -n %i\n',cluster.numnodes,cluster.cpuspernode);
     87                        fprintf(fid,'#SBATCH --time=%i\n',cluster.time*60) %walltime is in seconds.
     88                        fprintf(fid,'#SBATCH --mem-per-cpu=%igb\n',cluster.memory);
     89                        fprintf(fid,'#SBATCH -o %s.outlog \n',modelname);
     90                        fprintf(fid,'#SBATCH -e %s.errlog \n\n',modelname);
     91                        fprintf(fid,'export ISSM_DIR="%s/../"\n',cluster.codepath); %FIXME
     92                        fprintf(fid,'source $ISSM_DIR/etc/environment.sh\n');       %FIXME
     93                        fprintf(fid,'cd %s/%s\n\n',cluster.executionpath,dirname);
     94                        fprintf(fid,'mpirun -np %i %s/issm.exe %s %s %s\n',cluster.np,cluster.codepath,solution,[cluster.executionpath '/' dirname],modelname);
     95                        if ~io_gather, %concatenate the output files:
     96                                fprintf(fid,'cat %s.outbin.* > %s.outbin',modelname,modelname);
     97                        end
     98                        fclose(fid);
    9999
    100                          %in interactive mode, create a run file, and errlog and outlog file
    101                          if cluster.interactive,
    102                                  fid=fopen([modelname '.run'],'w');
    103                                  fprintf(fid,'mpirun -np %i %s/issm.exe %s %s %s\n',cluster.np,cluster.codepath,solution,[cluster.executionpath '/' dirname],modelname);
    104                                  if ~io_gather, %concatenate the output files:
    105                                          fprintf(fid,'cat %s.outbin.* > %s.outbin',modelname,modelname);
    106                                  end
    107                                  fclose(fid);
    108                                  fid=fopen([modelname '.errlog'],'w');
    109                                  fclose(fid);
    110                                  fid=fopen([modelname '.outlog'],'w');
    111                                  fclose(fid);
    112                          end
    113                  end %}}}
    114                  function UploadQueueJob(cluster,modelname,dirname,filelist)% {{{
     100                        %in interactive mode, create a run file, and errlog and outlog file
     101                        if cluster.interactive,
     102                                fid=fopen([modelname '.run'],'w');
     103                                fprintf(fid,'mpirun -np %i %s/issm.exe %s %s %s\n',cluster.np,cluster.codepath,solution,[cluster.executionpath '/' dirname],modelname);
     104                                if ~io_gather, %concatenate the output files:
     105                                        fprintf(fid,'cat %s.outbin.* > %s.outbin',modelname,modelname);
     106                                end
     107                                fclose(fid);
     108                                fid=fopen([modelname '.errlog'],'w');
     109                                fclose(fid);
     110                                fid=fopen([modelname '.outlog'],'w');
     111                                fclose(fid);
     112                        end
     113                end %}}}
     114                function UploadQueueJob(cluster,modelname,dirname,filelist) % {{{
    115115
    116                          %compress the files into one zip.
    117                          compressstring=['tar -zcf ' dirname '.tar.gz '];
    118                          for i=1:numel(filelist),
    119                                  compressstring = [compressstring ' ' filelist{i}];
    120                          end
    121                          if cluster.interactive,
    122                                  compressstring = [compressstring ' ' modelname '.errlog ' modelname '.outlog '];
    123                          end
    124                          system(compressstring);
     116                        %compress the files into one zip.
     117                        compressstring=['tar -zcf ' dirname '.tar.gz '];
     118                        for i=1:numel(filelist),
     119                                compressstring = [compressstring ' ' filelist{i}];
     120                        end
     121                        if cluster.interactive,
     122                                compressstring = [compressstring ' ' modelname '.errlog ' modelname '.outlog '];
     123                        end
     124                        system(compressstring);
    125125
    126                          disp('uploading input file and queueing script');
    127                          issmscpout(cluster.name,cluster.executionpath,cluster.login,cluster.port,{[dirname '.tar.gz']});
     126                        disp('uploading input file and queueing script');
     127                        issmscpout(cluster.name,cluster.executionpath,cluster.login,cluster.port,{[dirname '.tar.gz']});
    128128
    129                  end %}}}
    130                  function LaunchQueueJob(cluster,modelname,dirname,filelist,restart,batch)% {{{
     129                end %}}}
     130                function LaunchQueueJob(cluster,modelname,dirname,filelist,restart,batch) % {{{
    131131
    132                          disp('launching solution sequence on remote cluster');
     132                        disp('launching solution sequence on remote cluster');
    133133             %
    134134             % qsub replaced by sbatch for csd3 system NSA 28/3/18
    135                          if ~isempty(restart)
    136                                  launchcommand=['cd ' cluster.executionpath ' && cd ' dirname ' && hostname && qsub ' modelname '.queue '];
    137                          else
    138                                  launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' dirname ' && mkdir ' dirname ...
    139                                          ' && cd ' dirname ' && mv ../' dirname '.tar.gz ./ && tar -zxf ' dirname '.tar.gz  && hostname && sbatch ' modelname '.queue '];
    140                          end
    141                          issmssh(cluster.name,cluster.login,cluster.port,launchcommand);
    142                  end %}}}
    143                  function Download(cluster,dirname,filelist)% {{{
     135                        if ~isempty(restart)
     136                                launchcommand=['cd ' cluster.executionpath ' && cd ' dirname ' && hostname && qsub ' modelname '.queue '];
     137                        else
     138                                launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' dirname ' && mkdir ' dirname ...
     139                                        ' && cd ' dirname ' && mv ../' dirname '.tar.gz ./ && tar -zxf ' dirname '.tar.gz  && hostname && sbatch ' modelname '.queue '];
     140                        end
     141                        issmssh(cluster.name,cluster.login,cluster.port,launchcommand);
     142                end %}}}
     143                function Download(cluster,dirname,filelist) % {{{
    144144
    145                          %copy files from cluster to current directory
    146                          directory=[cluster.executionpath '/' dirname '/'];
    147                          issmscpin(cluster.name,cluster.login,cluster.port,directory,filelist);
     145                        %copy files from cluster to current directory
     146                        directory=[cluster.executionpath '/' dirname '/'];
     147                        issmscpin(cluster.name,cluster.login,cluster.port,directory,filelist);
    148148
    149                  end %}}}
     149                end %}}}
    150150        end
    151151end
  • issm/trunk-jpl/src/m/classes/clusters/discover.m

    r25018 r26330  
    1 %PFE class definition
     1%DISCOVER cluster class definition
    22%
    33%   Usage:
     
    66%      cluster=discover('np',3,'login','username');
    77
    8 classdef discover 
    9     properties (SetAccess=public) 
    10                  % {{{
    11                  name=oshostname();
    12                  login='';
    13                  modules        = {};
    14                  numnodes=20;
    15                  cpuspernode=8;
    16                  port=0;
    17                  queue='general';
    18                  time=12*60*60;
    19                  processor='west';
    20                  codepath='';
    21                  executionpath='';
    22                  interactive=0;
    23                  bbftp=0;
    24                  numstreams=8;
    25                  hyperthreading=0;
    26                  email='';
    27          end
    28          %}}}
    29          methods
    30                  function cluster=discover(varargin) % {{{
    31 
    32                          %initialize cluster using default settings if provided
    33                          if (exist('discover_settings')==2), discover_settings; end
    34 
    35                          %use provided options to change fields
    36                          cluster=AssignObjectFields(pairoptions(varargin{:}),cluster);
    37                  end
    38                  %}}}
    39                  function disp(cluster) % {{{
    40                          %  display the object
    41                          disp(sprintf('class ''%s'' object ''%s'' = ',class(cluster),inputname(1)));
    42                          disp(sprintf('    name: %s',cluster.name));
    43                          disp(sprintf('    login: %s',cluster.login));
    44                          disp(sprintf('    modules: %s',strjoin(cluster.modules,', ')));
    45                          disp(sprintf('    port: %i',cluster.port));
    46                          disp(sprintf('    numnodes: %i',cluster.numnodes));
    47                          disp(sprintf('    cpuspernode: %i',cluster.cpuspernode));
    48                          disp(sprintf('    np: %i',cluster.cpuspernode*cluster.numnodes));
    49                          disp(sprintf('    queue: %s',cluster.queue));
    50                          disp(sprintf('    time: %i',cluster.time));
    51                          disp(sprintf('    processor: %s',cluster.processor));
    52                          disp(sprintf('    codepath: %s',cluster.codepath));
    53                          disp(sprintf('    executionpath: %s',cluster.executionpath));
    54                          disp(sprintf('    interactive: %i',cluster.interactive));
    55                          disp(sprintf('    hyperthreading: %i',cluster.hyperthreading));
    56                          disp(sprintf('    email: %s',cluster.email));
    57                  end
    58                  %}}}
    59                  function numprocs=np(cluster) % {{{
    60                          %compute number of processors
    61                          numprocs=cluster.numnodes*cluster.cpuspernode;
    62                  end
    63                  %}}}
    64                  function md = checkconsistency(cluster,md,solution,analyses) % {{{
    65 
    66                          available_queues={'long','allnccs','debug'};
    67                          queue_requirements_time=[24*60*60 12*60*60 1*60*60];
    68                          queue_requirements_np=[560 6000 532];
    69 
    70                          QueueRequirements(available_queues,queue_requirements_time,queue_requirements_np,cluster.queue,cluster.np,cluster.time)
    71 
    72                          %now, check cluster.cpuspernode according to processor type
    73                          if ( strcmpi(cluster.processor,'sand')),
    74                                  if ((cluster.cpuspernode>16 ) | (cluster.cpuspernode<1)),
    75                                          md = checkmessage(md,'cpuspernode should be between 1 and 16 for ''sand'' processors');
    76                                  end
    77                          elseif strcmpi(cluster.processor,'hasw'),
    78                                  if ((cluster.cpuspernode>28 ) | (cluster.cpuspernode<1)),
    79                                          md = checkmessage(md,'cpuspernode should be between 1 and 28 for ''hasw'' processors');
    80                                  end
    81                          else
    82                                  md = checkmessage(md,'unknown processor type, should be ''sand'' or ''hasw'' ');
    83                          end
    84 
    85                          %Miscelaneous
    86                          if isempty(cluster.login), md = checkmessage(md,'login empty'); end
    87                          if isempty(cluster.codepath), md = checkmessage(md,'codepath empty'); end
    88                          if isempty(cluster.executionpath), md = checkmessage(md,'executionpath empty'); end
    89 
    90                  end
    91                  %}}}
    92                  function BuildQueueScript(cluster,dirname,modelname,solution,io_gather,isvalgrind,isgprof,isdakota,isoceancoupling) % {{{
    93 
    94                          if(isgprof),    disp('gprof not supported by cluster, ignoring...'); end
    95 
    96                          executable='issm.exe';
    97                          if isdakota,
    98                                  version=IssmConfig('_DAKOTA_VERSION_'); version=str2num(version(1:3));
    99                                  if (version>=6),
    100                                          executable='issm_dakota.exe';
    101                                  end
    102                          end
    103                          if isoceancoupling,
    104                                  executable='issm_ocean.exe';
    105                          end
    106 
    107                          %write queuing script
    108                          fid=fopen([modelname '.queue'],'w');
    109 
    110                          fprintf(fid,'#!/bin/bash\n');
    111                          fprintf(fid,'#SBATCH -J %s \n',modelname);
    112                          fprintf(fid,'#SBATCH --qos=%s \n',cluster.queue);
    113                          fprintf(fid,'#SBATCH -o %s.outlog \n',modelname);
    114                          fprintf(fid,'#SBATCH -e %s.errlog \n',modelname);
    115                          fprintf(fid,'#SBATCH -n %i \n',cluster.numnodes*cluster.cpuspernode);
    116                          fprintf(fid,'#SBATCH -N %i \n',cluster.numnodes);
    117                          fprintf(fid,'#SBATCH -t %02i:%02i:00 \n',floor(cluster.time/3600),floor(mod(cluster.time,3600)/60));
    118                          fprintf(fid,'#SBATCH -A s1690 \n\n');
    119                          for i=1:numel(cluster.modules),
    120                                  fprintf(fid,['module load ' cluster.modules{i} '\n']);
    121                          end
    122                          if length(find(cluster.email=='@'))>0
    123                                  fprintf(fid,'#SBATCH --mail-user=%s \n',cluster.email);
    124                                  fprintf(fid,'#SBATCH --mail-type=end \n\n');
    125                          end
    126                          fprintf(fid,'. /usr/share/modules/init/bash\n\n');
    127                          fprintf(fid,'module load comp/intel/20.0.0.166\n');
    128                          fprintf(fid,'module load mpi/sgi-mpt/2.17\n');
    129                          fprintf(fid,'module load cmake/3.17.0\n');
    130                          fprintf(fid,'export MPI_GROUP_MAX=64\n\n');
    131                          fprintf(fid,'export MPI_UNBUFFERED_STDIO=true\n\n');
    132                          fprintf(fid,'export PATH="$PATH:."\n\n');
    133                          fprintf(fid,'export ISSM_DIR="%s/../"\n',cluster.codepath); %FIXME
    134                          fprintf(fid,'source $ISSM_DIR/etc/environment.sh\n');       %FIXME
    135                          fprintf(fid,'cd %s/%s\n\n',cluster.executionpath,dirname);
    136 
    137                          fprintf(fid,'mpiexec -np %i %s/%s %s %s %s\n',cluster.np,cluster.codepath,executable,solution,[cluster.executionpath '/' dirname],modelname);
    138                          if ~io_gather, %concatenate the output files:
    139                                  fprintf(fid,'cat %s.outbin.* > %s.outbin',modelname,modelname);
    140                          end
    141                          fclose(fid);
    142 
    143                          %in interactive mode, create a run file, and errlog and outlog file
    144                          if cluster.interactive,
    145                                  fid=fopen([modelname '.run'],'w');
    146                                  if ~isvalgrind,
    147                                          fprintf(fid,'mpiexec -np %i %s/%s %s %s %s\n',cluster.np,cluster.codepath,executable,solution,[cluster.executionpath '/' dirname],modelname);
    148                                  else
    149                                          fprintf(fid,'mpiexec -np %i valgrind --leak-check=full %s/%s %s %s %s\n',cluster.np,cluster.codepath,executable,solution,[cluster.executionpath '/' dirname],modelname);
    150                                  end
    151                                  if ~io_gather, %concatenate the output files:
    152                                          fprintf(fid,'cat %s.outbin.* > %s.outbin',modelname,modelname);
    153                                  end
    154                                  fclose(fid);
    155                                  fid=fopen([modelname '.errlog'],'w');
    156                                  fclose(fid);
    157                                  fid=fopen([modelname '.outlog'],'w');
    158                                  fclose(fid);
    159                          end
    160                  end %}}}
    161                  function UploadQueueJob(cluster,modelname,dirname,filelist)% {{{
    162 
    163                          %compress the files into one zip.
    164                          compressstring=['tar -zcf ' dirname '.tar.gz '];
    165                          for i=1:numel(filelist),
    166                                  compressstring = [compressstring ' ' filelist{i}];
    167                          end
    168                          if cluster.interactive,
    169                                  compressstring = [compressstring ' ' modelname '.run '  modelname '.errlog ' modelname '.outlog '];
    170                          end
    171                          system(compressstring);
    172 
    173                          disp('uploading input file and queueing script');
    174                          if cluster.interactive,
    175                                  directory=[cluster.executionpath '/Interactive' num2str(cluster.interactive)];
    176                          else
    177                                  directory=cluster.executionpath;
    178                          end
    179 
    180                          if ~cluster.bbftp,
    181                                  issmscpout(cluster.name,directory,cluster.login,cluster.port,{[dirname '.tar.gz']});
    182                          else
    183                                  issmbbftpout(cluster.name,directory,cluster.login,cluster.port,cluster.numstreams,{[dirname '.tar.gz']});
    184                          end
    185 
    186                  end
    187                  %}}}
    188                  function LaunchQueueJob(cluster,modelname,dirname,filelist,restart,batch)% {{{
    189 
    190                          if ~cluster.interactive,
    191                                  if ~isempty(restart)
    192                                          launchcommand=['cd ' cluster.executionpath ' && cd ' dirname ' && sbatch ' modelname '.queue '];
    193                                  else
    194                                          launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' dirname ' && mkdir ' dirname ...
    195                                                  ' && cd ' dirname ' && mv ../' dirname '.tar.gz ./ && tar -zxf ' dirname '.tar.gz  && sbatch ' modelname '.queue '];
    196                                  end
    197                          else
    198                                  if ~isempty(restart)
    199                                          launchcommand=['cd ' cluster.executionpath '/Interactive' num2str(cluster.interactive)];
    200                                  else
    201                                          launchcommand=['cd ' cluster.executionpath '/Interactive' num2str(cluster.interactive) ' && tar -zxf ' dirname '.tar.gz'];
    202                                  end
    203                          end
    204 
    205                          disp('launching solution sequence on remote cluster');
    206                          issmssh(cluster.name,cluster.login,cluster.port,launchcommand);
    207                  end
    208                  %}}}
    209                  function Download(cluster,dirname,filelist)% {{{
    210 
    211                          %copy files from cluster to current directory
    212                          if ~cluster.interactive,
    213                                  directory=[cluster.executionpath '/' dirname '/'];
    214                          else
    215                                  directory=[cluster.executionpath '/Interactive' num2str(cluster.interactive) '/'];
    216                          end
    217 
    218                          if ~cluster.bbftp,
    219                                  issmscpin(cluster.name,cluster.login,cluster.port,directory,filelist);
    220                          else
    221                                  issmbbftpin(cluster.name, cluster.login, cluster.port, cluster.numstreams, directory, filelist);
    222                          end
    223 
    224                  end %}}}
     8classdef discover
     9        properties (SetAccess=public)
     10                % {{{
     11                name=oshostname();
     12                login='';
     13                modules        = {};
     14                numnodes=20;
     15                cpuspernode=8;
     16                port=0;
     17                queue='general';
     18                time=12*60*60;
     19                processor='west';
     20                codepath='';
     21                executionpath='';
     22                interactive=0;
     23                bbftp=0;
     24                numstreams=8;
     25                hyperthreading=0;
     26                email='';
     27        end
     28        %}}}
     29        methods
     30                function cluster=discover(varargin) % {{{
     31
     32                        %initialize cluster using default settings if provided
     33                        if (exist('discover_settings')==2), discover_settings; end
     34
     35                        %use provided options to change fields
     36                        cluster=AssignObjectFields(pairoptions(varargin{:}),cluster);
     37                end
     38                %}}}
     39                function disp(cluster) % {{{
     40                        %  display the object
     41                        disp(sprintf('class ''%s'' object ''%s'' = ',class(cluster),inputname(1)));
     42                        disp(sprintf('    name: %s',cluster.name));
     43                        disp(sprintf('    login: %s',cluster.login));
     44                        disp(sprintf('    modules: %s',strjoin(cluster.modules,', ')));
     45                        disp(sprintf('    port: %i',cluster.port));
     46                        disp(sprintf('    numnodes: %i',cluster.numnodes));
     47                        disp(sprintf('    cpuspernode: %i',cluster.cpuspernode));
     48                        disp(sprintf('    np: %i',cluster.cpuspernode*cluster.numnodes));
     49                        disp(sprintf('    queue: %s',cluster.queue));
     50                        disp(sprintf('    time: %i',cluster.time));
     51                        disp(sprintf('    processor: %s',cluster.processor));
     52                        disp(sprintf('    codepath: %s',cluster.codepath));
     53                        disp(sprintf('    executionpath: %s',cluster.executionpath));
     54                        disp(sprintf('    interactive: %i',cluster.interactive));
     55                        disp(sprintf('    hyperthreading: %i',cluster.hyperthreading));
     56                        disp(sprintf('    email: %s',cluster.email));
     57                end
     58                %}}}
     59                function numprocs=nprocs(cluster) % {{{
     60                        %compute number of processors
     61                        numprocs=cluster.numnodes*cluster.cpuspernode;
     62                end
     63                %}}}
     64                function md = checkconsistency(cluster,md,solution,analyses) % {{{
     65
     66                        available_queues={'long','allnccs','debug'};
     67                        queue_requirements_time=[24*60*60 12*60*60 1*60*60];
     68                        queue_requirements_np=[560 6000 532];
     69
     70                        QueueRequirements(available_queues,queue_requirements_time,queue_requirements_np,cluster.queue,cluster.np,cluster.time)
     71
     72                        %now, check cluster.cpuspernode according to processor type
     73                        if ( strcmpi(cluster.processor,'sand')),
     74                                if ((cluster.cpuspernode>16 ) | (cluster.cpuspernode<1)),
     75                                        md = checkmessage(md,'cpuspernode should be between 1 and 16 for ''sand'' processors');
     76                                end
     77                        elseif strcmpi(cluster.processor,'hasw'),
     78                                if ((cluster.cpuspernode>28 ) | (cluster.cpuspernode<1)),
     79                                        md = checkmessage(md,'cpuspernode should be between 1 and 28 for ''hasw'' processors');
     80                                end
     81                        else
     82                                md = checkmessage(md,'unknown processor type, should be ''sand'' or ''hasw'' ');
     83                        end
     84
     85                        %Miscelaneous
     86                        if isempty(cluster.login), md = checkmessage(md,'login empty'); end
     87                        if isempty(cluster.codepath), md = checkmessage(md,'codepath empty'); end
     88                        if isempty(cluster.executionpath), md = checkmessage(md,'executionpath empty'); end
     89
     90                end
     91                %}}}
     92                function BuildQueueScript(cluster,dirname,modelname,solution,io_gather,isvalgrind,isgprof,isdakota,isoceancoupling) % {{{
     93
     94                        if(isgprof),    disp('gprof not supported by cluster, ignoring...'); end
     95
     96                        executable='issm.exe';
     97                        if isdakota,
     98                                version=IssmConfig('_DAKOTA_VERSION_'); version=str2num(version(1:3));
     99                                if (version>=6),
     100                                        executable='issm_dakota.exe';
     101                                end
     102                        end
     103                        if isoceancoupling,
     104                                executable='issm_ocean.exe';
     105                        end
     106
     107                        %write queuing script
     108                        fid=fopen([modelname '.queue'],'w');
     109
     110                        fprintf(fid,'#!/bin/bash\n');
     111                        fprintf(fid,'#SBATCH -J %s \n',modelname);
     112                        fprintf(fid,'#SBATCH --qos=%s \n',cluster.queue);
     113                        fprintf(fid,'#SBATCH -o %s.outlog \n',modelname);
     114                        fprintf(fid,'#SBATCH -e %s.errlog \n',modelname);
     115                        fprintf(fid,'#SBATCH -n %i \n',cluster.numnodes*cluster.cpuspernode);
     116                        fprintf(fid,'#SBATCH -N %i \n',cluster.numnodes);
     117                        fprintf(fid,'#SBATCH -t %02i:%02i:00 \n',floor(cluster.time/3600),floor(mod(cluster.time,3600)/60));
     118                        fprintf(fid,'#SBATCH -A s1690 \n\n');
     119                        for i=1:numel(cluster.modules),
     120                                fprintf(fid,['module load ' cluster.modules{i} '\n']);
     121                        end
     122                        if length(find(cluster.email=='@'))>0
     123                                fprintf(fid,'#SBATCH --mail-user=%s \n',cluster.email);
     124                                fprintf(fid,'#SBATCH --mail-type=end \n\n');
     125                        end
     126                        fprintf(fid,'. /usr/share/modules/init/bash\n\n');
     127                        fprintf(fid,'module load comp/intel/20.0.0.166\n');
     128                        fprintf(fid,'module load mpi/sgi-mpt/2.17\n');
     129                        fprintf(fid,'module load cmake/3.17.0\n');
     130                        fprintf(fid,'export MPI_GROUP_MAX=64\n\n');
     131                        fprintf(fid,'export MPI_UNBUFFERED_STDIO=true\n\n');
     132                        fprintf(fid,'export PATH="$PATH:."\n\n');
     133                        fprintf(fid,'export ISSM_DIR="%s/../"\n',cluster.codepath); %FIXME
     134                        fprintf(fid,'source $ISSM_DIR/etc/environment.sh\n');       %FIXME
     135                        fprintf(fid,'cd %s/%s\n\n',cluster.executionpath,dirname);
     136
     137                        fprintf(fid,'mpiexec -np %i %s/%s %s %s %s\n',cluster.np,cluster.codepath,executable,solution,[cluster.executionpath '/' dirname],modelname);
     138                        if ~io_gather, %concatenate the output files:
     139                                fprintf(fid,'cat %s.outbin.* > %s.outbin',modelname,modelname);
     140                        end
     141                        fclose(fid);
     142
     143                        %in interactive mode, create a run file, and errlog and outlog file
     144                        if cluster.interactive,
     145                                fid=fopen([modelname '.run'],'w');
     146                                if ~isvalgrind,
     147                                        fprintf(fid,'mpiexec -np %i %s/%s %s %s %s\n',cluster.np,cluster.codepath,executable,solution,[cluster.executionpath '/' dirname],modelname);
     148                                else
     149                                        fprintf(fid,'mpiexec -np %i valgrind --leak-check=full %s/%s %s %s %s\n',cluster.np,cluster.codepath,executable,solution,[cluster.executionpath '/' dirname],modelname);
     150                                end
     151                                if ~io_gather, %concatenate the output files:
     152                                        fprintf(fid,'cat %s.outbin.* > %s.outbin',modelname,modelname);
     153                                end
     154                                fclose(fid);
     155                                fid=fopen([modelname '.errlog'],'w');
     156                                fclose(fid);
     157                                fid=fopen([modelname '.outlog'],'w');
     158                                fclose(fid);
     159                        end
     160                end %}}}
     161                function UploadQueueJob(cluster,modelname,dirname,filelist) % {{{
     162
     163                        %compress the files into one zip.
     164                        compressstring=['tar -zcf ' dirname '.tar.gz '];
     165                        for i=1:numel(filelist),
     166                                compressstring = [compressstring ' ' filelist{i}];
     167                        end
     168                        if cluster.interactive,
     169                                compressstring = [compressstring ' ' modelname '.run '  modelname '.errlog ' modelname '.outlog '];
     170                        end
     171                        system(compressstring);
     172
     173                        disp('uploading input file and queueing script');
     174                        if cluster.interactive,
     175                                directory=[cluster.executionpath '/Interactive' num2str(cluster.interactive)];
     176                        else
     177                                directory=cluster.executionpath;
     178                        end
     179
     180                        if ~cluster.bbftp,
     181                                issmscpout(cluster.name,directory,cluster.login,cluster.port,{[dirname '.tar.gz']});
     182                        else
     183                                issmbbftpout(cluster.name,directory,cluster.login,cluster.port,cluster.numstreams,{[dirname '.tar.gz']});
     184                        end
     185
     186                end
     187                %}}}
     188                function LaunchQueueJob(cluster,modelname,dirname,filelist,restart,batch) % {{{
     189
     190                        if ~cluster.interactive,
     191                                if ~isempty(restart)
     192                                        launchcommand=['cd ' cluster.executionpath ' && cd ' dirname ' && sbatch ' modelname '.queue '];
     193                                else
     194                                        launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' dirname ' && mkdir ' dirname ...
     195                                                ' && cd ' dirname ' && mv ../' dirname '.tar.gz ./ && tar -zxf ' dirname '.tar.gz  && sbatch ' modelname '.queue '];
     196                                end
     197                        else
     198                                if ~isempty(restart)
     199                                        launchcommand=['cd ' cluster.executionpath '/Interactive' num2str(cluster.interactive)];
     200                                else
     201                                        launchcommand=['cd ' cluster.executionpath '/Interactive' num2str(cluster.interactive) ' && tar -zxf ' dirname '.tar.gz'];
     202                                end
     203                        end
     204
     205                        disp('launching solution sequence on remote cluster');
     206                        issmssh(cluster.name,cluster.login,cluster.port,launchcommand);
     207                end
     208                %}}}
     209                function Download(cluster,dirname,filelist) % {{{
     210
     211                        %copy files from cluster to current directory
     212                        if ~cluster.interactive,
     213                                directory=[cluster.executionpath '/' dirname '/'];
     214                        else
     215                                directory=[cluster.executionpath '/Interactive' num2str(cluster.interactive) '/'];
     216                        end
     217
     218                        if ~cluster.bbftp,
     219                                issmscpin(cluster.name,cluster.login,cluster.port,directory,filelist);
     220                        else
     221                                issmbbftpin(cluster.name, cluster.login, cluster.port, cluster.numstreams, directory, filelist);
     222                        end
     223
     224                end %}}}
    225225        end
    226226end
  • issm/trunk-jpl/src/m/classes/clusters/generic.m

    r26168 r26330  
    286286                end
    287287                %}}}
    288                 function UploadQueueJob(cluster,modelname,dirname,filelist)% {{{
     288                function UploadQueueJob(cluster,modelname,dirname,filelist) % {{{
    289289
    290290                        if ~ispc,
     
    307307                        end
    308308                end %}}}
    309                 function LaunchQueueJob(cluster,modelname,dirname,filelist,restart,batch)% {{{
     309                function LaunchQueueJob(cluster,modelname,dirname,filelist,restart,batch) % {{{
    310310
    311311                        if ~ispc,
     
    336336
    337337                end %}}}
    338                 function LaunchQueueJobIceOcean(cluster,modelname,dirname,filelist,restart,batch)% {{{
     338                function LaunchQueueJobIceOcean(cluster,modelname,dirname,filelist,restart,batch) % {{{
    339339
    340340                        if ~ispc,
     
    365365
    366366                end %}}}
    367                 function Download(cluster,dirname,filelist)% {{{
     367                function Download(cluster,dirname,filelist) % {{{
    368368
    369369                        if ispc(),
  • issm/trunk-jpl/src/m/classes/clusters/generic.py

    r26184 r26330  
    44import numpy as np
    55
     6from fielddisplay import fielddisplay
    67try:
    78    from generic_settings import generic_settings
     
    3940        self.shell = '/bin/sh'
    4041
    41         #use provided options to change fields
     42        # Use provided options to change fields
    4243        options = pairoptions(*args)
    4344
    44         #get name
     45        # Get name
    4546        self.name = gethostname()
    4647
    47         #initialize cluster using user settings if provided
    48 
     48        # Initialize cluster using user settings if provided
    4949        try:
    5050            self = generic_settings(self)
    5151        except NameError:
    52             print("generic_settings.py not found, using default settings")
    53 
    54         #OK get other fields
     52            print('generic_settings.py not found, using default settings')
     53
     54        # OK get other fields
    5555        self = options.AssignObjectFields(self)
    5656    # }}}
     
    5959        #  display the object
    6060        s = "class '%s' object '%s' = \n" % (type(self), 'self')
    61         s += "    name: %s\n" % self.name
    62         s += "    login: %s\n" % self.login
    63         s += "    np: %i\n" % self.np
    64         s += "    port: %i\n" % self.port
    65         s += "    codepath: %s\n" % self.codepath
    66         s += "    executionpath: %s\n" % self.executionpath
    67         s += "    valgrind: %s\n" % self.valgrind
    68         s += "    valgrindlib: %s\n" % self.valgrindlib
    69         s += "    valgrindsup: %s\n" % self.valgrindsup
    70         s += "    verbose: %s\n" % self.verbose
    71         s += "    shell: %s\n" % self.shell
     61        s += '{}\n'.format(fielddisplay(self, 'name', ''))
     62        s += '{}\n'.format(fielddisplay(self, 'login', ''))
     63        s += '{}\n'.format(fielddisplay(self, 'np', ''))
     64        s += '{}\n'.format(fielddisplay(self, 'port', ''))
     65        s += '{}\n'.format(fielddisplay(self, 'codepath', ''))
     66        s += '{}\n'.format(fielddisplay(self, 'executionpath', ''))
     67        s += '{}\n'.format(fielddisplay(self, 'valgrind', ''))
     68        s += '{}\n'.format(fielddisplay(self, 'valgrindlib', ''))
     69        s += '{}\n'.format(fielddisplay(self, 'valgrindsup', ''))
     70        s += '{}\n'.format(fielddisplay(self, 'verbose', ''))
     71        s += '{}\n'.format(fielddisplay(self, 'shell', ''))
    7272        return s
    7373    # }}}
  • issm/trunk-jpl/src/m/classes/clusters/greenplanet.m

    r25871 r26330  
    1 %PFE class definition
     1%GREENPLANET cluster class definition
    22%
    33%   Usage:
     
    77
    88classdef greenplanet
    9     properties (SetAccess=public) 
    10                  % {{{
    11                  name          = 'greenplanet'
    12                  login         = '';
    13                  numnodes      = 20;
    14                  cpuspernode   = 8;
    15                  port          = 8000;
    16                  queue         = 'c6145';
    17                  codepath      = '';
    18                  executionpath = '';
    19                  interactive   = 0;
    20                  time          = 24*60;
    21                  memory        = 2;
    22          end
    23          %}}}
    24          methods
    25                  function cluster=greenplanet(varargin) % {{{
     9        properties (SetAccess=public)
     10                % {{{
     11                name          = 'greenplanet'
     12                login         = '';
     13                numnodes      = 20;
     14                cpuspernode   = 8;
     15                port          = 8000;
     16                queue         = 'c6145';
     17                codepath      = '';
     18                executionpath = '';
     19                interactive   = 0;
     20                time          = 24*60;
     21                memory        = 2;
     22        end
     23        %}}}
     24        methods
     25                function cluster=greenplanet(varargin) % {{{
    2626
    27                          %initialize cluster using default settings if provided
    28                          if (exist('greenplanet_settings')==2), greenplanet_settings; end
     27                        %initialize cluster using default settings if provided
     28                        if (exist('greenplanet_settings')==2), greenplanet_settings; end
    2929
    30                          %use provided options to change fields
    31                          cluster=AssignObjectFields(pairoptions(varargin{:}),cluster);
    32                  end
    33                  %}}}
    34                  function disp(cluster) % {{{
    35                          %  display the object
    36                          disp(sprintf('class ''%s'' object ''%s'' = ',class(cluster),inputname(1)));
    37                          disp(sprintf('    name: %s',cluster.name));
    38                          disp(sprintf('    login: %s',cluster.login));
    39                          disp(sprintf('    port: %i',cluster.port));
    40                          disp(sprintf('    numnodes: %i',cluster.numnodes));
    41                          disp(sprintf('    cpuspernode: %i',cluster.cpuspernode));
    42                          disp(sprintf('    np: %i',cluster.cpuspernode*cluster.numnodes));
    43                          disp(sprintf('    queue: %s',cluster.queue));
    44                          disp(sprintf('    codepath: %s',cluster.codepath));
    45                          disp(sprintf('    executionpath: %s',cluster.executionpath));
    46                          disp(sprintf('    interactive: %i',cluster.interactive));
    47                          disp(sprintf('    time: %i',cluster.time));
    48                          disp(sprintf('    memory: %i',cluster.memory));
    49                  end
    50                  %}}}
    51                  function numprocs=np(cluster) % {{{
    52                          %compute number of processors
    53                          numprocs=cluster.numnodes*cluster.cpuspernode;
    54                  end
    55                  %}}}
    56                  function md = checkconsistency(cluster,md,solution,analyses) % {{{
     30                        %use provided options to change fields
     31                        cluster=AssignObjectFields(pairoptions(varargin{:}),cluster);
     32                end
     33                %}}}
     34                function disp(cluster) % {{{
     35                        %  display the object
     36                        disp(sprintf('class ''%s'' object ''%s'' = ',class(cluster),inputname(1)));
     37                        disp(sprintf('    name: %s',cluster.name));
     38                        disp(sprintf('    login: %s',cluster.login));
     39                        disp(sprintf('    port: %i',cluster.port));
     40                        disp(sprintf('    numnodes: %i',cluster.numnodes));
     41                        disp(sprintf('    cpuspernode: %i',cluster.cpuspernode));
     42                        disp(sprintf('    np: %i',cluster.cpuspernode*cluster.numnodes));
     43                        disp(sprintf('    queue: %s',cluster.queue));
     44                        disp(sprintf('    codepath: %s',cluster.codepath));
     45                        disp(sprintf('    executionpath: %s',cluster.executionpath));
     46                        disp(sprintf('    interactive: %i',cluster.interactive));
     47                        disp(sprintf('    time: %i',cluster.time));
     48                        disp(sprintf('    memory: %i',cluster.memory));
     49                end
     50                %}}}
     51                function numprocs=nprocs(cluster) % {{{
     52                        %compute number of processors
     53                        numprocs=cluster.numnodes*cluster.cpuspernode;
     54                end
     55                %}}}
     56                function md = checkconsistency(cluster,md,solution,analyses) % {{{
    5757
    58                          available_queues={'brd2.4','has2.5','ilg2.3','m-c1.9','m-c2.2','nes2.8','sib2.9','m2090','default'};
    59                          queue_requirements_time=[Inf Inf Inf Inf Inf Inf Inf Inf Inf];
    60                          queue_requirements_np=[80 80 80 80 80 80 80 80 80];
     58                        available_queues={'brd2.4','has2.5','ilg2.3','m-c1.9','m-c2.2','nes2.8','sib2.9','m2090','default'};
     59                        queue_requirements_time=[Inf Inf Inf Inf Inf Inf Inf Inf Inf];
     60                        queue_requirements_np=[80 80 80 80 80 80 80 80 80];
    6161
    62                          QueueRequirements(available_queues,queue_requirements_time,queue_requirements_np,cluster.queue,cluster.np,1)
     62                        QueueRequirements(available_queues,queue_requirements_time,queue_requirements_np,cluster.queue,cluster.np,1)
    6363
    64                          %Miscelaneous
    65                          if isempty(cluster.login), md = checkmessage(md,'login empty'); end
    66                          if isempty(cluster.codepath), md = checkmessage(md,'codepath empty'); end
    67                          if isempty(cluster.executionpath), md = checkmessage(md,'executionpath empty'); end
     64                        %Miscelaneous
     65                        if isempty(cluster.login), md = checkmessage(md,'login empty'); end
     66                        if isempty(cluster.codepath), md = checkmessage(md,'codepath empty'); end
     67                        if isempty(cluster.executionpath), md = checkmessage(md,'executionpath empty'); end
    6868
    69                  end
    70                  %}}}
    71                  function BuildKrigingQueueScript(cluster,dirname,modelname,solution,io_gather,isvalgrind,isgprof,isdakota,isoceancoupling) % {{{
     69                end
     70                %}}}
     71                function BuildKrigingQueueScript(cluster,dirname,modelname,solution,io_gather,isvalgrind,isgprof,isdakota,isoceancoupling) % {{{
    7272
    73                          if(isvalgrind), disp('valgrind not supported by cluster, ignoring...'); end
    74                          if(isgprof),    disp('gprof not supported by cluster, ignoring...'); end
     73                        if(isvalgrind), disp('valgrind not supported by cluster, ignoring...'); end
     74                        if(isgprof),    disp('gprof not supported by cluster, ignoring...'); end
    7575
    76                          %write queuing script
    77                          fid=fopen([modelname '.queue'],'w');
    78                          fprintf(fid,'#!/bin/bash\n');
    79                          fprintf(fid,'#SBATCH --job-name=%s\n',modelname);
    80                          fprintf(fid,'#SBATCH -p %s \n',cluster.queue);
    81                          fprintf(fid,'#SBATCH -N %i -n %i\n',cluster.numnodes,cluster.cpuspernode);
    82                          fprintf(fid,'#SBATCH --time=%i\n',cluster.time*60); %walltime is in seconds.
    83                          fprintf(fid,'#SBATCH --mem-per-cpu=%igb\n',cluster.memory);
    84                          fprintf(fid,'#SBATCH -o %s.outlog \n',modelname);
    85                          fprintf(fid,'#SBATCH -e %s.errlog \n\n',modelname);
    86                          fprintf(fid,'export ISSM_DIR="%s/../"\n',cluster.codepath); %FIXME
    87                          fprintf(fid,'source $ISSM_DIR/etc/environment.sh\n');       %FIXME
    88                          fprintf(fid,'cd %s/%s\n\n',cluster.executionpath,dirname);
    89                          fprintf(fid,'mpiexec -np %i %s/kriging.exe %s %s\n',cluster.np,cluster.codepath,[cluster.executionpath '/' modelname],modelname);
    90                          if ~io_gather, %concatenate the output files:
    91                                  fprintf(fid,'cat %s.outbin.* > %s.outbin',modelname,modelname);
    92                          end
    93                          fclose(fid);
    94                  end
    95                  %}}}
    96                  function BuildQueueScript(cluster,dirname,modelname,solution,io_gather,isvalgrind,isgprof,isdakota,isoceancoupling) % {{{
     76                        %write queuing script
     77                        fid=fopen([modelname '.queue'],'w');
     78                        fprintf(fid,'#!/bin/bash\n');
     79                        fprintf(fid,'#SBATCH --job-name=%s\n',modelname);
     80                        fprintf(fid,'#SBATCH -p %s \n',cluster.queue);
     81                        fprintf(fid,'#SBATCH -N %i -n %i\n',cluster.numnodes,cluster.cpuspernode);
     82                        fprintf(fid,'#SBATCH --time=%i\n',cluster.time*60); %walltime is in seconds.
     83                        fprintf(fid,'#SBATCH --mem-per-cpu=%igb\n',cluster.memory);
     84                        fprintf(fid,'#SBATCH -o %s.outlog \n',modelname);
     85                        fprintf(fid,'#SBATCH -e %s.errlog \n\n',modelname);
     86                        fprintf(fid,'export ISSM_DIR="%s/../"\n',cluster.codepath); %FIXME
     87                        fprintf(fid,'source $ISSM_DIR/etc/environment.sh\n');       %FIXME
     88                        fprintf(fid,'cd %s/%s\n\n',cluster.executionpath,dirname);
     89                        fprintf(fid,'mpiexec -np %i %s/kriging.exe %s %s\n',cluster.np,cluster.codepath,[cluster.executionpath '/' modelname],modelname);
     90                        if ~io_gather, %concatenate the output files:
     91                                fprintf(fid,'cat %s.outbin.* > %s.outbin',modelname,modelname);
     92                        end
     93                        fclose(fid);
     94                end
     95                %}}}
     96                function BuildQueueScript(cluster,dirname,modelname,solution,io_gather,isvalgrind,isgprof,isdakota,isoceancoupling) % {{{
    9797
    98                          if(isvalgrind), disp('valgrind not supported by cluster, ignoring...'); end
    99                          if(isgprof),    disp('gprof not supported by cluster, ignoring...'); end
     98                        if(isvalgrind), disp('valgrind not supported by cluster, ignoring...'); end
     99                        if(isgprof),    disp('gprof not supported by cluster, ignoring...'); end
    100100
    101                          %write queuing script
    102                          fid=fopen([modelname '.queue'],'w');
    103                          fprintf(fid,'#!/bin/bash\n');
    104                          fprintf(fid,'#SBATCH --job-name=%s\n',modelname);
    105                          fprintf(fid,'#SBATCH --partition=%s',cluster.queue{1});
    106                          for i=2:length(cluster.queue)
     101                        %write queuing script
     102                        fid=fopen([modelname '.queue'],'w');
     103                        fprintf(fid,'#!/bin/bash\n');
     104                        fprintf(fid,'#SBATCH --job-name=%s\n',modelname);
     105                        fprintf(fid,'#SBATCH --partition=%s',cluster.queue{1});
     106                        for i=2:length(cluster.queue)
    107107                                fprintf(fid,',%s',cluster.queue{i});
    108                          end
    109                          fprintf(fid,'\n');
    110                          %fprintf(fid,'#SBATCH -N %i -n %i\n',cluster.numnodes,cluster.cpuspernode);
    111                          %fprintf(fid,'#SBATCH --mem-per-cpu=%igb\n',cluster.memory);
    112                          fprintf(fid,'#SBATCH --nodes=%i\n',cluster.numnodes); % in general, just 1
    113                          fprintf(fid,'#SBATCH --ntasks=%i\n',cluster.cpuspernode); % in general, just 1
    114                          fprintf(fid,'#SBATCH --cpus-per-task=%i\n',1);
    115                          fprintf(fid,'#SBATCH --mem=%igb\n',cluster.memory); % minimum total node memory required
    116                          fprintf(fid,'#SBATCH --time=%s\n',datestr(cluster.time/24,'HH:MM:SS')); %walltime is in HH:MM:SS format. cluster.time is in hour
    117                          fprintf(fid,'#SBATCH -o %s.outlog \n',modelname);
    118                          fprintf(fid,'#SBATCH -e %s.errlog \n\n',modelname);
    119                          fprintf(fid,'export ISSM_DIR="%s/../"\n',cluster.codepath); %FIXME
    120                          fprintf(fid,'source $ISSM_DIR/etc/environment.sh\n');       %FIXME
    121                          fprintf(fid,'cd %s/%s\n\n',cluster.executionpath,dirname);
    122                          fprintf(fid,'mpiexec -n %i %s/issm.exe %s %s %s\n',cluster.np,cluster.codepath,solution,[cluster.executionpath '/' dirname],modelname);
    123                          if ~io_gather, %concatenate the output files:
    124                                  fprintf(fid,'cat %s.outbin.* > %s.outbin',modelname,modelname);
    125                          end
    126                          fclose(fid);
     108                        end
     109                        fprintf(fid,'\n');
     110                        %fprintf(fid,'#SBATCH -N %i -n %i\n',cluster.numnodes,cluster.cpuspernode);
     111                        %fprintf(fid,'#SBATCH --mem-per-cpu=%igb\n',cluster.memory);
     112                        fprintf(fid,'#SBATCH --nodes=%i\n',cluster.numnodes); % in general, just 1
     113                        fprintf(fid,'#SBATCH --ntasks=%i\n',cluster.cpuspernode); % in general, just 1
     114                        fprintf(fid,'#SBATCH --cpus-per-task=%i\n',1);
     115                        fprintf(fid,'#SBATCH --mem=%igb\n',cluster.memory); % minimum total node memory required
     116                        fprintf(fid,'#SBATCH --time=%s\n',datestr(cluster.time/24,'HH:MM:SS')); %walltime is in HH:MM:SS format. cluster.time is in hour
     117                        fprintf(fid,'#SBATCH -o %s.outlog \n',modelname);
     118                        fprintf(fid,'#SBATCH -e %s.errlog \n\n',modelname);
     119                        fprintf(fid,'export ISSM_DIR="%s/../"\n',cluster.codepath); %FIXME
     120                        fprintf(fid,'source $ISSM_DIR/etc/environment.sh\n');       %FIXME
     121                        fprintf(fid,'cd %s/%s\n\n',cluster.executionpath,dirname);
     122                        fprintf(fid,'mpiexec -n %i %s/issm.exe %s %s %s\n',cluster.np,cluster.codepath,solution,[cluster.executionpath '/' dirname],modelname);
     123                        if ~io_gather, %concatenate the output files:
     124                                fprintf(fid,'cat %s.outbin.* > %s.outbin',modelname,modelname);
     125                        end
     126                        fclose(fid);
    127127
    128                          %in interactive mode, create a run file, and errlog and outlog file
    129                          if cluster.interactive,
    130                                  fid=fopen([modelname '.run'],'w');
    131                                  fprintf(fid,'mpiexec -n %i %s/issm.exe %s %s %s\n',cluster.np,cluster.codepath,solution,[cluster.executionpath '/' dirname],modelname);
    132                                  if ~io_gather, %concatenate the output files:
    133                                          fprintf(fid,'cat %s.outbin.* > %s.outbin',modelname,modelname);
    134                                  end
    135                                  fclose(fid);
    136                                  fid=fopen([modelname '.errlog'],'w');
    137                                  fclose(fid);
    138                                  fid=fopen([modelname '.outlog'],'w');
    139                                  fclose(fid);
    140                          end
    141                  end %}}}
    142                  function UploadQueueJob(cluster,modelname,dirname,filelist)% {{{
     128                        %in interactive mode, create a run file, and errlog and outlog file
     129                        if cluster.interactive,
     130                                fid=fopen([modelname '.run'],'w');
     131                                fprintf(fid,'mpiexec -n %i %s/issm.exe %s %s %s\n',cluster.np,cluster.codepath,solution,[cluster.executionpath '/' dirname],modelname);
     132                                if ~io_gather, %concatenate the output files:
     133                                        fprintf(fid,'cat %s.outbin.* > %s.outbin',modelname,modelname);
     134                                end
     135                                fclose(fid);
     136                                fid=fopen([modelname '.errlog'],'w');
     137                                fclose(fid);
     138                                fid=fopen([modelname '.outlog'],'w');
     139                                fclose(fid);
     140                        end
     141                end %}}}
     142                function UploadQueueJob(cluster,modelname,dirname,filelist) % {{{
    143143
    144                          %compress the files into one zip.
    145                          compressstring=['tar -zcf ' dirname '.tar.gz '];
    146                          for i=1:numel(filelist),
    147                                  compressstring = [compressstring ' ' filelist{i}];
    148                          end
    149                          if cluster.interactive,
    150                                  compressstring = [compressstring ' ' modelname '.errlog ' modelname '.outlog '];
    151                          end
    152                          system(compressstring);
     144                        %compress the files into one zip.
     145                        compressstring=['tar -zcf ' dirname '.tar.gz '];
     146                        for i=1:numel(filelist),
     147                                compressstring = [compressstring ' ' filelist{i}];
     148                        end
     149                        if cluster.interactive,
     150                                compressstring = [compressstring ' ' modelname '.errlog ' modelname '.outlog '];
     151                        end
     152                        system(compressstring);
    153153
    154                          disp('uploading input file and queueing script');
    155                          issmscpout(cluster.name,cluster.executionpath,cluster.login,cluster.port,{[dirname '.tar.gz']});
     154                        disp('uploading input file and queueing script');
     155                        issmscpout(cluster.name,cluster.executionpath,cluster.login,cluster.port,{[dirname '.tar.gz']});
    156156
    157                  end %}}}
    158                  function LaunchQueueJob(cluster,modelname,dirname,filelist,restart,batch)% {{{
     157                end %}}}
     158                function LaunchQueueJob(cluster,modelname,dirname,filelist,restart,batch) % {{{
    159159
    160                          disp('launching solution sequence on remote cluster');
    161                          if ~isempty(restart)
    162                                  launchcommand=['cd ' cluster.executionpath ' && cd ' dirname ' && hostname && sbatch ' modelname '.queue '];
    163                          else
    164                                  launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' dirname ' && mkdir ' dirname ...
    165                                          ' && cd ' dirname ' && mv ../' dirname '.tar.gz ./ && tar -zxf ' dirname '.tar.gz  && hostname && sbatch ' modelname '.queue '];
    166                          end
    167                          issmssh(cluster.name,cluster.login,cluster.port,launchcommand);
    168                  end %}}}
    169                  function Download(cluster,dirname,filelist)% {{{
     160                        disp('launching solution sequence on remote cluster');
     161                        if ~isempty(restart)
     162                                launchcommand=['cd ' cluster.executionpath ' && cd ' dirname ' && hostname && sbatch ' modelname '.queue '];
     163                        else
     164                                launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' dirname ' && mkdir ' dirname ...
     165                                        ' && cd ' dirname ' && mv ../' dirname '.tar.gz ./ && tar -zxf ' dirname '.tar.gz  && hostname && sbatch ' modelname '.queue '];
     166                        end
     167                        issmssh(cluster.name,cluster.login,cluster.port,launchcommand);
     168                end %}}}
     169                function Download(cluster,dirname,filelist) % {{{
    170170
    171                          %copy files from cluster to current directory
    172                          directory=[cluster.executionpath '/' dirname '/'];
    173                          issmscpin(cluster.name,cluster.login,cluster.port,directory,filelist);
     171                        %copy files from cluster to current directory
     172                        directory=[cluster.executionpath '/' dirname '/'];
     173                        issmscpin(cluster.name,cluster.login,cluster.port,directory,filelist);
    174174
    175                  end %}}}
     175                end %}}}
    176176        end
    177177end
  • issm/trunk-jpl/src/m/classes/clusters/hpc.m

    r23775 r26330  
    1 %HPC class definition
     1%HPC cluster class definition
    22%
    33%   Usage:
     
    77
    88classdef hpc
    9     properties (SetAccess=public) 
    10                  % {{{
    11                  name='hpc.oit.uci.edu'
    12                  login='';
    13                  numnodes=1;
    14                  cpuspernode=4;
    15                  port=0;
    16                  queue='pub64';
    17                  codepath='';
    18                  executionpath='';
    19                  interactive=0;
    20          end
    21          %}}}
    22          methods
    23                  function cluster=hpc(varargin) % {{{
     9        properties (SetAccess=public)
     10                % {{{
     11                name='hpc.oit.uci.edu'
     12                login='';
     13                numnodes=1;
     14                cpuspernode=4;
     15                port=0;
     16                queue='pub64';
     17                codepath='';
     18                executionpath='';
     19                interactive=0;
     20        end
     21        %}}}
     22        methods
     23                function cluster=hpc(varargin) % {{{
    2424
    25                          %initialize cluster using default settings if provided
    26                          if (exist('hpc_settings')==2), hpc_settings; end
     25                        %initialize cluster using default settings if provided
     26                        if (exist('hpc_settings')==2), hpc_settings; end
    2727
    28                          %use provided options to change fields
    29                          cluster=AssignObjectFields(pairoptions(varargin{:}),cluster);
    30                  end
    31                  %}}}
    32                  function disp(cluster) % {{{
    33                          %  display the object
    34                          disp(sprintf('class ''%s'' object ''%s'' = ',class(cluster),inputname(1)));
    35                          disp(sprintf('    name: %s',cluster.name));
    36                          disp(sprintf('    login: %s',cluster.login));
    37                          disp(sprintf('    port: %i',cluster.port));
    38                          disp(sprintf('    numnodes: %i',cluster.numnodes));
    39                          disp(sprintf('    cpuspernode: %i',cluster.cpuspernode));
    40                          disp(sprintf('    np: %i',cluster.cpuspernode*cluster.numnodes));
    41                          disp(sprintf('    queue: %s',cluster.queue));
    42                          disp(sprintf('    codepath: %s',cluster.codepath));
    43                          disp(sprintf('    executionpath: %s',cluster.executionpath));
    44                          disp(sprintf('    interactive: %i',cluster.interactive));
    45                  end
    46                  %}}}
    47                  function numprocs=np(cluster) % {{{
    48                          %compute number of processors
    49                          numprocs=cluster.numnodes*cluster.cpuspernode;
    50                  end
    51                  %}}}
    52                  function md = checkconsistency(cluster,md,solution,analyses) % {{{
     28                        %use provided options to change fields
     29                        cluster=AssignObjectFields(pairoptions(varargin{:}),cluster);
     30                end
     31                %}}}
     32                function disp(cluster) % {{{
     33                        %  display the object
     34                        disp(sprintf('class ''%s'' object ''%s'' = ',class(cluster),inputname(1)));
     35                        disp(sprintf('    name: %s',cluster.name));
     36                        disp(sprintf('    login: %s',cluster.login));
     37                        disp(sprintf('    port: %i',cluster.port));
     38                        disp(sprintf('    numnodes: %i',cluster.numnodes));
     39                        disp(sprintf('    cpuspernode: %i',cluster.cpuspernode));
     40                        disp(sprintf('    np: %i',cluster.cpuspernode*cluster.numnodes));
     41                        disp(sprintf('    queue: %s',cluster.queue));
     42                        disp(sprintf('    codepath: %s',cluster.codepath));
     43                        disp(sprintf('    executionpath: %s',cluster.executionpath));
     44                        disp(sprintf('    interactive: %i',cluster.interactive));
     45                end
     46                %}}}
     47                function numprocs=nprocs(cluster) % {{{
     48                        %compute number of processors
     49                        numprocs=cluster.numnodes*cluster.cpuspernode;
     50                end
     51                %}}}
     52                function md = checkconsistency(cluster,md,solution,analyses) % {{{
    5353
    54                          available_queues={'pub64','free64','free48','free*,pub64','free*'};
    55                          queue_requirements_time=[Inf Inf Inf Inf Inf];
    56                          queue_requirements_np=[64 64 48 48 48];
     54                        available_queues={'pub64','free64','free48','free*,pub64','free*'};
     55                        queue_requirements_time=[Inf Inf Inf Inf Inf];
     56                        queue_requirements_np=[64 64 48 48 48];
    5757
    58                          QueueRequirements(available_queues,queue_requirements_time,queue_requirements_np,cluster.queue,cluster.np,1)
     58                        QueueRequirements(available_queues,queue_requirements_time,queue_requirements_np,cluster.queue,cluster.np,1)
    5959
    60                          %Miscelaneous
    61                          if isempty(cluster.login), md = checkmessage(md,'login empty'); end
    62                          if isempty(cluster.codepath), md = checkmessage(md,'codepath empty'); end
    63                          if isempty(cluster.executionpath), md = checkmessage(md,'executionpath empty'); end
     60                        %Miscelaneous
     61                        if isempty(cluster.login), md = checkmessage(md,'login empty'); end
     62                        if isempty(cluster.codepath), md = checkmessage(md,'codepath empty'); end
     63                        if isempty(cluster.executionpath), md = checkmessage(md,'executionpath empty'); end
    6464
    65                  end
    66                  %}}}
    67                  function BuildKrigingQueueScript(cluster,modelname,solution,io_gather,isvalgrind,isgprof) % {{{
     65                end
     66                %}}}
     67                function BuildKrigingQueueScript(cluster,modelname,solution,io_gather,isvalgrind,isgprof) % {{{
    6868
    69                          if(isvalgrind), disp('valgrind not supported by cluster, ignoring...'); end
    70                          if(isgprof),    disp('gprof not supported by cluster, ignoring...'); end
     69                        if(isvalgrind), disp('valgrind not supported by cluster, ignoring...'); end
     70                        if(isgprof),    disp('gprof not supported by cluster, ignoring...'); end
    7171
    72                          %write queuing script
    73                          fid=fopen([modelname '.queue'],'w');
    74                          fprintf(fid,'#!/bin/bash\n');
    75                          fprintf(fid,'#$ -N %s\n',modelname);
    76                          fprintf(fid,'#$ -q %s \n',cluster.queue);
    77                          fprintf(fid,'#$ -pe one-node-mpi 2-64\n');
    78                          fprintf(fid,'#$ -R y\n');
    79                          fprintf(fid,'#$ -m beas\n');
    80                          fprintf(fid,'#$ -o %s.outlog \n',modelname);
    81                          fprintf(fid,'#$ -e %s.errlog \n\n',modelname);
    82                          fprintf(fid,'export ISSM_DIR="%s/../"\n',cluster.codepath); %FIXME
    83                          fprintf(fid,'source $ISSM_DIR/etc/environment.sh\n');       %FIXME
    84                          fprintf(fid,'cd %s/%s\n\n',cluster.executionpath,modelname);
    85                          fprintf(fid,'mpiexec -np %i %s/kriging.exe %s %s\n',cluster.np,cluster.codepath,[cluster.executionpath '/' modelname],modelname);
    86                          if ~io_gather, %concatenate the output files:
    87                                  fprintf(fid,'cat %s.outbin.* > %s.outbin',modelname,modelname);
    88                          end
    89                          fclose(fid);
    90                  end
    91                  %}}}
    92                  function BuildQueueScript(cluster,dirname,modelname,solution,io_gather,isvalgrind,isgprof,isdakota,isoceancoupling) % {{{
     72                        %write queuing script
     73                        fid=fopen([modelname '.queue'],'w');
     74                        fprintf(fid,'#!/bin/bash\n');
     75                        fprintf(fid,'#$ -N %s\n',modelname);
     76                        fprintf(fid,'#$ -q %s \n',cluster.queue);
     77                        fprintf(fid,'#$ -pe one-node-mpi 2-64\n');
     78                        fprintf(fid,'#$ -R y\n');
     79                        fprintf(fid,'#$ -m beas\n');
     80                        fprintf(fid,'#$ -o %s.outlog \n',modelname);
     81                        fprintf(fid,'#$ -e %s.errlog \n\n',modelname);
     82                        fprintf(fid,'export ISSM_DIR="%s/../"\n',cluster.codepath); %FIXME
     83                        fprintf(fid,'source $ISSM_DIR/etc/environment.sh\n');       %FIXME
     84                        fprintf(fid,'cd %s/%s\n\n',cluster.executionpath,modelname);
     85                        fprintf(fid,'mpiexec -np %i %s/kriging.exe %s %s\n',cluster.np,cluster.codepath,[cluster.executionpath '/' modelname],modelname);
     86                        if ~io_gather, %concatenate the output files:
     87                                fprintf(fid,'cat %s.outbin.* > %s.outbin',modelname,modelname);
     88                        end
     89                        fclose(fid);
     90                end
     91                %}}}
     92                function BuildQueueScript(cluster,dirname,modelname,solution,io_gather,isvalgrind,isgprof,isdakota,isoceancoupling) % {{{
    9393
    94                          if(isvalgrind), disp('valgrind not supported by cluster, ignoring...'); end
    95                          if(isgprof),    disp('gprof not supported by cluster, ignoring...'); end
     94                        if(isvalgrind), disp('valgrind not supported by cluster, ignoring...'); end
     95                        if(isgprof),    disp('gprof not supported by cluster, ignoring...'); end
    9696
    97                          %write queuing script
    98                          fid=fopen([modelname '.queue'],'w');
    99                          fprintf(fid,'#!/bin/bash\n');
    100                          fprintf(fid,'#$ -N %s\n',modelname);
    101                          fprintf(fid,'#$ -q %s \n',cluster.queue);
    102                          fprintf(fid,'#$ -pe one-node-mpi 2-64\n');
    103                          fprintf(fid,'#$ -R y\n');
    104                          %fprintf(fid,'#$ -m beas\n');
    105                          fprintf(fid,'#$ -o %s.outlog \n',modelname);
    106                          fprintf(fid,'#$ -e %s.errlog \n\n',modelname);
    107                          fprintf(fid,'export ISSM_DIR="%s/../"\n',cluster.codepath); %FIXME
    108                          fprintf(fid,'source $ISSM_DIR/etc/environment.sh\n');       %FIXME
    109                          fprintf(fid,'cd %s/%s\n\n',cluster.executionpath,dirname);
    110                          fprintf(fid,'mpiexec -np %i %s/issm.exe %s %s %s\n',cluster.np,cluster.codepath,solution,[cluster.executionpath '/' dirname],modelname);
    111                          if ~io_gather, %concatenate the output files:
    112                                  fprintf(fid,'cat %s.outbin.* > %s.outbin',modelname,modelname);
    113                          end
    114                          fclose(fid);
     97                        %write queuing script
     98                        fid=fopen([modelname '.queue'],'w');
     99                        fprintf(fid,'#!/bin/bash\n');
     100                        fprintf(fid,'#$ -N %s\n',modelname);
     101                        fprintf(fid,'#$ -q %s \n',cluster.queue);
     102                        fprintf(fid,'#$ -pe one-node-mpi 2-64\n');
     103                        fprintf(fid,'#$ -R y\n');
     104                        %fprintf(fid,'#$ -m beas\n');
     105                        fprintf(fid,'#$ -o %s.outlog \n',modelname);
     106                        fprintf(fid,'#$ -e %s.errlog \n\n',modelname);
     107                        fprintf(fid,'export ISSM_DIR="%s/../"\n',cluster.codepath); %FIXME
     108                        fprintf(fid,'source $ISSM_DIR/etc/environment.sh\n');       %FIXME
     109                        fprintf(fid,'cd %s/%s\n\n',cluster.executionpath,dirname);
     110                        fprintf(fid,'mpiexec -np %i %s/issm.exe %s %s %s\n',cluster.np,cluster.codepath,solution,[cluster.executionpath '/' dirname],modelname);
     111                        if ~io_gather, %concatenate the output files:
     112                                fprintf(fid,'cat %s.outbin.* > %s.outbin',modelname,modelname);
     113                        end
     114                        fclose(fid);
    115115
    116                          %in interactive mode, create a run file, and errlog and outlog file
    117                          if cluster.interactive,
    118                                  fid=fopen([modelname '.run'],'w');
    119                                  fprintf(fid,'mpiexec -np %i %s/issm.exe %s %s %s\n',cluster.np,cluster.codepath,solution,[cluster.executionpath '/' dirname],modelname);
    120                                  if ~io_gather, %concatenate the output files:
    121                                          fprintf(fid,'cat %s.outbin.* > %s.outbin',modelname,modelname);
    122                                  end
    123                                  fclose(fid);
    124                                  fid=fopen([modelname '.errlog'],'w');
    125                                  fclose(fid);
    126                                  fid=fopen([modelname '.outlog'],'w');
    127                                  fclose(fid);
    128                          end
    129                  end %}}}
    130                  function UploadQueueJob(cluster,modelname,dirname,filelist)% {{{
     116                        %in interactive mode, create a run file, and errlog and outlog file
     117                        if cluster.interactive,
     118                                fid=fopen([modelname '.run'],'w');
     119                                fprintf(fid,'mpiexec -np %i %s/issm.exe %s %s %s\n',cluster.np,cluster.codepath,solution,[cluster.executionpath '/' dirname],modelname);
     120                                if ~io_gather, %concatenate the output files:
     121                                        fprintf(fid,'cat %s.outbin.* > %s.outbin',modelname,modelname);
     122                                end
     123                                fclose(fid);
     124                                fid=fopen([modelname '.errlog'],'w');
     125                                fclose(fid);
     126                                fid=fopen([modelname '.outlog'],'w');
     127                                fclose(fid);
     128                        end
     129                end %}}}
     130                function UploadQueueJob(cluster,modelname,dirname,filelist) % {{{
    131131
    132                          %compress the files into one zip.
    133                          compressstring=['tar -zcf ' dirname '.tar.gz '];
    134                          for i=1:numel(filelist),
    135                                  compressstring = [compressstring ' ' filelist{i}];
    136                          end
    137                          if cluster.interactive,
    138                                  compressstring = [compressstring ' ' modelname '.errlog ' modelname '.outlog '];
    139                          end
    140                          system(compressstring);
     132                        %compress the files into one zip.
     133                        compressstring=['tar -zcf ' dirname '.tar.gz '];
     134                        for i=1:numel(filelist),
     135                                compressstring = [compressstring ' ' filelist{i}];
     136                        end
     137                        if cluster.interactive,
     138                                compressstring = [compressstring ' ' modelname '.errlog ' modelname '.outlog '];
     139                        end
     140                        system(compressstring);
    141141
    142                          disp('uploading input file and queueing script');
    143                          issmscpout(cluster.name,cluster.executionpath,cluster.login,cluster.port,{[dirname '.tar.gz']});
     142                        disp('uploading input file and queueing script');
     143                        issmscpout(cluster.name,cluster.executionpath,cluster.login,cluster.port,{[dirname '.tar.gz']});
    144144
    145                  end %}}}
    146                  function LaunchQueueJob(cluster,modelname,dirname,filelist,restart,batch)% {{{
     145                end %}}}
     146                function LaunchQueueJob(cluster,modelname,dirname,filelist,restart,batch) % {{{
    147147
    148                          disp('launching solution sequence on remote cluster');
    149                          if ~isempty(restart)
    150                                  launchcommand=['cd ' cluster.executionpath ' && cd ' dirname ' && hostname && qsub ' modelname '.queue '];
    151                          else
    152                                  launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' dirname ' && mkdir ' dirname ...
    153                                          ' && cd ' dirname ' && mv ../' dirname '.tar.gz ./ && tar -zxf ' dirname '.tar.gz  && hostname && qsub ' modelname '.queue '];
    154                          end
    155                          issmssh(cluster.name,cluster.login,cluster.port,launchcommand);
    156                  end %}}}
    157                  function Download(cluster,dirname,filelist)% {{{
     148                        disp('launching solution sequence on remote cluster');
     149                        if ~isempty(restart)
     150                                launchcommand=['cd ' cluster.executionpath ' && cd ' dirname ' && hostname && qsub ' modelname '.queue '];
     151                        else
     152                                launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' dirname ' && mkdir ' dirname ...
     153                                        ' && cd ' dirname ' && mv ../' dirname '.tar.gz ./ && tar -zxf ' dirname '.tar.gz  && hostname && qsub ' modelname '.queue '];
     154                        end
     155                        issmssh(cluster.name,cluster.login,cluster.port,launchcommand);
     156                end %}}}
     157                function Download(cluster,dirname,filelist) % {{{
    158158
    159                          %copy files from cluster to current directory
    160                          directory=[cluster.executionpath '/' dirname '/'];
    161                          issmscpin(cluster.name,cluster.login,cluster.port,directory,filelist);
     159                        %copy files from cluster to current directory
     160                        directory=[cluster.executionpath '/' dirname '/'];
     161                        issmscpin(cluster.name,cluster.login,cluster.port,directory,filelist);
    162162
    163                  end %}}}
     163                end %}}}
    164164        end
    165165end
  • issm/trunk-jpl/src/m/classes/clusters/hpc_simba.m

    r25192 r26330  
    1 %HPC class definition
     1%HPC_SIMBA cluster class definition
    22%
    33%   Usage:
     
    77
    88classdef hpc_simba
    9     properties (SetAccess=public) 
    10                  % {{{
    11                  name='simba00'
    12                  login='inwoo';
    13                  numnodes=1;
    14                  cpuspernode=36;
    15                  np=4;
    16                  port=7777;
    17                  queue='pub64';
    18                  codepath='/home/DATA/externalpackagesissm/issm/trunk-jpl/bin';
    19                  executionpath='/home/DATA/externalpackages/issm/trunk-jpl/execution/';
    20                  interactive=0;
    21          end
    22          %}}}
    23          methods
    24                  function cluster=hpc_simba(varargin) % {{{
     9        properties (SetAccess=public)
     10                % {{{
     11                name='simba00'
     12                login='inwoo';
     13                numnodes=1;
     14                cpuspernode=36;
     15                np=4;
     16                port=7777;
     17                queue='pub64';
     18                codepath='/home/DATA/externalpackagesissm/issm/trunk-jpl/bin';
     19                executionpath='/home/DATA/externalpackages/issm/trunk-jpl/execution/';
     20                interactive=0;
     21        end
     22        %}}}
     23        methods
     24                function cluster=hpc_simba(varargin) % {{{
    2525
    26                          %initialize cluster using default settings if provided
    27                          if (exist('hpc_settings')==2), hpc_settings; end
     26                        %initialize cluster using default settings if provided
     27                        if (exist('hpc_settings')==2), hpc_settings; end
    2828
    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('    queue: %s',cluster.queue));
    43                          disp(sprintf('    codepath: %s',cluster.codepath));
    44                          disp(sprintf('    executionpath: %s',cluster.executionpath));
    45                          disp(sprintf('    interactive: %i',cluster.interactive));
    46                  end
    47                  %}}}
    48                  %function numprocs=np(cluster) % {{{
    49                 %        %compute number of processors
    50                 %        numprocs=cluster.numnodes*cluster.cpuspernode;
     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('    queue: %s',cluster.queue));
     43                        disp(sprintf('    codepath: %s',cluster.codepath));
     44                        disp(sprintf('    executionpath: %s',cluster.executionpath));
     45                        disp(sprintf('    interactive: %i',cluster.interactive));
     46                end
     47                %}}}
     48                %function numprocs=nprocs(cluster) % {{{
     49                %       %compute number of processors
     50                %       numprocs=cluster.numnodes*cluster.cpuspernode;
    5151                % end
    52                  %}}}
    53                  function md = checkconsistency(cluster,md,solution,analyses) % {{{
     52                %}}}
     53                function md = checkconsistency(cluster,md,solution,analyses) % {{{
    5454
    55                          available_queues={'pub64','free64','free48','free*,pub64','free*'};
    56                          queue_requirements_time=[Inf Inf Inf Inf Inf];
    57                          queue_requirements_np=[64 64 48 48 48];
     55                        available_queues={'pub64','free64','free48','free*,pub64','free*'};
     56                        queue_requirements_time=[Inf Inf Inf Inf Inf];
     57                        queue_requirements_np=[64 64 48 48 48];
    5858
    59                          QueueRequirements(available_queues,queue_requirements_time,queue_requirements_np,cluster.queue,cluster.np,1)
     59                        QueueRequirements(available_queues,queue_requirements_time,queue_requirements_np,cluster.queue,cluster.np,1)
    6060
    61                          %Miscelaneous
    62                          if isempty(cluster.login), md = checkmessage(md,'login empty'); end
    63                          if isempty(cluster.codepath), md = checkmessage(md,'codepath empty'); end
    64                          if isempty(cluster.executionpath), md = checkmessage(md,'executionpath empty'); end
     61                        %Miscelaneous
     62                        if isempty(cluster.login), md = checkmessage(md,'login empty'); end
     63                        if isempty(cluster.codepath), md = checkmessage(md,'codepath empty'); end
     64                        if isempty(cluster.executionpath), md = checkmessage(md,'executionpath empty'); end
    6565
    66                  end
    67                  %}}}
    68                  function BuildKrigingQueueScript(cluster,modelname,solution,io_gather,isvalgrind,isgprof) % {{{
     66                end
     67                %}}}
     68                function BuildKrigingQueueScript(cluster,modelname,solution,io_gather,isvalgrind,isgprof) % {{{
    6969
    70                          if(isvalgrind), disp('valgrind not supported by cluster, ignoring...'); end
    71                          if(isgprof),    disp('gprof not supported by cluster, ignoring...'); end
     70                        if(isvalgrind), disp('valgrind not supported by cluster, ignoring...'); end
     71                        if(isgprof),    disp('gprof not supported by cluster, ignoring...'); end
    7272
    73                          %write queuing script
    74                          fid=fopen([modelname '.queue'],'w');
    75                          fprintf(fid,'#!/bin/bash\n');
    76                          fprintf(fid,'#$ -N %s\n',modelname);
    77                          fprintf(fid,'#$ -q %s \n',cluster.queue);
    78                          fprintf(fid,'#$ -pe one-node-mpi 2-64\n');
    79                          fprintf(fid,'#$ -R y\n');
    80                          fprintf(fid,'#$ -m beas\n');
    81                          fprintf(fid,'#$ -o %s.outlog \n',modelname);
    82                          fprintf(fid,'#$ -e %s.errlog \n\n',modelname);
    83                          fprintf(fid,'export ISSM_DIR="%s/../"\n',cluster.codepath); %FIXME
    84                          fprintf(fid,'source $ISSM_DIR/etc/environment.sh\n');       %FIXME
    85                          fprintf(fid,'cd %s/%s\n\n',cluster.executionpath,modelname);
    86                          fprintf(fid,'mpiexec -np %i %s/kriging.exe %s %s\n',cluster.np,cluster.codepath,[cluster.executionpath '/' modelname],modelname);
    87                          if ~io_gather, %concatenate the output files:
    88                                  fprintf(fid,'cat %s.outbin.* > %s.outbin',modelname,modelname);
    89                          end
    90                          fclose(fid);
    91                  end
    92                  %}}}
    93                  function BuildQueueScript(cluster,dirname,modelname,solution,io_gather,isvalgrind,isgprof,isdakota,isoceancoupling) % {{{
     73                        %write queuing script
     74                        fid=fopen([modelname '.queue'],'w');
     75                        fprintf(fid,'#!/bin/bash\n');
     76                        fprintf(fid,'#$ -N %s\n',modelname);
     77                        fprintf(fid,'#$ -q %s \n',cluster.queue);
     78                        fprintf(fid,'#$ -pe one-node-mpi 2-64\n');
     79                        fprintf(fid,'#$ -R y\n');
     80                        fprintf(fid,'#$ -m beas\n');
     81                        fprintf(fid,'#$ -o %s.outlog \n',modelname);
     82                        fprintf(fid,'#$ -e %s.errlog \n\n',modelname);
     83                        fprintf(fid,'export ISSM_DIR="%s/../"\n',cluster.codepath); %FIXME
     84                        fprintf(fid,'source $ISSM_DIR/etc/environment.sh\n');       %FIXME
     85                        fprintf(fid,'cd %s/%s\n\n',cluster.executionpath,modelname);
     86                        fprintf(fid,'mpiexec -np %i %s/kriging.exe %s %s\n',cluster.np,cluster.codepath,[cluster.executionpath '/' modelname],modelname);
     87                        if ~io_gather, %concatenate the output files:
     88                                fprintf(fid,'cat %s.outbin.* > %s.outbin',modelname,modelname);
     89                        end
     90                        fclose(fid);
     91                end
     92                %}}}
     93                function BuildQueueScript(cluster,dirname,modelname,solution,io_gather,isvalgrind,isgprof,isdakota,isoceancoupling) % {{{
    9494
    95                          if(isvalgrind), disp('valgrind not supported by cluster, ignoring...'); end
    96                          if(isgprof),    disp('gprof not supported by cluster, ignoring...'); end
     95                        if(isvalgrind), disp('valgrind not supported by cluster, ignoring...'); end
     96                        if(isgprof),    disp('gprof not supported by cluster, ignoring...'); end
    9797
    98                          %write queuing script
    99                          fid=fopen([modelname '.queue'],'w');
    100                          if 0
    101                                  fprintf(fid,'#!/bin/bash\n');
    102                                  fprintf(fid,'#$ -N %s\n',modelname);
    103                                  fprintf(fid,'#$ -q %s \n',cluster.queue);
    104                                  fprintf(fid,'#$ -pe one-node-mpi 2-64\n');
    105                                  fprintf(fid,'#$ -R y\n');
    106                                  %fprintf(fid,'#$ -m beas\n');
    107                                  fprintf(fid,'#$ -o %s.outlog \n',modelname);
    108                                  fprintf(fid,'#$ -e %s.errlog \n\n',modelname);
    109                          else % FIXME : This script for SIMBA-Kopri
    110                                  fprintf(fid,'#!/bin/bash\n');
    111                                  %fprintf(fid,'#PBS -q workq\n');
    112                                  fprintf(fid,'#PBS -N %s\n',modelname);
    113                                  %fprintf(fid,'#PBS -l nodes=simba01:ppn=%d\n',...
    114                                 %        ceil(cluster.np/cluster.cpuspernode), cluster.np);
    115                                  fprintf(fid,'#PBS -l nodes=simba01:ppn=%d\n',...
     98                        %write queuing script
     99                        fid=fopen([modelname '.queue'],'w');
     100                        if 0
     101                                fprintf(fid,'#!/bin/bash\n');
     102                                fprintf(fid,'#$ -N %s\n',modelname);
     103                                fprintf(fid,'#$ -q %s \n',cluster.queue);
     104                                fprintf(fid,'#$ -pe one-node-mpi 2-64\n');
     105                                fprintf(fid,'#$ -R y\n');
     106                                %fprintf(fid,'#$ -m beas\n');
     107                                fprintf(fid,'#$ -o %s.outlog \n',modelname);
     108                                fprintf(fid,'#$ -e %s.errlog \n\n',modelname);
     109                        else % FIXME : This script for SIMBA-Kopri
     110                                fprintf(fid,'#!/bin/bash\n');
     111                                %fprintf(fid,'#PBS -q workq\n');
     112                                fprintf(fid,'#PBS -N %s\n',modelname);
     113                                %fprintf(fid,'#PBS -l nodes=simba01:ppn=%d\n',...
     114                                %       ceil(cluster.np/cluster.cpuspernode), cluster.np);
     115                                fprintf(fid,'#PBS -l nodes=simba01:ppn=%d\n',...
    116116                                        cluster.np);
    117                                  fprintf(fid,'#PBS -o %s.outlog \n',modelname);
    118                                  fprintf(fid,'#PBS -e %s.errlog \n\n',modelname);
    119                                  fprintf(fid,'\n');
    120                          end
    121                          fprintf(fid,'export ISSM_DIR="%s/../"\n',cluster.codepath); %FIXME
    122                          fprintf(fid,'source $ISSM_DIR/etc/environment.sh\n');       %FIXME
    123                          fprintf(fid,'\n');
    124                          fprintf(fid,'module load intel18/impi-18\n');
    125                          fprintf(fid,'\n');
    126                          fprintf(fid,'cd %s/%s\n\n',cluster.executionpath,dirname);
    127                          fprintf(fid,'mpirun -np %i %s/issm.exe %s %s %s\n',cluster.np,cluster.codepath,solution,[cluster.executionpath '/' dirname],modelname);
    128                          if ~io_gather, %concatenate the output files:
    129                                  fprintf(fid,'cat %s.outbin.* > %s.outbin',modelname,modelname);
    130                          end
    131                          fclose(fid);
     117                                fprintf(fid,'#PBS -o %s.outlog \n',modelname);
     118                                fprintf(fid,'#PBS -e %s.errlog \n\n',modelname);
     119                                fprintf(fid,'\n');
     120                        end
     121                        fprintf(fid,'export ISSM_DIR="%s/../"\n',cluster.codepath); %FIXME
     122                        fprintf(fid,'source $ISSM_DIR/etc/environment.sh\n');       %FIXME
     123                        fprintf(fid,'\n');
     124                        fprintf(fid,'module load intel18/impi-18\n');
     125                        fprintf(fid,'\n');
     126                        fprintf(fid,'cd %s/%s\n\n',cluster.executionpath,dirname);
     127                        fprintf(fid,'mpirun -np %i %s/issm.exe %s %s %s\n',cluster.np,cluster.codepath,solution,[cluster.executionpath '/' dirname],modelname);
     128                        if ~io_gather, %concatenate the output files:
     129                                fprintf(fid,'cat %s.outbin.* > %s.outbin',modelname,modelname);
     130                        end
     131                        fclose(fid);
    132132
    133                          %in interactive mode, create a run file, and errlog and outlog file
    134                          if cluster.interactive,
    135                                  fid=fopen([modelname '.run'],'w');
    136                                  fprintf(fid,'mpiexec -np %i %s/issm.exe %s %s %s\n',cluster.np,cluster.codepath,solution,[cluster.executionpath '/' dirname],modelname);
    137                                  if ~io_gather, %concatenate the output files:
    138                                          fprintf(fid,'cat %s.outbin.* > %s.outbin',modelname,modelname);
    139                                  end
    140                                  fclose(fid);
    141                                  fid=fopen([modelname '.errlog'],'w');
    142                                  fclose(fid);
    143                                  fid=fopen([modelname '.outlog'],'w');
    144                                  fclose(fid);
    145                          end
    146                  end %}}}
    147                  function UploadQueueJob(cluster,modelname,dirname,filelist)% {{{
     133                        %in interactive mode, create a run file, and errlog and outlog file
     134                        if cluster.interactive,
     135                                fid=fopen([modelname '.run'],'w');
     136                                fprintf(fid,'mpiexec -np %i %s/issm.exe %s %s %s\n',cluster.np,cluster.codepath,solution,[cluster.executionpath '/' dirname],modelname);
     137                                if ~io_gather, %concatenate the output files:
     138                                        fprintf(fid,'cat %s.outbin.* > %s.outbin',modelname,modelname);
     139                                end
     140                                fclose(fid);
     141                                fid=fopen([modelname '.errlog'],'w');
     142                                fclose(fid);
     143                                fid=fopen([modelname '.outlog'],'w');
     144                                fclose(fid);
     145                        end
     146                end %}}}
     147                function UploadQueueJob(cluster,modelname,dirname,filelist) % {{{
    148148
    149                          %compress the files into one zip.
    150                          compressstring=['tar -zcf ' dirname '.tar.gz '];
    151                          for i=1:numel(filelist),
    152                                  compressstring = [compressstring ' ' filelist{i}];
    153                          end
    154                          if cluster.interactive,
    155                                  compressstring = [compressstring ' ' modelname '.errlog ' modelname '.outlog '];
    156                          end
    157                          system(compressstring);
     149                        %compress the files into one zip.
     150                        compressstring=['tar -zcf ' dirname '.tar.gz '];
     151                        for i=1:numel(filelist),
     152                                compressstring = [compressstring ' ' filelist{i}];
     153                        end
     154                        if cluster.interactive,
     155                                compressstring = [compressstring ' ' modelname '.errlog ' modelname '.outlog '];
     156                        end
     157                        system(compressstring);
    158158
    159                          disp('uploading input file and queueing script');
    160                          issmscpout(cluster.name,cluster.executionpath,cluster.login,cluster.port,{[dirname '.tar.gz']});
     159                        disp('uploading input file and queueing script');
     160                        issmscpout(cluster.name,cluster.executionpath,cluster.login,cluster.port,{[dirname '.tar.gz']});
    161161
    162                  end %}}}
    163                  function LaunchQueueJob(cluster,modelname,dirname,filelist,restart,batch)% {{{
     162                end %}}}
     163                function LaunchQueueJob(cluster,modelname,dirname,filelist,restart,batch) % {{{
    164164
    165                          disp('launching solution sequence on remote cluster');
    166                          if ~isempty(restart)
    167                                  launchcommand=['cd ' cluster.executionpath ' && cd ' dirname ' && hostname && qsub ' modelname '.queue '];
    168                          else
    169                                  launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' dirname ' && mkdir ' dirname ...
    170                                          ' && cd ' dirname ' && mv ../' dirname '.tar.gz ./ && tar -zxf ' dirname '.tar.gz  && hostname && qsub ' modelname '.queue '];
    171                          end
    172                          issmssh(cluster.name,cluster.login,cluster.port,launchcommand);
    173                  end %}}}
    174                  function Download(cluster,dirname,filelist)% {{{
     165                        disp('launching solution sequence on remote cluster');
     166                        if ~isempty(restart)
     167                                launchcommand=['cd ' cluster.executionpath ' && cd ' dirname ' && hostname && qsub ' modelname '.queue '];
     168                        else
     169                                launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' dirname ' && mkdir ' dirname ...
     170                                        ' && cd ' dirname ' && mv ../' dirname '.tar.gz ./ && tar -zxf ' dirname '.tar.gz  && hostname && qsub ' modelname '.queue '];
     171                        end
     172                        issmssh(cluster.name,cluster.login,cluster.port,launchcommand);
     173                end %}}}
     174                function Download(cluster,dirname,filelist) % {{{
    175175
    176                          %copy files from cluster to current directory
    177                          directory=[cluster.executionpath '/' dirname '/'];
    178                          issmscpin(cluster.name,cluster.login,cluster.port,directory,filelist);
     176                        %copy files from cluster to current directory
     177                        directory=[cluster.executionpath '/' dirname '/'];
     178                        issmscpin(cluster.name,cluster.login,cluster.port,directory,filelist);
    179179
    180                  end %}}}
     180                end %}}}
    181181        end
    182182end
  • issm/trunk-jpl/src/m/classes/clusters/lonestar.m

    r26291 r26330  
    1 %LONESTAR class definition
     1%LONESTAR cluster class definition
    22%
    33%   Usage:
     
    77
    88classdef lonestar
    9     properties (SetAccess=public) 
    10                  % {{{
    11                  name          = 'ls5.tacc.utexas.edu'
    12                  login         = '';
    13                  modules        = {'intel/18.0.2' 'gsl'};
    14                  numnodes      = 1;
    15                  cpuspernode   = 24;
    16                  port          = 1099;
    17                  queue         = 'normal';
    18                  codepath      = '';
    19                  executionpath = '';
    20                  interactive   = 0;
    21                  time          = 48*60*60;
    22                  email         = '';
    23          end
    24          %}}}
    25          methods
    26                  function cluster=lonestar(varargin) % {{{
    27 
    28                          %initialize cluster using default settings if provided
    29                          if (exist('lonestar_settings')==2), lonestar_settings; end
    30 
    31                          %use provided options to change fields
    32                          cluster=AssignObjectFields(pairoptions(varargin{:}),cluster);
    33 
    34                  end
    35                  %}}}
    36                  function disp(cluster) % {{{
    37                          %  display the object
    38                          disp(sprintf('class ''%s'' object ''%s'' = ',class(cluster),inputname(1)));
    39                          disp(sprintf('    name: %s',cluster.name));
    40                          disp(sprintf('    login: %s',cluster.login));
    41                          disp(sprintf('    modules: %s',strjoin(cluster.modules,', ')));
    42                          disp(sprintf('    port: %i',cluster.port));
    43                          disp(sprintf('    numnodes: %i',cluster.numnodes));
    44                          disp(sprintf('    cpuspernode: %i',cluster.cpuspernode));
    45                          disp(sprintf('    np: %i',cluster.np));
    46                          disp(sprintf('    queue: %s',cluster.queue));
    47                          disp(sprintf('    codepath: %s',cluster.codepath));
    48                          disp(sprintf('    executionpath: %s',cluster.executionpath));
    49                          disp(sprintf('    interactive: %i',cluster.interactive));
    50                          disp(sprintf('    time: %i',cluster.time));
    51                          disp(sprintf('    email: %s',cluster.email));
    52                  end
    53                  %}}}
    54                  function numprocs=np(cluster) % {{{
    55                          %compute number of processors
    56                          numprocs=cluster.numnodes*cluster.cpuspernode;
    57                  end
    58                  %}}}
    59                  function md = checkconsistency(cluster,md,solution,analyses) % {{{
    60 
    61                          available_queues={'normal','development'};
    62                          queue_requirements_time=[48*60*60 2*60*60];
    63                          queue_requirements_np=[4104 264];
    64 
    65                          QueueRequirements(available_queues,queue_requirements_time,queue_requirements_np,cluster.queue,cluster.np,cluster.time)
    66 
    67                          %Miscelaneous
    68                          if isempty(cluster.login), md = checkmessage(md,'login empty'); end
    69                          if isempty(cluster.codepath), md = checkmessage(md,'codepath empty'); end
    70                          if isempty(cluster.executionpath), md = checkmessage(md,'executionpath empty'); end
    71                  end
    72                  %}}}
    73                  function BuildKrigingQueueScript(cluster,modelname,solution,io_gather,isvalgrind,isgprof) % {{{
    74 
    75                          if(isvalgrind), disp('valgrind not supported by cluster, ignoring...'); end
    76                          if(isgprof),    disp('gprof not supported by cluster, ignoring...'); end
    77 
    78                          %write queuing script
    79                          fid=fopen([modelname '.queue'],'w');
    80                          fprintf(fid,'#!/bin/bash\n');
    81                          fprintf(fid,'#$ -N %s\n',modelname);
    82                          fprintf(fid,'#$ -q %s \n',cluster.queue);
    83                          fprintf(fid,'#$ -pe one-node-mpi 2-64\n');
    84                          fprintf(fid,'#$ -R y\n');
    85                          fprintf(fid,'#$ -m beas\n');
    86                          fprintf(fid,'#$ -o %s.outlog \n',modelname);
    87                          fprintf(fid,'#$ -e %s.errlog \n\n',modelname);
    88                          fprintf(fid,'export ISSM_DIR="%s/../"\n',cluster.codepath); %FIXME
    89                          fprintf(fid,'source $ISSM_DIR/etc/environment.sh\n');       %FIXME
    90                          fprintf(fid,'cd %s/%s\n\n',cluster.executionpath,modelname);
    91                          fprintf(fid,'mpiexec -np %i %s/kriging.exe %s %s\n',cluster.np,cluster.codepath,[cluster.executionpath '/' modelname],modelname);
    92                          if ~io_gather, %concatenate the output files:
    93                                  fprintf(fid,'cat %s.outbin.* > %s.outbin',modelname,modelname);
    94                          end
    95                          fclose(fid);
    96                  end
    97                  %}}}
    98                  function BuildQueueScript(cluster,dirname,modelname,solution,io_gather,isvalgrind,isgprof,isdakota,isoceancoupling) % {{{
    99 
    100                          if(isvalgrind), disp('valgrind not supported by cluster, ignoring...'); end
    101                          if(isgprof),    disp('gprof not supported by cluster, ignoring...'); end
    102 
    103                          executable='issm.exe';
    104                          if isdakota,
    105                                  version=IssmConfig('_DAKOTA_VERSION_'); version=str2num(version(1:3));
    106                                  if (version>=6),
    107                                          executable='issm_dakota.exe';
    108                                  end
    109                          end
    110                          if isoceancoupling,
    111                                  executable='issm_ocean.exe';
    112                          end
    113 
    114                          %write queuing script
    115                          fid=fopen([modelname '.queue'],'w');
    116 
    117                          fprintf(fid,'#!/bin/bash\n');
    118                          fprintf(fid,'#SBATCH -J %s \n',modelname);
    119                          fprintf(fid,'#SBATCH -p %s \n',cluster.queue);
    120                          fprintf(fid,'#SBATCH -o %s.outlog \n',modelname);
    121                          fprintf(fid,'#SBATCH -e %s.errlog \n',modelname);
    122                          fprintf(fid,'#SBATCH -n %i \n',cluster.numnodes*max(cluster.np/cluster.numnodes,24));
    123                          fprintf(fid,'#SBATCH -N %i \n',cluster.numnodes);
    124                          fprintf(fid,'#SBATCH -t %02i:%02i:00 \n\n',floor(cluster.time/3600),floor(mod(cluster.time,3600)/60));
    125                          for i=1:numel(cluster.modules),
    126                                  fprintf(fid,['module load ' cluster.modules{i} '\n']);
    127                          end
    128 
    129                          if isdakota,
    130                                  fprintf(fid,'export KMP_AFFINITY="granularity=fine,compact,verbose" \n\n');
    131                          end
    132 
    133                          if length(find(cluster.email=='@'))>0
    134                                  fprintf(fid,'#SBATCH --mail-user=%s \n',cluster.email);
    135                                  fprintf(fid,'#SBATCH --mail-type=end \n\n');
    136 
    137                                  %fprintf(fid,'ssh login1 "mail -s ''SLURM Jobid=${SLURM_JOBID} Name=${SLURM_JOB_NAME} Began on Lonestar 5.'' %s <<< ''Job Started'' " \n\n',cluster.email);
    138                          end
    139 
    140                          fprintf(fid,'export PATH="$PATH:."\n\n');
    141                          fprintf(fid,'export ISSM_DIR="%s/../"\n',cluster.codepath); %FIXME
    142                          fprintf(fid,'source $ISSM_DIR/etc/environment.sh\n');       %FIXME
    143                          fprintf(fid,'cd %s/%s\n\n',cluster.executionpath,dirname);
    144                          fprintf(fid,'ibrun -np %i %s/%s %s %s %s\n',cluster.np,cluster.codepath,executable,solution,[cluster.executionpath '/' dirname],modelname);
    145                          if ~io_gather, %concatenate the output files:
    146                                  fprintf(fid,'cat %s.outbin.* > %s.outbin',modelname,modelname);
    147                          end
    148 
    149                          fclose(fid);
    150 
    151                          %in interactive mode, create a run file, and errlog and outlog file
    152                          if cluster.interactive,
    153                                  fid=fopen([modelname '.run'],'w');
    154                                  fprintf(fid,'ibrun -np %i %s/%s %s %s %s\n',cluster.np,executable,cluster.codepath,solution,[cluster.executionpath '/' dirname],modelname);
    155                                  if ~io_gather, %concatenate the output files:
    156                                          fprintf(fid,'cat %s.outbin.* > %s.outbin',modelname,modelname);
    157                                  end
    158                                  fclose(fid);
    159                                  fid=fopen([modelname '.errlog'],'w');
    160                                  fclose(fid);
    161                                  fid=fopen([modelname '.outlog'],'w');
    162                                  fclose(fid);
    163                          end
    164                  end %}}}
    165                  function UploadQueueJob(cluster,modelname,dirname,filelist)% {{{
    166 
    167                          %compress the files into one zip.
    168                          compressstring=['tar -zcf ' dirname '.tar.gz '];
    169                          for i=1:numel(filelist),
    170                                  compressstring = [compressstring ' ' filelist{i}];
    171                          end
    172                          if cluster.interactive,
    173                                  compressstring = [compressstring ' ' modelname '.errlog ' modelname '.outlog '];
    174                          end
    175                          system(compressstring);
    176 
    177                          disp('uploading input file and queueing script');
    178                          issmscpout(cluster.name,cluster.executionpath,cluster.login,cluster.port,{[dirname '.tar.gz']});
    179 
    180                  end %}}}
    181                  function LaunchQueueJob(cluster,modelname,dirname,filelist,restart,batch)% {{{
    182 
    183                          disp('launching solution sequence on remote cluster');
    184                          if ~isempty(restart)
    185                                  launchcommand=['cd ' cluster.executionpath ' && cd ' dirname ' && hostname && sbatch ' modelname '.queue '];
    186                          else
    187                                  launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' dirname ' && mkdir ' dirname ...
    188                                          ' && cd ' dirname ' && mv ../' dirname '.tar.gz ./ && tar -zxf ' dirname '.tar.gz  && hostname && sbatch ' modelname '.queue '];
    189                          end
    190                          issmssh(cluster.name,cluster.login,cluster.port,launchcommand);
    191                  end %}}}
    192                  function Download(cluster,dirname,filelist)% {{{
    193 
    194                          %copy files from cluster to current directory
    195                          directory=[cluster.executionpath '/' dirname '/'];
    196                          issmscpin(cluster.name,cluster.login,cluster.port,directory,filelist);
    197 
    198                  end %}}}
     9        properties (SetAccess=public)
     10                % {{{
     11                name          = 'ls5.tacc.utexas.edu'
     12                login         = '';
     13                modules        = {'intel/18.0.2' 'gsl'};
     14                numnodes      = 1;
     15                cpuspernode   = 24;
     16                port          = 1099;
     17                queue         = 'normal';
     18                codepath      = '';
     19                executionpath = '';
     20                interactive   = 0;
     21                time          = 48*60*60;
     22                email         = '';
     23        end
     24        %}}}
     25        methods
     26                function cluster=lonestar(varargin) % {{{
     27
     28                        %initialize cluster using default settings if provided
     29                        if (exist('lonestar_settings')==2), lonestar_settings; end
     30
     31                        %use provided options to change fields
     32                        cluster=AssignObjectFields(pairoptions(varargin{:}),cluster);
     33
     34                end
     35                %}}}
     36                function disp(cluster) % {{{
     37                        %  display the object
     38                        disp(sprintf('class ''%s'' object ''%s'' = ',class(cluster),inputname(1)));
     39                        disp(sprintf('    name: %s',cluster.name));
     40                        disp(sprintf('    login: %s',cluster.login));
     41                        disp(sprintf('    modules: %s',strjoin(cluster.modules,', ')));
     42                        disp(sprintf('    port: %i',cluster.port));
     43                        disp(sprintf('    numnodes: %i',cluster.numnodes));
     44                        disp(sprintf('    cpuspernode: %i',cluster.cpuspernode));
     45                        disp(sprintf('    np: %i',cluster.np));
     46                        disp(sprintf('    queue: %s',cluster.queue));
     47                        disp(sprintf('    codepath: %s',cluster.codepath));
     48                        disp(sprintf('    executionpath: %s',cluster.executionpath));
     49                        disp(sprintf('    interactive: %i',cluster.interactive));
     50                        disp(sprintf('    time: %i',cluster.time));
     51                        disp(sprintf('    email: %s',cluster.email));
     52                end
     53                %}}}
     54                function numprocs=nprocs(cluster) % {{{
     55                        %compute number of processors
     56                        numprocs=cluster.numnodes*cluster.cpuspernode;
     57                end
     58                %}}}
     59                function md = checkconsistency(cluster,md,solution,analyses) % {{{
     60
     61                        available_queues={'normal','development'};
     62                        queue_requirements_time=[48*60*60 2*60*60];
     63                        queue_requirements_np=[4104 264];
     64
     65                        QueueRequirements(available_queues,queue_requirements_time,queue_requirements_np,cluster.queue,cluster.np,cluster.time)
     66
     67                        %Miscelaneous
     68                        if isempty(cluster.login), md = checkmessage(md,'login empty'); end
     69                        if isempty(cluster.codepath), md = checkmessage(md,'codepath empty'); end
     70                        if isempty(cluster.executionpath), md = checkmessage(md,'executionpath empty'); end
     71                end
     72                %}}}
     73                function BuildKrigingQueueScript(cluster,modelname,solution,io_gather,isvalgrind,isgprof) % {{{
     74
     75                        if(isvalgrind), disp('valgrind not supported by cluster, ignoring...'); end
     76                        if(isgprof),    disp('gprof not supported by cluster, ignoring...'); end
     77
     78                        %write queuing script
     79                        fid=fopen([modelname '.queue'],'w');
     80                        fprintf(fid,'#!/bin/bash\n');
     81                        fprintf(fid,'#$ -N %s\n',modelname);
     82                        fprintf(fid,'#$ -q %s \n',cluster.queue);
     83                        fprintf(fid,'#$ -pe one-node-mpi 2-64\n');
     84                        fprintf(fid,'#$ -R y\n');
     85                        fprintf(fid,'#$ -m beas\n');
     86                        fprintf(fid,'#$ -o %s.outlog \n',modelname);
     87                        fprintf(fid,'#$ -e %s.errlog \n\n',modelname);
     88                        fprintf(fid,'export ISSM_DIR="%s/../"\n',cluster.codepath); %FIXME
     89                        fprintf(fid,'source $ISSM_DIR/etc/environment.sh\n');       %FIXME
     90                        fprintf(fid,'cd %s/%s\n\n',cluster.executionpath,modelname);
     91                        fprintf(fid,'mpiexec -np %i %s/kriging.exe %s %s\n',cluster.np,cluster.codepath,[cluster.executionpath '/' modelname],modelname);
     92                        if ~io_gather, %concatenate the output files:
     93                                fprintf(fid,'cat %s.outbin.* > %s.outbin',modelname,modelname);
     94                        end
     95                        fclose(fid);
     96                end
     97                %}}}
     98                function BuildQueueScript(cluster,dirname,modelname,solution,io_gather,isvalgrind,isgprof,isdakota,isoceancoupling) % {{{
     99
     100                        if(isvalgrind), disp('valgrind not supported by cluster, ignoring...'); end
     101                        if(isgprof),    disp('gprof not supported by cluster, ignoring...'); end
     102
     103                        executable='issm.exe';
     104                        if isdakota,
     105                                version=IssmConfig('_DAKOTA_VERSION_'); version=str2num(version(1:3));
     106                                if (version>=6),
     107                                        executable='issm_dakota.exe';
     108                                end
     109                        end
     110                        if isoceancoupling,
     111                                executable='issm_ocean.exe';
     112                        end
     113
     114                        %write queuing script
     115                        fid=fopen([modelname '.queue'],'w');
     116
     117                        fprintf(fid,'#!/bin/bash\n');
     118                        fprintf(fid,'#SBATCH -J %s \n',modelname);
     119                        fprintf(fid,'#SBATCH -p %s \n',cluster.queue);
     120                        fprintf(fid,'#SBATCH -o %s.outlog \n',modelname);
     121                        fprintf(fid,'#SBATCH -e %s.errlog \n',modelname);
     122                        fprintf(fid,'#SBATCH -n %i \n',cluster.numnodes*max(cluster.np/cluster.numnodes,24));
     123                        fprintf(fid,'#SBATCH -N %i \n',cluster.numnodes);
     124                        fprintf(fid,'#SBATCH -t %02i:%02i:00 \n\n',floor(cluster.time/3600),floor(mod(cluster.time,3600)/60));
     125                        for i=1:numel(cluster.modules),
     126                                fprintf(fid,['module load ' cluster.modules{i} '\n']);
     127                        end
     128
     129                        if isdakota,
     130                                fprintf(fid,'export KMP_AFFINITY="granularity=fine,compact,verbose" \n\n');
     131                        end
     132
     133                        if length(find(cluster.email=='@'))>0
     134                                fprintf(fid,'#SBATCH --mail-user=%s \n',cluster.email);
     135                                fprintf(fid,'#SBATCH --mail-type=end \n\n');
     136
     137                                %fprintf(fid,'ssh login1 "mail -s ''SLURM Jobid=${SLURM_JOBID} Name=${SLURM_JOB_NAME} Began on Lonestar 5.'' %s <<< ''Job Started'' " \n\n',cluster.email);
     138                        end
     139
     140                        fprintf(fid,'export PATH="$PATH:."\n\n');
     141                        fprintf(fid,'export ISSM_DIR="%s/../"\n',cluster.codepath); %FIXME
     142                        fprintf(fid,'source $ISSM_DIR/etc/environment.sh\n');       %FIXME
     143                        fprintf(fid,'cd %s/%s\n\n',cluster.executionpath,dirname);
     144                        fprintf(fid,'ibrun -np %i %s/%s %s %s %s\n',cluster.np,cluster.codepath,executable,solution,[cluster.executionpath '/' dirname],modelname);
     145                        if ~io_gather, %concatenate the output files:
     146                                fprintf(fid,'cat %s.outbin.* > %s.outbin',modelname,modelname);
     147                        end
     148
     149                        fclose(fid);
     150
     151                        %in interactive mode, create a run file, and errlog and outlog file
     152                        if cluster.interactive,
     153                                fid=fopen([modelname '.run'],'w');
     154                                fprintf(fid,'ibrun -np %i %s/%s %s %s %s\n',cluster.np,executable,cluster.codepath,solution,[cluster.executionpath '/' dirname],modelname);
     155                                if ~io_gather, %concatenate the output files:
     156                                        fprintf(fid,'cat %s.outbin.* > %s.outbin',modelname,modelname);
     157                                end
     158                                fclose(fid);
     159                                fid=fopen([modelname '.errlog'],'w');
     160                                fclose(fid);
     161                                fid=fopen([modelname '.outlog'],'w');
     162                                fclose(fid);
     163                        end
     164                end %}}}
     165                function UploadQueueJob(cluster,modelname,dirname,filelist) % {{{
     166
     167                        %compress the files into one zip.
     168                        compressstring=['tar -zcf ' dirname '.tar.gz '];
     169                        for i=1:numel(filelist),
     170                                compressstring = [compressstring ' ' filelist{i}];
     171                        end
     172                        if cluster.interactive,
     173                                compressstring = [compressstring ' ' modelname '.errlog ' modelname '.outlog '];
     174                        end
     175                        system(compressstring);
     176
     177                        disp('uploading input file and queueing script');
     178                        issmscpout(cluster.name,cluster.executionpath,cluster.login,cluster.port,{[dirname '.tar.gz']});
     179
     180                end %}}}
     181                function LaunchQueueJob(cluster,modelname,dirname,filelist,restart,batch) % {{{
     182
     183                        disp('launching solution sequence on remote cluster');
     184                        if ~isempty(restart)
     185                                launchcommand=['cd ' cluster.executionpath ' && cd ' dirname ' && hostname && sbatch ' modelname '.queue '];
     186                        else
     187                                launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' dirname ' && mkdir ' dirname ...
     188                                        ' && cd ' dirname ' && mv ../' dirname '.tar.gz ./ && tar -zxf ' dirname '.tar.gz  && hostname && sbatch ' modelname '.queue '];
     189                        end
     190                        issmssh(cluster.name,cluster.login,cluster.port,launchcommand);
     191                end %}}}
     192                function Download(cluster,dirname,filelist) % {{{
     193
     194                        %copy files from cluster to current directory
     195                        directory=[cluster.executionpath '/' dirname '/'];
     196                        issmscpin(cluster.name,cluster.login,cluster.port,directory,filelist);
     197
     198                end %}}}
    199199        end
    200200end
  • issm/trunk-jpl/src/m/classes/clusters/maui.m

    r25395 r26330  
    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('    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=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.np,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                        %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) % {{{
    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.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);
    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.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) % {{{
    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
  • issm/trunk-jpl/src/m/classes/clusters/pfe.m

    r26034 r26330  
    1 %PFE class definition
     1%PFE cluster class definition
    22%
    33%   Usage:
     
    77
    88classdef pfe
    9         properties (SetAccess=public) 
     9        properties (SetAccess=public)
    1010                % {{{
    1111                name           = 'pfe'
     
    3939                %}}}
    4040                function disp(cluster) % {{{
    41                         %  display the object
     41                        % TODO:
     42                        % - Correct formatting of modules and cluster.np
     43                        %
     44
     45                        % display the object
    4246                        disp(sprintf('class ''%s'' object ''%s'' = ',class(cluster),inputname(1)));
    43                         disp(sprintf('    name: %s',cluster.name));
    44                         disp(sprintf('    login: %s',cluster.login));
    45                         modules=''; for i=1:length(cluster.modules), modules=[modules cluster.modules{i} ',']; end; modules=modules(1:end-1);
    46                         disp(sprintf('    modules: %s',modules));
    47                         disp(sprintf('    port: %i',cluster.port));
    48                         disp(sprintf('    numnodes: %i',cluster.numnodes));
    49                         disp(sprintf('    cpuspernode: %i',cluster.cpuspernode));
    50                         disp(sprintf('    np: %i',cluster.cpuspernode*cluster.numnodes));
    51                         disp(sprintf('    queue: %s',cluster.queue));
    52                         disp(sprintf('    time: %i',cluster.time));
    53                         disp(sprintf('    processor: %s',cluster.processor));
    54                         disp(sprintf('    srcpath: %s ($ISSM_DIR on pfe)',cluster.srcpath));
    55                         disp(sprintf('    codepath: %s  ($ISSM_DIR/bin on pfe)',cluster.codepath));
    56                         disp(sprintf('    executionpath: %s  (directory containing issm.exe on pfe)',cluster.executionpath));
    57                         disp(sprintf('    grouplist: %s',cluster.grouplist));
    58                         disp(sprintf('    interactive: %i',cluster.interactive));
    59                         disp(sprintf('    hyperthreading: %i',cluster.hyperthreading));
     47                        fielddisplay(cluster,'name','name of the cluster');
     48                        fielddisplay(cluster,'login','login');
     49                        modules=''; for i=1:length(cluster.modules), modules=[modules cluster.modules{i} ',']; end; modules=modules(1:end-1);
     50                        disp(sprintf('         modules                : %s',modules));
     51                        fielddisplay(cluster,'port','machine access port');
     52                        fielddisplay(cluster,'numnodes','number of nodes');
     53                        fielddisplay(cluster,'cpuspernode','number of CPUs per node');
     54                        disp(sprintf('         np:                    : %i             -- %s',cluster.np(),'number of CPUs'));
     55                        fielddisplay(cluster,'queue','name of the queue');
     56                        fielddisplay(cluster,'time','walltime requested');
     57                        fielddisplay(cluster,'processor','type of processor');
     58                        fielddisplay(cluster,'srcpath','$ISSM_DIR on pfe');
     59                        fielddisplay(cluster,'codepath','$ISSM_DIR/bin on pfe');
     60                        fielddisplay(cluster,'executionpath','directory containing issm.exe on pfe');
     61                        fielddisplay(cluster,'grouplist','grouplist');
     62                        fielddisplay(cluster,'interactive','');
     63                        fielddisplay(cluster,'bbftp','');
     64                        fielddisplay(cluster,'numstreams','');
     65                        fielddisplay(cluster,'hyperthreading','');
    6066                end
    6167                %}}}
     
    128134                       
    129135                        else
    130                                 md = checkmessage(md,'unknown processor type, should be ''bro'' or ''has'' or ''ivy'' or ''san'' or ''cas_ait''');
     136                                md = checkmessage(md,'unknown processor type, should be ''bro'', ''has'', ''ivy'', ''san'', or ''cas_ait''');
    131137                        end
    132138
     
    137143                        if isempty(cluster.executionpath), md = checkmessage(md,'executionpath empty'); end
    138144                        if isempty(cluster.grouplist), md = checkmessage(md,'grouplist empty'); end
     145                        if ~isempty(cluster.interactive), md = checkmessage(md,'interactive mode not implemented'); end
    139146
    140147                end
     
    164171                        fprintf(fid,'#PBS -W group_list=%s\n',cluster.grouplist);
    165172                        fprintf(fid,'#PBS -m e\n');
    166                         fprintf(fid,'#PBS -o %s.outlog \n',[cluster.executionpath '/' dirname '/' modelname]);
    167                         fprintf(fid,'#PBS -e %s.errlog \n\n',[cluster.executionpath '/' dirname '/' modelname]);
     173                        fprintf(fid,'#PBS -o %s/%s/%s.outlog \n',cluster.executionpath,dirname,modelname);
     174                        fprintf(fid,'#PBS -e %s/%s/%s.errlog \n\n',cluster.executionpath,dirname,modelname);
    168175                        fprintf(fid,'. /usr/share/modules/init/bash\n\n');
    169176                        for i=1:numel(cluster.modules), fprintf(fid,['module load ' cluster.modules{i} '\n']); end
     
    176183                        fprintf(fid,'cd %s/%s/\n\n',cluster.executionpath,dirname);
    177184                        if ~isvalgrind,
    178                                 fprintf(fid,'/u/scicon/tools/bin/several_tries mpiexec -np %i /u/scicon/tools/bin/mbind.x -cs -n%i %s/%s %s %s %s\n',cluster.np,cluster.cpuspernode,cluster.codepath,executable,solution,[cluster.executionpath '/' dirname],modelname);
     185                                fprintf(fid,'/u/scicon/tools/bin/several_tries mpiexec -np %i /u/scicon/tools/bin/mbind.x -cs -n%i %s/%s %s %s/%s %s\n',cluster.np,cluster.cpuspernode,cluster.codepath,executable,solution,cluster.executionpath,dirname,modelname);
    179186                        else
    180187                                fprintf(fid,'mpiexec -np %i valgrind --leak-check=full %s/%s %s %s %s\n',cluster.np,cluster.codepath,executable,solution,[cluster.executionpath '/' dirname],modelname);
     
    382389
    383390                end %}}}
    384                 function UploadQueueJob(cluster,modelname,dirname,filelist)% {{{
     391                function UploadQueueJob(cluster,modelname,dirname,filelist) % {{{
    385392
    386393                        %compress the files into one zip.
    387                         compressstring=['tar -zcf ' dirname '.tar.gz '];
     394                        compressstring=['tar -zcf ' dirname '.tar.gz'];
    388395                        for i=1:numel(filelist),
    389396                                compressstring = [compressstring ' ' filelist{i}];
     
    411418                end
    412419                %}}}
    413                 function LaunchQueueJob(cluster,modelname,dirname,filelist,restart,batch)% {{{
     420                function LaunchQueueJob(cluster,modelname,dirname,filelist,restart,batch) % {{{
    414421
    415422                        %lauch command, to be executed via ssh
     
    437444                end
    438445                %}}}
    439                 function Download(cluster,dirname,filelist)% {{{
     446                function Download(cluster,dirname,filelist) % {{{
    440447
    441448                        %copy files from cluster to current directory
  • issm/trunk-jpl/src/m/classes/clusters/pfe.py

    r25453 r26330  
    11import subprocess
     2
    23from fielddisplay import fielddisplay
    3 from pairoptions import pairoptions
    4 from issmssh import issmssh
     4from IssmConfig import IssmConfig
    55from issmscpin import issmscpin
    66from issmscpout import issmscpout
    7 from QueueRequirements import QueueRequirements
    8 from IssmConfig import IssmConfig
     7from issmssh import issmssh
     8from pairoptions import pairoptions
    99try:
    1010    from pfe_settings import pfe_settings
    1111except ImportError:
    1212    print('You need pfe_settings.py to proceed, check presence and sys.path')
    13 
     13from QueueRequirements import QueueRequirements
    1414
    1515class pfe(object):
     16    """PFE cluster class definition
     17
     18    Usage:
     19        cluster = pfe()
     20        cluster = pfe('np', 3)
     21        cluster = pfe('np', 3, 'login', 'username')
    1622    """
    17     PFE cluster class definition
    18 
    19        Usage:
    20           cluster = pfe()
    21           cluster = pfe('np', 3)
    22           cluster = pfe('np', 3, 'login', 'username')
    23     """
    24 
    25     def __init__(self, *args):    # {{{
     23
     24    def __init__(self, *args):  # {{{
    2625        self.name = 'pfe'
    2726        self.login = ''
     27        self.modules = ['comp-intel/2016.2.181', 'mpi-sgi/mpt']
    2828        self.numnodes = 20
    2929        self.cpuspernode = 8
     
    3131        self.queue = 'long'
    3232        self.time = 12 * 60
    33         self.processor = 'bro'
     33        self.processor = 'ivy'
    3434        self.srcpath = ''
    3535        self.codepath = ''
    3636        self.executionpath = ''
    37         self.grouplist = 's1010'
     37        self.grouplist = 's1690'
    3838        self.interactive = 0
    3939        self.bbftp = 0
     
    4141        self.hyperthreading = 0
    4242
    43         #use provided options to change fields
     43        # Use provided options to change fields
    4444        options = pairoptions(*args)
    4545
    46         #initialize cluster using user settings if provided
    47         self = pfe_settings(self)
    48         self.np = self.nprocs()
     46        # Initialize cluster using user settings if provided
     47        try:
     48            self = pfe_settings(self)
     49        except NameError:
     50            print('pfe_settings.py not found, using default settings')
    4951
    5052        #OK get other fields
    5153        self = options.AssignObjectFields(self)
    52 
    53     # }}}
    54 
    55     def __repr__(self):    # {{{
    56         #  display the object
    57         s = "class pfe object:"
    58         s = "%s\n%s" % (s, fielddisplay(self, 'name', 'name of the cluster'))
    59         s = "%s\n%s" % (s, fielddisplay(self, 'login', 'login'))
    60         s = "%s\n%s" % (s, fielddisplay(self, 'numnodes', 'number of nodes'))
    61         s = "%s\n%s" % (s, fielddisplay(self, 'cpuspernode', 'number of nodes per CPUs'))
    62         s = "%s\n%s" % (s, fielddisplay(self, 'np', 'number of CPUs'))
    63         s = "%s\n%s" % (s, fielddisplay(self, 'port', 'machine access port'))
    64         s = "%s\n%s" % (s, fielddisplay(self, 'queue', 'name of the queue'))
    65         s = "%s\n%s" % (s, fielddisplay(self, 'time', 'walltime requested'))
    66         s = "%s\n%s" % (s, fielddisplay(self, 'processor', 'type of processor'))
    67         s = "%s\n%s" % (s, fielddisplay(self, 'codepath', '$ISSM_DIR on pfe'))
    68         s = "%s\n%s" % (s, fielddisplay(self, 'executionpath', 'directory containing issm.exe on pfe'))
    69         s = "%s\n%s" % (s, fielddisplay(self, 'grouplist', 'name of the group'))
    70         s = "%s\n%s" % (s, fielddisplay(self, 'interactive', ''))
    71         s = "%s\n%s" % (s, fielddisplay(self, 'bbftp', ''))
    72         s = "%s\n%s" % (s, fielddisplay(self, 'numstreams', ''))
    73         s = "%s\n%s" % (s, fielddisplay(self, 'hyperthreading', ''))
     54    # }}}
     55
     56    def __repr__(self):  # {{{
     57        # TODO:
     58        # - Correct formatting of modules and cluster.np
     59        #
     60
     61        # Display the object
     62        s = 'class pfe object\n'
     63        s += '{}\n'.format(fielddisplay(self, 'name', 'name of the cluster'))
     64        s += '{}\n'.format(fielddisplay(self, 'login', 'login'))
     65        modules = ''
     66        for i in range(len(self.modules)):
     67            modules += self.modules[i] + ','
     68        modules = modules[:-1]
     69        s += '         modules                : {}\n'.format(modules)
     70        s += '{}\n'.format(fielddisplay(self, 'port', 'machine access port'))
     71        s += '{}\n'.format(fielddisplay(self, 'numnodes', 'number of nodes'))
     72        s += '{}\n'.format(fielddisplay(self, 'cpuspernode', 'number of CPUs per node'))
     73        s += '         np:                    : {}             -- {}\n'.format(self.nprocs(), 'number of CPUs')
     74        s += '{}\n'.format(fielddisplay(self, 'queue', 'name of the queue'))
     75        s += '{}\n'.format(fielddisplay(self, 'time', 'walltime requested'))
     76        s += '{}\n'.format(fielddisplay(self, 'processor', 'type of processor'))
     77        s += '{}\n'.format(fielddisplay(self, 'srcpath', '$ISSM_DIR on pfe'))
     78        s += '{}\n'.format(fielddisplay(self, 'codepath', '$ISSM_DIR/bin on pfe'))
     79        s += '{}\n'.format(fielddisplay(self, 'executionpath', 'directory containing issm.exe on pfe'))
     80        s += '{}\n'.format(fielddisplay(self, 'grouplist', 'grouplist'))
     81        s += '{}\n'.format(fielddisplay(self, 'interactive', ''))
     82        s += '{}\n'.format(fielddisplay(self, 'bbftp', ''))
     83        s += '{}\n'.format(fielddisplay(self, 'numstreams', ''))
     84        s += '{}\n'.format(fielddisplay(self, 'hyperthreading', ''))
    7485        return s
    7586    # }}}
    7687
    77     def nprocs(self):    # {{{
    78         self.np = self.numnodes * self.cpuspernode
    79         return self.np
    80     # }}}
    81 
    82     def checkconsistency(self, md, solution, analyses):    # {{{
     88    def nprocs(self):  # {{{
     89        return self.numnodes * self.cpuspernode
     90    # }}}
     91
     92    def checkconsistency(self, md, solution, analyses):  # {{{
    8393        queuedict = {'long': [5 * 24 * 60, 2048],
    8494                     'normal': [8 * 60, 2048],
     
    8797        QueueRequirements(queuedict, self.queue, self.nprocs(), self.time)
    8898
    89         #now, check cluster.cpuspernode according to processor type
    90         if self.processor == 'har' or self.processor == 'neh':
     99        # Now, check cluster.cpuspernode according to processor type
     100        if self.processor == 'ivy':
    91101            if self.hyperthreading:
    92                 if not 0 < self.cpuspernode < 17:
     102                if self.cpuspernode > 40 or self.cpuspernode < 1:
     103                    md = md.checkmessage('cpuspernode should be between 1 and 40 for ''ivy'' processors in hyperthreading mode')
     104            else:
     105                if self.cpuspernode > 20 or self.cpuspernode < 1:
     106                    md = md.checkmessage('cpuspernode should be between 1 and 20 for ''ivy'' processors')
     107        elif self.processor == 'bro':
     108            if self.hyperthreading:
     109                if self.cpuspernode > 56 or self.cpuspernode < 1:
     110                    md = md.checkmessage('cpuspernode should be between 1 and 56 for ''bro'' processors in hyperthreading mode')
     111            else:
     112                if self.cpuspernode > 28 or self.cpuspernode < 1:
     113                    md = md.checkmessage('cpuspernode should be between 1 and 28 for ''bro'' processors')
     114        elif self.processor == 'har' or self.processor == 'neh':
     115            if self.hyperthreading:
     116                if self.cpuspernode > 16 or self.cpuspernode < 1:
    93117                    md = md.checkmessage('cpuspernode should be between 1 and 16 for ''neh'' and ''har'' processors in hyperthreading mode')
    94118            else:
    95                 if not 0 < self.cpuspernode < 9:
     119                if self.cpuspernode > 8 or self.cpuspernode < 1:
    96120                    md = md.checkmessage('cpuspernode should be between 1 and 8 for ''neh'' and ''har'' processors')
    97 
    98         elif self.processor == 'bro':
    99             if self.hyperthreading:
    100                 if not 0 < self.cpuspernode < 57:
    101                     md = md.checkmessage('cpuspernode should be between 1 and 56 for ''bro'' processors in hyperthreading mode')
    102             else:
    103                 if not 0 < self.cpuspernode < 29:
    104                     md = md.checkmessage('cpuspernode should be between 1 and 28 for ''bro'' processors')
    105 
    106         elif self.processor == 'ivy':
    107             if self.hyperthreading:
    108                 if not 0 < self.cpuspernode < 41:
    109                     md = md.checkmessage('cpuspernode should be between 1 and 40 for ''ivy'' processors in hyperthreading mode')
    110             else:
    111                 if not 0 < self.cpuspernode < 21:
    112                     md = md.checkmessage('cpuspernode should be between 1 and 20 for ''ivy'' processors')
    113121        else:
    114             md = md.checkmessage('unknown processor type, should be ''neh'', ''bro'' or ''har'' or ''ivy''')
    115 
    116         #Miscellaneous
     122            md = md.checkmessage('unknown processor type, should be \'ivy\', \'bro\', \'har\', or \'neh\'')
     123
     124        # Miscellaneous
    117125        if not self.login:
    118126            md = md.checkmessage('login empty')
     
    131139    # }}}
    132140
    133     def BuildQueueScript(self, dirname, modelname, solution, io_gather, isvalgrind, isgprof, isdakota, isoceancoupling):    # {{{
     141    def BuildQueueScript(self, dirname, modelname, solution, io_gather, isvalgrind, isgprof, isdakota, isoceancoupling):  # {{{
     142        if isgprof:
     143            print('gprof not supported by cluster, ignoring...')
     144
    134145        executable = 'issm.exe'
    135146        if isdakota:
     
    141152            executable = 'issm_ocean.exe'
    142153
    143     #write queuing script
     154        # Write queuing script
    144155        fid = open(modelname + '.queue', 'w')
    145         fid.write('#PBS -S / bin / bash\n')
    146         fid.write('#PBS -l select=%i:ncpus=%i:model=%s\n' % (self.numnodes, self.cpuspernode, self.processor))
    147         fid.write('#PBS -l walltime=%i\n' % (self.time * 60))
    148         fid.write('#PBS -q %s \n' % self.queue)
    149         fid.write('#PBS -W group_list=%s\n' % self.grouplist)
     156        fid.write('#PBS -S /bin/bash\n')
     157        fid.write('#PBS -l select={}:ncpus={}:model={}\n'.format(self.numnodes, self.cpuspernode, self.processor))
     158        fid.write('#PBS -l walltime={}\n'.format(self.time * 60)) # walltime is in seconds
     159        fid.write('#PBS -q {} \n'.format(self.queue))
     160        fid.write('#PBS -W group_list={}\n'.format(self.grouplist))
    150161        fid.write('#PBS -m e\n')
    151         fid.write('#PBS -o %s/%s/%s.outlog \n' % (self.executionpath, dirname, modelname))
    152         fid.write('#PBS -e %s/%s/%s.errlog \n\n' % (self.executionpath, dirname, modelname))
    153         fid.write('./usr/share/modules/init/bash\n\n')
    154         fid.write('module load comp-intel/2015.0.090\n')
    155         fid.write('module load mpi-sgi/mpt.2.11r13\n')
     162        fid.write('#PBS -o {}/{}/{}.outlog \n'.format(self.executionpath, dirname, modelname))
     163        fid.write('#PBS -e {}/{}/{}.errlog \n\n'.format(self.executionpath, dirname, modelname))
     164        fid.write('. /usr/share/modules/init/bash\n\n')
     165        for i in range(len(self.modules)):
     166            fid.write('module load {}\n'.format(self.modules[i]))
    156167        fid.write('export PATH="$PATH:."\n\n')
     168        fid.write('export MPI_LAUNCH_TIMEOUT=520\n')
    157169        fid.write('export MPI_GROUP_MAX=64\n\n')
    158         fid.write('export ISSM_DIR="%s"\n' % self.srcpath)
    159         fid.write('source $ISSM_DIR/etc/environment.sh\n')
     170        fid.write('export ISSM_DIR="{}"\n'.format(self.srcpath)) # FIXME
     171        fid.write('source $ISSM_DIR/etc/environment.sh\n') # FIXME
    160172        fid.write('export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$ISSM_DIR/externalpackages/petsc/install/lib"\n')
    161         fid.write('cd %s/%s/ \n\n' % (self.executionpath, dirname))
    162         fid.write('mpiexec - np %i %s/%s %s %s/%s %s\n' % (self.nprocs(), self.codepath, executable, str(solution), self.executionpath, dirname, modelname))
     173        fid.write('cd %s/%s/\n\n'.format(self.executionpath, dirname))
     174        fid.write('mpiexec -np {} {}/{} {} {}/{} {}\n'.format(self.nprocs(), self.cpuspernode, self.codepath, executable, solution, self.executionpath, dirname, modelname))
    163175
    164176        fid.close()
     
    166178    # }}}
    167179
    168     def UploadQueueJob(self, modelname, dirname, filelist):    # {{{
    169         #compress the files into one zip.
    170         compressstring = 'tar -zcf %s.tar.gz ' % dirname
     180    def UploadQueueJob(self, modelname, dirname, filelist):  # {{{
     181        # Compress the files into one zip
     182        compressstring = 'tar -zcf {}.tar.gz'.format(dirname)
    171183        for file in filelist:
    172             compressstring += ' %s' % file
     184            compressstring += file
    173185        subprocess.call(compressstring, shell=True)
    174186
    175187        print('uploading input file and queueing script')
    176         issmscpout(self.name, self.executionpath, self.login, self.port, [dirname + '.tar.gz'])
    177 
    178     # }}}
    179     def LaunchQueueJob(self, modelname, dirname, filelist, restart, batch):    # {{{
     188        directory = self.executionpath
     189        issmscpout(self.name, directory, self.login, self.port, [dirname + '.tar.gz'])
     190
     191    # }}}
     192    def LaunchQueueJob(self, modelname, dirname, filelist, restart, batch):  # {{{
     193        if restart:
     194            launchcommand = 'cd {} && cd {} && qsub {}.queue'.format(self.executionpath, dirname, modelname)
     195        else:
     196            launchcommand = 'cd {} && rm -rf ./{} && mkdir {} && cd {} && mv ../{}.tar.gz ./ && tar -zxf {}.tar.gz  && qsub {}.queue'.format(self.executionpath, dirname, dirname, dirname, dirname, dirname, modelname)
     197
    180198        print('launching solution sequence on remote cluster')
    181         if restart:
    182             launchcommand = 'cd %s && cd %s && qsub %s.queue' % (self.executionpath, dirname, modelname)
    183         else:
    184             launchcommand = 'cd %s && rm -rf ./%s && mkdir %s && cd %s && mv ../%s.tar.gz ./ && tar -zxf %s.tar.gz  && qsub %s.queue' % (self.executionpath, dirname, dirname, dirname, dirname, dirname, modelname)
    185199        issmssh(self.name, self.login, self.port, launchcommand)
    186200
    187201    # }}}
    188     def Download(self, dirname, filelist):    # {{{
    189         #copy files from cluster to current directory
    190         directory = '%s/%s/' % (self.executionpath, dirname)
     202    def Download(self, dirname, filelist):  # {{{
     203        # Copy files from cluster to current directory
     204        directory = '{}/{}/'.format(self.executionpath, dirname)
    191205        issmscpin(self.name, self.login, self.port, directory, filelist)
    192206    # }}}
  • issm/trunk-jpl/src/m/classes/clusters/sherlock.m

    r24160 r26330  
    1 %PFE class definition
     1%SHERLOCK cluster class definition
    22%
    33%   Usage:
     
    77
    88classdef 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) % {{{
     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) % {{{
    2525
    26                          %initialize cluster using default settings if provided
    27                          if (exist('sherlock_settings')==2), sherlock_settings; end
     26                        %initialize cluster using default settings if provided
     27                        if (exist('sherlock_settings')==2), sherlock_settings; end
    2828
    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) % {{{
     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=nprocs(cluster) % {{{
     50                        %compute number of processors
     51                        numprocs=cluster.numnodes*cluster.cpuspernode;
     52                end
     53                %}}}
     54                function md = checkconsistency(cluster,md,solution,analyses) % {{{
    5555
    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
     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
    6060
    61                  end
    62                  %}}}
    63                  function BuildKrigingQueueScript(cluster,dirname,modelname,solution,io_gather,isvalgrind,isgprof,isdakota,isoceancoupling) % {{{
     61                end
     62                %}}}
     63                function BuildKrigingQueueScript(cluster,dirname,modelname,solution,io_gather,isvalgrind,isgprof,isdakota,isoceancoupling) % {{{
    6464
    65                          if(isvalgrind), disp('valgrind not supported by cluster, ignoring...'); end
    66                          if(isgprof),    disp('gprof not supported by cluster, ignoring...'); end
     65                        if(isvalgrind), disp('valgrind not supported by cluster, ignoring...'); end
     66                        if(isgprof),    disp('gprof not supported by cluster, ignoring...'); end
    6767
    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) % {{{
     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) % {{{
    8989
    90                          if(isvalgrind), disp('valgrind not supported by cluster, ignoring...'); end
    91                          if(isgprof),    disp('gprof not supported by cluster, ignoring...'); end
     90                        if(isvalgrind), disp('valgrind not supported by cluster, ignoring...'); end
     91                        if(isgprof),    disp('gprof not supported by cluster, ignoring...'); end
    9292
    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);
     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);
    110110
    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)% {{{
     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) % {{{
    126126
    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);
     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);
    136136
    137                          disp('uploading input file and queueing script');
    138                          issmscpout(cluster.name,cluster.executionpath,cluster.login,cluster.port,{[dirname '.tar.gz']});
     137                        disp('uploading input file and queueing script');
     138                        issmscpout(cluster.name,cluster.executionpath,cluster.login,cluster.port,{[dirname '.tar.gz']});
    139139
    140                  end %}}}
    141                  function LaunchQueueJob(cluster,modelname,dirname,filelist,restart,batch)% {{{
     140                end %}}}
     141                function LaunchQueueJob(cluster,modelname,dirname,filelist,restart,batch) % {{{
    142142
    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)% {{{
     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) % {{{
    153153
    154                          %copy files from cluster to current directory
    155                          directory=[cluster.executionpath '/' dirname '/'];
    156                          issmscpin(cluster.name,cluster.login,cluster.port,directory,filelist);
     154                        %copy files from cluster to current directory
     155                        directory=[cluster.executionpath '/' dirname '/'];
     156                        issmscpin(cluster.name,cluster.login,cluster.port,directory,filelist);
    157157
    158                  end %}}}
     158                end %}}}
    159159        end
    160160end
  • issm/trunk-jpl/src/m/classes/clusters/tetralith.m

    r23265 r26330  
    1 %teralith class definition
     1%TERALITH cluster class definition
    22%
    33%   Usage:
     
    77
    88classdef tetralith
    9         properties (SetAccess=public) 
     9        properties (SetAccess=public)
    1010                % {{{
    1111                name           = 'tetralith';
     
    6666                end
    6767                %}}}
    68                 function numprocs=np(self) % {{{
     68                function numprocs=nprocs(self) % {{{
    6969                        %compute number of processors
    7070                        numprocs=self.numnodes*self.cpuspernode;
     
    7878                        %compute number of processors
    7979%                       cluster.np=cluster.numnodes*cluster.cpuspernode;
    80                         np(cluster);%=cluster.numnodes*cluster.cpuspernode;
     80                        nprocs(cluster);%=cluster.numnodes*cluster.cpuspernode;
    8181
    8282                        %write queuing script
     
    106106%                       fprintf(fid,'mpiexec -np %i %s/%s %s %s %s\n',cluster.np,cluster.codepath,executable,solution,[cluster.executionpath '/' dirname],modelname);
    107107%                       fprintf(fid,'mpiexec_mpt -np %i %s/%s %s %s %s\n',cluster.np,cluster.codepath,executable,solution,[cluster.executionpath '/' dirname],modelname);
    108                          fprintf(fid,'mpiexec -np %i %s/issm.exe %s %s %s\n',cluster.np,cluster.codepath,solution,[cluster.executionpath '/' dirname],modelname);
     108                        fprintf(fid,'mpiexec -np %i %s/issm.exe %s %s %s\n',cluster.np,cluster.codepath,solution,[cluster.executionpath '/' dirname],modelname);
    109109%                       fprintf(fid,'mpirun -np %i %s/issm.exe %s %s %s\n',cluster.np,cluster.codepath,solution,[cluster.executionpath '/' dirname],modelname);
    110                          if ~io_gather, %concatenate the output files:
    111                                  fprintf(fid,'cat %s.outbin.* > %s.outbin',modelname,modelname);
    112                          end
    113                          fclose(fid);
     110                        if ~io_gather, %concatenate the output files:
     111                                fprintf(fid,'cat %s.outbin.* > %s.outbin',modelname,modelname);
     112                        end
     113                        fclose(fid);
    114114                end
    115115                %}}}
     
    132132                        %compute number of processors
    133133%                       cluster.np=cluster.numnodes*cluster.cpuspernode;
    134                         np(cluster);%=cluster.numnodes*cluster.cpuspernode;                     
     134                        nprocs(cluster);%=cluster.numnodes*cluster.cpuspernode;
    135135%                       shortname = substring(modelname,1,min(12,length(modelname)));
    136136
     
    160160                        fprintf(fid,'cd %s/%s\n\n',cluster.executionpath,dirname);
    161161%                       fprintf(fid,'mpiexec -np %i %s/%s %s %s %s\n',cluster.np,cluster.codepath,executable,solution,[cluster.executionpath '/' dirname],modelname);
    162                          fprintf(fid,'mpiexec -np %i %s/issm.exe %s %s %s\n',cluster.np,cluster.codepath,solution,[cluster.executionpath '/' dirname],modelname);
     162                        fprintf(fid,'mpiexec -np %i %s/issm.exe %s %s %s\n',cluster.np,cluster.codepath,solution,[cluster.executionpath '/' dirname],modelname);
    163163%                       fprintf(fid,'mpirun -np %i %s/issm.exe %s %s %s\n',cluster.np,cluster.codepath,solution,[cluster.executionpath '/' dirname],modelname);
    164164%                       fprintf(fid,'mpiexec_mpt -np %i %s/%s %s %s %s\n',cluster.np,cluster.codepath,executable,solution,[cluster.executionpath '/' dirname],modelname);
     
    183183                        end
    184184                end %}}}
    185                 function UploadQueueJob(cluster,modelname,dirname,filelist)% {{{
     185                function UploadQueueJob(cluster,modelname,dirname,filelist) % {{{
    186186
    187187                        %compress the files into one zip.
     
    198198                end
    199199                %}}}
    200                 function LaunchQueueJob(cluster,modelname,dirname,filelist,restart,batch)% {{{
     200                function LaunchQueueJob(cluster,modelname,dirname,filelist,restart,batch) % {{{
    201201
    202202                        disp('launching solution sequence on remote cluster');
     
    206206                        issmssh(cluster.name,cluster.login,cluster.port,launchcommand);
    207207                end %}}}
    208                 function Download(cluster,dirname,filelist)% {{{
     208                function Download(cluster,dirname,filelist) % {{{
    209209
    210210                        %copy files from cluster to current directory
  • issm/trunk-jpl/src/m/classes/clusters/yellowstone.m

    r21699 r26330  
    1 %YELLOWSTONE class definition
     1%YELLOWSTONE cluster class definition
    22%
    33%   Usage:
     
    77
    88classdef yellowstone
    9     properties (SetAccess=public) 
    10                  % {{{
    11                  name           = 'yellowstone.ucar.edu'
    12                  login          = '';
    13                  modules        = {'ncarenv/1.0' 'ncarbinlibs/1.1' 'perlmods/5.0' 'gmake/4.1' 'python/2.7.7' 'all-python-libs' 'git/2.3.0' 'intel/15.0.3' 'mkl/11.1.2' 'esmf' 'esmf-6.3.0rp1-defio-mpi-O' 'netcdf-mpi/4.3.3.1' 'pnetcdf/1.6.1' 'ncarcompilers/1.0' 'cmake/3.0.2' 'matlab/R2015b' 'issm'};
    14                  numnodes       = 1;
    15                  cpuspernode    = 8;
    16                  port           = 0;
    17                  queue          = 'premium';
    18                  time           = 12*60;
    19                  processor      = 'sandy';
    20                  codepath       = '';
    21                  executionpath  = '';
    22                  grouplist     = 'P93300301';
    23          end
    24          %}}}
    25          methods
    26                  function cluster=yellowstone(varargin) % {{{
     9        properties (SetAccess=public)
     10                % {{{
     11                name           = 'yellowstone.ucar.edu'
     12                login          = '';
     13                modules        = {'ncarenv/1.0' 'ncarbinlibs/1.1' 'perlmods/5.0' 'gmake/4.1' 'python/2.7.7' 'all-python-libs' 'git/2.3.0' 'intel/15.0.3' 'mkl/11.1.2' 'esmf' 'esmf-6.3.0rp1-defio-mpi-O' 'netcdf-mpi/4.3.3.1' 'pnetcdf/1.6.1' 'ncarcompilers/1.0' 'cmake/3.0.2' 'matlab/R2015b' 'issm'};
     14                numnodes       = 1;
     15                cpuspernode    = 8;
     16                port           = 0;
     17                queue          = 'premium';
     18                time           = 12*60;
     19                processor      = 'sandy';
     20                codepath       = '';
     21                executionpath  = '';
     22                grouplist     = 'P93300301';
     23        end
     24        %}}}
     25        methods
     26                function cluster=yellowstone(varargin) % {{{
    2727
    28                          %initialize cluster using default settings if provided
    29                          if (exist('yellowstone_settings')==2), yellowstone_settings; end
     28                        %initialize cluster using default settings if provided
     29                        if (exist('yellowstone_settings')==2), yellowstone_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                          modules=''; for i=1:length(cluster.modules), modules=[modules cluster.modules{i} ',']; end; modules=modules(1:end-1);
    41                          disp(sprintf('    modules: %s',modules));
    42                          disp(sprintf('    port: %i',cluster.port));
    43                          disp(sprintf('    numnodes: %i',cluster.numnodes));
    44                          disp(sprintf('    cpuspernode: %i',cluster.cpuspernode));
    45                          disp(sprintf('    np: %i',cluster.cpuspernode*cluster.numnodes));
    46                          disp(sprintf('    queue: %s',cluster.queue));
    47                          disp(sprintf('    time: %i',cluster.time));
    48                          disp(sprintf('    processor: %s',cluster.processor));
    49                          disp(sprintf('    codepath: %s',cluster.codepath));
    50                          disp(sprintf('    executionpath: %s',cluster.executionpath));
    51                          disp(sprintf('    grouplist: %s',cluster.grouplist));
    52                  end
    53                  %}}}
    54                  function numprocs=np(cluster) % {{{
    55                          %compute number of processors
    56                          numprocs=cluster.numnodes*cluster.cpuspernode;
    57                  end
    58                  %}}}
    59                  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                        modules=''; for i=1:length(cluster.modules), modules=[modules cluster.modules{i} ',']; end; modules=modules(1:end-1);
     41                        disp(sprintf('    modules: %s',modules));
     42                        disp(sprintf('    port: %i',cluster.port));
     43                        disp(sprintf('    numnodes: %i',cluster.numnodes));
     44                        disp(sprintf('    cpuspernode: %i',cluster.cpuspernode));
     45                        disp(sprintf('    np: %i',cluster.cpuspernode*cluster.numnodes));
     46                        disp(sprintf('    queue: %s',cluster.queue));
     47                        disp(sprintf('    time: %i',cluster.time));
     48                        disp(sprintf('    processor: %s',cluster.processor));
     49                        disp(sprintf('    codepath: %s',cluster.codepath));
     50                        disp(sprintf('    executionpath: %s',cluster.executionpath));
     51                        disp(sprintf('    grouplist: %s',cluster.grouplist));
     52                end
     53                %}}}
     54                function numprocs=nprocs(cluster) % {{{
     55                        %compute number of processors
     56                        numprocs=cluster.numnodes*cluster.cpuspernode;
     57                end
     58                %}}}
     59                function md = checkconsistency(cluster,md,solution,analyses) % {{{
    6060
    61                          available_queues={'premium','regular'};
    62                          queue_requirements_time=[12*60 12*650];
    63                          queue_requirements_np=[16384 16384];
     61                        available_queues={'premium','regular'};
     62                        queue_requirements_time=[12*60 12*650];
     63                        queue_requirements_np=[16384 16384];
    6464
    65                          QueueRequirements(available_queues,queue_requirements_time,queue_requirements_np,cluster.queue,cluster.np,cluster.time)
     65                        QueueRequirements(available_queues,queue_requirements_time,queue_requirements_np,cluster.queue,cluster.np,cluster.time)
    6666
    67                          %Miscelaneous
    68                          if isempty(cluster.login), md = checkmessage(md,'login empty'); end
    69                          if isempty(cluster.codepath), md = checkmessage(md,'codepath empty'); end
    70                          if isempty(cluster.executionpath), md = checkmessage(md,'executionpath empty'); end
    71                          if isempty(cluster.grouplist), md = checkmessage(md,'grouplist empty'); end
     67                        %Miscelaneous
     68                        if isempty(cluster.login), md = checkmessage(md,'login empty'); end
     69                        if isempty(cluster.codepath), md = checkmessage(md,'codepath empty'); end
     70                        if isempty(cluster.executionpath), md = checkmessage(md,'executionpath empty'); end
     71                        if isempty(cluster.grouplist), md = checkmessage(md,'grouplist empty'); end
    7272
    73                  end
    74                  %}}}
    75                  function BuildQueueScript(cluster,dirname,modelname,solution,io_gather,isvalgrind,isgprof,isdakota,isoceancoupling) % {{{
     73                end
     74                %}}}
     75                function BuildQueueScript(cluster,dirname,modelname,solution,io_gather,isvalgrind,isgprof,isdakota,isoceancoupling) % {{{
    7676
    77                          executable='issm.exe';
    78                          if isdakota,
    79                                  version=IssmConfig('_DAKOTA_VERSION_'); version=str2num(version(1:3));
    80                                  if (version>=6),
    81                                          executable='issm_dakota.exe';
    82                                  end
    83                          end
    84                          if isoceancoupling,
    85                                  executable='issm_ocean.exe';
    86                          end
     77                        executable='issm.exe';
     78                        if isdakota,
     79                                version=IssmConfig('_DAKOTA_VERSION_'); version=str2num(version(1:3));
     80                                if (version>=6),
     81                                        executable='issm_dakota.exe';
     82                                end
     83                        end
     84                        if isoceancoupling,
     85                                executable='issm_ocean.exe';
     86                        end
    8787
    8888
    89                          %write queuing script
    90                          fid=fopen([modelname '.queue'],'w');
    91                          fprintf(fid,'#!/bin/tcsh\n');
    92                          fprintf(fid,'#BSUB -P %s\n',cluster.grouplist);
    93                          fprintf(fid,'#BSUB -W %i:%i\n',floor(cluster.time/60),cluster.time-floor(cluster.time/60)*60);
    94                          fprintf(fid,'#BSUB -n %i\n',cluster.np);
    95                          fprintf(fid,'#BSUB -J %s\n',modelname);
    96                          fprintf(fid,'#BSUB -o %s.outlog \n',[cluster.executionpath '/' dirname '/' modelname]);
    97                          fprintf(fid,'#BSUB -e %s.errlog \n',[cluster.executionpath '/' dirname '/' modelname]);
    98                          fprintf(fid,'#BSUB -q %s\n',cluster.queue);
     89                        %write queuing script
     90                        fid=fopen([modelname '.queue'],'w');
     91                        fprintf(fid,'#!/bin/tcsh\n');
     92                        fprintf(fid,'#BSUB -P %s\n',cluster.grouplist);
     93                        fprintf(fid,'#BSUB -W %i:%i\n',floor(cluster.time/60),cluster.time-floor(cluster.time/60)*60);
     94                        fprintf(fid,'#BSUB -n %i\n',cluster.np);
     95                        fprintf(fid,'#BSUB -J %s\n',modelname);
     96                        fprintf(fid,'#BSUB -o %s.outlog \n',[cluster.executionpath '/' dirname '/' modelname]);
     97                        fprintf(fid,'#BSUB -e %s.errlog \n',[cluster.executionpath '/' dirname '/' modelname]);
     98                        fprintf(fid,'#BSUB -q %s\n',cluster.queue);
    9999
    100                          fprintf(fid,'module purge\n');
    101                          for i=1:length(cluster.modules),
    102                                  fprintf(fid,'module load %s\n',cluster.modules{i});
    103                          end
     100                        fprintf(fid,'module purge\n');
     101                        for i=1:length(cluster.modules),
     102                                fprintf(fid,'module load %s\n',cluster.modules{i});
     103                        end
    104104
    105                          fprintf(fid,'setenv OMP_STACKSIZE 256M\n');
    106                          fprintf(fid,'setenv MP_LABELIO yes\n');
    107                          fprintf(fid,'setenv MP_INFOLEVEL 2\n');
    108                          fprintf(fid,'setenv MP_SHARED_MEMORY yes\n');
    109                          fprintf(fid,'setenv MP_EUILIB us\n');
    110                          fprintf(fid,'setenv MP_STDOUTMODE unordered\n');
    111                          fprintf(fid,'setenv MP_RC_USE_LMC yes\n');
    112                          fprintf(fid,'setenv MP_MPILIB mpich2\n');
    113                          fprintf(fid,'setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:/opt/ibmhpc/pecurrent/mpich2/intel/lib64/\n');
    114                          fprintf(fid,'setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:/ncar/opt/intel/psxe-2015_update3/impi/5.0.3.048/lib64/\n');
     105                        fprintf(fid,'setenv OMP_STACKSIZE 256M\n');
     106                        fprintf(fid,'setenv MP_LABELIO yes\n');
     107                        fprintf(fid,'setenv MP_INFOLEVEL 2\n');
     108                        fprintf(fid,'setenv MP_SHARED_MEMORY yes\n');
     109                        fprintf(fid,'setenv MP_EUILIB us\n');
     110                        fprintf(fid,'setenv MP_STDOUTMODE unordered\n');
     111                        fprintf(fid,'setenv MP_RC_USE_LMC yes\n');
     112                        fprintf(fid,'setenv MP_MPILIB mpich2\n');
     113                        fprintf(fid,'setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:/opt/ibmhpc/pecurrent/mpich2/intel/lib64/\n');
     114                        fprintf(fid,'setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:/ncar/opt/intel/psxe-2015_update3/impi/5.0.3.048/lib64/\n');
    115115
    116                          fprintf(fid,'cd %s/%s/\n\n',cluster.executionpath,dirname);
     116                        fprintf(fid,'cd %s/%s/\n\n',cluster.executionpath,dirname);
    117117
    118                          fprintf(fid,'mpirun.lsf %s/%s %s %s %s\n',cluster.codepath,executable,solution,[cluster.executionpath '/' dirname],modelname);
    119                          fclose(fid);
     118                        fprintf(fid,'mpirun.lsf %s/%s %s %s %s\n',cluster.codepath,executable,solution,[cluster.executionpath '/' dirname],modelname);
     119                        fclose(fid);
    120120
    121                  end %}}}
    122                  function UploadQueueJob(cluster,modelname,dirname,filelist)% {{{
     121                end %}}}
     122                function UploadQueueJob(cluster,modelname,dirname,filelist) % {{{
    123123
    124                          %compress the files into one zip.
    125                          compressstring=['tar -zcf ' dirname '.tar.gz '];
    126                          for i=1:numel(filelist),
    127                                  compressstring = [compressstring ' ' filelist{i}];
    128                          end
    129                          system(compressstring);
     124                        %compress the files into one zip.
     125                        compressstring=['tar -zcf ' dirname '.tar.gz '];
     126                        for i=1:numel(filelist),
     127                                compressstring = [compressstring ' ' filelist{i}];
     128                        end
     129                        system(compressstring);
    130130
    131                          disp('uploading input file and queueing script');
    132                          directory=cluster.executionpath;
     131                        disp('uploading input file and queueing script');
     132                        directory=cluster.executionpath;
    133133
    134                          issmscpout(cluster.name,directory,cluster.login,cluster.port,{[dirname '.tar.gz']});
     134                        issmscpout(cluster.name,directory,cluster.login,cluster.port,{[dirname '.tar.gz']});
    135135
    136                  end
    137                  %}}}
    138                  function LaunchQueueJob(cluster,modelname,dirname,filelist,restart,batch)% {{{
     136                end
     137                %}}}
     138                function LaunchQueueJob(cluster,modelname,dirname,filelist,restart,batch) % {{{
    139139
    140                          %lauch command, to be executed via ssh
    141                          launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' dirname ' && mkdir ' dirname ...
    142                                                  ' && cd ' dirname ' && mv ../' dirname '.tar.gz ./ && tar -zxf ' dirname '.tar.gz  && bsub < ' modelname '.queue '];
     140                        %lauch command, to be executed via ssh
     141                        launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' dirname ' && mkdir ' dirname ...
     142                                                ' && cd ' dirname ' && mv ../' dirname '.tar.gz ./ && tar -zxf ' dirname '.tar.gz  && bsub < ' modelname '.queue '];
    143143
    144                          disp('launching solution sequence on remote cluster');
    145                          issmssh(cluster.name,cluster.login,cluster.port,launchcommand);
    146                  end
    147                  %}}}
    148                  function Download(cluster,dirname,filelist)% {{{
     144                        disp('launching solution sequence on remote cluster');
     145                        issmssh(cluster.name,cluster.login,cluster.port,launchcommand);
     146                end
     147                %}}}
     148                function Download(cluster,dirname,filelist) % {{{
    149149
    150                          %copy files from cluster to current directory
    151                          directory=[cluster.executionpath '/' dirname '/'];
    152                          issmscpin(cluster.name,cluster.login,cluster.port,directory,filelist);
     150                        %copy files from cluster to current directory
     151                        directory=[cluster.executionpath '/' dirname '/'];
     152                        issmscpin(cluster.name,cluster.login,cluster.port,directory,filelist);
    153153
    154                  end %}}}
     154                end %}}}
    155155        end
    156156end
Note: See TracChangeset for help on using the changeset viewer.