Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | |||
doku:simple [2014/06/10 09:51] – markus | doku:simple [2014/06/10 09:58] (current) – markus | ||
---|---|---|---|
Line 31: | Line 31: | ||
{{: | {{: | ||
- | < | ||
- | #!/bin/bash | ||
- | |||
- | |||
- | source $HOME/ | ||
- | export SIMPLESYS=VSC2 | ||
- | |||
- | PRIME_RUN_DIR=${HOME}/ | ||
- | ITERATION_START=3 | ||
- | ITERATION_STOP=7 | ||
- | VOL1=recvol_state1.spi | ||
- | NODES=8 | ||
- | PRIME_ARGS=" | ||
- | PRIME_CMD=" | ||
- | PRIME_ITERATION_STORAGE=" | ||
- | |||
- | |||
- | function get_current_iteration(){ | ||
- | if [ ! -f " | ||
- | echo "found file $PRIME_ITERATION_STORAGE" | ||
- | CURRENT_ITERATION=$ITERATION_START | ||
- | echo ${CURRENT_ITERATION} > ${PRIME_ITERATION_STORAGE} | ||
- | else | ||
- | # | ||
- | CURRENT_ITERATION=`cat ${PRIME_ITERATION_STORAGE}` | ||
- | #update iteration | ||
- | fi | ||
- | } | ||
- | |||
- | function get_status(){ | ||
- | RUNNING_JOBS=`ls JOB_RUNNING_* 2> /dev/null |wc -l` | ||
- | if [ $RUNNING_JOBS == 0 ] && [ ! -f " | ||
- | SUBMIT=" | ||
- | # | ||
- | rm -f JOB_FINISHED_* | ||
- | #proceed to next iteration | ||
- | CURRENT_ITERATION=$(echo " | ||
- | echo ${CURRENT_ITERATION} > ${PRIME_ITERATION_STORAGE} | ||
- | else | ||
- | SUBMIT="" | ||
- | fi | ||
- | } | ||
- | |||
- | cd $PRIME_RUN_DIR | ||
- | get_current_iteration | ||
- | get_status | ||
- | CMD=" | ||
- | echo $CMD | ||
- | $CMD | ||
- | |||
- | </ | ||
adjusted distr_simple_prime_vsc2.pl: | adjusted distr_simple_prime_vsc2.pl: | ||
- | < | + | {{:doku:simple:distr_simple_prime_vsc2.pl}} |
- | + | ||
- | # | + | |
- | + | ||
- | use warnings; | + | |
- | use strict; | + | |
- | use Env; | + | |
- | use Cwd qw(getcwd); | + | |
- | use List::Util qw(max min); | + | |
- | + | ||
- | # ASSUMES SIMPLEBIN ENVIRONMENT VARIABLE SET | + | |
- | # ASSUMES SIMPLESYS ENVIRONMENT VARIABLE SET | + | |
- | + | ||
- | # global variables | + | |
- | my%name_value; | + | |
- | my$folder; | + | |
- | $name_value{' | + | |
- | $name_value{' | + | |
- | $name_value{' | + | |
- | $name_value{' | + | |
- | $name_value{' | + | |
- | $name_value{' | + | |
- | $name_value{' | + | |
- | + | ||
- | # make command line instructions | + | |
- | my$instructions = `$name_value{' | + | |
- | $instructions =~ s/ | + | |
- | $instructions =~ s/ | + | |
- | my@should_not_be_there = glob(" | + | |
- | # | + | |
- | #markus stoehr | + | |
- | #comment out to allow restart of the script: | + | |
- | #if( scalar(@should_not_be_there) >= 1 ){ | + | |
- | # die "ERROR: files match the pattern recvol_state*, | + | |
- | #} | + | |
- | + | ||
- | # if too few argument given, print instructions | + | |
- | if(scalar(@ARGV) < 5){ | + | |
- | print $instructions; | + | |
- | } | + | |
- | + | ||
- | # parse the command line | + | |
- | # %name_value is the hash with input data | + | |
- | foreach my $cmd (@ARGV){ | + | |
- | chomp($cmd); | + | |
- | my @tmp = split(' | + | |
- | $name_value{$tmp[0]} = $tmp[1]; | + | |
- | } | + | |
- | + | ||
- | # check so that a volume is inputted | + | |
- | if( !defined($name_value{' | + | |
- | die "Need at least one starting volume for prime exec!\n"; | + | |
- | } | + | |
- | + | ||
- | # set the number of particles | + | |
- | $name_value{' | + | |
- | + | ||
- | # check so that npart is set (number of partitions) | + | |
- | if( !defined $name_value{' | + | |
- | die "npart need to be set\n"; | + | |
- | } | + | |
- | + | ||
- | # check so that nspace is set (number of projection directions) | + | |
- | if( !defined $name_value{' | + | |
- | $name_value{' | + | |
- | } | + | |
- | + | ||
- | # check so that nthr is set (number of threads) | + | |
- | if( !defined $name_value{' | + | |
- | $name_value{' | + | |
- | } | + | |
- | + | ||
- | # check so that fstep is set | + | |
- | if( !defined $name_value{' | + | |
- | $name_value{' | + | |
- | } | + | |
- | + | ||
- | # check so that dynlp is set | + | |
- | if( !defined($name_value{' | + | |
- | $name_value{' | + | |
- | } | + | |
- | + | ||
- | # determine initial and final Fourier index | + | |
- | if( $name_value{' | + | |
- | # determine the initial low-pass limit | + | |
- | if( !defined($name_value{' | + | |
- | $name_value{' | + | |
- | my$lp = get_lp($name_value{' | + | |
- | # print " | + | |
- | } | + | |
- | # determine the final low-pass limit | + | |
- | if( defined($name_value{' | + | |
- | delete $name_value{' | + | |
- | } | + | |
- | $name_value{' | + | |
- | my$lp = get_lp($name_value{' | + | |
- | # print " | + | |
- | } | + | |
- | + | ||
- | # check so that trs is set (origin shift) | + | |
- | if( !defined $name_value{' | + | |
- | $name_value{' | + | |
- | } | + | |
- | + | ||
- | # check so that maxits is set | + | |
- | if( !defined($name_value{' | + | |
- | $name_value{' | + | |
- | } | + | |
- | + | ||
- | # set number of states (by counting input volumes) | + | |
- | my @keys = keys %name_value; | + | |
- | my $nstates = 0; | + | |
- | foreach my $key(@keys){ | + | |
- | if($key =~ /vol\d/ ){$nstates++}; | + | |
- | } | + | |
- | $name_value{' | + | |
- | + | ||
- | # set time per image | + | |
- | if( defined($name_value{' | + | |
- | } else { | + | |
- | if( defined($name_value{' | + | |
- | $name_value{' | + | |
- | }else{ | + | |
- | $name_value{' | + | |
- | } | + | |
- | } | + | |
- | + | ||
- | # do the refinement | + | |
- | my$converged = 0; | + | |
- | my$round; | + | |
- | my$round_stop; | + | |
- | if( defined($name_value{' | + | |
- | $round = $name_value{' | + | |
- | } else { | + | |
- | $round = 0; | + | |
- | } | + | |
- | while( $round < $name_value{' | + | |
- | + | ||
- | # make refinement folder | + | |
- | $round++; | + | |
- | $folder = ' | + | |
- | mkdir $folder; | + | |
- | + | ||
- | # parallell execution | + | |
- | if (defined($name_value{' | + | |
- | exec_prime_para(); | + | |
- | die; | + | |
- | }else{ | + | |
- | + | ||
- | # determine when the jobs have finished | + | |
- | # | + | |
- | #sleep(10) while( njobs_finished() < $name_value{' | + | |
- | # | + | |
- | # | + | |
- | # | + | |
- | #markus stoehr | + | |
- | #for usage with cronjob, here you need an exit | + | |
- | if ( njobs_finished() < $name_value{' | + | |
- | # merge alignment docs | + | |
- | if( defined($name_value{' | + | |
- | delete $name_value{' | + | |
- | } | + | |
- | $name_value{' | + | |
- | system(" | + | |
- | system(" | + | |
- | system(" | + | |
- | + | ||
- | # assemble volumes | + | |
- | exec_assemble_volumes(); | + | |
- | + | ||
- | # automask | + | |
- | if( defined($name_value{' | + | |
- | exec_automask(); | + | |
- | } | + | |
- | + | ||
- | my $conv = exec_check_conv(); | + | |
- | if( $round > 1 ){ | + | |
- | if( $conv == 2 ){ | + | |
- | die "**** DISTR_SIMPLE_PRIME NORMAL STOP ****\n"; | + | |
- | }elsif ( $conv == 1 ){ | + | |
- | if( !defined($name_value{' | + | |
- | die "Want 2 do dynamic low-pass update, but find is not defined, weird!\n"; | + | |
- | } | + | |
- | if( defined($name_value{' | + | |
- | delete $name_value{' | + | |
- | $name_value{' | + | |
- | } | + | |
- | $name_value{' | + | |
- | if( $name_value{' | + | |
- | $name_value{' | + | |
- | } | + | |
- | } | + | |
- | } | + | |
- | # | + | |
- | | + | |
- | die; | + | |
- | } | + | |
- | } | + | |
- | + | ||
- | sub exec_prime_para{ | + | |
- | my$i; | + | |
- | my$vol; | + | |
- | my@submitted; | + | |
- | my$qsubout; | + | |
- | my@args = parse_args($name_value{' | + | |
- | my$prime_cmd_string = $name_value{' | + | |
- | $i = 1; | + | |
- | $vol = ' | + | |
- | while( defined($name_value{$vol}) ){ | + | |
- | $prime_cmd_string = add2string($vol, | + | |
- | $i++; | + | |
- | $vol = ' | + | |
- | } | + | |
- | foreach (@args) { | + | |
- | $prime_cmd_string = add2string($_, | + | |
- | } | + | |
- | $prime_cmd_string =~ s/\s+$//; # removes trailing whitespace | + | |
- | print $prime_cmd_string, | + | |
- | my $stop; | + | |
- | my $start; | + | |
- | my $ptcls_per_part = int($name_value{' | + | |
- | for(my $i=1; $i< | + | |
- | $stop = min $i*$ptcls_per_part, | + | |
- | if($i == $name_value{' | + | |
- | $start | + | |
- | my $time = $name_value{' | + | |
- | my $hours = int($time/ | + | |
- | my $min = (($time/ | + | |
- | open(FHANDLE, | + | |
- | if ($ENV{SIMPLESYS} eq ' | + | |
- | print FHANDLE "# | + | |
- | #PBS -N distr_simple | + | |
- | #PBS -l nodes=1: | + | |
- | #PBS -l walltime=$time | + | |
- | #PBS -o outfile.\$PBS_JOBID | + | |
- | #PBS -e errfile.\$PBS_JOBID | + | |
- | #PBS -q SP | + | |
- | cd $name_value{' | + | |
- | $prime_cmd_string fromp=$start top=$stop part=$i outfile=algndoc_$i.txt > OUT$i\nexit\n"; | + | |
- | }elsif ($ENV{SIMPLESYS} eq ' | + | |
- | print FHANDLE "# | + | |
- | #\$ \-N d_simple | + | |
- | #\$ \-cwd | + | |
- | #\$ \-pe multi $name_value{' | + | |
- | #\$ \-V | + | |
- | #\$ \-o outfile.\$PBS_JOBID | + | |
- | #\$ \-e errfile.\$PBS_JOBID | + | |
- | cd $name_value{' | + | |
- | $prime_cmd_string fromp=$start top=$stop part=$i outfile=algndoc_$i.txt > OUT$i\nexit\n"; | + | |
- | }elsif ($ENV{SIMPLESYS} eq ' | + | |
- | print FHANDLE "# | + | |
- | #\$ \-N d_simple | + | |
- | #\$ \-cwd | + | |
- | #\$ \-pe mpich $name_value{' | + | |
- | #\$ \-V | + | |
- | #\$ \-o outfile.\$PBS_JOBID | + | |
- | #\$ \-e errfile.\$PBS_JOBID | + | |
- | cd $name_value{' | + | |
- | $prime_cmd_string fromp=$start top=$stop part=$i outfile=algndoc_$i.txt > OUT$i\n | + | |
- | rm -f JOB_RUNNING_$i\n | + | |
- | exit\n"; | + | |
- | } else { | + | |
- | die " | + | |
- | } | + | |
- | close(FHANDLE); | + | |
- | chmod 0777, ' | + | |
- | if( $ENV{SIMPLESYS} eq ' | + | |
- | system(" | + | |
- | }elsif( $ENV{SIMPLESYS} eq ' | + | |
- | my$qsubcmd = "qsub ./ | + | |
- | $qsubout = `$qsubcmd`; | + | |
- | if( $qsubout =~ / | + | |
- | $submitted[$i] = 1; | + | |
- | }else{ | + | |
- | $submitted[$i] = 0; | + | |
- | } | + | |
- | }elsif( ($ENV{SIMPLESYS} eq ' | + | |
- | print " | + | |
- | my$qsubcmd = "qsub ./ | + | |
- | $qsubout = `$qsubcmd`; | + | |
- | if( $qsubout =~ /has been submitted/ ){ | + | |
- | $submitted[$i] = 1; | + | |
- | print " | + | |
- | #markus stoehr: | + | |
- | #mark submitted jobs for external script | + | |
- | system (" | + | |
- | }else{ | + | |
- | $submitted[$i] = 0; | + | |
- | } | + | |
- | }else{ | + | |
- | die " | + | |
- | } | + | |
- | } | + | |
- | print " | + | |
- | if( $ENV{SIMPLESYS} eq ' | + | |
- | # resubmission if failed | + | |
- | for(my $i=1; $i< | + | |
- | if( $submitted[$i] == 0 ){ | + | |
- | my$qsubcmd = "qsub ./ | + | |
- | $qsubout = `$qsubcmd`; | + | |
- | if( $qsubout !~ / | + | |
- | chomp($qsubout); | + | |
- | print " | + | |
- | } | + | |
- | } | + | |
- | } | + | |
- | #} elsif( ($ENV{SIMPLESYS} eq ' | + | |
- | } elsif( ($ENV{SIMPLESYS} eq ' | + | |
- | # resubmission if failed | + | |
- | for(my $i=1; $i< | + | |
- | if( $submitted[$i] == 0 ){ | + | |
- | my$qsubcmd = "qsub ./ | + | |
- | $qsubout = `$qsubcmd`; | + | |
- | if( $qsubout !~ /has been submitted/ ){ | + | |
- | chomp($qsubout); | + | |
- | print " | + | |
- | } | + | |
- | } | + | |
- | } | + | |
- | } | + | |
- | print " | + | |
- | } | + | |
- | + | ||
- | sub njobs_finished{ | + | |
- | my$nfini = 0; | + | |
- | my@jobs; | + | |
- | @jobs = < | + | |
- | return scalar(@jobs); | + | |
- | } | + | |
- | + | ||
- | sub exec_assemble_volumes{ | + | |
- | my$i; | + | |
- | my$vol; | + | |
- | my@refvols; | + | |
- | my@recvols; | + | |
- | my@args = parse_args($name_value{' | + | |
- | my$assemble_cmd_string = $name_value{' | + | |
- | foreach (@args) { | + | |
- | $assemble_cmd_string = add2string($_, | + | |
- | } | + | |
- | $assemble_cmd_string =~ s/\s+$//; # removes trailing whitespace | + | |
- | print $assemble_cmd_string, | + | |
- | system($assemble_cmd_string); | + | |
- | my@kernels = < | + | |
- | my@recbins = < | + | |
- | if( scalar(@kernels) != scalar(@recbins) ){ | + | |
- | die " | + | |
- | } | + | |
- | foreach my$i (0 .. $# | + | |
- | system(" | + | |
- | } | + | |
- | @recvols = < | + | |
- | if( scalar(@recvols) != $name_value{' | + | |
- | die " | + | |
- | } else { | + | |
- | @refvols = @recvols; | + | |
- | } | + | |
- | foreach $i ( 1 .. $name_value{' | + | |
- | $vol = ' | + | |
- | if( defined($name_value{$vol}) ){ | + | |
- | delete $name_value{$vol}; | + | |
- | } | + | |
- | $name_value{$vol} = $refvols[$i-1]; | + | |
- | system(" | + | |
- | } | + | |
- | } | + | |
- | + | ||
- | sub exec_automask{ | + | |
- | my$i; | + | |
- | my$vol; | + | |
- | my@args = parse_args($name_value{' | + | |
- | my$automask_cmd_string = $name_value{' | + | |
- | $i = 1; | + | |
- | $vol = ' | + | |
- | while( defined($name_value{$vol}) ){ | + | |
- | $automask_cmd_string = add2string($vol, | + | |
- | $i++; | + | |
- | $vol = ' | + | |
- | } | + | |
- | foreach (@args) { | + | |
- | $automask_cmd_string = add2string($_, | + | |
- | } | + | |
- | $automask_cmd_string =~ s/\s+$//; # removes trailing whitespace | + | |
- | print $automask_cmd_string, | + | |
- | system($automask_cmd_string); | + | |
- | my$fbody | + | |
- | $fbody | + | |
- | my@maskedvols = < | + | |
- | foreach $i ( 1 .. $name_value{' | + | |
- | $vol = ' | + | |
- | system(" | + | |
- | system(" | + | |
- | } | + | |
- | } | + | |
- | + | ||
- | sub exec_check_conv{ | + | |
- | my$status; | + | |
- | my@args = parse_args($name_value{' | + | |
- | my$check_conv_cmd_string = $name_value{' | + | |
- | foreach (@args) { | + | |
- | $check_conv_cmd_string = add2string($_, | + | |
- | } | + | |
- | $check_conv_cmd_string =~ s/\s+$//; # removes trailing whitespace | + | |
- | print $check_conv_cmd_string, | + | |
- | my$conv_info = `$check_conv_cmd_string`; | + | |
- | my@conv_info_lines = split(/ | + | |
- | $status = 0; | + | |
- | foreach my$line (@conv_info_lines){ | + | |
- | print $line, " | + | |
- | if( $line =~ / | + | |
- | if( $line =~ / | + | |
- | } | + | |
- | return $status; | + | |
- | } | + | |
- | + | ||
- | sub exec_check_nptcls{ | + | |
- | my$nptcls; | + | |
- | my$check_nptcls_cmd_string = $name_value{' | + | |
- | $check_nptcls_cmd_string = add2string(' | + | |
- | $check_nptcls_cmd_string = add2string(' | + | |
- | $check_nptcls_cmd_string =~ s/\s+$//; # removes trailing whitespace | + | |
- | print $check_nptcls_cmd_string, | + | |
- | my$nptcls_info = `$check_nptcls_cmd_string`; | + | |
- | if( $nptcls_info =~ />>> | + | |
- | $nptcls = $1; | + | |
- | } | + | |
- | return $nptcls; | + | |
- | } | + | |
- | + | ||
- | sub add2string{ | + | |
- | my$var = shift; | + | |
- | my$str = shift; | + | |
- | if( defined($name_value{$var}) ){ | + | |
- | $str = $str.$var.' | + | |
- | } | + | |
- | return $str; | + | |
- | } | + | |
- | + | ||
- | sub parse_args{ | + | |
- | my$prg = shift; # get program name with absolute path | + | |
- | # make command line instructions | + | |
- | my$instructions = `$prg`; | + | |
- | # parse the instructions | + | |
- | my@splitted = split(/ | + | |
- | my@args; | + | |
- | foreach (@splitted) { | + | |
- | if( $_ =~ / | + | |
- | if( $1 !~ /vol\d+/ ){ | + | |
- | push(@args, | + | |
- | } | + | |
- | } | + | |
- | } | + | |
- | return @args; | + | |
- | } | + | |
- | + | ||
- | sub get_find{ | + | |
- | my$res = shift; | + | |
- | return int((($name_value{' | + | |
- | } | + | |
- | + | ||
- | sub get_lp{ | + | |
- | my$find = shift; | + | |
- | return (($name_value{' | + | |
- | } | + | |
- | + | ||
- | + | ||
- | </ | + | |