subroutine openw(iounit,fname) c Open a file for writing, deleting any existing version first. implicit none c input: c Fortran I/O unit to use integer iounit c file name character*(*) fname c local c whether the file already exists logical exists c executable 10 format(a,' ',a) c see whether an old file with this name already exists: inquire(file=fname,exist=exists,err=990) c if yes, delete it if(exists)then print10,'Deleting old file',fname open(iounit,file=fname,status='old',err=990) close(iounit,status='delete',err=990) endif c open the file open(iounit,file=fname,status='new',err=990) return 990 print10,'Problem opening file',fname stop end