I'm trying to write binary data files from fortran, but I find the regular file interfaces very limiting, I wonder if Fortran has POSIX compilant functions.
I found this standard: IEEE 1003.9-1992, but I don't know it if is fully supported by most common compilers (or if I have to activate any flags). I can't find any practical information, can you give me any suggestion?
BTW I'm trying to write image files, first I want to try with tga/pgm. Also I don't want to add any dependency to external libraries, thanks!
Solution:
Finally I was able to write ppm files, and I had to avoid printing newline at the end of the internal loop, the final code is like this:
subroutine imgwrite()
implicit none
* ******************************************************************
include 'image.f'
* ******************************************************************
integer x, y, i
write(imgunit, '(A)') 'P3'
write(imgunit, '(I4)') imgwidth
write(imgunit, '(I4)') imgheight
write(imgunit, *) 255
do 10 y=1, imgheight
do 20 x=1,imgwidth
write(imgunit,100) (int(imgpixels(x,y,i)*255D0), i=1,3)
20 continue
write(imgunit,110)
10 continue
100 FORMAT(3(I4),$)
110 FORMAT((/))
return
end
Nobody provided any information about POSIX in FORTRAN.
Thanks.