subroutine solid_init_part1(me, krn, cfg, h5, sim)
type(solid_t), intent(out) :: me
type(krn_t), intent(inout) :: krn
class(input_t), pointer, intent(in) :: cfg
class(hdf5_t), intent(inout) :: h5
type(simulation_t), intent(inout) :: sim
real(dp) :: T_init
integer :: i, ii, nb_non_zeros_exp, nb_non_zeros_imp, nb_SS_src_ports
if(cfg%has_key('nodes')) then ! means uniform mesh
me%MC_Prop%NbCells = cfg%int('nodes')
allocate(me%MC_Prop%dxLoc(me%MC_Prop%NbCells),me%MC_Prop%volLoc(me%MC_Prop%NbCells))
me%MC_Prop%dxLoc(:) = cfg%dbl('length')/me%MC_Prop%NbCells
me%MC_Prop%volLoc(:) = cfg%dbl('volume')/me%MC_Prop%NbCells
else ! variable mesh
me%MC_Prop%NbCells=size(cfg%dbl1d('length'))
allocate(me%MC_Prop%dxLoc(me%MC_Prop%NbCells),me%MC_Prop%volLoc(me%MC_Prop%NbCells))
me%MC_Prop%dxLoc(:) = cfg%dbl1d('length')
me%MC_Prop%volLoc(:) = cfg%dbl1d('volume', n=me%MC_Prop%NbCells)
endif
me%MC_Prop%SSsrcLink = cfg%bin('solid_link')
call material_init(me%mat,cfg)
allocate(me%MC_Prop%FSlink(me%MC_Prop%NbCells))
me%MC_Prop%FSlink(:) = cfg%bin1D('channel_link', n=me%MC_Prop%NbCells)
! For HDF5
me%hdf%name = cfg%str('id')
me%hdf%node_x = [(sum(me%MC_Prop%dxLoc(1:i-1)) + me%MC_Prop%dxLoc(i)/2, &
i = 1, me%MC_Prop%NbCells)]
call h5%add_to_table(me%hdf,'solid')
call all_solid_allocation(me)
call me%Q_ext_load%init(sim,cfg,'flux',me%hdf%node_x)
T_init=cfg%dbl('initial/t')
do ii=1,me%MC_Prop%NbCells
me%StVar%MCtemp(ii)=T_init
enddo
me%MC_Prop%cond_btw_nodes=cfg%bin('conduction_between_nodes')
nb_non_zeros_exp=me%MC_Prop%NbCells
if(me%MC_Prop%cond_btw_nodes) then
nb_non_zeros_imp=2
do i=2,me%MC_Prop%NbCells-1
nb_non_zeros_imp=nb_non_zeros_imp+3
enddo
nb_non_zeros_imp=nb_non_zeros_imp+2
else
nb_non_zeros_imp=me%MC_Prop%NbCells
endif
me%MC_Prop%nb_FS_ports=0
do ii=1,me%MC_Prop%NbCells
if(me%MC_Prop%FSlink(ii)) me%MC_Prop%nb_FS_ports=me%MC_Prop%nb_FS_ports+1
enddo
if(me%MC_Prop%SSsrcLink) then
nb_SS_src_ports=me%MC_Prop%NbCells
else
nb_SS_src_ports=0
endif
call krn%add(cfg%str('id'),me%MC_Prop%NbCells,nb_non_zeros_exp,nb_non_zeros_imp,0,me%MC_Prop%nb_FS_ports,0,0,nb_SS_src_ports)
end subroutine solid_init_part1