For Programmers: Free Programming Magazines  


Home > Archive > Fortran > December 2005 > Empty line after writing to file









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Empty line after writing to file
morten.langer@gmail.com

2005-12-17, 7:01 pm

Hi NG,

First of all, I'm VERY new to Fortran, so I appreciate all the help I
can get, and please bear with my stupid questions.

So: I have a piece of code that writes some coordinates to a file in a
nested loop. After having completed all the inner loops, the outer loop
writes a string to the file, making a section of it look like this:

..
..
2 6
4 7
1 9
STRING1
4 8
7 9
1 6
6 9
STRING2
4 6
7 9
1 6
..
..

And so on..

However, after the last STRINGX has been written to the file, an empty
line is inserted in the file. How can this be? As seen in the example
above, it doesn't happen in the middle of the run..

Thanks in advance for any input.

Best regards,

M.L.

Jim

2005-12-17, 7:01 pm


<morten.langer@gmail.com> wrote in message
news:1134850160.245986.273210@z14g2000cwz.googlegroups.com...
> Hi NG,
>
> First of all, I'm VERY new to Fortran, so I appreciate all the help I
> can get, and please bear with my stupid questions.
>
> So: I have a piece of code that writes some coordinates to a file in a
> nested loop. After having completed all the inner loops, the outer loop
> writes a string to the file, making a section of it look like this:
>
> .
> .
> 2 6
> 4 7
> 1 9
> STRING1
> 4 8
> 7 9
> 1 6
> 6 9
> STRING2
> 4 6
> 7 9
> 1 6
> .
> .
>
> And so on..
>
> However, after the last STRINGX has been written to the file, an empty
> line is inserted in the file. How can this be? As seen in the example
> above, it doesn't happen in the middle of the run..
>
> Thanks in advance for any input.
>
> Best regards,
>
> M.L.
>

Please specify compiler and os. Also furnish the format statements.
Jim


morten.langer@gmail.com

2005-12-17, 7:01 pm

Hi,

The OS is Solaris 9, and the compiler is.. Hmm.. Don't know really. I
use a "Make XXXXX" syntax, which triggers a call to f77, as far as I
can see. Is that enough information?

The statements I use in the code are done like this:

open(67,file='output.txt')

Outer loop begin
Inner loop begin
write(67,*) t, y
Inner loop end
write(67,'(a)') stringName
Outer loop end

close(67, status='keep')



Thanks!

/M.L.

Richard Maine

2005-12-18, 3:56 am

<morten.langer@gmail.com> wrote:


> The statements I use in the code are done like this:

....
> Outer loop begin


That doesn't look like Fortran. You need to show what you actually did
in order for there to be much hope of debugging it. I'd guess that the
problem is in the parts that you didn't actually show.

--
Richard Maine | Good judgement comes from experience;
email: last name at domain . net | experience comes from bad judgement.
domain: summertriangle | -- Mark Twain
morten.langer@gmail.com

2005-12-18, 7:01 pm

I know it doesn't look like Fortran - I just wrote the pseudo-code to
illustrate the structure. But here is the real code, somewhat
abbreviated - I have cut out some pieces which I know to be irrelevant
for writing to the file.

Thanks for the help!

------------- CODE ------------

do it=1,ntoproc

ifile=itrc(iordtrc(it))
icount=icount+1
itoplot=0

isbot=istop-isheight
call twindo(isleft,isright,isbot,istop)
ami=ampmin(ifile)
ama=ampmax(ifile)
call dwindo(tim1,tim2,ami,ama)

ip1=ifirst1ar(ifile)
ip2=ilast1ar(ifile)
ip1p=ip1
ip2p=ip2

do ip=ip1p,ip2p
t=tarr(ip)
y=show(ip,ifile)
if(ip.eq.ip1p) then
call movea(t,y)
else

call drawa(t,y)

write(67,*) t, y

endif

enddo

write(67,'(a6)') stnName

enddo

close(67, status='keep')

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com