C++*********************************************************************
C
C VORA.F                          07/12/93  PP
C                                 ADDED 'VO RAS' MAY 01 ARDEAN LEITH
C                                 -K DOES NOT PRINT *** JULY 01 AL
C
C **********************************************************************
C=* FROM: SPIDER - MODULAR IMAGE PROCESSING SYSTEM.   AUTHOR: J.FRANK  *
C=* Copyright (C) 1985-2005  Health Research Inc.                      *
C=*                                                                    *
C=* HEALTH RESEARCH INCORPORATED (HRI),                                *   
C=* ONE UNIVERSITY PLACE, RENSSELAER, NY 12144-3455.                   *
C=*                                                                    *
C=* Email:  spider@wadsworth.org                                       *
C=*                                                                    *
C=* This program is free software; you can redistribute it and/or      *
C=* modify it under the terms of the GNU General Public License as     *
C=* published by the Free Software Foundation; either version 2 of the *
C=* License, or (at your option) any later version.                    *
C=*                                                                    *
C=* This program is distributed in the hope that it will be useful,    *
C=* but WITHOUT ANY WARRANTY; without even the implied warranty of     *
C=* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU  *
C=* General Public License for more details.                           *
C=*                                                                    *
C=* You should have received a copy of the GNU General Public License  *
C=* along with this program; if not, write to the                      *
C=* Free Software Foundation, Inc.,                                    *
C=* 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.      *
C=*                                                                    *
C **********************************************************************
C
C  VORA(MAXMEM)
C
C  PURPOSE:  ROTATE DOCUMENT FILE  07/12/93
C            MULTIPLIES INVERTED INPUT ANGLES BY THE ANGLES FROM THE 
C            ANG DOC FILE
C
C23456789012345678901234567890123456789012345678901234567890123456789012
C--*********************************************************************

         SUBROUTINE VORA(MAXMEM)

         INCLUDE 'CMBLOCK.INC'

         COMMON        FI1(3),FI2(3),FIO(4)
         CHARACTER*81  DOCFIL
         CHARACTER*1   NULL

         DATA          NDOC,NDOUT/55,56/

         NULL  =CHAR(0)

         CALL FILERD(DOCFIL,NLETI,NULL,'ANGULAR DOCUMENT',IRTFLG)
         IF (IRTFLG .EQ. -1)  RETURN

         IF (FCHAR(4:6) .EQ. 'RAS') THEN
            CALL  RDPRM3S(FI1(1),FI1(2),FI1(3),NOT_USED,
     &                   'ROTATION ANGLES - PSI, THETA & PHI',IRTFLG)
            IF (IRTFLG .NE. 0)  RETURN

11          CALL  RDPRM2S(FANG,FVAL,NOT_USED,
     &                   'ANGLE NUMBER(e.g. PSI IS 1) & VALUE',IRTFLG)
            IF (IRTFLG .NE. 0)  RETURN

            IANG = FANG
            IF (IANG .LT. 0 .OR. IANG .GT. 3) THEN
               CALL ERRT(100,'ANGLE NUMBER MUST BE 0...3',IDUM)
               GOTO 11
            ENDIF
         ELSE

            CALL RDPRM2(FI1(1),FI1(2),NOT_USED,
     &                   'ROTATION ANGLES - PSI, THETA')

            CALL RDPRM(FI1(3),NOT_USED,'ROTATION ANGLE - PHI')
            IANG = 0
         ENDIF

         NLIST = 4
         K     = 0
         K2    = 1

778      LERR = -1
         KEY  = K+1
         CALL  UNSAV(DOCFIL,-K,NDOC,KEY,FI2,3,LERR,K2)
         IF (LERR .EQ. 0)  THEN
            K = K + 1
            CALL CALD(FI1,FI2,FIO(2))
            FIO(1) = K

C           CAN SET ONE ANGLE TO SPECIFIED VALUE
            IF (IANG .GT. 0) FIO(IANG+1) = FVAL

            CALL SAVD(NDOUT,FIO,NLIST,IRTFLG)
            IF (IRTFLG .EQ. -1) GOTO  5
            GOTO 778
         ENDIF

5        CALL  SAVDC
         CLOSE(NDOUT)
         CLOSE(NDOC)
         END

