CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > General Forums > Main CFD Forum

[Fortran] DO loop bounds calculation

Register Blogs Community New Posts Updated Threads Search

Like Tree8Likes
  • 1 Post By FMDenaro
  • 1 Post By flotus1
  • 1 Post By sbaffini
  • 1 Post By sbaffini
  • 1 Post By sbaffini
  • 1 Post By Gerry Kan
  • 1 Post By Simbelmynė
  • 1 Post By Simbelmynė

 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old   August 17, 2021, 12:35
Default [Fortran] DO loop bounds calculation
  #1
Senior Member
 
Gerry Kan's Avatar
 
Gerry Kan
Join Date: May 2016
Posts: 348
Rep Power: 10
Gerry Kan is on a distinguished road
Howdy Folks:

I have a block of code in a do loop that is abbreviated as follows:
Code:
integer :: k0, k1, k, kN

k0 = 0
kN = 100
k1 = k0 + 1

do k = k1,kN
   ! do something
end do
Some guy tells me that the do loop has to be done like this:

Code:
do k = k0+1,kN
Is there any hidden reason that makes the second approach superior? Also, wouldn't k0+1 run a risk of being needlessly evaluated in every iteration of the do loop?

Your comments would be quite welcomed.

Gerry.
Gerry Kan is offline   Reply With Quote

 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Transfer output data as input for second calculation mannobot Main CFD Forum 3 December 7, 2018 09:37
Determining the calculation sequence of the regions in multe regions calculation peterhess OpenFOAM Running, Solving & CFD 4 March 9, 2016 03:07
Quick Question on Calculation Time Davitt COMSOL 0 January 14, 2016 14:16
Understanding the PISO loop of icoFoam ooo OpenFOAM Programming & Development 0 March 14, 2014 09:28
Defining output as input for second calculation mannobot FLUENT 1 June 2, 2010 04:20


All times are GMT -4. The time now is 05:03.