Silverfrost Forums

Welcome to our forums

DO LOOP working....and not working!?

31 Jan 2011 7:02 #7662

I am completely new to Fortran and am learning using Silverfrost and the Plato IDE on my XP box.

Could somebody help me understand why the yn do loop in the lines below does not execute?

Thank you.

      program TonMiles
      implicit none
      real Lh, TM, Wdp, Wdc, Whw, BF, MW
      integer Unit_Transform
      parameter (Unit_Transform = 10560000)
      character(1) :: yn
     
! This program prompt user for Depth (in ft) and Mud Weight (in PPG) and returns TM for the
! Drilling String described in HW1 Prob 5.
     
      interactive_loop: do   !Keeps routine running if user chooses so with a 'y' screen input
                             !or stops after a 'n' screen user input
                                     
      write (*,*) 'Enter Depth in ft:'
      read  (*,*) Lh
      write (*,*) 'Enter Mud Weight in PPG:'
      read  (*,*) MW
     
      BF = 1-MW/65.5
      Wdp = 19.5*BF
      Wdc = (96.2-19.5)*BF*660
      Whw = (50-19.5)*BF*270
     
      TM = (Lh*(93+Lh)*Wdp+4*Lh*(50000+Wdc/2+Whw/2))/Unit_Transform

     
      write (*,*) 'TM = ', TM

      yn = ' '
      yn_loop: do
      write(*,*) 'Perform one more Round Trip TM calculation? y[n]'
      read(*,'(a1)') yn
      if (yn=='y' .or. yn=='Y') exit yn_loop
      if (yn=='n' .or. yn=='N' .or. yn==' ') exit interactive_loop
      end do yn_loop
 
      end do interactive_loop

      end program TonMiles
2 Feb 2011 2:46 #7689

I have copied your code into Plato and runed it as well as Release Wind32 as Release net and it works perfectly !

2 Feb 2011 4:20 #7690

Quoted from Jeannot I have copied your code into Plato and runed it as well as Release Wind32 as Release net and it works perfectly !

Merci Jeannot.

After your post, I tried to run the code again and the loop is now executing. The only thing I did in the mean time was to close Plato and reopen it. Not sure what happened. But it works now. Thanks for the help.

I am going through the tutorial that comes with Plato to learn Fortran, but couldn't find a tutorial for 95, only for 90. Would you know of a tutorial for 95, or are they enough similarities between 90 and 95 that learning with a 90 tutorial is OK?

I have not quite figured out how to run the debugger yet. I hope it will get clearer after a few more reads of the instructions......

2 Feb 2011 4:25 #7691

There are very few differences between Fortran 90 and 95.

2 Feb 2011 6:21 #7695

Quoted from PaulLaidler There are very few differences between Fortran 90 and 95.

Thank you.

Please login to reply.