/usr/bin/fdf2fit is in grace 1:5.1.24-3.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | #!/bin/sh
exec perl -x $0 ${1+"$@"}
#!perl
# fdf2fit - script to convert Origin-4 .fdf fit parameter files to ACE/gr's
# Version 0.3a
# Author Yu. V. Ralchenko <fnralch@plasma-gate.weizmann.ac.il>
($input_file,$output_file) = @ARGV;
# read from STDIN if input file name is '-'
$input_file = 'STDIN' if $input_file eq '-';
open (INP,$input_file) or die "Can't open file $input_file: $!\n";
while (<INP>) {
/^Function Name=([^;]+)/i && (($function_name = $1) =~ s/\s+$//) && next;
/^Brief Description=([^;]+)/i && (($description = $1) =~ s/\s+$//) && next;
/^Number Of Parameters=([^;]+)/i && (($numb_of_pars = $1) =~ s/\s+$//) && next;
/^Number Of Independent Variables=(\d+)/i && ($1 > 1) && (print STDERR "\nMore than 1 independent variable!\n\n") && exit;
if (s/^Names=(.+)/\1/i) {
s/\s+//g;
@a=split(/,/);
foreach $ind (0..$numb_of_pars-1) {
my $cin = 'orig2acegr'.$ind;
$var_new{$a[$ind]} = $cin;
}
next;
} elsif (s/^Initial Values=(.+)/\1/i) {
s/\(.+?\)|\cM//g;
chomp;
@a=split(/,/);
foreach $ind (0..$numb_of_pars-1) {
my $cin = 'orig2acegr'.$ind;
$ini_new{$cin} = $a[$ind] if $a[$ind] ne '--';
}
next;
} elsif (s/^Meanings=(.+)/\1/i) {
s/\(.+?\)|\cM//g;
chomp;
@a=split(/,/);
foreach $ind (0..$numb_of_pars-1) {
my $cin = 'orig2acegr'.$ind;
$mea_new{$cin} = $a[$ind];
}
next;
} elsif (s/^Lower Bounds=(.+)/\1/i) {
s/\(.+?\)|\cM//g;
chomp;
@a=split(/,/);
foreach $ind (0..$numb_of_pars-1) {
my $cin = 'orig2acegr'.$ind;
$low_new{$cin} = (($a[$ind] =~ /--/) ? '' : $a[$ind]);
}
next;
} elsif (s/^Upper Bounds=(.+)/\1/i) {
s/\(.+?\)|\cM//g;
chomp;
@a=split(/,/);
foreach $ind (0..$numb_of_pars-1) {
my $cin = 'orig2acegr'.$ind;
$upp_new{$cin} = (($a[$ind] =~ /--/) ? '' : $a[$ind]);
}
next;
} elsif (/Formula/i) {
while (<INP>) {last unless /^\s*$/};
tr/\r//;
#chomp;
s/^y\s*=\s*//i;
foreach $key (sort keys %var_new) {
s/\b$key\b/$var_new{$key}/ig;
}
s/orig2acegr/a/g;
s/\s+$//;
$formula = 'y = '.$_;
last;
}
}
if (!defined $output_file) {
($output_file = $input_file) =~ s/\.fdf$/\.fit/i;
open (OUT,">$output_file") or die "Can't open file $output_file: $!\n";
$OUT='OUT';
} elsif ($output_file ne '-') {
open (OUT,">$output_file") or die "Can't open file $output_file: $!\n";
$OUT='OUT';
} else {
$OUT='STDOUT';
}
print $OUT "#fit name \"$function_name\"\n";
print $OUT "fit title \"$description\"\n";
print $OUT "fit with $numb_of_pars parameters\n";
print $OUT "fit formula \"$formula\"\n";
foreach $ind (0..$numb_of_pars-1) {
$var='a'.$ind;
$old='orig2acegr'.$ind;
print $OUT "#$var description \"",$mea_new{$old},"\"\n";
print $OUT ($ini_new{$old}?'':'#'),$var," = $ini_new{$old}\n";
print $OUT (($low_new{$old} ? '' : '#'),$var,"min = $low_new{$old}\n");
print $OUT (($upp_new{$old} ? '' : '#'),$var,"max = $upp_new{$old}\n");
print $OUT $var," constraints ";
print $OUT (($low_new{$old}=~/^\s*$/ and $upp_new{$old}=~/^\s*$/) ? "off\n" : "on\n");
}
exit 0;
|