root/branches/newmole/source/cloudy_ch.pl

Revision 13, 1.2 kB (checked in by gary, 3 years ago)

adjust file properties for ascii and perl files - no source change

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1#!usr/bin/perl
2# Program to swap the position of indexes of a two-dimentional array
3#abund.xIonFracs[b][a], i.e., abund.xIonFracs[b][a]<->abund.xIonFracs[a][b]
4
5#Store the changes initially into a temporary directory.
6$ndir='cloudy_ch/';
7if(!-e $ndir)
8{
9  system "mkdir $ndir";
10}
11else
12{
13 system "rm -f $ndir/*.*";
14}
15
16#Reading the files and swapping the indexes of array abund.xIonFracs
17while(defined($input=glob("*.c *.h")))
18{
19   if((system "grep 'abund.xIonFracs' $input")==0)
20   {
21     $input=~s/\n//;
22     $out=$input;
23     $out=~s/$input/$ndir$input/;
24     open(OUTFILE,">$out");
25     open(INFILE,"$input");
26     while(<INFILE>)
27     {
28       if($_=~/abund.xIonFracs\[\S*\]\[\S*\]/)
29       {
30         $_=~s/abund.xIonFracs\[(\w*|\w*\.\w*\[\w*\]\W\w*|\w*\W\w*)\]\[(\w*|\w*\.\w*\[\w*\]\W\w*|\w*\W\w*)\]/abund.xIonFracs\[$2\]\[$1\]/gi;
31         print OUTFILE "$_";
32       }
33
34       else
35       {
36        print OUTFILE "$_";
37       }
38     }
39 }
40#closing both the input and output files.
41close(OUTFILE);
42close(INFILE);
43}
44
45# Copying the files of temporary directory into original files and
46# then removing the temporary directory
47#system " cd cloudy_ch; cp *.* ..; rm *.* .*";
48#system "rmdir cloudy_ch";
Note: See TracBrowser for help on using the browser.