Hello, In my view these are both the same. Any optimizer you paid money for will recognize the variables to be unused outisde the subroutine and will recignize references to ubound() to be a constant which may be hoisted out of the inner loop. If you've detected a speed difference, you may have uncovered a compiler bug of some sort or other. IMHO, of course. "Nofal, Mostafa" wrote: > > Dear Colleagues > > I would like to get your opinion about the difference in speed between the > following two options and why do you prefer one over the other. > > Option 1 > -------- > Subroutine dosomething( a, b, c ) > IMPLICIT NONE > REAL, INTENT(in) :: a(:,:) > REAL, INTENT(in out) :: b(:,:), c(:) > INTEGER :: i, j > DO i = 1, UBOUND(a,1) > DO j = 1,UBOUND(a,2) > .... > END DO > END DO > RETURN > END SUBROUTINE > > Option 2 > -------- > Subroutine dosomething( a, b, c ) > IMPLICIT NONE > REAL, INTENT(in) :: a(:,:) > REAL, INTENT(in out) :: b(:,:), c(:) > INTEGER :: i, j, length, width > length = UBOUND(a,1) > width = UBOUND(a,2) > DO i = 1, length > DO j = 1, width > .... > END DO > END DO > RETURN > END SUBROUTINE > > Regards > > > Mostafa Nofal, Ph.D. E-mail: [log in to unmask] > Associate Research Officer URL: http://www.nrc.ca/irc/bes/ > Building Envelope & Structure tel. (613) 993-9672 > Institute for Research in Construction fax (613) 954-3733 > National Research Council of Canada > Bldg. M-24, Rm. 322A, > 1500 Montreal Road, Ottawa, Ontario, > Canada, K1A 0R6 > > ------------------------------------------------------------------------ > > Part 1.2 Type: application/ms-tnef > Encoding: base64 -- Cheers! Dan Nagle [log in to unmask] Purple Sage Computing Solutions, Inc. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%