Graphs in Fortran: Making tcentre(i) vs. t(i)

  • Context: Comp Sci 
  • Thread starter Thread starter polka129
  • Start date Start date
  • Tags Tags
    Fortran Graphs
Click For Summary
SUMMARY

The discussion focuses on generating a graph of the variable Tcenter(i) against t(i) in Fortran. The provided code snippet demonstrates variable declarations, calculations, and the use of the Newton method for root finding. It concludes that Fortran lacks built-in graphing capabilities but suggests exploring external graphics packages or seeking guidance from instructors or peers for solutions.

PREREQUISITES
  • Understanding of Fortran programming syntax and structure
  • Familiarity with numerical methods, specifically the Newton method
  • Basic knowledge of temperature calculations and physics concepts
  • Awareness of external graphics libraries compatible with Fortran
NEXT STEPS
  • Research available Fortran graphics packages such as DISLIN or PLplot
  • Learn about integrating external libraries in Fortran projects
  • Explore data visualization techniques in scientific computing
  • Study the implementation of the Newton method in various programming contexts
USEFUL FOR

This discussion is beneficial for Fortran developers, students in computational physics, and anyone looking to visualize data generated from Fortran programs.

polka129
Messages
43
Reaction score
0
hello..here is a program..

and i need to make a graph of tcentre(i) against t(i)..how to do this...

these variables are bold in the below code


Code:
!here are the declaration of variables 

DIMENSION THEETA(10),DF(10),F(10),c(10),b(10),t(10),z(10),sum_1(10),Tcenter(10),r(10),w(10)
REAL K,THEETA,DF,F,c,b,sum_1,x,z,T0,Tcenter,alpha,r,q
integer t,y,p,j,l,m,s

!the assignments of constants 
 			
A = .1
H = 23.
SIGMA = 46.
Alpha=0.000012
K = 1.-(A*H/SIGMA)
EPS = .0001


! initial temperature in KELVIN

T0=250.0+273.0
 

!a do loop which caculates and assigns elements to the declared variables
 
DO N=1,10
!
! First calculating THEETA value
!
RN = N
THEETA(N)=(1.-1./(((RN-0.5)**2)*(3.142**2)*(K**2)))*3.142*(RN-0.5)
!
! Then using that THEETA value we get derivative
! converting degrees to radians
r(n)=theeta(n)*3.142/180

!derivative


DF(N) = 1./COS(r(N)**2)
!
! Then using that same THEETA value we get F
!
F(N) = r(N)*(1./K)

  WRITE(*,*)r(n),df(n),f(n)


 



END DO


! here starts the loop for generation of roots

!Newton method used

  	s=1	

do l=1,10

	

           do 

			  if(s.EQ.L)q=r(s) 
			  



	10       x=q-(q*(1./K)/1./COS(q**2))


	if (abs(x-q).lt.eps)goto 20

	q=x

	goto 10

	end do


	20 	 w(l)=x


   ! thee roots are printed
	 write(*,*)'roots',w(l)

	  
	
	
	   s=s+1

	end do


!-----------------

!-calculation of other variables in the temperature formula





	do p=1,10

 
 C(p)=(4*sin(w(p)))/(2*(w(p))-sin(2*(w(p))))



B(p)=(w(p)*alpha**2)/(a**2)

   write(*,*)c(p),b(p)

  

   end do


	do i=0,9

	t(i)=i*60

	[B]print*,'time',t(i)[/B]

	enddo

!- this loop calculates the temperature at the centre for each value of time  
do j=1,10

 y=j-1
z(j)=-(b(j)*t(y))
sum_1(j)=(C(j)*z(j))



  Tcenter(j)=T0*((a*h)/(sigma))*sum_1(j)

  write(*,*)'temperature at centre',[B]Tcenter(j)[/B]


 

 


  end do






end
 
Physics news on Phys.org
Fortran itself doesn't have any graphing capabilities that are part of the language, to the best of my knowledge, but perhaps there are some graphics packages that you can import to do this.

Are you doing this on your own or is it a part of a class. If it's for a class, your instructor should provide some means for your to be able to graph a set of data.

If you're doing it on your own or as a work project, either ask someone about graphics packages or do a Web search for something like "Fortran graphics package". That's what I would do.
 

Similar threads

  • · Replies 10 ·
Replies
10
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 2 ·
Replies
2
Views
6K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 10 ·
Replies
10
Views
2K