!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! @ nostokes file.uvt
!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
begin data gag_scratch:uv_splitpolar.init
  TASK\FILE "Input multi-polarization UV Table" INPUT$ 'atmp_iname'.uvt
  TASK\FILE "Output single polarization UV Table" OUTPUT$ 'atmp_oname'.uvt
  TASK\CHARACTER "Stokes parameter" STOKES$ 'atmp_stokes'
  TASK\GO
end data gag_scratch:uv_splitpolar.init
!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
if .not.file("&2.uvt") then
  message e uv_stokes "No such file &2.uvt"
  return error
endif
!
define header a &2.uvt read
if (a%nstokes.le.1) then
  message w uv_stokes "File &2.uvt has only 1 polarization state"
  return 
endif
!
define char atmp_iname*128 atmp_oname*128 atmp_stokes*4 /global
let atmp_stokes &1
if (pro%narg.eq.3) then
   let atmp_iname &2
   let atmp_oname &3
   run uv_splitpolar gag_scratch:uv_splitpolar.init /nowindow
else
   sic rename &2.uvt &2-stokes.uvt
   let atmp_iname &2-stokes
   let atmp_oname &2
   run uv_splitpolar gag_scratch:uv_splitpolar.init /nowindow
   sic delete 'atmp_iname'.uvt
endif
delete /var atmp_iname atmp_oname atmp_stokes
!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
