|
From: Thomas Raab on 7 Apr 2008 09:33 Hello, I'm trying to write data sets to an ASCII file. As the length of these data sets can vary, I need some sort of variable format for the write statement. I tried the following open(unit=101,file='test_data/test.out', status='new', iostat=ios) write(tes,"('''(' ,I2,'E20.6)''' )"), x do i=1,z do j=1,y write(unit=101,fmt=tes) data(i,:,j) end do end do where x is an Integer in the range of 1 to 500 Unfortunately it doesn't work, giving the error: PGFIO-F-246/formatted write/unit=101/infinite format scan for edit descriptor. Any help is appreciated Thomas
From: meek on 7 Apr 2008 09:56 In a previous article, Thomas Raab <spamnews.20.fonsi(a)spamgourmet.com> wrote: >Hello, > >I'm trying to write data sets to an ASCII file. As the length of these >data sets can vary, I need some sort of variable format for the write >statement. I tried the following > >open(unit=101,file='test_data/test.out', status='new', iostat=ios) >write(tes,"('''(' ,I2,'E20.6)''' )"), x >do i=1,z > do j=1,y > write(unit=101,fmt=tes) data(i,:,j) > end do >end do > >where x is an Integer in the range of 1 to 500 >Unfortunately it doesn't work, giving the error: Presubalby you could do write(101,*)x,(data(i,:,j) (there seem to be a lot of other errors - at least they would be in F77, so I'll et others pick those out. E.g. write(tes -- when it doesn't know the unit to write to.) Chris > >PGFIO-F-246/formatted write/unit=101/infinite format scan for edit >descriptor. > > >Any help is appreciated > >Thomas
From: Dr Ivan D. Reid on 7 Apr 2008 09:53 On Mon, 07 Apr 2008 15:33:38 +0200, Thomas Raab <spamnews.20.fonsi(a)spamgourmet.com> wrote in <47fa22b2$1(a)sia.uibk.ac.at>: > open(unit=101,file='test_data/test.out', status='new', iostat=ios) > write(tes,"('''(' ,I2,'E20.6)''' )"), x > do i=1,z > do j=1,y > write(unit=101,fmt=tes) data(i,:,j) > end do > end do > where x is an Integer in the range of 1 to 500 > Unfortunately it doesn't work, giving the error: > PGFIO-F-246/formatted write/unit=101/infinite format scan for edit > descriptor. Lose the explicit single quotes in your format string, and make that I3 if you're really going above 99. You can also drop the comma before x. You can achieve the same thing with write(unit=101,fmt='(500e20.6)') data(i,:,j) as the format terminates when all output items have been written. You may have trouble writing records that large, though. -- Ivan Reid, School of Engineering & Design, _____________ CMS Collaboration, Brunel University. Ivan.Reid@[brunel.ac.uk|cern.ch] Room 40-1-B12, CERN KotPT -- "for stupidity above and beyond the call of duty".
From: Klaus Wacker on 7 Apr 2008 10:04 Thomas Raab <spamnews.20.fonsi(a)spamgourmet.com> wrote: > Hello, > > I'm trying to write data sets to an ASCII file. As the length of these > data sets can vary, I need some sort of variable format for the write > statement. I tried the following > > open(unit=101,file='test_data/test.out', status='new', iostat=ios) > write(tes,"('''(' ,I2,'E20.6)''' )"), x > do i=1,z > do j=1,y > write(unit=101,fmt=tes) data(i,:,j) > end do > end do > > where x is an Integer in the range of 1 to 500 > Unfortunately it doesn't work, giving the error: > > PGFIO-F-246/formatted write/unit=101/infinite format scan for edit > descriptor. > You don't need a varaiable format for this. Just use '(500E20.6)'. It doesn't matter, and it is not an error, if you write fewer items with one write. The next write will start a new record anyway. (Apart from that, I2 is not really an appropriate format for a number in the range 1 to 500.) -- Klaus Wacker klaus.wacker(a)udo.edu Experimentelle Physik V http://www.physik.uni-dortmund.de/~wacker Universitaet Dortmund Tel.: +49 231 755 3587 D-44221 Dortmund Fax: +49 231 755 4547
From: fj on 7 Apr 2008 10:19 On 7 avr, 15:33, Thomas Raab <spamnews.20.fo...(a)spamgourmet.com> wrote: > Hello, > > I'm trying to write data sets to an ASCII file. As the length of these > data sets can vary, I need some sort of variable format for the write > statement. I tried the following > > open(unit=101,file='test_data/test.out', status='new', iostat=ios) > write(tes,"('''(' ,I2,'E20.6)''' )"), x > do i=1,z > do j=1,y > write(unit=101,fmt=tes) data(i,:,j) > end do > end do > > where x is an Integer in the range of 1 to 500 > Unfortunately it doesn't work, giving the error: > > PGFIO-F-246/formatted write/unit=101/infinite format scan for edit > descriptor. > > Any help is appreciated > > Thomas In addition to the previous remarks, do not forget that the case of a too short format is automatically managed by FORTRAN which can create many records with a single WRITE statement. For all the records except the first one, the format is reduced to the part between parentheses (if such a part exist of course else the full format is used for all the records). Example : WRITE(*,'(A,(10e12.5))') 'output : ',(x(i),i=100) => 10 records but only the first one starts by the string 'output :'.
|
Next
|
Last
Pages: 1 2 Prev: EXTERNAL statement for subroutines: is it ever needed? Next: f2003 or F2003 ? |