Code Comments
Programming Forum and web based access to our favorite programming groups.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
Post Follow-up to this message
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 =
---
Post Follow-up to this messageOn 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
Post Follow-up to this message"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]
Post Follow-up to this messageOn 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?
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.