#!/usr/bin/perl $t=" c------------------------------------------------- program test1 c23456789----------------------------------------- c implicit none c 10 20 30 40 50 60 71COMMENT !..... other way of comment real a(10),b(10) !..... declare arrays of type real real*4 c(10),d(10) parameter(n=10) !..... end of declarations, first executable statement if(.true.) then write(6,*)' ' write(6,*)' loop1' write(6,*)' ' !.... every variable starting with i,j,k,l,m,n is implicitly integer ! unless declared otherwise do i=1,10 a(I)=(10.0**(5-I))*float(I)**2 !.... NOT case sensitive b(i)=sin(a(i)) write(0,*) 'a(i) is ', a(i) enddo c stop endif do 100 k=1,10 c(k)=a(k)*b(k) 100 continue m=0 do 200 i=1,10 m=m+0.1 !..... watch out: m is an integer d(i)=m 200 continue write(6,*)' ' write(6,*)' loop 300' write(6,*)' ' do 300 i=1,n write(6,*) i,a(i),b(i),c(i),d(i) 300 continue write(6,*)' ' write(6,*)' loop 400' write(6,*)' ' do 400 i=1,n write(6,'(i4,4(1x,f12.5))') + i,a(i),b(i),c(i),d(i) !.... continuation line 400 continue 500 format(a,i6.6,12x,4(1x,g12.5)) do i=1,n if(i.gt.3) write(0,500)' using FP g format ',i,a(i),b(i),c(i),d(i) enddo do i=1,10 a(i)=i b(i)=i-1 enddo s=dotprod(a,b,3) write(6,*)' ' write(6,*)' dotprod(a,b,5) is ',s s=dotprod(a(3),b(2),3) write(6,*)' ' write(6,*)' dotprod(a(3),b(2),5) is ',s call matvec3(a,b,c,3) write(6,*)' ' write(6,*)' matvec3: ',c(1),c(2),c(3) stop end ! .... demonstrate errors from non-matching actual/dummy parameters c------------------------------------------------- real function dotprod(x,y,n) c------------------------------------------------- implicit none real x(*),y(*) real s integer i,n s=0.0 do i=1,n s=s+x(i)*y(i) enddo dotprod=s return end c------------------------------------------------- subroutine matvec3(a,b,c,n) c------------------------------------------------- real a(n,n), b(n), c(n), e(n) do j=1,3 s=0.0 do i=1,3 s=s+a(i,j)*b(i) enddo c(j)=s enddo return end "; system("/bin/rm -vf a.out tmp.f"); #...... remove stale files open(FF,">tmp.f"); print FF $t; close(FF); system("gfortran tmp.f"); if( -e "a.out"){ system("./a.out"); }