subroutine rfxqlo_system_dflts(zsys)
  !  get default settings for instance of rfxqlo_system compound data type
  use rfxqlo_types
  implicit NONE
  type (rfxqlo_system), intent(out) :: zsys

  integer :: i

  do i=1,5
     zsys%lunut(i) = 30 + i
  enddo
  zsys%luntmp1 = 41
  zsys%luntmp2 = 42

  zsys%run_id = " "
  zsys%run_label = " "
  zsys%filepath = " "
  zsys%workpth_log = " "
  zsys%wavecode = " "
  zsys%vv_bdy = .FALSE.
  zsys%batchmode = .FALSE.
  zsys%time = 0

end subroutine rfxqlo_system_dflts

subroutine rfxqlo_system_close_all(zsys)

  ! close files on all non-zero LUNs -- ignore errors

  use rfxqlo_types
  implicit NONE
  type (rfxqlo_system) :: zsys

  integer :: i,istat

  do i=1,5
     close(unit=zsys%lunut(i),iostat=istat)
  enddo
  close(unit=zsys%luntmp1,iostat=istat)
  close(unit=zsys%luntmp2,iostat=istat)

end subroutine rfxqlo_system_close_all

subroutine rfxqlo_system_set(zsys,ierr)
  !  define system settings for rfxqlo module
  use rfxqlo_private
  implicit NONE
  type (rfxqlo_system), intent(in) :: zsys
  integer, intent(out) :: ierr     ! 0: OK; 1: error

  ierr=0
  have_sys = .TRUE.
  rfx_sys = zsys

end subroutine rfxqlo_system_set

subroutine rfxqlo_system_get(zsys,ierr)
  !  fetch system settings from rfxqlo module
  use rfxqlo_private
  implicit NONE
  type (rfxqlo_system), intent(out) :: zsys
  integer, intent(out) :: ierr     ! 0: OK; 1: error

  ierr=0
  if(.not.have_sys) then
     ierr=1
     write(lunmsg,*) &
          ' ?rfxqlo_system: system settings have not been provided', &
          ' to rfxqlo module.'
  else
     zsys = rfx_sys
  endif

end subroutine rfxqlo_system_get
