How to Output the Objective Function to a Separate File
Here is an answer that is easy to use on a system that supports awk and
grep (all unix and versions are available for DOS and other OSs).
If you want to capture the obj func value at the end of each iteration
you can extract it from the NONMEM listing as it produced.
I use grep to search the NONMEM output as
follows:
grep "OBJECTIVE VALUE" nonmem.lst
You could use awk to extract the obj value itself from each line.
grep "OBJECTIVE VALUE" nonmem.lst|awk '{print $6}'
As supplied NONMEM leaves the OS to flush the output file buffer when it
feels like it instead of after printing the results of each iteration.
If you want to have a continuously updated output file while NONMEM is
running then you need to flush the file buffer.
If your f77 compiler supports flush() or something like that then it easy to
make the change to the NONMEM source so that the output file buffer is
flushed as soon as a new obj value is printed. I can supply details if
you wish.