Solved

Digital Fortran 6.5 Question

Posted on 2002-05-07
7
244 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
Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 
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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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.
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

773 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