Sun Studio 12: Fortran Library Reference

1.4.19 getfd: Get File Descriptor for External Unit Number

The function is called by:

INTEGER*4 getfd

fildes = getfd( unitn )

unitn

INTEGER*4

Input 

External unit number 

Return value 

INTEGER*4 or INTEGER*8

Output 

File descriptor if file is connected; -1 if file is not connected An INTEGER*8 result is returned when compiling for 64-bit environments

Example: getfd():


       INTEGER*4 fildes, getfd, unitn/1/
       open( unitn, file=’tgetfd.data’ )
       fildes = getfd( unitn )
       if ( fildes .eq. -1 ) stop ’getfd: file not connected’
       write(*,*) ’file descriptor = ’, fildes
       end

See also open(2).