- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
When I compile and run the code below, with the -standard-semantics option, logical values are not written to the output file, and therefore the subsequent reads from the file fail. Without that option, I/O operations work just fine.
I'm not sure whether it has to do with the nested derived types. Is that the intended behavior? ---i.e., is it what the F2003 standard requires?
[fortran]module mod1 implicit none private save type, public :: tm logical :: file = .FALSE. end type type, public :: tt integer :: seconds = -1 end type type, public :: tf character(260) :: dir = '' integer :: sz = -1 type(tt):: freq logical :: inv = .FALSE. type :: other end type type, public :: test character(63) :: name = '' type(tf) :: file end type public readTest, writeTest contains subroutine writeTest(this, file) type(test), allocatable, intent(IN) :: this(:) character(*), intent(IN) :: file integer :: i, ios, TMP_UNIT, nTest continue open (NEWUNIT = TMP_UNIT, FILE = file, STATUS = 'UNKNOWN', & ACCESS = 'SEQUENTIAL', DELIM = 'APOSTROPHE', ACTION = 'WRITE', & POSITION = 'REWIND', IOSTAT = ios, RECL = 512) if (ios /= 0) stop 'Error opening file' if (ALLOCATED(this)) then nTest = SIZE(this) else nTest = 0 endif write (TMP_UNIT, *, IOSTAT = ios) nTest do i = 1, nTest write (TMP_UNIT, *, IOSTAT = ios) this(i)%name write (TMP_UNIT, *, IOSTAT = ios) this(i)%file enddo endfile (TMP_UNIT) close (TMP_UNIT) end subroutine logical function readTest(this, file) result(status) type(test), allocatable, intent(OUT) :: this(:) character(*), intent(IN) :: file integer :: i, ios, TMP_UNIT, nTest logical :: fileExists continue status = .FALSE. inquire (FILE = file, EXIST = fileExists) if (.NOT. fileExists) then call writeTest(this, file) status = .TRUE.; return endif open (NEWUNIT = TMP_UNIT, FILE = file, STATUS = 'OLD', ACTION = 'READ', & POSITION = 'REWIND', IOSTAT = ios, RECL = 512) if (ios /= 0) stop 'Error opening file' read (TMP_UNIT, *, IOSTAT = ios) nTest if (nTest > 0) allocate (this(nTest)) do i = 1, nTest read (TMP_UNIT, *, IOSTAT = ios) this(i)%name if (ios /= 0) stop 'Error loading file' read (TMP_UNIT, *, IOSTAT = ios) this(i)%file if (ios /= 0) stop 'Error loading file' enddo close (TMP_UNIT) status = .TRUE. end function end module mod1 program prog1 use mod1 implicit none type(test), allocatable :: t(:) logical :: retlog continue allocate (t(5)) call writeTest(t, 'garrick.dat') retlog = readTest(t, 'garrick.dat') print *, retlog end program prog1[/fortran]
1 Solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Interesting. I'll take a look at this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The culprit is /assume:noold_ldout_format. For some reason it screws up LOGICAL components in nested types - works when you have the component directly in the output list. Issue ID is DPD200167936.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This has been fixed in our sources, but I don't yet know when the fix will appear in the product.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The fix for this will be in Update 6.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page