Quantcast
Channel: Fortran
Viewing all articles
Browse latest Browse all 3108

Assign allocated array to other allocatable array

$
0
0

Hi,

I've got two codes, which I want to combine. In one code I've got type:

  TYPE, PUBLIC ::m_type
    INTEGER :: m,
    REAL ( KIND( 1.0D+0 ) ), ALLOCATABLE, DIMENSION(:) :: val
  END TYPE

and subroutine which uses this type as an input:

   subroutine sub(m)
      type(m_type), intent(in) :: matrix
      ....
   end subroutine

In the second code, which calls the subroutine sub(), I have already allocated array, let say x(:), and I don't want to allocate once more memory for m%val, just for copying data, because size of x(:) is huge. Is there any way to assign m%val with values of x(:) without allocating additional memory? In C pointer will do the trick, but I don't know how I could use it here. I dont want to change subroutine sub(), because it will cause changes not only in my part of the code.

Any ideas?


Viewing all articles
Browse latest Browse all 3108


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