I have a simple question concerning the management of the output after running a Fortran code, having a NESTED LOOP..I want to calculate for different k=1,5,9 the value $\mathbf{Sin(kx)}$ in the range $\mathbf{x=0:2\pi}$ with the step $\mathbf{h=0.01}$.As the range of $\mathbf{x}$ for all $\mathbf{k}$ is the same, I would like to do an output in a cal.dat file as the following (of course without the functions and just number):$x$ $\quad\qquad\sin(x)$   $\qquad\sin(5x)$    $\qquad\sin(9x)$ $0.0$ $\quad\qquad0$ $\qquad\qquad0$ $\quad\qquad\qquad0$$...$ $\quad\qquad...$ $\qquad\qquad...$ $\quad\qquad\qquad...$My code is:         program test3         real dx,f,x         k=1         pi=4.0*atan(1.0)         open(11,file='sinkx.dat',status='unknown',form='formatted')         do  while(k<10)         x=0.0         dx=0.01         do while(x<2*pi)         f=sin(k*x)          write(11,1001) x,f1001     format(' ',f9.3,' ',e12.3)         x=x+dx         enddo         k=k+4         enddo         end  The questions is that when you run this code, you get the output not in a multi-column out put as desired, but in a two column out put in which first come numbers for the $\mathbf{x}$ range and in the second column the values of $\mathbf{Sin(kx)}$ for different $\mathbf{k=1}$, then $\mathbf{k=5}$ and then $\mathbf{k=9}$.  How to write results in a multi-column out put, as I have indicated in the above?  I think that the question is in write operator rather than in the calculations?  Of course, I could write the results in thre different cal.dat, but I prefer to write it in a one dat file, since the range of $\mathbf{x}$ is the same for all $\mathbf{k}$. 
How in Fortran 77 or in the next standards to do a multi-column out put in a simple calculation, having a Nested loop?
fortran