([prj-radius],[iter],[grp]) ; Volume projection loop
 ;
 ; SOURCE: spider/docs/techs/recon1/Procs/refine-prjloop.spi
 ;         New                              ArDean Leith  Nov 2015
 ; 
 ; PURPOSE: Projection loop.  Runs for each parallel group on each iteration.
 ;          Creates projections from reference volume.
 ;
 ; CALLED FROM: pub_refine_start 
 ;
 ; INPUT REGISTERS:
 ;   [prj-radius]        Projection radius of structure (pixels)
 ;   [iter]              Alignment iteration  
 ;   [grp]               Current parallel group                      
 ;
 ; FILES ARE SET IN: refine settings.spi
 ;                      '##' denotes iteration,  '%' denotes subset, and '***' denotes group
 ; INPUT FILES:
 ;   [sel_group]         win_1/sel_group            Group selection file         (one)
 ;   [iter_refangs]      work/ang_refs_##           Reference angles doc file    (one)      
 ;   [current_vol]       final/vol_##_s%            Current reference volume     (two) 
 ;
 ; OUTPUT FILES:
 ;   [iter_refangs_grp]  work/ref_angs_##_***       Reference projection angles doc file (one/group/iter)
 ;   [ref_projs_s_grp]   work/ref_projs_##_s%_***@  Group reference projections  (two/group/iter) (deleted)
 ;    
 ; ----------------- END BATCH HEADER -------------------------------------

 UD N [num-grps]            ; Find number of groups
   [sel_group]              ; Group selection file      (input)

 UD N [num-angs]            ; Get number of reference images used
   [iter_refangs]           ; Reference images angles doc. file (input)

 [num-in-grp] = INT ( [num-angs] / [num-grps])
 IF ( ([num-in-grp] *[num-grps]) < [num-angs]) [num-in-grp] = [num-in-grp] + 1
  
 [igo]  = ([grp] - 1) * [num-in-grp] + 1
 [iend] = [igo] + [num-in-grp] - 1
 IF ( [iend] > [num-angs] ) [iend] = [num-angs] 
[ngot] = [iend] - [igo] + 1

 SYS
   echo  "  Starting: refine-prjloop  Iteration: {%I0%[iter]}  Group:{%I3%[grp]}  Projections: {%i4%[igo]} ... {%i4%[iend]} " 

 DE
   [iter_refangs_grp]      ; Reference projection angles doc file (removed)

 ; Create doc file listing projection angles in use for this parallel group

 DOC SLICE                 ; Extract angles for [igo]...[iend] into temp file
   [iter_refangs]          ; Reference projection angles doc file (input)
   [iter_refangs_grp]      ; Reference projection angles doc file (output)
   [igo]-[iend]            ; Slice numbers transferred

 ; Create stacks holding this iterations's set of reference projections from current volume subsets.
 
 DO [s] = 1,2              ; Loop over subvolumes
   PJ 3F                   ; Projection operation
     [vol_s]               ; Current reference volume             (input) 
     [prj-radius]          ; Radius of object
     1-[ngot]              ; Reference angles used    
     [iter_refangs_grp]    ; Reference angles doc file            (input)
     [ref_projs_s_grp]     ; Reference projection stack           (output) 
 ENDDO                     ; End of: DO  [s] = 1,2

 RE

 ;