C Copyright (c) 1980 Regents of the University of California.
C All rights reserved. The Berkeley software License Agreement
C specifies the terms and conditions for redistribution.
C @(#)ioinit.f 5.1 (Berkeley) 6/8/85
C ioinit - initialize the I/O system
C logical function ioinit (cctl, bzro, apnd, prefix, vrbose)
C logical cctl, bzro, apnd, vrbose
C cctl is .true. to turn on fortran-66 carriage control
C bzro is .true. to cause blank space to be zero on input
C apnd is .true. to open files at their end
C prefix is a string defining environment variables to
C be used to initialize logical units.
C vrbose is .true. if the caller wants output showing the lu association
C .true. if all went well
logical function ioinit (cctl, bzro, apnd, prefix, vrbose)
logical cctl, bzro, apnd, vrbose
automatic iok, fenv, ienv, ename, fname, form, blank
integer*2 ieof, ictl, izro
common /ioiflg/ ieof, ictl, izro
open (unit=5, form=form, blank=blank)
open (unit=6, form=form, blank=blank)
if ((lp .gt. 0) .and. (lp .le. 30) .and. (prefix .ne. " ")) then
if (nb .eq. 0) nb = lp + 1
if (vrbose) write (0, 2002) ename(:nb-1)
write (ename(nb:), "(i2.2)") lu
call getenv (ename, fname)
if (fname .eq. " ") go to 200
open (unit=lu, file=fname, form='f', access='s', err=100)
if (vrbose) write (0, 2000) lu, fname(:lnblnk(fname))
100 write (0, 2003) ename(:nb+1)
call perror (fname(:lnblnk(fname)))
if (ienv .and. (.not. fenv)) write (0, 2001) ename(:nb-1)
write (0, 2004) cctl, bzro, apnd
2000 format ('ioinit: logical unit ', i2,' opened to ', a)
2001 format ('ioinit: no initialization found for ', a)
2002 format ('ioinit: initializing from ', a, 'nn')
2003 format ('ioinit: ', a, ' ', $)
2004 format ('ioinit: cctl=', l, ', bzro=', l, ', apnd=', l)