Software Archive
Read-only legacy content
17061 Discussions

Access times for derived type variables

Intel_C_Intel
Employee
343 Views
Hi,

I was just curious - in F90, and in particular, for CVF, if I have a routine that accesses a derived-type variable many times during the course of a simulation, is it any more advantageous to store that derived type variable as a local variable as opposed to just using it directly. In other words, is it significantly faster to access a variable ala

var1 = data%var1

DO i = 1, 10000
var2 = var1
ENDDO

or would it make no difference in terms of execution speed to just do

DO i = 1, 10000
var2 = data%var1
ENDDO

If not, would it also hold true for multiply embedded derived types, ala

var2 = data%var1(1)%var3%var4

Chris
0 Kudos
1 Reply
Steven_L_Intel1
Employee
343 Views
In current versions of CVF, it should make no difference. My general recommendation is to write code in a way that makes sense to you, and not spend time worrying up front about which programming paradigm is "fastest". (You should try to be aware of significant performance divots, such as vector subscripts.)

Steve
0 Kudos
Reply