[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference turris::fortran

Title:Digital Fortran
Notice:Read notes 1.* for important information
Moderator:QUARK::LIONEL
Created:Thu Jun 01 1995
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:1333
Total number of notes:6734

1146.0. "i/o efficiency and thread safeness" by SEAWLF::FOHLIN () Thu Jan 23 1997 12:50

T.RTitleUserPersonal
Name
DateLines
1146.1QUARK::LIONELFree advice is worth every centThu Jan 23 1997 15:0610
1146.2SEAWLF::FOHLINThu Jan 23 1997 16:527
1146.3QUARK::LIONELFree advice is worth every centThu Jan 23 1997 21:268
1146.4SEAWLF::FOHLINFri Jan 24 1997 00:345
    Why use implied DO loops?  Why not just set the recl = array size and
    read one record?
    
    Jim Fohlin
    
1146.5QUARK::LIONELFree advice is worth every centFri Jan 24 1997 09:184
You can do that too, though I'm not 100% sure the RTL can handle reading a
3GB array in one swell foop.

				Steve
1146.6Aren't two copies implied when using the Fortran RTL?SUBPAC::FARICELLIFri Jan 24 1997 12:598
   Won't using the Fortran RTL imply two copies: one from the Unix IO
   subsystem to the RTL internal buffer, and then from the RTL buffer to
   to the target array?

   Sounds like mmap() would be your best bet, if it were allowed.

   -- John Faricelli
1146.7SEAWLF::FOHLINMon Jan 27 1997 01:2915
    Could someone confirm that two copies are required?  If they are, that
    could help explain the comments I have heard about slow Fortran I/O.           
    
    mmap() is a good idea.  I have used it for other benchmarks.  But the           
    current RFP requires that I only use Fortran and COTS/GOTS/PD
    libraries.  So unless the mmap() Fortran binding is generally
    available, I can't use it.  Nor can I use my open/close/read/write
    Fortran bindings.
    
    How do I contribute code that would appear as an unsupported subset as
    part of the Fortran kit?  That would solve the problem for this RFP
    and maybe help other people.
    
    Jim Fohlin
    
1146.8Might get by with just a jacket to read/writeSUBPAC::FARICELLIMon Jan 27 1997 08:1711
   You can get the underlying file descriptor that corresponds
   to a  Fortran IO unit number via getfd(3f). That should avoid
   needing a jacket to open(2)/close(2).

   You'd just need a jacket to read(2)/write(2). At one point,
   there was/is an IEEE standard for interfaces to POSIX from Fortran.
   If they had interfaces to read(2)/write(2), then you might want
   to use their calling semantics.

   -- John Faricelli
1146.9posix fortran bindingsSEAWLF::FOHLINTue Jan 28 1997 23:515
    Could you please provide more info on the IEEE/POSIX Fortran bindings?
    Does Digital have an implementation?  Is it publically available?
    
    Jim Fohlin
    
1146.10QUARK::LIONELFree advice is worth every centWed Jan 29 1997 10:503
    We don't have an implementation.  Almost noone uses them.
    
    				Steve
1146.11Posix binding for read()/write()SUBPAC::FARICELLIWed Jan 29 1997 11:1832
   The relevant Posix standard for f77 is P1003.9, dated 1992.
   According to a Digital internal chart, the f90 standard was withdrawn.

   According to an old draft, the bindings for read(2) and write(2) are:

   PFXREAD(ifildes, buf, nbyte, nread, ierror)

   integer ifildes     ! file descriptor
   character buf(*)    ! character buffer
   integer nbyte       ! bytes to read
   integer nread       ! bytes actually read
   integer ierror      ! error condition, zero if successful

   PFXWRITE(ifildes, buf, nbyte, nwritten, ierror)

   integer ifildes     ! file descriptor
   character buf(*)    ! character buffer
   integer nbyte       ! bytes to write
   integer nwritten    ! bytes actually written
   integer ierror      ! error condition, zero if successful

   You might do an external AltaVista search, some place like NIST
   might have done a PD implementation of this binding...

   Anyway, from what Steve indicates, sounds like not many vendors
   bought into providing this binding.

   -- John Faricelli


   
1146.12Example of Fortran read(2)/write(2) without bindingsSUBPAC::FARICELLIThu Jan 30 1997 08:5365
   Come to think of it, you don't need extra bindings at all to call read(2)
   or write(2). Just use the cdec$ alias avoid the trailing underscores,
   and %val() where needed.

   Here are some examples, would they be "OK" since they only use Fortran
   (albeit, using nonstandard extensions to Fortran, but your bindings
   would be nonstandard as well).

   -- John Faricelli

** f77_write.f
        implicit none
        integer getfd, fd
        integer IARRAY
        parameter (IARRAY=10)
        integer ibuf(IARRAY), i, nbytes, nwritten, write
c
cdec$   alias write,"write"
c
        do i=1,IARRAY
           ibuf(i) = i
        end do
c
        open(unit=10,file='bintest',status='unknown')
        fd = getfd(10)
        nbytes = IARRAY*sizeof(i)
        nwritten = write(%val(fd),ibuf,%val(nbytes))
        close(unit=10)
c
        write(6,*) 'Number of bytes written: ', nwritten
c
        end

** f77_read.f
        implicit none
        integer getfd, fd
        integer IARRAY
        parameter (IARRAY=10)
        integer ibuf(IARRAY), i, nbytes, nread, read
c
cdec$   alias read,"read"
c
        open(unit=10,file='bintest',status='unknown')
        fd = getfd(10)
        nbytes = IARRAY*sizeof(i)
        nread = read(%val(fd),ibuf,%val(nbytes))
        close(unit=10)
c
        write(6,*) 'Number of bytes read: ', nread
c
        do i=1,IARRAY
           write(6,*) ibuf(i)
        end do
c
        end