How to implement a couple of PXF routines?
Walter Spector
w6ws@earthlink.net
Wed Aug 8 06:19:00 GMT 2007
Steve Kargl wrote:
>
> On Sun, Aug 05, 2007 at 10:14:45AM -0700, Walter Spector wrote:
> >
> > 1.) PXFFILENO - Given a Fortran unit 'iunit', return the POSIX file
> > descriptor associated with that unit. If all is well, 0 is returned
> > in ierror. Otherwise ierror returns EINVAL (iunit is not an open unit)
> > or EBADF (iunit is not connected with a file descriptor)...
> gfortran has FNUM for compatiability with g77...
Ok, I took a look at the source. It seems all I have to do is call
unit_to_fd to get the file descriptor. Nice. So PXFFILENO would look
something like:
int unit_to_fd (int fd);
void
pxffileno_ (int *iunit, int *ifildes, int *ierror)
{
*ifildes = unit_to_fd (*iunit);
*ierror = (*ifildes >= 0) ? 0 : EBADF;
}
(Feel free to add it to the gfortran library.)
By the POSIX spec, it would be nice to distinguish between EINVAL and EBADF.
But looking upwards into unit_to_fd and friends, it doesn't look easy enough
to be worth the effort.
Onwards to PXFFDOPEN - but not tonight.
W.
More information about the Fortran
mailing list