- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello all,
I have a problem regarding setting a dynamic format statement. I believe examples will help explain better than I can explain it.
I have a code that writes out a set of data to a file, but the amount of data changes with each loopiterationso I write it this way
-----------------------
character*14 string
do
...Some calculations ...
string='( (F9.5))'
j = n * 2 ! For 2 sets of vectors
write(string(2:4),'(I3)')j
write(4,string)(ropls(i),i=1,n),(dfopls(i),i=1,n)
end do
------------------------
This code works fine. With each loop n can change from 1 to 100.
The next step reads in this data file, but since I can not figure out how to get the read to be formatted I set it as a generic read
-----------------------
-----------------------
Now the first set of data it reads fine, deallocates the arrays and attempts to read the next set but fails with a forrtl sever(59) I/O error. So, giving the format may alleviate this problem but I can not format the read the same way as the write. Trying to to the read the same way gives different errors and fails with the first read.
Thanks in advance
Chris
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Have you considered writing out STRING to unit 4 prior to writing the data. Then reading it back in the input routine. i.e. store the format string along with the data?
Jim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Have you considered writing out STRING to unit 4 prior to writing the data. Then reading it back in the input routine. i.e. store the format string along with the data?
Jim
Jim,
Thanks, after a little work I seemed to do that successfully. It works now, that is what matters.
Best
Chris

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page