pgfortran 13.10 incorrect record mark

This is an update to “pgfortran 13.7 incorrect record mark”, which was given
TPR #19513.
My reproducer shows the problem has not been fixed if you use the “-byteswapio”
flag. Here it is in full.

      PROGRAM MKGRID
C
C   Illustrating a problem with pgfortran 13.10 and the last record mark
C   in an unformatted file when compiling with -byteswapio.
C   Compile via: pgfortran -byteswapio mkgrid.f -o mkgrid
C   Run via: mkgrid
C   You get a file grid.in, size 224020.
C   With "od -x grid.in | head -2" I see (on a Xeon E5-2630)
C    0000000 0000 0c00 0000 3d00 0000 3300 0000 0300
C    0000020 0000 0c00 0300 f86a 0000 0000 0000 0000
C   and "od -x grid.in | tail -4" produces for me
C    0604740 0040 0000 0000 0000 0040 0000 0000 0000
C    *
C    0665420 fd00 0795
C    0665424
C
C   Note that the first record of the file contains 3 integers, so
C   12 bytes, and the record mark is accordingly 0C byte-swapped.
C   The second record of the file contains 61*51*3*3=27999 8-byte
C   reals, a total of 223992 bytes (hex 36AF8), record mark is 36AF8
C   byte-swapped. But the last record mark is not 36AF8.  This incorrect
C   record mark will cause problems with a code that uses BACKSPACE, for example.
C
C   This problem does not occur if you omit the "-byteswapio" flag.
C
C   pgfortran -V (13.10) returns:
C     pgfortran 13.10-0 64-bit target on x86-64 Linux -tp sandybridge
C
      IMPLICIT NONE
      INTEGER, PARAMETER :: JD=61,KD=51,LD=3
C
      CALL DOIT(JD,KD,LD)
      END
C*********************************************************
      SUBROUTINE DOIT(JD,KD,LD)
      IMPLICIT NONE
      INTEGER, INTENT(IN) :: JD,KD,LD
C
      REAL(8) :: X(JD,KD,LD),Y(JD,KD,LD),Z(JD,KD,LD)
      INTEGER :: J,K,L
C
C
      DO L = 1,LD
         DO K = 1,KD
            DO J = 1,JD
               X(J,K,L)   = REAL(J-1,8)
               Y(J,K,L)   = REAL(K-1,8)
               Z(J,K,L)   = REAL(L-1,8)
            ENDDO
         ENDDO
      ENDDO
C
      OPEN(UNIT=2,FILE='grid.in',STATUS='UNKNOWN',FORM='UNFORMATTED')
      WRITE(2) JD,KD,LD
      WRITE(2) X,Y,Z
      CLOSE(UNIT=2)
C
      RETURN
      END

Thanks Dennis. I added TRP#19692 for this additional issue.

Best Regards,
Mat

TPR 19692 - UF: pgfortran incorrect record mark with -Mbyteswapio
has been fixed in the current 14.4 release.

Thanks again for the original report.

regards,
dave