c_to_f_string Subroutine

private subroutine c_to_f_string(s, f)

Arguments

Type IntentOptional Attributes Name
character(kind=C_CHAR, len=1), intent(in) :: s(*)
character(len=:), intent(out), allocatable :: f

Called by

proc~~c_to_f_string~~CalledByGraph proc~c_to_f_string c_to_f_string proc~init_gvec_to_gene_c init_gvec_to_gene_c proc~init_gvec_to_gene_c->proc~c_to_f_string proc~write_data_to_vtk_c write_data_to_vtk_c proc~write_data_to_vtk_c->proc~c_to_f_string

Source Code

  subroutine c_to_f_string(s,f)
    character(kind=C_CHAR, len=1), intent(in) :: s(*)
    character(len=:), allocatable, intent(out) :: f
    integer :: nchars

    nchars = 0
    do while( s(nchars+1).ne.C_NULL_CHAR )
       nchars = nchars + 1
    end do

    allocate(character(len=nchars) :: f)
    if( storage_size(f).eq.storage_size(s)*nchars) then
       f = transfer(s(1:nchars), f)
    else
       stop "can't transfer C_CHAR array to fortran character, do explicit copy!"
    end if
  end subroutine c_to_f_string