查找Fortran可分配字符串的长度

时间:2019-04-16 00:00:29

标签: fortran

如何在子例程path中找到动态分配的对象newcase的大小?

  subroutine newcase(path)

  character(:, kind=c_char),
 &     allocatable                     :: path
  integer(kind=c_int)                  :: sizepath

  write(*,*) "Trim Path: ", path, ":"
  this% object = newcase_c(path, sizepath)

  end subroutine newcase

在调用子例程时分配对象,如下所示:

  character(256, kind=c_char)   :: cwd
  character(:, kind=c_char)
 & , allocatable                :: trimpath

  call GETCWD(cwd)
  trimpath = trim(cwd)

  call newcase(trimpath)

1 个答案:

答案 0 :(得分:1)

我使用len来查找path的长度。文档为here