Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

how to output to multiple files?
I need to output the data to multiple files.  That's, it's a time
dependant execution and I want to dump the data to each timestep.  For
example:

test_1.dat
test_2.dat
test_3.dat
test_4.dat
and so on.

Any guideline on how to do this,

Greetings,

Joe

Report this thread to moderator Post Follow-up to this message
Old Post
joel GUERRERO
09-26-04 01:57 AM


Re: how to output to multiple files?
joegi.geo@yahoo.com (joel GUERRERO) wrote:
>I need to output the data to multiple files.  That's, it's a time
>dependant execution and I want to dump the data to each timestep.  For
>example:
>
>test_1.dat
>test_2.dat
>test_3.dat
>test_4.dat
>and so on.

Put the file name into a string using an "internal write", OPEN the file,
WRITE to it, and CLOSE it, as shown below:

program xfile_name
implicit none
integer            :: i
integer, parameter :: out_unit=20,num_files=4
character (len=20) :: file_name
do i=1,num_files
write (file_name,"('test_',i1,'.dat')") i
open (unit=out_unit,file=file_name,action="write",status="replace")
write (out_unit,*) i,i**2
close (out_unit)
write (*,*) trim(file_name)
end do
end program xfile_name

To write to more than 9 files, the format string "('test_',i1,'.dat')" must
be changed.



----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==--
--
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 News
groups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =
---

Report this thread to moderator Post Follow-up to this message
Old Post
beliavsky@aol.com
09-26-04 01:57 AM


Re: how to output to multiple files?
On Sat, 25 Sep 2004 22:08:40 UTC, joegi.geo@yahoo.com (joel GUERRERO)
wrote:

> I need to output the data to multiple files.  That's, it's a time
> dependant execution and I want to dump the data to each timestep.  For
> example:
>
> test_1.dat
> test_2.dat
> test_3.dat
> test_4.dat
> and so on.
>
> Any guideline on how to do this,
>

I think you can do this by having the unchanging part of your output
as a variable and adding the time dependent parts.

--
Jim Backus OS/2 user since 1994
bona fide replies to j <dot> backus <the circle thingy> jita <dot>
demon <dot> co <dot> uk


Report this thread to moderator Post Follow-up to this message
Old Post
Jim Backus
09-26-04 02:07 PM


Re: how to output to multiple files?
"beliavsky@aol.com" <beliavsky@127.0.0.1:7501> wrote in message news:<4155f81c$1_1@127.0.0.
1>...
> joegi.geo@yahoo.com (joel GUERRERO) wrote: 
>
> Put the file name into a string using an "internal write", OPEN the file,
> WRITE to it, and CLOSE it, as shown below:
>
> program xfile_name
> implicit none
> integer            :: i
> integer, parameter :: out_unit=20, num_files=4
> character (len=20) :: file_name
> do i=1,num_files
>    write (file_name,"('test_',i1,'.dat')") i
>    open (unit=out_unit,file=file_name,action="write",status="replace")
>    write (out_unit,*) i,i**2
>    close (out_unit)
>    write (*,*) trim(file_name)
> end do
> end program xfile_name
>
> To write to more than 9 files, the format string "('test_',i1,'.dat')" mus
t
> be changed.

Changing (Fortran 95)

write (file_name,"('test_',i1,'.dat')") i

to

write (file_name, "('test_', i0, '.dat')") i

gives you "unlimited" number of output files.

[JvO]

Report this thread to moderator Post Follow-up to this message
Old Post
jan van oosterwijk
09-27-04 09:01 PM


Re: how to output to multiple files?
On 27 Sep 2004 06:33:31 -0700, jvo_36@hotmail.com (jan van oosterwijk)
wrote:

[snip]
>       write (file_name, "('test_', i0, '.dat')") i
>
>gives you "unlimited" number of output files.

My preference would be to use something like i3.3 or i4.4, so the
files collate in sequence.  Not unlimited, but it can be made as wide
as expected - maybe i20.20?

Report this thread to moderator Post Follow-up to this message
Old Post
Ken Plotkin
09-27-04 09:01 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Fortran archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 05:25 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.