Quantcast
Channel: Intel® Software - Intel® Visual Fortran Compiler for Windows*
Viewing all articles
Browse latest Browse all 5691

Problem with alocation of character deferred length string in defined type

$
0
0

I have defined a type in a module as:

    TYPE::CHARARRAY
        sequence
        CHARACTER*32 NAME
        CHARACTER(LEN=:),ALLOCATABLE :: CA(:)
        INTEGER VTYPE
        INTEGER NLEN
    END TYPE
    TYPE(CHARARRAY),ALLOCATABLE:: UDCA(:)

 

I then allocate the array as:
    ALLOCATE(UDCA(NUDCASIZE),STAT=ERR)

THen the string CA as:
    ALLOCATE(CHARACTER(LEN=CLEN)::UDCA(NUMUDCA+1)%CA(NSIZE),STAT=ERR)

Where CLEN, NUMUDCA, and NSIZE are all integers defined at runtime.

Looking at this in the debugger shows CA as an udefined pointer, but ERR=0 and checking ALLOCATED(UDCA(NUMUDCA+1)%CA) don't show any errors. The code seems to be able to set the string and print it out again.  But using it as an argument to a subroutine crashes:

        CALL SAVUDCA(NREC,UDCA(I)%CA,UDCA(I)%NLEN,NFILE)

Any idea why?

RUnning with PSXE2016

 


Viewing all articles
Browse latest Browse all 5691

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>