fortran 去掉字符两边的空格
·

len 字符串的长度
trim 去掉字符串右边的空格
len_trim 不算字符串右边的空格的字符串的长度
lnblnk 字符串最后一个非空格的字符的位置
index/scan 寻找指定字符的在字符串出现的位置
verify 第一个非指定字符在字符串出现的位置
adjustl 移动字符串左对齐,去掉打头的空格 adjustr 移动字符串右对齐,去掉尾部的空格
lge/lle 字符串大小对比
repeat 计算字符在字符串中重复出现的次数
参数Doc自己定义的是80,肯酌情修改(character*80,Doc可以使用 CHARACTER*(*) doc 替换,不用再定义其长度)
!=======================================================================
! Str_Doc
! 將字符串转化避免传入接口中乱码
! 该Doc将通过导入导出作为接口的参数使用C++处理
!=======================================================================
SUBROUTINE Str_Doc(Doc)
character*80,Doc
nlen = LEN_TRIM(Doc)
Doc = Doc(1:nlen)//char(0)
end subroutine Str_Doc
!=======================================================================
! Str_DocNoBlank
! 去掉数字字符串中的空格
! 对于字符后面有空格的需要有自定义的结束标志,我定义为 @
! 对于不需要结束标志的进行直接去除即可
! 根据最后是否需要作为字符传入C++,接上 char(0)
!=======================================================================
SUBROUTINE Str_DocNoBlank(Doc)
character Doc*80
Doc = adjustl(Doc)
nlen = LEN_TRIM(Doc)
Doc = trim(doc)
!num = trim(adjustl(Doc))
nlen = nlen + 1
Doc = Doc(1:nlen)
end subroutine Str_DocNoBlank
!=======================================================================
! Str_Str_Cat
! 字符串拼接,并且去掉不需要的空格,
! 比如:数字字符串中的空格需要全部去掉,字符串有的不需要去掉
! 对于字符后面有空格的需要有自定义的结束标志,我定义为 @
! 对于不需要结束标志的进行直接去除即可
! 根据最后是否需要作为字符传入C++,接上 char(0)
!=======================================================================
SUBROUTINE Str_Cat(Doc,tempDoc)
character Doc*80,tempDoc*80,cDoc*1
INTEGER mumber,endindex,endflag
endindex = LEN_TRIM(Doc)
cDoc = Doc(endindex:endindex)
endflag = IACHAR(cDoc)
if(endflag.eq.64)then
nlen = LEN_TRIM(Doc)
nlen = nlen - 1
else
nlen = LEN_TRIM(Doc)
nlen = nlen
endif
endindex = LEN_TRIM(tempDoc)
cDoc = tempDoc(endindex:endindex)
endflag = IACHAR(cDoc)
if(endflag.eq.64)then
nlen1 = LEN_TRIM(tempDoc)
!nlen1 = nlen1 - 1
mumber = nlen + nlen1
else
nlen1 = LEN_TRIM(tempDoc)
nlen1 = nlen1 + 1
mumber = nlen + nlen1
endif
if(mumber.lt.80) then
Doc = Doc(1:nlen)//tempDoc(1:nlen1)
!Doc = Doc(1:mumber)//char(0)
endif
end subroutine Str_Cat
更多推荐



所有评论(0)