!   TITLE:  mod_coord_system.mac (MANAGEMENT)
!
!
!   This sub-macro creates the model coordinate systems for a particular
!   part.  It is called by the part macro, and is found in section 2 of
!   MACRO_TEMPLATE.MAC.  The coordinate system names are defined in
!   PARAMETER_FILE_TEMPLATE.PARM, and the coordinate system positional
!   stack-ups are tracked by C_S_POSITION.MAC. The relative position of
!   these model coordinate systems are measured from an active coordinate
!   system (ACS), as specified by argument 1 (ARG1).
!
!   If the model coordinate system names are not specified, then the names
!   'cs0_', 'cs1_' and 'cs2_' will be assigned to 'ct_name', 'cyl_name' and
!   'sph_name', respectively, by default.
!
!   After creation of the model coordinate systems, the cartesian model c.s.,
!   %ct_name%, is made active by default. If another c.s. is desired for the
!   next set of operations, then the user must manually activate it.
!
!
!
! MOD_COORD_SYSTEM, acs, xc, yc, zc, rotxy, rotyz, rotzx
!
!
*get,prkey_,active,0,prkey
/nopr
!
acs_mcs=arg1        ! active coordinate system (c.s.) locating model c.s.
!
!
xc_mcs=arg2             ! x (r) coordinate center
yc_mcs=arg3             ! y (theta) coordinate center
zc_mcs=arg4             ! z (z or phi) coordinate center
!
!
rotxymcs=arg5           ! 1st rotation angle (+x to +y)
rotyzmcs=arg6           ! 2nd rotation angle (+y to +z)
rotzxmcs=arg7           ! 3rd rotation angle (+z to +x)
!
!
*get,_parchk1,parm,ct_name,type
*get,_parchk2,parm,cyl_name,type
*get,_parchk3,parm,sph_name,type
!
*if,_parchk1,eq,-1,then
    ct_name='cs0_'
*endif
!
*if,_parchk2,eq,-1,then
    cyl_name='cs1_'
*endif
!
*if,_parchk3,eq,-1,then
    sph_name='cs2_'
*endif
!
csn=csn+1
%ct_name%=csn       ! cartesian model c.s. number
!
csn=csn+1
%cyl_name%=csn      ! cylindrical model c.s. number
!
csn=csn+1
%sph_name%=csn      ! spherical model c.s. number
!
csys,acs_mcs
clocal,%ct_name%,0,xc_mcs,yc_mcs,zc_mcs,rotxymcs,rotyzmcs,rotzxmcs
!
csys,acs_mcs
clocal,%cyl_name%,1,xc_mcs,yc_mcs,zc_mcs,rotxymcs,rotyzmcs,rotzxmcs
!
csys,acs_mcs
clocal,%sph_name%,2,xc_mcs,yc_mcs,zc_mcs,rotxymcs,rotyzmcs,rotzxmcs
!
c_s_position        ! calculates c.s. position stack_ups
!
cs_file,1           ! files newly formed c.s. in array
!
*set,_parchk1,
*set,_parchk2,
*set,_parchk3,
*set,acs,
*set,xc,
*set,yc,
*set,zc,
*set,rotxyc,
*set,rotyzc,
*set,rotzxc,
!
csys,%ct_name%

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