?
Solved

Digital Fortran 6.5 Question

Posted on 2002-05-07
7
Medium Priority
?
306 Views
Last Modified: 2013-11-08
Hi All,

I'm trying to write the content of an 2-dimensional array (integers) to a comma seperated file. I have trouble to convert the numbers into a "string". I want to do things like this:

integer myarray(20,3)
! I fill the array here with data
open(10,'c:\tmp\file.dat',STATUS='REPLACE'
do n=1 to 20
  mystring=myarr(n,1)//','
  mystring=myarr(n,2)//','
  mystring=myarr(n,3)//','
  write (10,*) mystring
enddo
etc...

I do not really how to format the numbers and change them into a "string" so I can write them to the file the way I want.

Does anyone have any experience with this?

Thanks in advance.

Hing.
0
Comment
Question by:Hing
7 Comments
 
LVL 2

Expert Comment

by:jonnin
ID: 6994605
write it to an internal file and read it back out. there may be a cleaner way, all i can think of...
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 6994655
Would the following work?
 
write (10,*) myarr(n,1),",",myarr(n,2),",",myarr(n,3)

mlmcc
0
 

Author Comment

by:Hing
ID: 6995816
Thanks mlmcc,

I thought about that too, but the problem is that each line I've written to the file will wrap automatically, something I don't want to happen.

anyone other ideas?

Hing.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 101

Expert Comment

by:mlmcc
ID: 6997721
What do you mean the line or file wraps?  

Generally wrapping is a function of the display not the file.  

It's been a long time since I did any FORTRAN but I thought the line I gave you would do something like

45,56,78
23,43,65

mlmcc
0
 

Expert Comment

by:jespernaur
ID: 7240058
    write(10,20)myarr(n,1),myarr(n,2),myarr(n,3)
20   format(1x,i5,",",i5,",",i5)

This is a completely simple application of the FORTRAN FORMAT capability - you really should look into what else can be done

Best regards
Jesper Naur
0
 
LVL 54

Expert Comment

by:nico5038
ID: 7515090

No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
 - PAQ'd and pts removed
Please leave any comments here within the
next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

Nic;o)
0
 

Accepted Solution

by:
Jgould earned 0 total points
ID: 7548151
Question has been closed as per recommendation

JGould-EE Moderator
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
What do responsible coders do? They don't take detrimental shortcuts. They do take reasonable security precautions, create important automation, implement sufficient logging, fix things they break, and care about users.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Suggested Courses
Course of the Month17 days, 5 hours left to enroll

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question