subroutine GetFile(fname, status, title)
use dfwin
character(max_path) dat_dir, fname

! Define types for structure "ofn"
!character*(*),parameter :: filter_spec ='*.*'C
character(max_path) :: file_spec = ""C
character(max_path) lpstrInitialDir ,lpstrFilter, lpstrTitle, &
					lpstrDefExt, lpstrFile
integer nFilterIndex
character(max_path) CurrentDirectory; integer istat
!integer SelectFile, status
integer status
integer lenCurr

character(*) title


lpstrInitialDir =""C	!NULL
lpstrFilter = &
  "Data Files (*.dat)"C//"*.dat"C// &
  "Text Files (*.txt)"C//"*.txt"C//&
  "Fortran Files"C//"*.f90;*.f"C//&
  "All files (*.*)"C//"*.*"C//""C
lpstrTitle = title		!'Select File'C
nFilterIndex =1
lpstrDefExt ='dat'C
lpstrFile ="*.dat"C	!""C

istat =GetCurrentDirectory(max_path, CurrentDirectory)

! Form "dat" dir
if(istat >0) then
dat_dir =CurrentDirectory(1:istat)//'\Dat\'//char(0)
lpstrInitialDir =dat_dir
endif


!status =SelectFile(lpstrInitialDir ,lpstrFilter, lpstrTitle, nFilterIndex, &
!					lpstrDefExt, fname, status)
call SelectFile(lpstrInitialDir ,lpstrFilter, lpstrTitle, nFilterIndex, &
					lpstrDefExt, fname, status)

END subroutine GetFile
