build_c_species_names Subroutine

private subroutine build_c_species_names(params, c_names_flat, n_len)

Build a flattened C-compatible species-name buffer.

Arguments

Type IntentOptional Attributes Name
type(case_params_t), intent(in) :: params
character(kind=c_char, len=1), intent(out), allocatable :: c_names_flat(:)
integer, intent(out) :: n_len

Source Code

   subroutine build_c_species_names(params, c_names_flat, n_len)
      type(case_params_t), intent(in) :: params
      character(kind=c_char), allocatable, intent(out) :: c_names_flat(:)
      integer, intent(out) :: n_len

      integer :: k, j, nsp

      nsp = max(1, params%nspecies)
      n_len = len(params%species_name(1))
      allocate(c_names_flat(n_len * nsp))
      c_names_flat = ' '

      do k = 1, nsp
         do j = 1, n_len
            c_names_flat((k-1)*n_len + j) = char(iachar(params%species_name(k)(j:j)), kind=c_char)
         end do
      end do
   end subroutine build_c_species_names