Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Avisos
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

Issue with MOVE_ALLOC

OP1
Nuevo Colaborador III
1.467 Vistas

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 Solución
FortranFan
Colaborador Distinguido III
1.359 Vistas

@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

Ver la solución en mensaje original publicado

4 Respuestas
Barbara_P_Intel
Empleados
1.463 Vistas

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

No error message printed on either OS.

 

 

jimdempseyatthecove
Colaborador Distinguido III
1.374 Vistas

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
Colaborador Distinguido III
1.360 Vistas

@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
Empleados
1.350 Vistas

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

Responder