Hi all,
I have successfully moved hydrodynamic code from Compaq Visual Fortran to PG Fortran in Unix. Everything works correctly except some outputs are not completly written. In other words, some data is missing at the end of each file.
Any suggestion from experts as why this happens. I need to fix this problem as soon as possible. Thanks for your help.
How does your program exit?
What kind of Fortran writes are you doing for the files? i.e. Formatted/Unformatted? Sequential/Direct?
What OPEN Specifiers are you using for the file?
Hi Mat,
Thanks for getting back to me.
Here is one of my open statements.
open (NFlog, file = file_name(1:len_trim(file_name)), status = ‘unknown’)
It is a formatted file. Some files are direct and some are sequential.
I have shown below top section of the output
Minimum droplet size = 11
Maximum droplet size = 133
My best guess is that I/O buffers aren’t getting flushed to disk before your program exits. Are you closing your files before exiting? Is the program abnormally exiting or hitting a stop statement before close can be called?
One thing to try is to disable buffering by calling “setvbuf3f(NFlog,2,0)”. It will slow down your program but ensure I/O gets to the disk.
Mat
From the PGI Fortran Reference Guide:
setvbuf3f
Change I/O buffering behavior.
interface
function setvbuf3f(lu, typ, size)
integer setvbuf3f, lu, typ, size
end function
end interface
Description
Fortran I/O supports 3 types of buffering., described in detail in the
description of “setvbuf,” on page 310
Logical units 5 (stdin) and 6 (stdout) are line buffered. Logical unit 0 (stderr) is unbuffered. Disk files are fully buffered. These defaults generally give the expected behavior. You can use setvbuf3f to change a unit’s buffering type and size of the buffer.
Note. The underlying stdio implementation may silently restrict your choice of buffer size. This function must be called after the unit is opened and before any I/O is done on the unit. The typ parameter can have the following values, 0 specifies full buffering, 1 specifies line buffering, and 2 specifies unbuffered. The size parameter specifies the size of the buffer.
This function returns zero on success and non-zero on failure. An example of a program in which this function might be useful is a long-running program that periodically writes a small amount of data to a log file. If the log file is line buffered, you could check the log file for progress. If the log file is fully buffered (the default), the data may not be written to disk until the program terminates.
Thanks Mat,
When I used your suggestion, couple of files wrote correctly.
But some files still does not show any data until the program is completed.
I will check some more and get back to you.