6 # Don't edit the line below, it must look exactly like this.
7 # Everything above this line will be replaced #
16 my @parameters = @{$params};
19 foreach my $parm ( @parameters ){
20 if( $parmcov =~ /^$parm(.*)/ ){
29 my $res = GetOptions( \%options,
34 my $self = Config::Tiny -> new();
36 open(OLDFILE, "<" . $ARGV[0] ) ||
37 die "Unable to open oldstyle file".$ARGV[0]."for parsing\n";
40 my @parameters = split( /,/ , $options{"parameters"} );
47 if ( /^\s*;;;\s*DECL:\s*(.*)\s*$/ ) { # Find DECL lines, $1 is string of covs
48 my @parmcovs = split(/\s+/,$1);
49 foreach my $parmcov ( @parmcovs ){
50 my ($parm, $cov) = split_parm_cov(\@parameters, $parmcov);
51 if( length( $cov ) > 0 ){
52 $covariates{$cov} = 1;
53 push( @{$test_relations{$parm}}, $cov );
56 } elsif ( /^\s*;;;\s*BOUNDS:\s*(.*)\s*;\s*(.*)\s*$/ ) {
59 my ($parm,$cov) = split_parm_cov(\@parameters, $label);
60 $bound =~ /\((.*),(.*),(.*)\)/;
65 if( length( $upper ) > 0 ){
66 $self -> {'upper_bounds'} -> {"$parm:$cov-2"} = "$upper";
67 $self -> {'upper_bounds'} -> {"$parm:$cov-3"} = "$upper,$upper";
70 if( length( $init ) > 0 ){
71 $self -> {'inits'} -> {"$parm:$cov-2"} = "$init";
72 $self -> {'inits'} -> {"$parm:$cov-3"} = "$init,$init";
75 if( length( $lower ) > 0 ){
76 $self -> {'lower_bounds'} -> {"$parm:$cov-2"} = "$lower";
77 $self -> {'lower_bounds'} -> {"$parm:$cov-3"} = "$lower,$lower";
80 } elsif (/^\s*;;;\s*GLOBAL_INIT:\s*(.*)\s*$/) {
81 $self -> {_} -> {'global_init'} = $1;
82 } elsif ( /^\s*;;;\s*DYNAMIC_INIT\s*$/) {
83 $self -> {_} -> {'dynamic_init'} = 1;
84 } elsif ( /^\s*;;;\s*MISS:\s*(.*)\s*/) {
85 $self -> {_} -> {'missing_data_token'} = $1;
86 } elsif ( /^\s*;;;\s*GOF:\s*(.*)\s*/) {
87 $self -> {_} -> {'gof'} = $1;
88 } elsif ( /^\s*;;;\s*TASK:\s*(.*)\s*/) {
89 $self -> {_} -> {'search_direction'} = $1;
90 } elsif ( /^\s*;;;\s*FIX:\s*(.*)\s*/) {
91 $self -> {_} -> {'fix'} = $1;
92 } elsif ( /^\s*;;;\s*(\w+)(\d+)\s*START/ ) {
100 last if( $line =~ /\s*;;;\s*.*\s*END\s*/ );
101 if( $line =~ /\s*;;;(.*)/ ){
104 push( @code_array, $line );
107 my ($parm, $cov) = split_parm_cov( \@parameters, $label );
109 for( my $i = 0; $i < $#code_array; $i++ ){
111 $self -> {'specific_code'}{"$parm:$cov-$level"} .= ' ' x (1+length( "$parm:$cov-$level" ));
113 $self -> {'specific_code'}{"$parm:$cov-$level"} .= $code_array[$i] . " \\\n";
115 if( $#code_array > 0 ){
116 $self -> {'specific_code'}{"$parm:$cov-$level"} .= ' ' x (1+length( "$parm:$cov-$level" ));
118 $self -> {'specific_code'}{"$parm:$cov-$level"} .= $code_array[$#code_array] . "\n";
120 } elsif ( /^\s*;;;\s*PFORW:\s*(\d+)/ ) {
121 $self -> {_} -> {'p_forward'} = $1;
122 } elsif ( /^\s*;;;\s*PBACK:\s*(\d+)/ ) {
123 $self -> {_} -> {'p_backward'} = $1;
124 } elsif ( /^\s*;;;\s*LST:\s*(.*)\s*$/ ) {
126 print( "LST option ignored.\n" )
128 #$self -> {_} -> {'listfile'} = $1;
132 foreach my $cov ( keys %covariates ) {
133 $self -> {_} -> {'covariates'} .= "$cov,";
136 foreach my $parm ( keys %test_relations ){
137 foreach my $cov ( @{$test_relations{$parm}} ){
138 $self -> {'test_relations'} -> {$parm} .= "$cov,";
142 # if ( defined $self -> {'models'} and
143 # scalar @{$self -> {'models'}} > 0 ) {
144 # die "Error in scm -> _read_scm_file: You can't ",
145 # "specify both a modelobject and a scm modelfile\n";
147 # my $scm_model = model -> new( 'filename' => $self -> {'scm_file'},
148 # 'outputfile' => $self -> {'listfile'},
149 # 'target' => 'disk',
150 # 'ignore_missing_files' => 1 );
152 # my @code_block = @{$scm_model -> pk};
153 # my @new_code_block;
154 # my $prev_code_row = '';
156 # foreach my $code_row ( @code_block ) {
157 # if ( $code_row =~ /^\s*;;;\s*(\w+)(\d+)\s*START/ ) {
160 # if ( $in_block and $code_row =~ /\s*;;;\s*.*\s*END\s*/ ) {
163 # unless( ($prev_code_row =~ /^$/ and $code_row =~ /^$/) ){
164 # unless( $code_row =~ /^\s*;;;/ or $in_block ){
165 # push(@new_code_block, $code_row);
166 # $prev_code_row = $code_row;
170 # $scm_model -> pk( 'new_pk' => \@new_code_block);
171 # push( @{$self -> {'models'}}, $scm_model);
174 $self -> write( $ARGV[1] );
176 print( "Configuration file written to $ARGV[1]\n" );