Solved

Digital Fortran 6.5 Question

Posted on 2002-05-07
7
256 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 100

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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

 
LVL 100

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
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.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

809 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