In January, there were two patches from Roger Sayle [1,2] which were quite an improvement for me. I'd like to suggest to do the same for derived type components. Example:
TYPE :: summed_amplitude COMPLEX, DIMENSION(:,:), POINTER :: alm END TYPE SUBROUTINE summed_amplitude_init_copy(this, other) TYPE(summed_amplitude), INTENT(out) :: this TYPE(summed_amplitude), INTENT(in) :: other ALLOCATE(this%alm(size(other%alm,1), size(other%alm,2))) this%alm = other%alm END SUBROUTINE Here, gfortran copies the arrays element-wise. In my code, this accounts for about 20% of the runtime (as shown by gprof). [1] http://gcc.gnu.org/ml/fortran/2007-01/msg00113.html (implement a(:) = b(:) using memcpy when possible) [2] http://gcc.gnu.org/ml/fortran/2007-01/msg00419.html (Use memcpy for array constructor assignments) -- Summary: derived type components: use memcpy when assigning arrays Product: gcc Version: 4.3.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: enhancement Priority: P3 Component: fortran AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: dfranke at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31009