In this routine the different matrices are constructed (except for the profile solver, in which case mafillpr is used). What has to be set up is summarized in the logicals mass, stiffness, buckling, rhsi and stiffonly. For instance, if the mass matrix must be calculated, mass=true, else mass=false. The routine consists of two major loops over all elements. The first loop constructs the mechanical part of the matrices, if applicable, the second loop constructs the thermal part, if applicable. Each loop runs over all elements, thereby collecting the element stiffness matrix and/or mass matrix from routine e_c3d and e_c3d_th for mechanical and thermal calculations, respectively, and inserting them into the global stiffness matrix and/or mass matrix, taking into account any linear multiple point constraints. The right-hand side matrices are also constructed from the element rand-hand sides and any point loading.