program SWAPPA implicit real*8(a-h,r-z) implicit integer(i-n) implicit character*20(o-q) logical logic parameter (MAXD=1000) dimension a(MAXD),b(MAXD) write (*,*) '' write (*,*) '' write (*,950) . '**********************************************************', . '* *', . '* SWAPPA *', . '* by Lorenzo Fortunato *', . '* March `02 *', . '* *', . '**********************************************************', . '* *', . '* Utility to swap two columns of data in a given file. *', . '* Change the parameter MAXD to augment the maximum *', . '* number of entries (now is 1000). *', . '* *', . '**********************************************************' write(*,*)'Which file to swap?' read(*,*) qinput 10 write(*,*)'Which filename for the output (NONE will overwrite the . old file)?' read(*,*) qout inquire(file=qout,exist=logic) 20 if (logic.eqv..true.) then write(*,*)'ALREADY EXISTENT FILE' write(*,*)'Do you want to overwrite (yes/no) ?' read(*,*) ohohoh if (ohohoh.eq.'yes') then goto 30 elseif (ohohoh.eq.'no') then goto 10 else goto 20 endif endif 30 if (qout.eq.'NONE') then n_ctrl=1 qout=qinput endif open(unit=5,file=qinput,status='old') do kk=1,MAXD read(5,*,end=50) a(kk),b(kk) enddo 50 nn=kk-1 if (n_ctrl.eq.1) then close(unit=5,status='delete') endif open(unit=6,file=qout) do kk=1,nn write(6,*)b(kk),a(kk) enddo close (unit=6) 950 format (14(a58,/)) 990 stop end