Passing arrays in subroutines

Passing arrays in subroutines

Hello!
I am interesting, in wich cases the compiler will force to allocate any of used array from the memory

Case 1:
subroutine VolFracToMassFrac(VolFrac, MassFrac)
  real, intent(in) :: VolFrac(:)  
  real, intent(in) :: MassFrac(:)
    ...
end function

Case 2:
function VolFracToMassFrac(VolFrac, SubstCodes) result(Res)
  real    , intent(in) :: VolFrac(:)
  real Res (SIZE(VolFrac))          
    ...
end function

Case 3:
subroutine VolFracToMassFrac(VolFrac, MassFrac)
  real, intent(in) :: VolFrac(:)  
  real, intent(in) :: MassFrac(:)
      real Temp(SIZE(VolFrac))
    ...
end function

I am using Compaq Visual Fortran, but I am also intresting how it will be in the Intel Compiler.
Thank you

 

2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

In case 2 it would be written:

Case 2:
function VolFracToMassFrac(VolFrac) result(Res)
  real    , intent(in) :: VolFrac(:)
  real Res (SIZE(VolFrac))          
    ...
end function

 

Leave a Comment

Please sign in to add a comment. Not a member? Join today