 |
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
wahorger

Joined: 13 Oct 2014 Posts: 1264 Location: Morrison, CO, USA
|
Posted: Thu Jul 24, 2025 2:12 pm Post subject: Limited record length |
|
|
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.
Code: |
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:
Quote: |
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 |
|
Back to top |
|
 |
Kenneth_Smith
Joined: 18 May 2012 Posts: 828 Location: Lanarkshire, Scotland.
|
Posted: Thu Jul 24, 2025 5:46 pm Post subject: |
|
|
Does this help?
Code: |
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 |
|
|
Back to top |
|
 |
wahorger

Joined: 13 Oct 2014 Posts: 1264 Location: Morrison, CO, USA
|
Posted: Thu Jul 24, 2025 7:37 pm Post subject: |
|
|
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 |
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8235 Location: Salford, UK
|
Posted: Fri Jul 25, 2025 8:01 am Post subject: |
|
|
I have looked at this and
a) the outcome is compiler dependent and
b) for FTN95, the only way I can see to change the outcome is to use ADVANCE as Ken advises. |
|
Back to top |
|
 |
JohnCampbell
Joined: 16 Feb 2006 Posts: 2620 Location: Sydney
|
Posted: Fri Jul 25, 2025 1:16 pm Post subject: |
|
|
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. |
|
Back to top |
|
 |
wahorger

Joined: 13 Oct 2014 Posts: 1264 Location: Morrison, CO, USA
|
Posted: Fri Jul 25, 2025 1:16 pm Post subject: |
|
|
Paul, thanks for taking a look at this! |
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|