subroutine ldread(nun,dum,n) c********************************************************************** c*****ldread does a list-directed read for exponent formatted * c*****numbers, allowing whitespace or a minus for a separator. * c*****last revision: 1/31/95, s.e.attenberger, ornl. * c*****input: * c*****nun -unit number for input * c*****output: * c*****dum -array of real values * c*****n -number of real values to read * c*****Note: 2d ufiles from DIIID use a (6e12.4) format, whereas * c*****2d ufiles from tftr use a (1x,6e13.6) format. In the latter * c*****case, there is no whitespace before negative numbers, * c*****which prevents list directed reads for the cf77 compiler. * c*****This routine reads a line of n numbers in (Ax,BeC.E) format, * c*****where A,B,C, and D are arbitrary numbers. * c********************************************************************** parameter(mxchr=80) dimension dum(n) character el*1,eu*1,line*80,minus*1,space*1,tab*1,form*20,flen*2 minus='-' space=' ' el='e' eu='E' tab=char(9) read(nun,'(a80)')line c*****find first non-blank character. (may or may not be a minus). do j=1,mxchr istart=j if((line(j:j).ne.space).and.(line(j:j).ne.tab))go to 100 enddo 100 if(istart.eq.mxchr)then write(*,*)'fatal error in ldread: blank line in input' stop endif do inum=1,n c*****find next exponent. iel=index(line(istart:),el) ieu=index(line(istart:),eu) if((iel.gt.0).and.(ieu.gt.0))then iexp=min(iel,ieu) elseif(iel.gt.0)then iexp=iel elseif(ieu.gt.0)then iexp=ieu else write(*,*)'fatal error in ldread: missing exponent' write(*,*)line stop endif c***** step over possible sign istep=istart+iexp+1 c***** find next space or minus. this starts the next number. is=index(line(istep:),space) im=index(line(istep:),minus) if((im.gt.0).and.(is.gt.0))then inext=istep-1+min(im,is) elseif(im.gt.0)then inext=istep-1+im elseif(is.gt.0)then inext=istep-1+is else c***** There may be no whitespace after the last number. inext=mxchr+1 endif c***** evaluate the current number ilen=inext-istart if(ilen.lt.10)then write(flen,'(i1)')ilen form='(e'//flen(1:1)//'.6)' else write(flen,'(i2)')ilen form='(e'//flen(1:2)//'.6)' endif read(line(istart:inext-1),fmt=form)dum(inum) istart=inext enddo return end