unformatted output with wild card in Fortran

739 views Asked by At

I've searched for a long time before I ask: I need to output a lot of unformatted files in Fortran to Ensight. I want to name them with geo.000000, geo.000001 ... geo.0001000. Here is how I deal with wild card:

character(54) :: filename, temp 
character(80) :: buffer
write(temp,'(i6.6)') step
filename = '/Users/jiecheng/Documents/SolidResults/solid.geo'//trim(temp) 
open(10,file=filename,form='UNFORMATTED')
open(10,file=filename,form='UNFORMATTED')
buffer = 'Fortran Binary'
write(10) buffer
buffer = 'Ensight Model Geometry File'
write(10) buffer

write(10,'(i10)') nn
write(10,'(i10)') node_id
do i=1,3
    write(10,'(E12.5)') sngl(coords1(i,:))
end do

Then I have

Fortran runtime error: Format present for UNFORMATTED data transfer

Could anybody tell me how to solve this?

1

There are 1 answers

1
Vladimir F Героям слава On BEST ANSWER

For a unit connected to a file for unformatted I/O it is illegal to specify a format as you do in

write(10,'(i10)') nn

The write of the value to the unformatted file is done in machine memory (binary) representation (some conversion may happen) and not as a human readable text. Therefore, the format specification does not have any sense.