Silverfrost Forums

Welcome to our forums

Limited record length

24 Jul 2025 1:12 #32239

While doing some debugging output for use as CSV data, I ran across a limitation that I'm not sure how to get past.

The following program code illustrates the issue.

	program test
	character*32:: comma_delimited='0123456789abcdefghijklmnopqrstuv'
        integer:: i
        open(unit=10,file='comma_delimited.txt',status='replace',access='sequential')
        write(10,*)(comma_delimited,',',i=1,5)
        write(10,90000)(comma_delimited,',',i=1,5)
90000 format(10(a,a))
        close(unit=10)
        stop
        end
        

What I would expect is to see 5 instances of the string separated by commas, and all in one record. Instead, I see:

0123456789abcdefghijklmnopqrstuv,0123456789abcdefghijklmnopqrstuv,0123456789abcdefghijklmnopqrstuv,0123456789abcdefghij klmnopqrstuv,0123456789abcdefghijklmnopqrstuv, 0123456789abcdefghijklmnopqrstuv,0123456789abcdefghijklmnopqrstuv,0123456789abcdefghijklmnopqrstuv,0123456789abcdefghijklmnopqrstuv,0123456789abcdefghijklmnopqrstuv,

I wonder if there is a way to specify a bigger record length for this type of output. BTW, when I specify a record length (i.e. RECL=256), it fills the first two records out to the new record length with NULL characters and does not 'join' the lines back together. The second line is totally unaffected by using RECL=.

If I use formatted output, there is no issue on record length, and no filling of the remainder of the records with NULL.

Bill

24 Jul 2025 4:46 #32240

Does this help?

program test
  character*32 :: comma_delimited = '0123456789abcdefghijklmnopqrstuv'
  integer :: i

  open(unit=10, file='comma_delimited.txt', status='replace')

  do i = 1, 5
     write(10,'(A)', advance='no') comma_delimited
     if (i < 5) write(10,'(A)', advance='no') ','  ! no trailing comma
  end do

  write(10,*)  ! move to new line

  ! Second line using FORMAT
  write(10,90000) (comma_delimited, ',', i=1,5)
90000 format(5(A, A))

  close(unit=10)
end program test
24 Jul 2025 6:37 #32241

Kenneth,

I see your solution will work. Thanks for the effort in preparing this. I'd never used ADVANCE before; useful!

My ultimate solution would be to write the entire output to a character variable, then output it with formatted WRITE so there is no 120 character limit. The real output has both character variables, integers, and floating point numbers. Since it is debugging information, it's constantly changing, and re-doing a formatted WRITE is not useful work.

I was curious why the line automatically folded at 120 characters. And is there a way to override this. And, if not, I'm moving on with this limitation in mind.

Bill

25 Jul 2025 7:01 #32242

I have looked at this and

  1. the outcome is compiler dependent and
  2. for FTN95, the only way I can see to change the outcome is to use ADVANCE as Ken advises.
25 Jul 2025 12:16 #32243

There are lots of record length limitations, which are difficult to find documented.

If I save an excel sheet of many columns as a .prn file, the records are dumped as approximately 256 character record lenght groups.

I think the best approach is to use more prescribed formats with shorter length records.

25 Jul 2025 12:16 #32244

Paul, thanks for taking a look at this!

Please login to reply.