Fortran coding do loop

luvbite38

Active Member
Joined
Jun 25, 2008
Messages
368
Can some1 kindly help me understand the following code, I am trying to translate the following code in VBA:

Thanks in advance

FFLC = FLC .......i understand this part
ANGLE=PI/6 !Suppose 30 Degrees .......i understand this part
Do 21800 I=i,5 .......Don't understand this
FLC=FFLC-COS(ANGLE)*NDIA
FLE=SQRT(FLB*FLB+FLC*FLC) .......i understand this part
21800 ANGLE=ATAN2(FLC,FLB).......i understand this part
if (R.NE.o.)D=R/2.+NDIA/2.......i understand this part
FLCUT = ........ .......i understand this part
LE=IFIX(FLE).......Don't understand this

My answer for FLCUT is 2387 when using the 30 degree angle but fortran result 2397 (after using the iteration which I dont understand)

Can someone please help me understand this please?

Regards
<!-- google_ad_section_end --><!-- / message -->
 
First loop says do for i = 1 to 10 incrementing by 1

Inside that loop is a second loop k= 5 to 1 incrementing by -1

N increments each time line 200 is reached - that is each time each loop is executed

So

10 loops each executing 5 loops = executes N=N+1 50 times: N=50
 
Upvote 0

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Note that there are at least 4 structures for do loops in VBA :eeek: and there may be more I dont know about as i am no VBA expert. These loops are Do While, Do-Loop While and Do Until and Do-Loop Until and they all have different ways of treating the test condition - sometimes they test after executing the loop and sometimes before.

The Do-Loop While and Do-Loop Until ALWAYS execute the loop at least once - regardless of the condition - as they do the test on exit so you must be careful when you "translate" code from other languages to make sure you get the result you expect.
 
Upvote 0

Similar threads

Forum statistics

Threads
1,223,953
Messages
6,175,598
Members
452,658
Latest member
GStorm

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top