Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29235 Discussions

I write a number in a file and read 0

jpprieto
Beginner
609 Views
Hello, I have a problem with a .f code.
I write a number of data in a file with
...
if (icomp.eq.0) then
open(11,file='ic_deltab',form='unformatted')
else if (icomp.eq.2) then
...
rewind 11
write(11) np1,np2,np3,dx,x1o+xoff,x2o+xoff,x3o+xoff,
& astart,omegam,omegav,h0
...
The number np1=np2=np3=128
But when I read the file ic_deltab and write the data with (.f90)
...
open(11,file='ic_deltab',form='unformatted')
rewind 11
read(11) np1,np2,np3,dx,x1o,x2o,x3o, &
& astart,omegam,omegav,h0
write(*,*) np1,np2,np3
...
I find 0 128 128, no 128 128 128
I did the following test. I wrote np2,np1,np3 and the result was the same: 0 128 128.
I write 128,np2,np3 and... the result was the same: 0 128 128.
If somebody can help me, thank you.
0 Kudos
3 Replies
TimP
Honored Contributor III
609 Views
For a sanity check, if you haven't done so, delete the file, so as to force its creation (in compatible format) on the first open.
0 Kudos
jpprieto
Beginner
609 Views
Quoting - tim18
For a sanity check, if you haven't done so, delete the file, so as to force its creation (in compatible format) on the first open.
The error is there yet.
I did the following test:
...
rewind 11
write(11) 1,2,3,dx,x1o+xoff,x2o+xoff,x3o+xoff,
& astart,omegam,omegav,h0
...
When I read the first 3 data (1 2 3) I get 0 1 2. It seems for a unknown reason the file start with a 0 or without a number.
Some clue?
0 Kudos
Steven_L_Intel1
Employee
609 Views
Please provide a short but complete example that demonstrates the problem.
0 Kudos
Reply