!   TITLE:  create_rotaset.mac (MANAGEMENT)
!
!
!   OBJECTIVE:
!
!   This macro assigns area number and associated material number into an
!   array called ROTASET for use in ROTATE_VOLM_MSH.
!
!   COMMAND SYNTAX:
!
!
!       CREATE_ROTASET, a1, mat1, a2, mat2, a3, mat3, a4, mat4
!
!
!   ARGUMENTS:
!
!           aN = area number
!
!           matN = associated material number for area aN.
!
!   DESCRIPTION:
!
!   This macro assigns to the N x 2 array ROTASET the area numbers which
!   are to be rotate meshed and the corresponding material number for that
!   area. Therefore, the area number in the N x 1 position is given a mat-
!   erial number in the N x 2 position.
!
!   The command can take up to 8 arguments; 4 area number and 4 material
!   numbers.  If more than 4 areas are needed to be specified, then simply
!   run this macro on a second line immediately following the first line,
!   and prior to ROTATE_VOLM_MSH. ( This may be repeated as many times as
!   necessary ) Once ROTATE_VOLM_MSH is run, this array is deleted, allowing
!   it to be initialized for another ROTATE_VOLM_MSH operation.
!
!
!
!
*get,prkey_,active,0,prkey
/nopr

*get,ptyp_,parm,rotaset,type        ! determine whether ROTASET exists
!
*if,ptyp_,ne,1,then                 ! If AMATMAX_ does not exist, then
    *dim,rotaset,array,1,2
    amatnum_=0                      ! initialize material numbers
    offst_=0                        ! initialize offset counter
*endif
!
*do,klm_,1,8,1                      ! assign material numbers
    !
    *if,arg%klm_%,eq,0,then         ! if argument = 0, then exit loop
        *exit
    *else                           ! if argument ~= 0, then store in array
        amatnum_=amatnum_+1
        !
        *if,mod(klm_,2),eq,1,then                   ! if argument # is odd then
            rotaset(amatnum_-offst_,1)=arg%klm_%    ! store in 1st column (area)
        *else
            offst_=offst_+1
            rotaset(amatnum_-offst_,2)=arg%klm_%    ! if argument # is even then
        *endif                                      ! store in 2nd column (mat)
        !
        *if,mod(klm_,2),eq,0,then
            *dim,buffer_,array,amatnum_-offst_,2    ! create buffer array
            !
            *do,ijk_,1,amatnum_-offst_,1            ! store contents of array
                buffer_(ijk_,1)=rotaset(ijk_,1)     ! in buffer
                buffer_(ijk_,2)=rotaset(ijk_,2)
            *enddo
            !
            *set,rotaset(1),                        ! delete array
            !
            *dim,rotaset,array,amatnum_-offst_+1,2  ! recreate array with 1
            !                                       ! higher DIM
            *do,ijk_,1,amatnum_-offst_,1            ! transfer buffer contents
                rotaset(ijk_,1)=buffer_(ijk_,1)     ! to array
                rotaset(ijk_,2)=buffer_(ijk_,2)
            *enddo
            !
            *set,buffer_(1),                        ! delete buffer
        *endif
    *endif
*enddo
!
!
*set,ijk_,
*set,klm_,
*set,ptyp_,


*if,prkey_,eq,1,then
    /go
*endif