UDDTIO just seems to be one of those areas that I can never get a clear run at, which means that I tend to avoid it, and hence I am not so familiar with it. Apologies if that leads to some noise in the following.
The compiler is complaining about private components when an object in a namelist group is being handled by defined input/output procedure. Note in this case the type of the object just has default accessibility for components of PRIVATE - there aren't actually any private components.
MODULE uddtio IMPLICIT NONE TYPE :: t PRIVATE ! #A CONTAINS PROCEDURE :: write_formatted GENERIC :: WRITE(FORMATTED) => write_formatted END TYPE t CONTAINS SUBROUTINE write_formatted(dtv, unit, iotype, v_list, iostat, iomsg) CLASS(t), INTENT(IN) :: dtv INTEGER, INTENT(IN) :: unit CHARACTER(*), INTENT(IN) :: iotype INTEGER, INTENT(IN) :: v_list(:) INTEGER, INTENT(OUT) :: iostat CHARACTER(*), INTENT(INOUT) :: iomsg iostat = 0 END SUBROUTINE write_formatted END MODULE uddtio PROGRAM bad_namelist USE uddtio IMPLICIT NONE TYPE(t) :: x NAMELIST /nml/ x WRITE (*, nml) END PROGRAM bad_namelist
>ifort /check:all /warn:all /standard-semantics "2016-03-17 bad-namelist.f90" Intel(R) Visual Fortran Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 16.0 Build 20160204 Copyright (C) 1985-2016 Intel Corporation. All rights reserved. 2016-03-17 bad-namelist.f90(12): remark #7712: This variable has not been used. [DTV] SUBROUTINE write_formatted(dtv, unit, iotype, v_list, iostat, iomsg) -----------------------------^ 2016-03-17 bad-namelist.f90(12): remark #7712: This variable has not been used. [V_LIST] SUBROUTINE write_formatted(dtv, unit, iotype, v_list, iostat, iomsg) ------------------------------------------------^ 2016-03-17 bad-namelist.f90(42): error #7299: This namelist group object in this context cannot have private components. [X] NAMELIST /nml/ x -----------------^ compilation aborted for 2016-03-17 bad-namelist.f90 (code 1)
When implementing defined input for a list-directed read from an internal file, attempts to read from the unit result in a crash (when running under debugger an exception related to heap corruption is reported).
MODULE uddtio IMPLICIT NONE TYPE :: t PRIVATE CONTAINS PROCEDURE :: read_formatted GENERIC :: READ(FORMATTED) => read_formatted END TYPE t CONTAINS SUBROUTINE read_formatted(dtv, unit, iotype, v_list, iostat, iomsg) CLASS(t), INTENT(INOUT) :: dtv INTEGER, INTENT(IN) :: unit CHARACTER(*), INTENT(IN) :: iotype INTEGER, INTENT(IN) :: v_list(:) INTEGER, INTENT(OUT) :: iostat CHARACTER(*), INTENT(INOUT) :: iomsg CHARACTER :: ch READ (unit, "(A)", IOSTAT=iostat, IOMSG=iomsg) ch END SUBROUTINE read_formatted END MODULE uddtio PROGRAM bad_listdirected_internal_read USE uddtio IMPLICIT NONE TYPE(t) :: x CHARACTER(10) :: buffer buffer = 'x' READ (buffer, *) x END PROGRAM bad_listdirected_internal_read
>ifort /check:all /warn:all /standard-semantics /traceback /debug /Od "2016-03-17 bad-listdirected_internal_read.f90"&&"2016-03-17 bad-listdirected_internal_read.exe" Intel(R) Visual Fortran Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 16.0 Build 20160204 Copyright (C) 1985-2016 Intel Corporation. All rights reserved. 2016-03-17 bad-listdirected_internal_read.f90(11): remark #7712: This variable has not been used. [DTV] SUBROUTINE read_formatted(dtv, unit, iotype, v_list, iostat, iomsg) ----------------------------^ 2016-03-17 bad-listdirected_internal_read.f90(11): remark #7712: This variable has not been used. [IOTYPE] SUBROUTINE read_formatted(dtv, unit, iotype, v_list, iostat, iomsg) ---------------------------------------^ 2016-03-17 bad-listdirected_internal_read.f90(11): remark #7712: This variable has not been used. [V_LIST] SUBROUTINE read_formatted(dtv, unit, iotype, v_list, iostat, iomsg) -----------------------------------------------^ Microsoft (R) Incremental Linker Version 10.00.40219.01 Copyright (C) Microsoft Corporation. All rights reserved. "-out:2016-03-17 bad-listdirected_internal_read.exe" -debug"-pdb:2016-03-17 bad-listdirected_internal_read.pdb" -subsystem:console -incremental:no"2016-03-17 bad-listdirected_internal_read.obj"
(Execution results in "xxx has stopped working... windows is checking for a solution to the problem.")
There is a requirement that, without an iostat in the parent statement, program execution should be terminated by a non-zero iostate, and if so, that the processor make available the iomsg error message(F2003 9.5.3.7.2p15 or so). I don't think ifort is doing this reliably.
MODULE uddtio IMPLICIT NONE TYPE :: t CONTAINS PROCEDURE :: write_formatted GENERIC :: WRITE(FORMATTED) => write_formatted END TYPE t CONTAINS SUBROUTINE write_formatted(dtv, unit, iotype, v_list, iostat, iomsg) CLASS(t), INTENT(IN) :: dtv INTEGER, INTENT(IN) :: unit CHARACTER(*), INTENT(IN) :: iotype INTEGER, INTENT(IN) :: v_list(:) INTEGER, INTENT(OUT) :: iostat CHARACTER(*), INTENT(INOUT) :: iomsg iostat = 1 iomsg = 'Tell me what went wrong!' END SUBROUTINE write_formatted END MODULE uddtio PROGRAM no_error_message USE uddtio IMPLICIT NONE TYPE(t) :: x PRINT *, x PRINT "('All done')" END PROGRAM no_error_message
>ifort /check:all /warn:all /standard-semantics /traceback "2016-03-17 no_error_message.f90"&& "2016-03-17 no_error_mes sage.exe" Intel(R) Visual Fortran Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 16.0 Build 20160204 Copyright (C) 1985-2016 Intel Corporation. All rights reserved. 2016-03-17 no_error_message.f90(10): remark #7712: This variable has not been used. [DTV] SUBROUTINE write_formatted(dtv, unit, iotype, v_list, iostat, iomsg) -----------------------------^ 2016-03-17 no_error_message.f90(10): remark #7712: This variable has not been used. [UNIT] SUBROUTINE write_formatted(dtv, unit, iotype, v_list, iostat, iomsg) ----------------------------------^ 2016-03-17 no_error_message.f90(10): remark #7712: This variable has not been used. [IOTYPE] SUBROUTINE write_formatted(dtv, unit, iotype, v_list, iostat, iomsg) ----------------------------------------^ 2016-03-17 no_error_message.f90(10): remark #7712: This variable has not been used. [V_LIST] SUBROUTINE write_formatted(dtv, unit, iotype, v_list, iostat, iomsg) ------------------------------------------------^ Microsoft (R) Incremental Linker Version 10.00.40219.01 Copyright (C) Microsoft Corporation. All rights reserved. "-out:2016-03-17 no_error_message.exe" -subsystem:console -incremental:no"2016-03-17 no_error_message.obj" All done