Changeset 32 for trunk


Ignore:
Timestamp:
Dec 1, 2011, 8:36:22 PM (12 years ago)
Author:
g7moreau
Message:
  • Add many option and now could be use outside OAR environment!
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/oarutils/oar-parexec

    r28 r32  
    1414use IO::File;
    1515use POSIX qw( WNOHANG WEXITSTATUS );
     16use Cwd qw( getcwd );
    1617
    1718my $file = '';
    1819my $verbose;
     20my $nodefile = $ENV{OAR_NODE_FILE} || '';
     21my $masterio;
    1922my $switchio;
    2023my $help;
     
    2225
    2326Getopt::Long::GetOptions(
    24    'file=s'   => \$file,
    25    'verbose'  => \$verbose,
    26    'help'     => \$help,
    27    'oarsh'    => \$oarsh,
    28    'switchio' => \$switchio,
     27   'file=s'     => \$file,
     28   'verbose'    => \$verbose,
     29   'help'       => \$help,
     30   'oarsh=s'    => \$oarsh,
     31   'nodefile=s' => \$nodefile,
     32   'masterio=s' => \$masterio,
     33   'switchio'   => \$switchio,
    2934   ) || pod2usage( -verbose => 0 );
    3035pod2usage( -verbose => 2 ) if $help;
     
    3641   chomp;
    3742   next if m/^#/;
    38    push @job, $_ if not m/^\s*$/;
     43   next if m/^\s*$/;
     44   push @job, $_ ;
    3945   }
    4046close JOB_LIST;
    4147
    42 my $stderr = $ENV{OAR_STDERR};
     48my $stderr = $ENV{OAR_STDERR} || '';
    4349$stderr =~ s/\.stderr$//;
    44 my $stdout = $ENV{OAR_STDOUT};
     50$stderr = $masterio if $masterio;
     51my $stdout = $ENV{OAR_STDOUT} || '';
    4552$stdout =~ s/\.stdout$//;
     53$stdout = $masterio if $masterio;
     54
     55my $current_dir = getcwd();
    4656
    4757my $finished = new Coro::Signal;
     
    5060
    5161my $ressources = new Coro::Channel;
    52 open( NODE_FILE, '<', "$ENV{OAR_NODE_FILE}" )
    53    or die "can't open ENV{OAR_NODE_FILE}: $!";
     62open( NODE_FILE, '<', "$nodefile" )
     63   or die "can't open $nodefile: $!";
    5464while (<NODE_FILE>) {
    5565   chomp;
     66   next if m/^#/;
     67   next if m/^\s*$/;
    5668   $ressources->put($_);
    5769   }
     
    8496      $job_stderr = "2> $stderr-$job_num.stderr" if $stderr ne '' and $switchio;
    8597
    86       $fh->print("cd $ENV{OAR_WORKDIR}\n");
     98      $fh->print("cd $current_dir\n");
    8799      $fh->print("$job $job_stdout $job_stderr\n");
    88100      $fh->print("exit\n");
     
    124136=head1 SYNOPSIS
    125137
    126  oar-parexec --file filepath [--verbose] [--switchio] [--oarsh sssh]
     138 oar-parexec --file filecommand [--verbose]  [--nodefile filenode] [--masterio basefileio] [--switchio] [--oarsh sssh]
    127139 oar-parexec --help
    128140
     141=head1 DESCRIPTION
     142
     143C<oar-parexec> execute lot of small job.in parallel inside a cluster.
     144Number of parallel job at one time cannot excede core number in the node file.
     145C<oar-parexec> is easier to use inside an OAR job environment
     146which define automatically theses strategics parameters...
     147
     148Option C<--file> is the only mandatory one.
     149
     150Small job will be launch in the same folder as the master job.
     151
     152
    129153=head1 OPTIONS
    130154
    131  --file file name which content job list
    132 
    133  --verbose
    134 
    135  --switchio each small job will have it's own output STDOUT and STDERR
    136             base on master OAR job with JOB_NUM inside. Example :
    137 
    138             OAR.151524.stdout -> OAR.151524-JOB_NUM.stdout
    139 
    140             where 151524 here is the master OAR_JOB_ID
    141 
    142  -oarsh command use to connect a shell on a node
    143         by default
     155=over 12
     156
     157=item B<-f|--file       filecommand>
     158
     159File name which content job list.
     160
     161=item B<-v|--verbose>
     162
     163=item B<-n|nodefile filenode>
     164
     165File name that list all the node to launch job.
     166By defaut, it's define automatically by OAR via
     167environment variable C<OAR_NODE_FILE>.
     168
     169For example, if you want to use 6 core on your cluster node,
     170you need to put 6 times the hostname node in this file,
     171one per line...
     172It's a very common file in MPI process !
     173
     174=item B<-m|--masterio basefileio>
     175
     176The C<basefileio> will be use in place of environment variable
     177C<OAR_STDOUT> and C<OAR_STDERR> (without extension) to build the base name of the small job standart output
     178(only when option C<swithio> is activated).
     179
     180=item B<-s|--switchio>
     181
     182Each small job will have it's own output STDOUT and STDERR
     183base on master OAR job with C<JOB_NUM> inside
     184(or base on C<basefileio> if option C<masterio>).
     185Example :
     186
     187 OAR.151524.stdout -> OAR.151524-JOB_NUM.stdout
     188
     189where 151524 here is the master C<OAR_JOB_ID>
     190and C<JOB_NUM> is the small job nnumber.
     191
     192=item B<-o|-oarsh command>
     193
     194Command use to launch a shell on a node.
     195By default
    144196
    145197        oarsh -q -T
    146198
    147  --help
    148 
    149 
    150 =head1 DESCRIPTION
    151 
    152 C<oar-parexec> need to be executed inside an OAR job environment.
    153 because it need the two environment variable that OAR define by
    154 default:
    155 
    156  OAR_NODE_FILE path to a file which content one node by line
    157 
    158  OAR_WORKDIR   dir to launch job and do a chdir inside
     199=item B<-h|--help>
     200
     201=back
     202
     203
     204=head1 EXAMPLE
    159205
    160206Content for the job file (option C<--file>) could have:
     
    170216 $HOME/test/subjob3.sh
    171217 $HOME/test/subjob4.sh
    172 
     218 ...
    173219 $HOME/test/subjob38.sh
    174220 $HOME/test/subjob39.sh
Note: See TracChangeset for help on using the changeset viewer.