Empty line after writing to file 
Author Message
 Empty line after writing to file

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.



Thu, 05 Jun 2008 04:09:20 GMT  
 Empty line after writing to file


Quote:
> 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


Thu, 05 Jun 2008 05:00:19 GMT  
 Empty line after writing to file
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.



Thu, 05 Jun 2008 05:42:52 GMT  
 Empty line after writing to file

Quote:

> 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



Thu, 05 Jun 2008 14:46:21 GMT  
 Empty line after writing to file
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')



Fri, 06 Jun 2008 02:04:53 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. one liner? --- split file at empty line

2. Opening and Writing to Empty VSAM File

3. Question: lines of numbers separated with empty lines

4. do NOT download, this file is EMPTY - empty.txt (1/1)

5. empty file returns nil not empty string?

6. Files write a new line in textfile

7. file.write[lines]() weirdness

8. Writing multiple lines to a file

9. Delete empty lines

10. Matching empty lines in a textfile?

11. Empty lines in the Body of a mail

12. Find empty lines in array

 

 
Powered by phpBB® Forum Software