1 Replies - 754 Views - Last Post: 10 December 2010 - 02:44 PM Rate Topic: -----

#1 smallhelp  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 15-November 10

Fortran Program small help

Posted 15 November 2010 - 08:43 PM

For getting no from 0 to 1 at constant difference following command I read on net what is meaning of format and using '' " etc I dont want 'x' to be displayed what to do .
Just 0.1
0.2
0.3
and not x before
.
program loop_step 
  ! Using real step size in loops
  implicit none

  real :: x, x_min, x_max, step
  integer :: i, n

  x_min = 0
  x_max = 1.0
  step = 0.1
  10 format(i2 a6 f3.2)

  write (*,*) 'Using DO loop with control variable:'
  x = x_min
  n = nint((x_max - x)/step)
  do i=1, n+1
    write(*,10)  i,". x = ",x 
    x = i*step
  end do
  write(*,*)

 
end program loop_step


I want to change step to 0.01 . What necessary changes I need to do .

Edited by macosxnerd101: Please, :code:.

Is This A Good Question/Topic? 0
  • +

Replies To: Fortran Program small help

#2 Guest_Guest*


Reputation:

Re: Fortran Program small help

Posted 10 December 2010 - 02:44 PM

Is this what you want?

	program loop_step
	  ! Using real step size in loops
	  implicit none
	 
	  real :: x, x_min, x_max, step
	  integer :: i, n
	 
	  x_min = 0
	  x_max = 1.0
	  step = 0.01
10    format(i2 a6 f3.2)
	 
	  write (*,*) 'Using DO loop with control variable:'
	  x = x_min
	  n = nint((x_max - x)/step)
	  do i=1, n+1
	    write(*,10)  i,"0",x
	    x = i*step
	  end do
	  write(*,*)
	 
	  
	end program loop_step


Was This Post Helpful? 0

Page 1 of 1