0

Code:

  double precision maxstress(w)
  real, dimension(:), allocatable, save :: han(w)
  integer jang(w)


  do i=1,nblock
     if(maxstress(i) . gt. 1000) then
        jang(i) =1
        han(i) = han(i) + 1
     else
        jang(i) =0
     endif

     write(*,*) "jang", i, jang(i)
     write(*,*) "han", i, han(i)
  enddo

gives error message:

findnode2.for(47): error #6646: ALLOCATABLE or POINTER attribute dictates a deferred-shape-array   [HAN]
      real, dimension(:), allocatable, save :: han(w)
-----------------------------------------------^

From this code I need to make static variable han but the error #6646 occurs.

What do I need to do?

H.Jang
  • 1
  • 2
  • Welcome, please take the [tour]. Related questions https://stackoverflow.com/questions/16654519/allocatable-array-must-have-deferred-shape-when-moving-from-g95-to-gfortran https://stackoverflow.com/questions/22154117/build-random-array-search-and-sort-fortran It is always good to search for the error message here or on the web in general. – Vladimir F Героям слава Dec 27 '17 at 17:50
  • Be sure to use [tag:fortran] for all Fortran questions. Fortran is the most important thing here. Abaqus, on the other hand, not so much. – Vladimir F Героям слава Dec 27 '17 at 17:52

2 Answers2

2

the obvious answer is to remove the allocatable attribute as there is nothing in the code shown to indicate why han should be allocatable. Note as well the dimension(:) is superfluous and ignored. Just do:

  real, save :: han(w)

(Presumably w is an integer parameter )

alternately do:

  real, dimension(:), allocatable, save :: han

then in the executable code do allocate(h(w))

There is nothing in your question to indicate this has anything to do with abaqus.

agentp
  • 6,849
  • 2
  • 19
  • 37
1

There's a lot of confusion here. You say that this is a subroutine, but you didn't show the subroutine header. I don't know if the three arrays are dummy arguments, which would make them "adjustable arrays" with the dimension (presumably) also passed as a dummy argument, or perhaps they are all local arrays with w being the only dummy, which makes them "automatic" arrays. In either case, the ALLOCATABLE or POINTER attribute would be a conflict.

You also talk about "static variable han" but there's nothing to suggest why it should be static (and it isn't.)

If you want one or more of the arrays to be allocatable, you use (:) as the bounds and then ALLOCATE them to the desired size. Note that if these are local variables, they will automatically be deallocated when the subroutine returns, unless they are also given the SAVE attribute. (If they are dummy arguments, you can't say SAVE and it's also likely that ALLOCATABLE and (:) are inappropriate if this is being called from ABAQUS.

My guess is that at least some of these arrays are dummy arguments, and maybe one or more are local variables. If so, simply removing ALLOCATABLE should be the right solution. But as others have noted, you've left out so much it's impossible to know for certain.

Steve Lionel
  • 6,972
  • 18
  • 31