! Two (of many) ways to make this code work are indicated ! below. Both work individually. program sample implicit none integer*8 :: object_holder ! it works if you comment out the line above this one and uncomment the line below ! integer*8 :: object_holder = 0 call object_holder_init(object_holder) call set_vals(object_holder) call print_vals(object_holder) end program sample subroutine object_holder_init(oh) implicit none integer*8, intent(inout) :: oh oh = malloc(3*8) end subroutine object_holder_init subroutine set_vals(oh) implicit none integer*8, intent(inout):: oh integer*8 :: obj(3) pointer(pobj, obj) pobj = oh obj(1) = 900 obj(2) = 800 obj(3) = 700 !uncomment the folloing line and everything works !print *,"Values in set_vals :", obj(1:3) end subroutine set_vals subroutine print_vals(oh) implicit none integer*8, intent(inout) :: oh integer*8 :: obj(3) pointer(pobj, obj) pobj = oh print *,"Values in print_vals :", obj(1:3) call free(oh) end subroutine print_vals