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

Allocate / Deallocate Question

KKA
Beginner
164 Views

Hi 

I am using Intel Fortran 19.0 Update 8.

 

I ALLOCATE a large array 'X(M,M)' for simultaneous equation solutions over many time steps.  At some point the model decreases in size where "M" becomes smaller.

 

I use the DEALLOCATE statement for array 'X' and want to ALLOCATE 'X(N,N)' for the smaller array.

Is there any way to do this within the program for the time step solutions continuing? It appears that "X" has lost its double precision definition.

 

Thanks 

Dennis

0 Kudos
3 Replies
Arjen_Markus
Honored Contributor I
118 Views

Can you show us a small reproducer? The precision of a variable/array is fixed by its declaration, so I do not see how it can loose its "double precision definition". The exception is if X is a unlimited polymorphic variable, but that seems unlikely for a variable participating in a numerical calculation.

Ideally, such a reproducer is a standalone buildable program that exhibits the same behaviour, but that may be difficult to achieve. In that case, could you at least show relevant code, including the declarations?

0 Kudos
jimdempseyatthecove
Honored Contributor III
84 Views

Barring compiler bug....

For this to occur,  you may have omitted IMPLICIT NONE, and failed to declare X as double precision.

 

I suggest you place X in a module (as opposed to in a named common), and USE the module.

 

Jim Dempsey

0 Kudos
JohnNichols
Valued Contributor III
80 Views
    !---------------------------------------------------------------------------------------------------------------------------
    !
    !   Four modules are called from the main program. Base holds the underlying FORTRAN elements such as dp etc.
    !
    !---------------------------------------------------------------------------------------------------------------------------

    subroutine analysis(count, ki, filename, num, numC, KR, MTYPE, NL)

    !---------------------------------------------------------------------------------------------------------------------------
    !
    !   Four modules are called from the main program. Base holds the underlying FORTRAN elements such as dp etc.
    !
    !---------------------------------------------------------------------------------------------------------------------------

    use SMA
    use Elements
    use SaveESM
    use Solver
    Use Scotia
    use ACADDraw

    !---------------------------------------------------------------------------------------------------------------------------
    !
    !   Implicit none is standard
    !   Integer variables
    !
    !---------------------------------------------------------------------------------------------------------------------------

    implicit none
    Integer             Triangles       !   Number of triangles in the model
    Integer             Beams, BeamNum, FrameNum
    Integer             I               !   Loop counter
    Integer             count1,ig,jg,k,ll,count3, ndf
    Integer             Loop
    Integer             MTYPE
    Integer             NL
    Integer             loopCycle

    integer beamID(mt1)
    Integer O(mt1)
    REAL     time1(2)         !   Holds the numbers for the run time calculation
    REAL timeA
    REAL (KIND=dp) scale
    REAL (KIND=dp) ki(mn_6)
    REAL (KIND=DP) OffStep(mt1,mn_4)
    REAL (KIND=dp) CORD(mt1,ml2)
    REAL (KIND=dp) num(ml1)
    integer Frame(mt1)
    integer MCON(mt1,mn1)
    integer count
    integer NM
    integer flag
    integer :: A_limit  = limit
    CHARACTER filename*60
    REAL (KIND=DP) NUMC(ml30, mn_3),KR


    !---------------------------------------------------------------------------------------------------------------------------
    !
    !   Type variables  model holds the overall model data and Triangle holds data for each triangular element
    !
    !---------------------------------------------------------------------------------------------------------------------------

    TYPE (Model),       TARGET :: ModelA                            !   Model for the FEM
    TYPE (Triangle),    allocatable,   TARGET :: sTriShells(:)      !   Each triangle that makes up the FEM model
    TYPE (sbeam),       allocatable,   TARGET :: sBeams(:)
    TYPE (aBeam),       allocatable,   TARGET :: saBeams(:)         !   Each beam that makes up the FEM model

    !---------------------------------------------------------------------------------------------------------------------------
    !
    !   Routine opens the files used for data input and output
    !   Base is the ultimate lowest module to allocate the file numbers, si, sw, sa, slog
    !
    !---------------------------------------------------------------------------------------------------------------------------
    call Files(1, filename)
    !call OpenFiles(si,sw,sa,slog,srA)                  Not used at this stage


    !---------------------------------------------------------------------------------------------------------------------------
    !
    !   Set up the model type used to hold the main details of the overall model
    !
    !---------------------------------------------------------------------------------------------------------------------------

    Call SetModel(ModelA, Triangles, BeamNum)

    !---------------------------------------------------------------------------------------------------------------------------
    !
    !   Allocate memory for the triangular elements
    !
    !---------------------------------------------------------------------------------------------------------------------------

    ALLOCATE (sTriShells(Triangles), ModelA%indexM(3,ModelA%MaxNodeNumber), ModelA%nodes(ModelA%MaxNodeNumber),ModelA%noderesults(ModelA%MaxNodeNumber,mn_6),ModelA%offsetnodes(ModelA%MaxNodeNumber),ModelA%nodeloads(ModelA%MaxNodeNumber,6), ModelA%temploads(ModelA%MaxNodeNumber,6),ModelA%windloads(ModelA%MaxNodeNumber,6),ModelA%nodeWeight(ModelA%MaxNodeNumber),sBeams(NTA), saBeams(Beamnum), STAT=astat)

    IF (astat.NE.0) then
        STOP 'Could not allocate Shells or Model'
    endif

I know this works without problems, well not computational problems. 

 A sample of what Jim is talking about.  

0 Kudos
Reply