module m02
implicit none

real(kind=16), parameter ::                                            &
                 e =2.7182818284590452353602874713526625_16,           &
                 pi=3.1415926535897932384626433832795029_16,           &
                 w2=1.4142135623730950488016887242096981_16
contains
!=======================================================================
subroutine kopieren
character(len=255) :: name1, name2, zeile
logical :: b1

write(*,"("" zu kopierende Datei""/"" Name 1: "")") 
read(*,*) name1
inquire(file=trim(name1), exist=b1)
if (.not.b1) then
   write(*,*) "Datei existiert nicht"; return
   end if 
inquire(file=trim(name1), opened=b1)
if (b1) then
   write(*,*) "Datei geoeffnet"; return
   end if 

write(*,"("" neuer Dateiname""/"" Name 2: "")") 
read(*,*) name2
inquire(file=trim(name2), exist=b1)
if (b1) then
   write(*,*) "Datei existiert bereits"; return
   end if 
open(999, trim(name1), action="read")
open(998, trim(name2), action="write")
do
   read(999,"(A)", end=997) zeile
   write(998,"(A)") trim(zeile)
   end do
997 close(999)
    close(998)
end subroutine kopieren
!=======================================================================
subroutine umbenennen
character(len=255) :: name1, name2, zeile
logical :: b1

write(*,"("" umzubenennende Datei""/"" Name 1: "")") 
read(*,*) name1
inquire(file=trim(name1), exist=b1)
if (.not.b1) then
   write(*,*) "Datei existiert nicht"; return
   end if 
inquire(file=trim(name1), opened=b1)
if (b1) then
   write(*,*) "Datei geoeffnet"; return
   end if 

write(*,"("" neuer Dateiname""/"" Name 2: "")") 
read(*,*) name2
inquire(file=trim(name2), exist=b1)
if (b1) then
   write(*,*) "Datei existiert bereits"; return
   end if 
open(999, trim(name1), action="read", status="scratch")
open(998, trim(name2), action="write")
do
   read(999,"(A)", end=997) zeile
   write(998,"(A)") trim(zeile)
   end do
997 close(999)
    close(998)
end subroutine umbenennen
!=======================================================================
subroutine loeschen
character(len=255) :: name1
character ::c
logical :: b1

write(*,"("" zu loeschende Datei""/"" Name: "")") 
read(*,*) name1
inquire(file=trim(name1), exist=b1)
if (.not.b1) then
   write(*,*) "Datei existiert nicht"; return
   end if 
inquire(file=trim(name1), opened=b1)
if (b1) then
   write(*,*) "Datei geoeffnet"; return
   end if 

write(*,"("" Datei ""A"" wirklich loeschen? (j/n)"")") trim(name1)
read(*,*) c
if ((c=="j").or.(c=="J")) then
   open(999, trim(name1), status="scratch")
   close(999)
   end if
end subroutine loeschen

end module m02