#!/usr/bin/perl use warnings; use strict; use List::Util qw(min max); my $case = $ARGV[0]; my $xcut = $ARGV[1]; my(@files,@index,$outfile); if($case==1){ @files = qw( pes_rhf.dat pes_CIo1.dat pes_CIo1.5.dat pes_CIo2.dat pes_CIo2.5.dat pes_CIo3.dat pes_CIo3.5.dat pes_CIo4.dat); @index = qw( 0 1 1.5 2 2.5 3 3.5 4); $outfile = "stat_CIo.dat"; } elsif($case==2){ @files = qw( pes_rhf.dat pes_ooCIo1.dat pes_ooCIo1.5.dat pes_ooCIo2.dat pes_ooCIo2.5.dat pes_ooCIo3.dat pes_ooCIo3.5.dat pes_ooCIo4.dat); @index = qw( 0 1 1.5 2 2.5 3 3.5 4); $outfile = "stat_ooCIo.dat"; } elsif($case==3){ @files = qw( pes_rhf.dat pes_rhf.dat pes_CISD.dat pes_CISDT.dat pes_CISDTQ.dat); @index = qw( 0 1 2 3 4); $outfile = "stat_CI.dat"; } elsif($case==4){ @files = qw( pes_rhf.dat pes_rhf.dat pes_ooCISD.dat pes_ooCISDT.dat); @index = qw( 0 1 2 3); $outfile = "stat_ooCI.dat"; } else{ print "case variable not recognized \n"; die; } my $fci_file = 'pes_fci.dat'; my $n_files = @files; my (@x0, @y0); my ($x, $y, $dy); my ($i, $n); $n=0; open(Fi, '<', $fci_file) or die $!; while(){ my @line = split( /\s+/, $_ ); $n++; $x0[$n] = $line[0]; $y0[$n] = $line[1]; if($x0[$n]>$xcut){last}; } close(Fi); if(-e $outfile){unlink $outfile}; open(Fo, '>>', $outfile) or die $!; for ( my $j = 0; $j < $n_files; $j++ ){ if(-e $files[$j]){ my $maxy = -1e99; my $miny = 1e99; # my $m=0; # open(Fi, '<', $files[$j]) or die $!; # while(){ # $m++; # } # close(Fi); # if($m==$n){ my $m=0; open(Fi, '<', $files[$j]) or die $!; while(){ my @line = split( /\s+/, $_ ); $m++; $x = $line[0]; $y = $line[1]; $dy = $y - $y0[$m]; $maxy = max($maxy,$dy); $miny = min($miny,$dy); if($x==$xcut){last}; } close(Fi); if($x==$xcut){ my $npe = $maxy - $miny; my $closeness = $maxy + $miny; print Fo "$index[$j] $npe $closeness $maxy $miny \n"; } # } } } close(Fo);