I have found that that dynamic character array of deferred length in subroutine could not be allocated.
Here is the sample code. One array is declared in the main program (var name is array_main) and is being passed to subroutine. In subroutine this array is being declared as array_sub1. Also subroutine contains another array - array_sub2.
And here is the problem. First array (array_sub1) has no problems with allocation in the subroutine. The allocation of array_sub2 is not seen in debugger ("Undefined pointer/array") when program is being run the next after allocation statements. At the same time there are no error signs such as non zero error stat.
Where is the problem? How to allocate array of this kind in subroutine?
Intel Visual Fortran Composer XE 2013 + Microsoft Visual Studio 2012
program TEST_PROG implicit none CHARACTER*(:), ALLOCATABLE :: array_main(:) INTERFACE SUBROUTINE TEST_SUB (array_sub1) IMPLICIT NONE INTEGER nword, wordlen, statv CHARACTER*(7) errv CHARACTER*(:), ALLOCATABLE :: array_sub1(:) CHARACTER*(:), ALLOCATABLE :: array_sub2(:) END SUBROUTINE END INTERFACE CALL TEST_SUB(array_main) end program TEST_PROG SUBROUTINE TEST_SUB (array_sub1) IMPLICIT NONE INTEGER nword, wordlen, statv CHARACTER*(7) errv CHARACTER*(:), ALLOCATABLE :: array_sub1(:) CHARACTER*(:), ALLOCATABLE :: array_sub2(:) nword = 3; wordlen = 4 ALLOCATE (CHARACTER(wordlen)::array_sub2(nword), STAT=statv, ERRMSG=errv) WRITE (*,*) statv, errv ALLOCATE (CHARACTER(wordlen)::array_sub1(nword), STAT=statv, ERRMSG=errv) WRITE (*,*) statv, errv array_sub2(1) = 'abab' array_sub2(2) = 'cdcd' array_sub2(3) = 'efef' END SUBROUTINE