#! /usr/bin/perl -w use strict; # parse specific results from MESHGEN console STDOUT # Markus K\"uhbach, m.kuehbach at mpie.de, 2018/02/08 #locals my $pstart = &trim(shift); my $pend = &trim(shift); my $nions = &trim(shift); if (int($pstart) < 0 || int($pend) < int($pstart)) { print("Argument pillar id invalid must be positive and first <= last!\n"); exit; } #if (int($nions) % 10000 != 0) { # print("Argument nions is no integer multiple of 10000!\n"); # exit; #} my $fn = ""; my @tmp = (); my $dat = ""; my $where = 0; my $kw = ""; my $this = 0; my @evaptimes = (); #results my $res = "PillarID;DelaunayTetrahedralization;SyncDataStructures;RelaxPotIterations;RelaxPotElapsedTime;MaxTimeEvaporation\n"; $res .= ";min;min;iter;min;min\n"; $res .= "PillarID;DelaunayTetrahedralization;SyncDataStructures;RelaxPotIterations;RelaxPotElapsedTime;MaxTimeEvaporation\n"; #looping for(my $id = $pstart; $id <= $pend; $id++) { $fn = "../maws08_zr/BatchMillSimID$id/raw/TAPSIMSimID$id.STDOUT.txt"; open(DATA,"<$fn") or die "Can't MESHGEN file"; @tmp = ; close(DATA); $dat = join('\n',@tmp); $where = 0; #char index location on string stream $kw = ""; #keyword $this = 0; #entry data i want $res .= "$id;"; $kw = 'Computing delaunay tetrahedralization \(elapsed time ='; $dat =~ m/$kw/g; $where = pos($dat); @tmp = split('\s+',substr($dat, $where, 1000)); #extract numeric information $res .= "$tmp[1];"; $kw = 'Syncronizing data structures \(elapsed time ='; $dat =~ m/$kw/g; $where = pos($dat); @tmp = split('\s+',substr($dat, $where, 1000)); $res .= "$tmp[1];"; $kw = 'Relaxing potential \=\> numerical limit reached:'; $dat =~ m/$kw/g; $where = pos($dat); @tmp = split('\s+',substr($dat, $where, 1000)); $res .= "$tmp[1];"; $kw = 'Elapsed time:'; $dat =~ m/$kw/g; $where = pos($dat); @tmp = split('\s+',substr($dat, $where, 1000)); $res .= "$tmp[1];"; #print("$res\n"); @evaptimes = (); for (my $ii = 1; $ii <= int($nions/10000); $ii++) { $kw = 'Time is'; $dat =~ m/$kw/g; $where = pos($dat); @tmp = split('\s+',substr($dat, $where, 1000)); $evaptimes[$ii] = $tmp[1]; #print("$tmp[1]\n"); } #take total time for evaporation simulation $res .= "$evaptimes[-1]\n"; # print("$res\n"); } my $fnout = 'parsed_tapsim_stdout.txt'; open ( RESULTS, ">$fnout") || die ( "ERROR.open.file=($fnout).mode=(r)"); print RESULTS $res; close ( RESULTS ); #print($res); sub trim { my $str = shift; $str =~ s/^\s+//; $str =~ s/\s+$//; return ( $str ); }