// solids1d apptype

$action = 'setup'
$do = ''
if ($# > 0) then
  $action = $1
  if ($# > 1) then
    $do = $2
  endif
endif

if ($action = 'setup') then

  on('wrtp'):$e
  if ($e > 0.5) then
    wrtp = ''
  endif
  
  if ($do = '') then
    $do = macro   
  endif
  fixtancpxpars
  exists($do,'parlib'):$e,$path
  if ($e) then
    rtx($path,'current','keep','noclear')
    rtv($path,'seqfil','pslabel','dg','dg2','ap')
    exists('wrtp','parameter'):$e
    if ($e>0.5) then
       setprotect('wrtp','off',16384)
    endif
    exists('clearparams','parameter'):$e
    if ($e>0.5) then
       setprotect(clearparams,'off',16384)
       destroy('clearparams')
    endif
  else
    write('error','parameters for %s do not exist',macro)
    return
  endif
  setref('setup')

/*Add solids fixes to parameter set*/

  setlimit('rp',1e7,-1e7,0.1)
  setlimit('rp1',1e7,-1e7,0.1)
  setlimit('lp',1e7,-1e7,0.1)
  setlimit('lp1',1e7,-1e7,0.1)
  lp1=0 vtwait=1
   
/* run a user customization macro*/
  
  on('wrtp'):$e
  if ($e > 0.5) then
    exec(wrtp)
  endif
  
  setref('setup') 
  sf=0 wf=np/sw/2
  sp=rfp-rfl wp=sw
  execseq('setup')  // Execute any sequence specific setup
  dps newdg dg
 
elseif ($action = 'process') then

  setref('setup')
  if (arraydim > 1) then
    procarray
  else
    format(tn,'lower'):$tn
    $procmacro=$tn+'p'
    exists($procmacro,'maclib'):$e
    if $e then
      exec($procmacro)
    else
      wft f ai         
      aph:$x           
      if $x<0.5 then
        aph0:$x
        if $x<0.5 then
          write('line3','Cannot phase spectrum')
        endif
      endif
      integrate        
      vsadj noislm     
      thadj            
    endif
  endif

  execseq('proc') // Execute any sequence specific processing

elseif ($action = 'plot') then

  if arraydim=1 then		
    plot1d			
  else
    plotarray						
  endif

  execseq('plot') // Custom  sequence-based plots if desired

endif




