Changeset 22054


Ignore:
Timestamp:
09/06/17 12:00:43 (8 years ago)
Author:
Mathieu Morlighem
Message:

CHG: fixing np

File:
1 edited

Legend:

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

    r21576 r22054  
    1 %PFE class definition
     1%vilje class definition
    22%
    33%   Usage:
     
    77
    88classdef vilje
    9     properties (SetAccess=public) 
    10                  % {{{
    11      name           = 'vilje';
    12                  login          = '';
    13                  numnodes       = 2;
    14                  cpuspernode    = 32;
    15      procspernodes  = 16;
    16      mem            = 28;
    17                  queue          = 'workq';
    18                  time           = 2*60;
    19                  codepath       = '';
    20                  executionpath  = '';
    21                  interactive    = 0;
    22      port           = [];
    23      accountname    = '';
     9        properties (SetAccess=public) 
     10                % {{{
     11                name           = 'vilje';
     12                login          = '';
     13                numnodes       = 2;
     14                cpuspernode    = 32;
     15                procspernodes  = 16;
     16                mem            = 28;
     17                queue          = 'workq';
     18                time           = 2*60;
     19                codepath       = '';
     20                executionpath  = '';
     21                interactive    = 0;
     22                port           = [];
     23                accountname    = '';
     24                % }}}
     25        end
     26        methods
     27                function cluster=vilje(varargin) % {{{
    2428
    25          end
    26          properties (SetAccess=private)
    27                  np=numnodes*procspernodes;
    28                  % }}}
    29          end
    30          methods
    31                  function cluster=vilje(varargin) % {{{
     29                        %initialize cluster using default settings if provided
     30                        if (exist('vilje_settings')==2), vilje_settings; end
    3231
    33                          %initialize cluster using default settings if provided
    34                          if (exist('vilje_settings')==2), vilje_settings; end
     32                        %use provided options to change fields
     33                        cluster=AssignObjectFields(pairoptions(varargin{:}),cluster);
     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('    accountname: %s',cluster.accountname));
     42                        disp(sprintf('    numnodes: %i',cluster.numnodes));
     43                        disp(sprintf('    cpuspernode: %i',cluster.cpuspernode));
     44                        disp(sprintf('    np: %i', cluster.cpuspernode*cluster.numnodes));
     45                        disp(sprintf('    procspernodes: %i',cluster.procspernodes));
     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('    memory: %i',cluster.mem));
     52                end
     53                %}}}
     54                function md = checkconsistency(cluster,md,solution,analyses) % {{{
    3555
    36                          %use provided options to change fields
    37                          cluster=AssignObjectFields(pairoptions(varargin{:}),cluster);
    38                  end
    39                  %}}}
    40                  function disp(cluster) % {{{
    41                          %  display the object
    42                          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        disp(sprintf('    accountname: %s',cluster.accountname));
    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('    procspernodes: %i',cluster.procspernodes));
    50                          disp(sprintf('    queue: %s',cluster.queue));
    51                          disp(sprintf('    codepath: %s',cluster.codepath));
    52                          disp(sprintf('    executionpath: %s',cluster.executionpath));
    53                          disp(sprintf('    interactive: %i',cluster.interactive));
    54                          disp(sprintf('    time: %i',cluster.time));
    55                          disp(sprintf('    memory: %i',cluster.mem));
    56                  end
    57                  %}}}
    58                  function md = checkconsistency(cluster,md,solution,analyses) % {{{
     56                        available_queues={'workq'};
     57                        queue_requirements_time=[5*24*60];
     58                        queue_requirements_np=[30];
    5959
    60                          available_queues={'workq'};
    61                          queue_requirements_time=[5*24*60];
    62                          queue_requirements_np=[30];
     60                        QueueRequirements(available_queues,queue_requirements_time,queue_requirements_np,cluster.queue,cluster.np,1)
    6361
    64                          QueueRequirements(available_queues,queue_requirements_time,queue_requirements_np,cluster.queue,cluster.np,1)
     62                        %Miscelaneous
     63                        if isempty(cluster.login), md = checkmessage(md,'login empty'); end
     64                        if isempty(cluster.accountname), md = checkmessage(md,'accountname empty'); end
     65                        if isempty(cluster.codepath), md = checkmessage(md,'codepath empty'); end
     66                        if isempty(cluster.executionpath), md = checkmessage(md,'executionpath empty'); end
    6567
    66                          %Miscelaneous
    67                          if isempty(cluster.login), md = checkmessage(md,'login empty'); end
    68        if isempty(cluster.accountname), md = checkmessage(md,'accountname empty'); end
    69                          if isempty(cluster.codepath), md = checkmessage(md,'codepath empty'); end
    70                          if isempty(cluster.executionpath), md = checkmessage(md,'executionpath empty'); end
     68                end
     69                %}}}
     70                function numprocs=np(self) % {{{
     71                        %compute number of processors
     72                        numprocs=self.numnodes*self.cpuspernode;
     73                end
     74                %}}}
     75                function BuildKrigingQueueScript(cluster,modelname,solution,io_gather,isvalgrind,isgprof) % {{{
    7176
    72                  end
    73                  %}}}
    74                  function BuildKrigingQueueScript(cluster,modelname,solution,io_gather,isvalgrind,isgprof) % {{{
     77                        if(isvalgrind), disp('valgrind not supported by cluster, ignoring...'); end
     78                        if(isgprof),    disp('gprof not supported by cluster, ignoring...'); end
    7579
    76                          if(isvalgrind), disp('valgrind not supported by cluster, ignoring...'); end
    77                          if(isgprof),    disp('gprof not supported by cluster, ignoring...'); end
     80                        %compute number of processors
     81                        cluster.np=cluster.numnodes*cluster.cpuspernode;
    7882
    79                          %compute number of processors
    80                          cluster.np=cluster.numnodes*cluster.cpuspernode;
     83                        %write queuing script
     84                        fid=fopen([modelname '.queue'],'w');
     85                        fprintf(fid,'#PBS -S /bin/bash\n');
     86                        fprintf(fid,'#PBS -N %s\n',modelname);
     87                        fprintf(fid,'#PBS -l select=%i:ncpus=%i:mpiprocs=%i\n',cluster.numnodes,cluster.cpuspernode,16);
     88                        fprintf(fid,'#PBS -l walltime=%s\n',cluster.time); %walltime is in seconds.
     89                        fprintf(fid,'#PBS -A %s\n',cluster.accountname);
     90                        fprintf(fid,'#PBS -o %s.outlog \n',modelname);
     91                        fprintf(fid,'#PBS -e %s.errlog \n\n',modelname);
     92                        fprintf(fid,'export ISSM_DIR="%s/../"\n',cluster.codepath); %FIXME
     93                        fprintf(fid,'source $ISSM_DIR/etc/environment.sh\n');       %FIXME
     94                        fprintf(fid,'cd %s/%s\n\n',cluster.executionpath,modelname);
     95                        fprintf(fid,'mpiexec_mpt -n %i %s/kriging.exe %s %s\n',cluster.np,cluster.codepath,[cluster.executionpath '/' modelname],modelname);
     96                        if ~io_gather, %concatenate the output files:
     97                                fprintf(fid,'cat %s.outbin.* > %s.outbin',modelname,modelname);
     98                        end
     99                        fclose(fid);
     100                end
     101                %}}}
     102                function BuildQueueScript(cluster,dirname,modelname,solution,io_gather,isvalgrind,isgprof,isdakota,isoceancoupling) % {{{
    81103
    82                          %write queuing script
    83                          fid=fopen([modelname '.queue'],'w');
    84                          fprintf(fid,'#PBS -S /bin/bash\n');
    85                          fprintf(fid,'#PBS -N %s\n',modelname);
    86        fprintf(fid,'#PBS -l select=%i:ncpus=%i:mpiprocs=%i\n',cluster.numnodes,cluster.cpuspernode,16);
    87        fprintf(fid,'#PBS -l walltime=%s\n',cluster.time); %walltime is in seconds.
    88        fprintf(fid,'#PBS -A %s\n',cluster.accountname);
    89                          fprintf(fid,'#PBS -o %s.outlog \n',modelname);
    90                          fprintf(fid,'#PBS -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,modelname);
    94                          fprintf(fid,'mpiexec_mpt -n %i %s/kriging.exe %s %s\n',cluster.np,cluster.codepath,[cluster.executionpath '/' modelname],modelname);
    95                          if ~io_gather, %concatenate the output files:
    96                                  fprintf(fid,'cat %s.outbin.* > %s.outbin',modelname,modelname);
    97                          end
    98                          fclose(fid);
    99                  end
    100                  %}}}
    101                  function BuildQueueScript(cluster,dirname,modelname,solution,io_gather,isvalgrind,isgprof,isdakota,isoceancoupling) % {{{
     104                        if(isvalgrind), disp('valgrind not supported by cluster, ignoring...'); end
     105                        if(isgprof),    disp('gprof not supported by cluster, ignoring...'); end
    102106
    103                          if(isvalgrind), disp('valgrind not supported by cluster, ignoring...'); end
    104                          if(isgprof),    disp('gprof not supported by cluster, ignoring...'); end
     107                        executable='issm.exe';
     108                        if isdakota,
     109                                version=IssmConfig('_DAKOTA_VERSION_'); version=str2num(version(1:3));
     110                                if (version>=6),
     111                                        executable='issm_dakota.exe';
     112                                end
     113                        end
     114                        if isoceancoupling,
     115                                executable='issm_ocean.exe';
     116                        end
    105117
    106                          executable='issm.exe';
    107                          if isdakota,
    108                                  version=IssmConfig('_DAKOTA_VERSION_'); version=str2num(version(1:3));
    109                                  if (version>=6),
    110                                          executable='issm_dakota.exe';
    111                                  end
    112                          end
    113                          if isoceancoupling,
    114                                  executable='issm_ocean.exe';
    115                          end
     118                        %compute number of processors
     119                        cluster.np=cluster.numnodes*cluster.cpuspernode;                     
     120                        shortname = substring(modelname,1,min(12,length(modelname)));
    116121
    117                          %compute number of processors
    118                          cluster.np=cluster.numnodes*cluster.cpuspernode;                     
    119        shortname = substring(modelname,1,min(12,length(modelname)));
     122                        %write queuing script
     123                        fid=fopen([modelname '.queue'],'w');
     124                        fprintf(fid,'#PBS -S /bin/bash\n');
     125                        fprintf(fid,'#PBS -N %s\n',shortname);
     126                        fprintf(fid,'#PBS -q %s \n',cluster.queue);
     127                        fprintf(fid,'#PBS -l select=%i:ncpus=%i:mpiprocs=%i\n',cluster.numnodes,cluster.cpuspernode,cluster.procspernodes);
     128                        fprintf(fid,'#PBS -l walltime=%s\n',duration(0,cluster.time,0)); %walltime is in minutes.
     129                        fprintf(fid,'#PBS -A %s\n',cluster.accountname);
     130                        fprintf(fid,'#PBS -o %s.outlog \n',[cluster.executionpath '/' dirname '/' modelname]);
     131                        fprintf(fid,'#PBS -e %s.errlog \n\n',[cluster.executionpath '/' dirname '/' modelname]);
     132                        fprintf(fid,'export ISSM_DIR="%s/../"\n',cluster.codepath); %FIXME
     133                        fprintf(fid,'source $ISSM_DIR/etc/environment.sh\n');       %FIXME
     134                        fprintf(fid,'cd %s/%s\n\n',cluster.executionpath,dirname);
     135                        fprintf(fid,'mpiexec -np %i %s/%s %s %s %s\n',cluster.np,cluster.codepath,executable,solution,[cluster.executionpath '/' dirname],modelname);
    120136
    121                          %write queuing script
    122                          fid=fopen([modelname '.queue'],'w');
    123                          fprintf(fid,'#PBS -S /bin/bash\n');
    124                          fprintf(fid,'#PBS -N %s\n',shortname);
    125                          fprintf(fid,'#PBS -q %s \n',cluster.queue);
    126        fprintf(fid,'#PBS -l select=%i:ncpus=%i:mpiprocs=%i\n',cluster.numnodes,cluster.cpuspernode,cluster.procspernodes);
    127                          fprintf(fid,'#PBS -l walltime=%s\n',duration(0,cluster.time,0)); %walltime is in minutes.
    128        fprintf(fid,'#PBS -A %s\n',cluster.accountname);
    129                          fprintf(fid,'#PBS -o %s.outlog \n',[cluster.executionpath '/' dirname '/' modelname]);
    130                          fprintf(fid,'#PBS -e %s.errlog \n\n',[cluster.executionpath '/' dirname '/' modelname]);
    131                          fprintf(fid,'export ISSM_DIR="%s/../"\n',cluster.codepath); %FIXME
    132                          fprintf(fid,'source $ISSM_DIR/etc/environment.sh\n');       %FIXME
    133                          fprintf(fid,'cd %s/%s\n\n',cluster.executionpath,dirname);
    134        fprintf(fid,'mpiexec -np %i %s/%s %s %s %s\n',cluster.np,cluster.codepath,executable,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);
    135141
    136                          if ~io_gather, %concatenate the output files:
    137                                  fprintf(fid,'cat %s.outbin.* > %s.outbin',modelname,modelname);
    138                          end
    139                          fclose(fid);
     142                        %in interactive mode, create a run file, and errlog and outlog file
     143                        if cluster.interactive,
     144                                fid=fopen([modelname '.run'],'w');
     145                                fprintf(fid,'mpiexec -np %i %s/issm.exe %s %s %s\n',cluster.np,cluster.codepath,solution,[cluster.executionpath '/' dirname],modelname);
     146                                if ~io_gather, %concatenate the output files:
     147                                        fprintf(fid,'cat %s.outbin.* > %s.outbin',modelname,modelname);
     148                                end
     149                                fclose(fid);
     150                                fid=fopen([modelname '.errlog'],'w');
     151                                fclose(fid);
     152                                fid=fopen([modelname '.outlog'],'w');
     153                                fclose(fid);
     154                        end
     155                end %}}}
     156                function UploadQueueJob(cluster,modelname,dirname,filelist)% {{{
    140157
    141                          %in interactive mode, create a run file, and errlog and outlog file
    142                          if cluster.interactive,
    143                                  fid=fopen([modelname '.run'],'w');
    144                                  fprintf(fid,'mpiexec -np %i %s/issm.exe %s %s %s\n',cluster.np,cluster.codepath,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                                  fclose(fid);
    149                                  fid=fopen([modelname '.errlog'],'w');
    150                                  fclose(fid);
    151                                  fid=fopen([modelname '.outlog'],'w');
    152                                  fclose(fid);
    153                          end
    154                  end %}}}
     158                        %compress the files into one zip.
     159                        compressstring=['tar -zcf ' dirname '.tar.gz '];
     160                        for i=1:numel(filelist),
     161                                compressstring = [compressstring ' ' filelist{i}];
     162                        end
     163                        system(compressstring);
     164                        disp('uploading input file and queueing script');
     165                        directory=cluster.executionpath;
     166                        issmbbftpout(cluster.name,directory,cluster.login,cluster.port,cluster.numstreams,{[dirname '.tar.gz']});
    155167
     168                end
     169                %}}}
     170                function LaunchQueueJob(cluster,modelname,dirname,filelist)% {{{
    156171
    157                  function UploadQueueJob(cluster,modelname,dirname,filelist)% {{{
     172                        disp('launching solution sequence on remote cluster');
     173                        launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' dirname ' && mkdir ' dirname ...
     174                                ' && cd ' dirname ' && mv ../' dirname '.tar.gz ./ && tar -zxf ' dirname '.tar.gz  && hostname && qsub ' modelname '.queue '];
     175                        issmssh(cluster.name,cluster.login,cluster.port,launchcommand);
     176                end %}}}
     177                function Download(cluster,dirname,filelist)% {{{
    158178
    159                          %compress the files into one zip.
    160                          compressstring=['tar -zcf ' dirname '.tar.gz '];
    161                          for i=1:numel(filelist),
    162                                  compressstring = [compressstring ' ' filelist{i}];
    163                          end
    164                          system(compressstring);
    165                          disp('uploading input file and queueing script');
    166                          directory=cluster.executionpath;
    167                          issmbbftpout(cluster.name,directory,cluster.login,cluster.port,cluster.numstreams,{[dirname '.tar.gz']});
     179                        %copy files from cluster to current directory
     180                        directory=[cluster.executionpath '/' dirname '/'];
     181                        issmscpin(cluster.name,cluster.login,cluster.port,directory,filelist);
    168182
    169                  end
    170                  %}}}
    171 
    172 
    173                  function LaunchQueueJob(cluster,modelname,dirname,filelist)% {{{
    174 
    175                          disp('launching solution sequence on remote cluster');
    176                           launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' dirname ' && mkdir ' dirname ...
    177                                                                                          ' && cd ' dirname ' && mv ../' dirname '.tar.gz ./ && tar -zxf ' dirname '.tar.gz  && hostname && qsub ' modelname '.queue '];
    178                          issmssh(cluster.name,cluster.login,cluster.port,launchcommand);
    179                  end %}}}
    180 
    181                  function Download(cluster,dirname,filelist)% {{{
    182 
    183                          %copy files from cluster to current directory
    184                          directory=[cluster.executionpath '/' dirname '/'];
    185                          issmscpin(cluster.name,cluster.login,cluster.port,directory,filelist);
    186 
    187                  end %}}}
     183                end %}}}
    188184        end
    189185end
Note: See TracChangeset for help on using the changeset viewer.