`Allocatable array must have deferred shape` when moving from g95 to gfortran

后端 未结 1 431
攒了一身酷
攒了一身酷 2021-01-25 07:54

When transitioning from using the g95 compiler to gfortran I get the following error when I try to compile what previously had been a working code

Error: Allocat         


        
相关标签:
1条回答
  • 2021-01-25 08:50

    The Fortran 2003 (and, I think, the 90,95 and 2008) standard states that the expression inside the parentheses of the dimension() clause in the declaration of an allocatable array must be a deferred-shape-spec-list and that a deferred-shape-spec-list is a list of colons, separated by , if there is more than one element in the list. There should be one colon for each dimension in the array.

    I suggest you replace statements such as

    integer, allocatable, dimension(1:,1:), INTENT(OUT)::inpoel
    

    with statements such as

    integer, allocatable, dimension(:,:), INTENT(OUT)::inpoel
    

    When you later allocate this array the lower bound on each dimension will be, by default, 1. If, on the other hand you wanted to allocate it with non-default bounds you might write

    allocate(inpoel(3:12,4:14))
    

    replacing, obviously, those constants with whatever values you wish.

    It's not terrifically surprising that code acceptable to one Fortran compiler is not acceptable to another.

    0 讨论(0)
提交回复
热议问题