program read_from_a_file *This program reads in data from a file called a.dat, * and stores the data as an array called x(i). Then it * takes a squared-root of every element in * x and write them in a file called b.dat. parameter(max=10000) real*4 x(max) open(2,file='/home/sgao/demo/07_f77/a.dat') do i=1,max read(2,*,end=222) x(i) print*,'x(', i, ') is ', x(i) enddo 222 close(2) ** The array is read. Now do some processing (taking the square-root of * each point) and write the results to b.dat open(1,file='b.dat') n=i-1 do i=1,n y=sqrt(x(i)) write(1,11) y write(6,11) y !! also write to screen in addition to writing to unit 1 11 format(f10.4) enddo close(1) print*,'The output file is b.dat' stop end