***********************1******* print*,"hello world" stop end ***********************2****** real a,b,c a=2 b=5 c=a+b print *,"a+b=",c stop end ***********************3****** real a,b,c read *,a,b c=a+b print*,"a+b=",c stop end ***********************4****** real a,b,c print '("a="$)' read *,a print '("b="$)' read *,b c=a+b print*,a,"+",b,"=",c stop end ***********************5****** real a,b,c open(10,file="test5.in") open(11,file="test5.out") read(10,*) a,b c=a+b print *,"a+b=",c write(11,*) c stop end **********************6******* real a,b,c open(10,file="test5.in") open(11,file="test5.out") read(10,*) a,b call sum(a,b,c) print *,"a+b=",c write(11,*) c stop end subroutine sum(a,b,c) c=a+b return end ***********************7****** real v(10),sum integer n open(10,file="test6.in") read(10,*) n read(10,*)(v(i),i=1,n) sum=0. do i=1,n sum=sum+v(i) enddo print*,"sum=",sum stop end ***********************8****** real v(10),sum integer n open(10,file="test6.in") read(10,*) n read(10,*)(v(i),i=1,n) call sumv(n,v,sum) print*,"sum=",sum stop end subroutine sumv(n,v,sum) real v(n) sum=0. do i=1,n sum=sum+v(i) enddo return end ***********************9****** real,allocatable:: v(:) integer n open(10,file="test6.in") read(10,*) n allocate (v(n)) read(10,*) v(:) sum=0. do i=1,n sum=sum+v(i) enddo print*,"sum=",sum stop end ***********************10****** real A(10) integer n open(10,file="test7.in") Read(10,*) n Read(10,*) (A(i),i=1,n) amax = -1.E+32 amin = 1.E+32 do i =1,n if(a(i).gt.amax)then amax=a(i) endif if(a(i).lt.amin)then amin=a(i) endif enddo print*,"max=",amax,"min=",amin stop end ************************11***** real a(10) integer n open(10,file="test7.in") Read(10,*) n Read(10,*) (a(i),i=1,n) call maxmin(n,a,amax,amin) print*,"max=",amax,"min=",amin stop end subroutine maxmin(n,a,amax,amin) real a(n) amax = -1.E+32 amin = 1.E+32 do i =1,n if(a(i).gt.amax)then amax=a(i) endif if(a(i).lt.amin)then amin=a(i) endif enddo return end ************************12**** real,allocatable:: a(:) integer n open(10,file="test7.in") Read(10,*) n allocate(a(n)) Read(10,*) a(:) call maxmin(n,a,amax,amin) print*,"max=",amax,"min=",amin stop end subroutine maxmin(n,a,amax,amin) real a(n) amax = -1.E+32 amin = 1.E+32 do i =1,n if(a(i).gt.amax)then amax=a(i) endif if(a(i).lt.amin)then amin=a(i) endif enddo return end *************************13**** integer n,i read *,n if(n.lt.0)then print *,"n on neg." stop endif if(n.eq.0)then ifakt=1 print 100,ifakt stop 100 format("fakt0=",I10) endif ifact=1 do i=2,n ifact=ifact*i enddo print 100,ifact stop end *************************14**** integer n read *,n call fact(n,ifact) print 100,ifact 100 format("fakt=",I10) end subroutine fact(n,ifact) if(n.lt.0)then print *,"n on neg." stop endif if(n.eq.0)then ifact=1 return endif ifact=1 do i=2,n ifact=ifact*i enddo return end *************************15**** real a,b,c read *,a,b,c diskr= b*b-4.*a*c if(deskr.lt.0)then x1=(-b+sqrt(-deskr))/(2.*a) x2=(-b-sqrt(-deskr))/(2.*a) print *,"root on complex = ",x1,"+i",x2,x1,"-i",x2 stop endif if(deskr.eq.0)then x1=-b/(2.*a) print*,"root on=",x1 stop endif if(deskr.gt.0)then x1=(-b+sqrt(deskr))/(2.*a) x2=(-b-sqrt(deskr))/(2.*a) print*,"root on=",x1," ",x2 stop endif end **************************16************ real a,b,c read *,a,b,c diskr= b*b-4.*a*c if(deskr.lt.0)then x1=(-b+sqrt(-deskr))/(2.*a) x2=(-b-sqrt(-deskr))/(2.*a) print *,"root on complex = ",x1,"+i",x2,x1,"-i",x2 stop endif if(deskr.eq.0)then x1=-b/(2.*a) print*,"root on=",x1 stop endif if(deskr.gt.0)then x1=(-b+sqrt(deskr))/(2.*a) x2=(-b-sqrt(deskr))/(2.*a) print*,"root on=",x1," ",x2 stop endif end *****************************17*************** real a(3),b(3) open(10,file="test10.in") read (10,*) a,b print *,a,b anorm=0. bnorm=0. scal=0. do i=1,3 anorm=anorm+a(i)**2 bnorm=bnorm+b(i)**2 scal=scal+a(i)*b(i) enddo angle=acos(scal/sqrt(anorm*bnorm)) print *, angle*180/3.1415926536 stop end