I did some additional experimenting with the program, and using the '*' as the format or a specific format (i.e. '(A)'), and it generates a run-time error; trying to have formatted data with ACCESS='STREAM' are incompatible.
From the HELP file:
ACCESS=<string>
This specifies the type of access for which the file is to be opened. <string> is either DIRECT, SEQUENTIAL or STREAM. As an extension to the Fortran standard <string> can also be TRANSPARENT (see the FORM specifier below). By default the ACCESS is SEQUENTIAL.
STREAM is part of the Fortran 2003 Standard and is similar to FTN95 TRANSPARENT access. When compared with DIRECT, STREAM uses POS in place of REC and has a fixed RECL value which for FTN95 is one. The Fortran 2003 intrinsic NEW_ LINE can be used within an WRITE statement. It returns a CHARACTER result which for FTN95 is CHAR(10) and is translated to CHAR(13) then CHAR(10) in the output file.
Note the implied RECL is one! Meaning that trying to use a FORMAT for output will likely result in multiple bytes trying to be written to a one-byte 'record'.
However, also from the HELP file, you might specify the access as TRANSPARENT.
For ACCESS = TRANSPARENT and FORM= FORMATTED, no carriage returns are output at the end of record on output (the user can output carriage returns with the '/' editing descriptor), and on input precisely the field widths specified in the input format are read, with no attempt to align to record boundaries (i.e. after carriage returns).
Your call as to what suits your situation best. The code has to change to work:
PROGRAM plumb
IMPLICIT NONE
INTEGER :: myvalue = 12345, i, ic
character ch
do i = 1,4
ic = mod(myvalue,256)
ch = char (ic)
myvalue = myvalue/256
write (*,*) i,ic,' ',ch
end do
myvalue = 12345
OPEN(10, FILE='myData.txt',ACCESS='TRANSPARENT',FORM='FORMATTED',status='replace')
WRITE(10,'(a)') 'first'
WRITE(10,'(a)') 'second'
WRITE(10,'(a)') 'myvalue'
WRITE(10,'(i0)') myvalue !my question
PRINT *, 'Done'
CLOSE(10)
END PROGRAM plumb
Here's the hex of the file:
https://www.dropbox.com/s/2r2nff2h96uqeuv/Screenshot%202023-03-23%20081400.png?dl=0