- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I searched through this forum and was not able to get relevant answers so wanted to post a query.
I have a derived data type that has a number of allocatable arrays within it. My query is under what circumstances is it better to use an array of derived data types when compared to using allocatable arrays within a derived data type. For example, say
TYPE Var1
REAL*8, ALLOCATABLE, DIMENSION(:) :: A
REAL*8, ALLOCATABLE, DIMENSION(:) :: B
END TYPE Var1
Call Calculateresult()
Subroutine Calculateresult()
j = getjValue()
result = Var1%A(j) + Var1%B(j) where the value of j is not sequential.
End Subroutine Calculateresult
-------------------
OR
-------------------
TYPE Var2
REAL*8 :: A
REAL*8 :: B
END TYPE Var2
TYPE(VAR2), ALLOCATABLE, DIMENSION(:) :: VarArray
CALL Calculateresult(VarArray(j))
Subroutine Calculateresult(Var)
result = Var%A + Var%B
End Subroutine Calculateresult
When would it be more efficient to use VarArray and Var2 instead of using Var1. Would the answer be any different, if Var1 and Var2 are themselves part of another derived data type.
If someone could point me to some literature that explains how nested derived data types are stored in memory, and what is an efficient way of using them, it would be great.
Thanks
Nitya
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page