source: PSPA/madxPSPA/tests/test-ptc-twiss-old6/read.magnet.errors @ 430

Last change on this file since 430 was 430, checked in by touze, 11 years ago

import madx-5.01.00

File size: 632 bytes
Line 
1#!/usr/bin/perl
2
3open(INPUT,$ARGV[0]) or die "Cannot find $ARGV[0]\n";
4@b=@a=(0,0,0,0,0,0,0,0,0,0);
5while(<INPUT>) {
6    if (/^[^\@\%\$\*]/) {
7        @vals=(split); shift @vals; $count = $mult = 0;
8        foreach $num (@vals) {
9            if ( $count ) {
10                $a[$mult]+=$num; $count=0; $mult++;
11            } else {
12                $b[$mult]+=$num; $count=1;
13            }
14        }
15        $line++;
16    }
17}
18open(OUTPUT,"> ".$ARGV[0].".mad");
19print OUTPUT "icount=$line;\n";
20($arc = $ARGV[0]) =~ s/.*MB\.//;
21for ($i=0; $i<@a; $i++) {
22    print OUTPUT "b".($i+1)."sum_mb.".$arc."=".$b[$i].";\n";
23    print OUTPUT "a".($i+1)."sum_mb.".$arc."=".$a[$i].";\n";
24}
25close(INPUT);
26close(OUTPUT);
Note: See TracBrowser for help on using the repository browser.