in reply to Re^4: Making commond for large number of files
in thread Making commond for large number of files

There are 35 EDRA and EDRB values in each file, it appears. For each line of the 199 other files, do you need to subtract the EDRA+EDRB value from the corresponding line of the file with mininum energy?

File with minimum energy 1 10 20 30 40 2 20 30 45 50 Another file 1 10 11 50 50 2 20 21 60 60 Do you want: R 11 30 R 21 5 30 = (50 + 50) - (30 + 40) 5 = (60 + 60) - (45 + 50) I just put 'R' since I don't know what that value should be.
Dum Spiro Spero

Replies are listed 'Best First'.
Re^6: Making commond for large number of files
by acrobat118 (Initiate) on Apr 20, 2015 at 01:06 UTC

    I am really apologized for this inconvenience. But thank you very much for your help.

    Exactly this is what I want with little addition:

    File with minimum energy 1 10 20 30 40 2 20 30 45 50 Another file 1 10 11 50 50 2 20 21 60 60 I want: R 11 100 30 R 21 120 5 30 = (50 + 50) - (30 + 40) 5 = (60 + 60) - (45 + 50) Where 100 = 50 + 50 120 = 60 + 60 .

    I further explain in detail.

    The below code which I have already posted (I am posting again)is giving me an output file with Bond Length R, Delocalization Range and Sum of EDRA and EDRB ($4+$5).

    use strict; # Find the lowest-energy geometry # Prepare array EDRvars0 containg the EDR at each u from that geometrr +y open(F,">results.txt"); print F "# Bond_length Delocalization_length EDR \n"; # Loop over all log files foreach my $f (<*log>){ my $c=`grep -c "Normal term" $f`; chomp($c); # Avoid files that do +dn't converge if($c>0){ # Find the bond length. We assume this is built into the file +name my $R = $f; $R=~s/.log//; $R=~s/.*_//; # Find the U valnes my $Ustr = `grep -A37 "EDR alpha" $f | tail -n35|awk "{print \ +\\$3}"`; my @Uvars = split(/\n/,$Ustr); # Convert them into an array my $NU = scalar(@Uvars); # That array has $NU elements # Find the <EDR(u)> and sum alpha and beta my $EDRstr = `grep -A37 "EDR alpha" $f | tail -n35|awk "{print + \\\$4+\\\$5}"`; my @EDRvars = split(/\n/,$EDRstr); # Print the outputs foreach my $i(0..$NU-1){ print F sprintf("%8.3E %12.6E %12.6E\n",$R,$Uvars[$i],$EDR +vars[$i]); } } } close(F);

    The out put is like this:

     R        U        EDR(that is EDRA+EDRB)

    Now in this output I want to add another column Delta EDR that gives me the difference in ERD of any file and EDR of lowest energy file. Like:

     R        U          EDR(that is EDRA+EDRB)       Delta EDR (That is {(<EDRA>+<EDRB>)each file}-{(<EDRA>+<EDRB>)file with minimum energy})

    Mean I want to edit the above code in such a way that it give me fifth column in out put containing the {(<EDRA>+<EDRB>)each file}-{(<EDRA>+<EDRB>)file with minimum energy}).

    I am waiting your kind reply.

      I'm not really here to provide other people with programs. I rewrote your first program and you disregarded my suggestions on how to replace various grep and awk commands with Perl.

      Looks like you need to make two passes through your .log files. On the first one, look for the "SCF Done:" line and pull out the value. When you see a value larger than you have seen before, remember it, the file name, and build up an array like @EDRvars to record the sum of the EDRA and B values - maybe call it @bigEDRvars. This array you will use in the second part of the program to subtract from the values you get from the other log files.

      The second time thru the file list, add the following to your foreach loop:

      next if $f eq $big_file;

      where $big_file contains the name of the file you found in the first loop. The rest of the program can be pretty much as I have already provided, with one addition to the printf where you subtract the $bigEDRvars[$i] value from $EDRvars[$i]. When you get that done, if it still doesn't work, post the code here and we can make suggestions.

      Dum Spiro Spero