[J3] C_LOC restriction is unhelpful

Van Snyder Van.Snyder at jpl.nasa.gov
Wed Apr 11 19:38:54 EDT 2018


The argument of C_LOC is not allowed to be a non-interoperable array.

I have a code that tries to track allocations and deallocations.  It
tries to write a log file with addresses of allocated and deallocated
objects, to try to do some leak detection.

It tries to do this:

    character(len=*), intent(in) :: ItsName, ModuleName
    integer(c_intptr_t) :: Addr
    integer :: STATUS
    integer :: S
    character(127) :: ERMSG
    if ( associated(To_Deallocate) ) then
      addr = transfer ( c_loc(to_deallocate), addr )
      if ( mod(trackallocates,2) > 0 ) &
        & call trackDeAllocate ( to_deAllocate, itsName, moduleName )
      s = ( storage_size(to_deallocate) * size(to_deallocate) ) / 8
      deallocate ( To_Deallocate, stat=status, errmsg=ermsg )
      call test_deallocate ( status, moduleName, itsName, s, ermsg=ermsg, &
        & address=addr )
      nullify ( to_Deallocate ) ! in case of nonzero status
    end if

which doesn't work if To_Deallocate is a logical array.

Can we remove the "scalar" requirement in the next revision?  The
obvious value is the address of the first element in array element
order.

For now, could processors that consider this to be an error please
change it to a warning?




More information about the J3 mailing list