I haven't had much luck searching for an answer, maybe a guru here has one.
This is the basic structure of my program:
program main
open(42,file='output.dat')
do while(x)
process a bunch of data
call output_function
end do
close(42)
end program
subroutine output_function...