c c------------------------------------------------------------------ c Begin file /home/sting/foster/getgcm/assgn.f c------------------------------------------------------------------ c subroutine assgn(dname,lu) c c Attach file dname to unit lu (dname and lu defined on input) c 11/91: Like assign.f, but took out nblocks, and changed the ishell c command to a call assign to avoid the fork necessary in ishell c character*(*) dname character fmt*120, cmnd*120 c c Check input: c idch = lenstr(dname) if (idch.le.0.or.idch.gt.99) then write(6,"('assgn: bad dname: idch=',i3,' dname=',a)") + idch,dname stop 'dname' endif if (lu.le.0.or.lu.gt.99) then write(6,"('assgn: bad lu=',i5,'(dname=',a,')')") lu,dname stop 'lu' endif c c Make format for 'assign -a flnm' part of command: c write(fmt(1:15),"('(''assign -a '',A')") if (idch.lt.10) then write(fmt(16:16),"(i1)") idch nfmt = 16 elseif (idch.lt.100) then write(fmt(16:17),"(i2)") idch nfmt = 17 endif c c Add format for lu part of command: c if (lu.lt.10) then write(fmt(nfmt+1:nfmt+16),"(','' fort.'',I1)')") elseif (lu.lt.100) then write(fmt(nfmt+1:nfmt+17),"(','' fort.'',I2)')") endif nfmt = nfmt+16 c c Make the command, using format just made: c write(cmnd,fmt) dname(1:idch),lu ncmnd = lnblnk2(cmnd) c c Execute the command and check status: c istat = 999 call assign(cmnd(1:ncmnd),istat) if (istat.ne.0) then write(6,"('assign: bad return from call assign=',i5)") istat write(6,"(' command=',a)") cmnd(1:ncmnd) stop 'assign' else write(6,"('assgn: successful assign of unit ',i3, + ' to file ',a)") lu,dname(1:idch) endif return end