-
Izzard, Robert Dr (Maths & Physics) authoredIzzard, Robert Dr (Maths & Physics) authored
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
grid-wrap.pl 9.58 KiB
#!/usr/bin/env perl
use 5.16.0;
use strict;
use Sort::Key qw(nsort);
use rob_misc;
use binary_grid;
use threads;
use threads::shared;
use Fcntl ':flock'; # import LOCK_* constants
use subs qw(logprint logprintf);
use Carp qw(confess);
use File::Path qw(make_path);
$|=1;
############################################################
my $outdir='/tmp/gridtest';
my $nmachines=20;
say "Run across (modulo=) ",scalar(@machines)," machines";
my $modulo=scalar(@machines);
my @pids;
my @datafiles;
my $offset=0;
my @spectral_type_strings=('O','B','A','F','G','K','M');
my %spectral_type; revspechash();
my @stellar_type_strings;
my @short_stellar_type_strings;
my %short_stellar_type_strings;
my $period_binwidth=0.1; # width in logP of histograms
my $log_fp;
defaults();
foreach my $machine (0..$nmachines)
{
my $datafile="$outdir/results.$offset";
my $cmd="./src/perl/scripts-flexigrid/grid-canberra.pl modulo=$modulo offset=$offset results_hash_dumpfile=$datafile";
say "Run $cmd";
my $forkr;
# run the models : should outsource this to binary_grid::condor module
if(1){
$forkr=fork();
if($forkr==0)
{
print `$cmd 2>$outdir/grid.$offset.err > $outdir/grid.$offset.out`;
exit;
}
}
push(@pids,$forkr);
push(@datafiles,$datafile);
$offset++;
}
# wait for children to finish
say "Waiting for children (pids: @pids)";
map { waitpid $_,0; }@pids;
say "Children finished\n";
# put all the data together
my $results=merge_results_hash_dumps(@datafiles);
# save ouput
output();