- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I am a new user who migrated to CVF from C++. I am trying to WRITE someelements of an array in a single output line.
CHARACTER*10 ARRAYC(100)
REAL*8 ARRAYINT(100)
INTEGER ii1
i.e I want ARRAYC(1), ARRAYC(2), ARRAYC(3) .... ARRAYC(ii1)in a single line followed by ARRAYINT(1), ARRAYUNT(2), ARRAYINT(3).....ARRAYINT(ii1)in the second line.In this example, my target output file should beonly 2 lines.'ii1' is not fixed. It takes any values from1 to 100.
I need to do it to port the output data to a spreadsheet application. If I couldformat the WRITE statement so that CHARACTER*10 and INTEGER will be of same width in the output file that would be great (spreadsheet will recognize it better). Can someone please help me with this. I tried implicit do statements but every single WRITE begins with a new line in output. I also thought about creating a very big CHARACTER array and concatenating the values and printing the final resulting string to a single line.Can someone please help me to do it in the correct way?
Thanks.
Link Copied
5 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I was able to print all the elements of an array in the same line by hard codingsize of array.
INTEGER ii1, Records
WRITE(3,'(40A25)') (EqRecords(ii1),ii1 = 1,Records)
In this case I know that there are only 40 Elements in the Array. The compiler does not allow me to do WRITE(3,'(RecordsA25)'). Can someone please tell me how to do this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can simply use e.g.
WRITE(3,'(1000A25)') (EqRecords(ii1),ii1 = 1,Records)
which enables you to write up to 1000 elements. You're not required to match the number of actual entries with the number in the format -- the latter may be bigger.
I think -- but I'm not sure -- that the following will also work:
WRITE(3,'((A25))') (EqRecords(ii1),ii1 = 1,Records)
(note the extra brackets)-- there's an obscure rule that when the format string is "exhausted", the formatting "returns" to the last bracket encountered -- if I remember correctly.
There's also non-standard (DEC/CVF/IVF extension) <> form:
WRITE(3,'( A25)') (EqRecords(ii1),ii1 = 1,Records)
I recommend against it unless it's really inavoidable.
Jugoslav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am getting an access violation when using this.
900 format(
901 format(
So, I should say
900 format(1000(f5.1,2x))
901 format(1000(f7.1,2x))
?
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It didn't work ....
Message Edited by bsully on 04-13-2004 06:10 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
bsully, it's hard to deduce what's happening without seeing the actual code. On first glance, it appears that the problem is in I/O list rather than in format string itself -- check whether the variables in I/O list are properly allocated and/or of the right type.
Jugoslav
![](/skins/images/7FC17B7B85029576C25F1E43CE255B51/responsive_peak/images/icon_anonymous_message.png)
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page