1 # {{{ include statements
3 start include statements
17 unless( defined $this -> {'outputfile'} ){
18 $this -> {'outputfile'} = $this -> {'modelfile'};
19 $this -> {'outputfile'} =~ s/\.mod$/\.lst/;
22 unless( defined $this -> {'nm_directory'} ){
23 my $nmdir = $PsN::config
-> { 'nm_versions' } -> { $this -> {'version'} };
25 unless( defined $nmdir ){
26 print "Unknown NONMEM version ",$this -> {'version'}," specified.\n";
27 my @nmkeys = keys %{$PsN::config
-> { 'nm_versions' }};
28 if ( $#nmkeys == 0 and
29 defined $nmkeys[0] and
30 defined $PsN::config
-> { 'nm_versions' } -> {$nmkeys[0]} ) {
31 print "Using ",$PsN::config
-> { 'nm_versions' } -> {$nmkeys[0]}," instead\n";
32 $nmdir = $PsN::config
-> { 'nm_versions' } -> {$nmkeys[0]};
36 $this -> {'nm_directory'} = $nmdir;
38 unless( defined $PsN::config
-> {'compiler'} and defined $PsN::config
-> {'compiler'} -> {'name'} ){
39 debug
-> warn( level
=> 1,
40 message
=> "No compiler defined, assuming g77" );
41 $this -> {'compiler'} = 'g77';
43 $this -> {'compiler'} = $PsN::config
-> {'compiler'} -> {'name'};
44 $this -> {'compiler_options'} = $PsN::config
-> {'compiler'} -> {'options'};
56 my $version = $self -> {'version'};
57 my $nmdir = $self -> {'nm_directory'};
61 if( -e
"$nmdir/util/nmlink5.exe" ){
62 $nmlink = "$nmdir/util/nmlink5.exe";
63 $self -> {'version'} = 5;
64 if( $self -> {'show_version'} ){
65 $version = $self -> {'version'};
69 } elsif ( -e
"$nmdir/util/nmlink6.exe" ){
70 $self -> {'version'} = 6;
71 if( $self -> {'show_version'} ){
72 $version = $self -> {'version'};
76 $nmlink = "$nmdir/util/nmlink6.exe";
77 if( $Config{osname
} eq 'MSWin32' ){
78 $includes = "-I$nmdir\\sizes";
80 $includes = "-I$nmdir/sizes";
83 my $err_version = ( defined $nmdir and $nmdir ne '' ) ?
$nmdir : 'undefined';
84 debug
-> die( message
=> "Unable to find a supported version of NONMEM\n".
85 "The NONMEM installation directory is $err_version for version ".
86 $self -> {'version'}." according to psn.conf" );
89 # first clean up from old compile
90 unlink( 'FCON', 'FDATA', 'FREPORT','FSUBS', 'FSUBS.f','LINK.LNK','FSTREAM', 'PRDERR', 'nonmem.exe', 'nonmem' );
94 if( $Config{osname
} eq 'MSWin32' ){
100 my $modelfile = $self -> {'modelfile'};
102 run3
( "$nmdir/tr/nmtran.exe", $modelfile, \
$self -> {'nmtran_message'}, \
$self -> {'nmtran_message'} );
104 #$self -> {'nmtran_message'} = `$nmdir/tr/nmtran.exe < $modelfile 2>&1`;
106 open( NMMSG
, '>compilation_output.txt' );
107 print( NMMSG
$self -> {'nmtran_message'}, "\n" );
109 unless(-e
'FREPORT'){
110 $self -> {'error_message'} = "NMtran failed: \n" . $self -> {'nmtran_message'} ;
115 run3
( "$nmlink", undef, \
$nmlink_message, \
$nmlink_message );
117 print( NMMSG
$nmlink_message, "\n" );
122 if( $self -> {'compiler'} eq 'g77' ){
123 cp
("FSUBS", "FSUBS.f");
126 cp
("FSUBS", "FSUBS.for");
131 if( defined $self -> {'fsubs'} ){
132 foreach my $sub ( @
{$self -> {'fsubs'}} ){
137 open( FH
, "<", 'LINK.LNK' );
149 if( $self -> {'compiler'} eq 'g77' ){
151 my @nmlib = ("$nm/NONMEM.o", "$nm/BLKDAT.o", "$nm/nonmem.a");
152 $compile_command = "g77 " . $self -> {'compiler_options'} . " -ononmem$version $includes $fsub @link @nmlib 2>&1";
154 } elsif( $self -> {'compiler'} eq 'df' or $self -> {'compiler'} eq 'fl32' ){
156 my @nmlib = ("$nm\\nonmem.obj", "$nm\\blkdat.obj", "$nm\\nonmem.lib");
157 # <<<<<<< nonmem_subs.pm
159 # $compile_command = "df " . $self -> {'compiler_options'} . " /Fenonmem $fsub @nmlib @link";
161 # $compile_command = "df " . $self -> {'compiler_options'} . " /Fenonmem @nmlib @link";
163 # } elsif( $self -> {'compiler'} eq 'fl32' ){
164 # my @nmlib = ("$nm\\nonmem.obj", "$nm\\blkdat.obj", "$nm\\nonmem.lib");
166 # $compile_command = "fl32 " . $self -> {'compiler_options'} . " /Fenonmem $fsub @nmlib @link";
168 # $compile_command = "fl32 " . $self -> {'compiler_options'} . " /Fenonmem @nmlib @link";
171 $compile_command = $self -> {'compiler'}." " . $self -> {'compiler_options'} . " /Fenonmem $fsub @nmlib @link";
176 run3
( "$compile_command", undef, \
$compile_message, \
$compile_message );
178 print( NMMSG
$compile_message, "\n" );
182 if( $self -> {'compiler'} eq 'df' or $self -> {'compiler'} eq 'fl32' ){
183 unless(-e
"nonmem.exe") {
184 $self -> {'error_message'} = "Fortran Compilation failed: \n" . $compile_message ;
188 unless(-e
"nonmem$version") {
189 $self -> {'error_message'} = "Fortran Compilation failed: \n" . $compile_message ;
201 my $version = $self -> {'version'};
202 my $nmdir = $self -> {'nm_directory'};
203 my $outputfile = $self -> {'outputfile'};
205 if( $Config{osname
} eq 'MSWin32' ){
206 run3
( "nonmem.exe", undef, undef );
208 cp
( "output", $outputfile );
210 } elsif ( -e
"OUTPUT" ) {
211 cp
( "OUTPUT", $outputfile );
215 unless( $self -> {'show_version'} ){
218 run3
( "nice -n " . $self -> {'nice'} . " ./nonmem$version", "FCON", $outputfile );
219 open( OUTPUTFILE
, '>>', $outputfile );
220 print( OUTPUTFILE
"This file was created using the NONMEM version in directory $nmdir\n" );
221 print( OUTPUTFILE
`date`, "\n" );