Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Issue with MOVE_ALLOC

OP1
New Contributor II
421 Views

The following code prints out a non-zero value for ERROR (the value is -858993460). I don't understand how MOVE_ALLOC fails here.

This is with Intel Fortran Compiler Classic 2021.5.0, on Windows 10, x64, non-coarray code.

It also looks like there is a non-printable character in MESSAGE - but that's probably a different problem.

MODULE M
    IMPLICIT NONE
    TYPE :: W
    END TYPE W
    TYPE :: T
        TYPE(W), ALLOCATABLE :: A(:)
        CONTAINS
            PROCEDURE :: P
    END TYPE T
    CONTAINS
    SUBROUTINE P(SELF, A)
        IMPLICIT NONE
        CLASS(T), INTENT(INOUT) :: SELF
        TYPE(W), ALLOCATABLE, INTENT(INOUT) :: A(:)
        CHARACTER(LEN = 132) :: MESSAGE
        INTEGER :: ERROR
        CALL MOVE_ALLOC(A, SELF%A, STAT = ERROR, ERRMSG = MESSAGE)
        IF (ERROR /= 0 ) THEN
            WRITE(*, *) ERROR, (MESSAGE == ' '), TRIM(MESSAGE)
            STOP
        END IF
    END SUBROUTINE P
END MODULE M

PROGRAM MAIN
    USE M
    IMPLICIT NONE
    TYPE(T) :: VAR
    TYPE(W), ALLOCATABLE :: A(:)
    ALLOCATE(A(1))
    CALL VAR%P(A)
END PROGRAM MAIN

 

0 Kudos
1 Solution
FortranFan
Honored Contributor II
313 Views

@Barbara_P_Intel ,

Please see this other thread by OP and comments in there re: debug compile (/Od) and the treatment of the optional STAT= dummy argument as possibly INTENT(INOUT) versus INTENT(OUT) per the standard, and Ron Green's investigation, etc.  Some or all of it may be relevant to this thread also:

https://community.intel.com/t5/Intel-Fortran-Compiler/Issue-with-MOVE-ALLOC/m-p/1368121#M160577

View solution in original post

4 Replies
Barbara_P_Intel
Moderator
417 Views

I just tried this using ifort 2021.5.0 on both Linux and Windows. 

No error message printed on either OS.

 

 

jimdempseyatthecove
Black Belt
328 Views

Barbra,

The issue was, on no error condition, the STAT= variable would be left untouched.

Therefore, should you have run your test from a Debug build, it would have pre-initialized the STAT variable ERROR with 0, and thus would not be a conclusive test. A proper test would be to pre-set the STAT variable ERROR to non-zero before the call to MOVE_ALLOC. 

Now, you may have done this with your test program, but the sample program, and your reply, give no assurance that you had done so.

 

Jim Dempsey

FortranFan
Honored Contributor II
314 Views

@Barbara_P_Intel ,

Please see this other thread by OP and comments in there re: debug compile (/Od) and the treatment of the optional STAT= dummy argument as possibly INTENT(INOUT) versus INTENT(OUT) per the standard, and Ron Green's investigation, etc.  Some or all of it may be relevant to this thread also:

https://community.intel.com/t5/Intel-Fortran-Compiler/Issue-with-MOVE-ALLOC/m-p/1368121#M160577

Barbara_P_Intel
Moderator
304 Views

Thanks for the clarification. My experience is mostly on Linux. I have limited experience with Windows and VS. I learned something new! 

Reply