How to Fix Fortran Formatting Issues in .pvd Files?

  • Context: Fortran 
  • Thread starter Thread starter cjm2176
  • Start date Start date
  • Tags Tags
    Format Fortran
cjm2176
Messages
8
Reaction score
0
Hi all

I am trying to use fortran to write a .pvd file, an example of what one line of such a file should look like is

<DataSet timestep="1.00000E-07" part="0" file="Psb000001.vtu"/>

however with the following code:

Code:
write(90,2000) ttim,fname
2000  format('<DataSet timestep="',1pe15.5,'" part="0" file="',
     &       a,'"/>')

gives me the following result:

<DataSet timestep=" 1.00000E-07" part="0" file="Psb000001.vtu
"/>

which happens to result in a bad .pvd file. Is there a way to garuantee that everything gets written on one line? Also, is it possible to get rid of the spaces before 1.00000E-07?

Thanks!
cjm2176
 
on Phys.org
Which FORTRAN are you writing in? I'm guessing 95?
 
yes I'm using FORTRAN 95, the compiler is gfortran
 
Let me play with this. I'll get back to you shortly.
 
Just played with testing this out. Here is what I wrote.

Code:
      program testformat
      implicit none
	  
!23456789012345678901234567890123456789012345678901234567890123456789012	  

      real ttim
      character fname*13
  
      open(unit=10,file='test.txt')

      ttim = 1.0E-7 
      fname = "Psb000001.vtu"

      write(10,2000) ttim,fname
 2000 format('<DataSet timestep="',es13.7,'" part="0" file="',a,'"/>')

      close(10)
 
      return
      end program

FORTRAN can go out to 72 columns, so you don't need to truncate your format statement and continue to the next line. The whole thing can fit on one line. Taking the 1 out of in front of your real ouput will remove that space.
 
works perfectly thanks!
 

Similar threads

  • · Replies 12 ·
Replies
12
Views
3K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 5 ·
Replies
5
Views
5K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 16 ·
Replies
16
Views
3K
  • · Replies 3 ·
Replies
3
Views
4K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K