!   TITLE:  mass_matrix.mac (MANAGEMENT)
!
!
!   OBJECTIVE:
!
!   This sub-macro creates the mass properties matrix for a model assembly.
!
!
!   COMMAND SYNTAX:
!
!       MASS_MATRIX
!
!
!   DESCRIPTION:
!
!   The mass/weight properties are compiled by use of the command macro
!   MASS_CALCS.
!
!   The CM/CG coordinates are derived relative to the Global cartesian
!   coordinate system (CS): (csys,0).
!
!   The models are from the model part listing array, MODEL. The data for
!   each part model is compiled in the same order as the parts in the
!   array MODEL.
!
!   The mass matrix is stored in an array named: MASS_MAT. The array
!   contains 5 pieces of data for each element:
!
!       1.) part mass/weight
!       2.) part material density
!       3.) X-coordinate of part centroid (relative to csys = 0)
!       4.) Y-coordinate of part centroid (relative to csys = 0)
!       5.) Z-coordinate of part centroid (relative to csys = 0)
!
!   Each piece of data is stored in each column, with each row a part (except
!   the last row, which is the total assembly). The array, MASS_MAT, has the
!   following format:
!
!                                 COLUMNS
!         ROW   |   1    |    2    |   3   |  4    |   5   |
!        ---------------------------------------------------
!          1    |  M_p1  |  dens1  |  Xc1  |  Yc1  |  Zc1  |
!          2    |  M_p2  |  dens2  |  Xc2  |  Yc2  |  Zc2  |
!          3    |  M_p3  |  dens3  |  Xc3  |  Yc3  |  Xc3  |
!          .    |   .    |   .     |   .   |   .   |   .   |
!          .    |   .    |   .     |   .   |   .   |   .   |
!          N    |  M_pN  |  densN  |  XcN  |  YcN  |  ZcN  |
!         N+1   |  M_tot |    0    |  X_cm |  Y_cm |  Z_cm |
!
!
!
*get,prkey_,active,0,prkey
/nopr
!
*set,mass_mat(1),
!
! Parameter type: 0=scalar, 1=array, 2=table, 3=character scalar,
!                 4=character array, -1=undefined
!
*get,ptyp_,parm,model,type
!
*if,ptyp_,eq,4,then
    *get,nparts_,parm,model,dim,x
    *dim,mass_mat,array,nparts_+1,5
    !
    *do,ijk__,1,nparts_+1,1
        *if,ijk__,lt,nparts_+1,then
            mass_calcs,model(ijk__,1)
            !
            mass_mat(ijk__,1)=m_tot
            mass_mat(ijk__,2)=elm_mass(1,3)
            mass_mat(ijk__,3)=x_cm
            mass_mat(ijk__,4)=y_cm
            mass_mat(ijk__,5)=z_cm
        *else
            select
            mass_calcs
            !
            mass_mat(ijk__,1)=m_tot
            mass_mat(ijk__,2)=0
            mass_mat(ijk__,3)=x_cm
            mass_mat(ijk__,4)=y_cm
            mass_mat(ijk__,5)=z_cm
        *endif
    *enddo
*endif
!
select
!
*set,ijk__,
*set,ptyp_,
*set,nparts_,
*set,m_tot,
*set,x_cm,
*set,y_cm,
*set,z_cm,
*set,elm_mass(1),
!
*if,prkey_,eq,1,then
    /go
*endif