forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Record length with formatted write
Goto page Previous  1, 2
 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
Norm.Campbell



Joined: 31 Aug 2007
Posts: 66

PostPosted: Tue Oct 16, 2012 3:53 am    Post subject: Reply with quote

Hi Paul

Has this been resolved?

Regards

Norm
Back to top
View user's profile Send private message
JohnCampbell



Joined: 16 Feb 2006
Posts: 2625
Location: Sydney

PostPosted: Tue Oct 16, 2012 6:49 am    Post subject: Reply with quote

Norm,

If it still does not work, you could read and write the character string to a file, using a "large buffer library", by opening the file as access=transparent.

You might only need:
open_big (unit, file_name)
close_big (unit)
read_big_string (unit, string)
write_big_string (unit, string)

something like ...
Code:
subroutine write_big_string (unit, string)
  integer*4 unit, i, iostat
  character string*(*)
!
!  Write string to transparent file
    do i = 1,len_trim(string)
       write (unit=unit, iostat=iostat) string(i:i)
    end do
!
!  Terminate string with <CR> <LF>
   write (unit=unit, iostat=iostat) char(13)
   write (unit=unit, iostat=iostat) char(10)
   write (*,*) i-1,' character string written'
end

subroutine read_big_string (unit, string)
  integer*4 unit, i, iostat, bad
  character string*(*)
!
!  Read string from transparent file
    string = ' '
!  Expect that string terminated with <CR> <LF>
    bad = 0
    do i = 1,len(string)
       read (unit=unit, iostat=iostat) string(i:i)
       if (iostat /= 0) then
          bad = bad + 1
          exit
       end if
       if (ichar(string(i:i)) >= 32) cycle
       bad = bad + 1
       if (ichar(string(i:i)) == 10) exit
       string(i:i) = ' '
    end do
    write (*,*) i-bad,' character string read'
!
end
subroutine open_big_string (unit, file_name)
  integer*4 unit, iostat
  character file_name*(*)
!
      open (unit   = unit,             &
            file   = file_name,        &
            status = 'OLD',            &
            form   = 'UNFORMATTED',    &
            access = 'TRANSPARENT',    &
            iostat = iostat)
      write (*,2000) 'Opening file ',trim(file_name),' iostat = ',iostat
2000  format (a,a,a,i0)
end

subroutine close_big_string (unit)
  integer*4 unit, iostat
!
      close (unit   = unit,               &
             iostat = iostat)
      write (*,2000) 'Closing file : iostat = ',iostat
2000  format (a,i0)
end
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support All times are GMT + 1 Hour
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
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