summaryrefslogtreecommitdiffstats
path: root/fortran/src/H5f90global.F90
diff options
context:
space:
mode:
authorScot Breitenfeld <brtnfld@hdfgroup.org>2015-04-15 22:03:33 (GMT)
committerScot Breitenfeld <brtnfld@hdfgroup.org>2015-04-15 22:03:33 (GMT)
commit7984de553e8ad2bbafa0840b207e762e2ed68f58 (patch)
treeb3c6bbddfb64fd00628d842bb804c9105b2d0cc5 /fortran/src/H5f90global.F90
parent9f4ed2197a8ce8c99ee84c7a7be9ecfa42d21044 (diff)
downloadhdf5-7984de553e8ad2bbafa0840b207e762e2ed68f58.zip
hdf5-7984de553e8ad2bbafa0840b207e762e2ed68f58.tar.gz
hdf5-7984de553e8ad2bbafa0840b207e762e2ed68f58.tar.bz2
[svn-r26819] Updated H5A, H5E, H5D, H5F APIs to F2003, added ifdef for parallel.
Diffstat (limited to 'fortran/src/H5f90global.F90')
-rw-r--r--fortran/src/H5f90global.F9067
1 files changed, 65 insertions, 2 deletions
diff --git a/fortran/src/H5f90global.F90 b/fortran/src/H5f90global.F90
index 6cb35c0..ac368d1 100644
--- a/fortran/src/H5f90global.F90
+++ b/fortran/src/H5f90global.F90
@@ -942,7 +942,9 @@ MODULE H5GLOBAL
CONTAINS
- SUBROUTINE C2F_string(c_string, f_string)
+ ! Copy a c string to a Fortran string
+
+ SUBROUTINE H5_Fortran_string_c2f(c_string, f_string)
USE, INTRINSIC :: ISO_C_BINDING
IMPLICIT NONE
@@ -966,7 +968,68 @@ CONTAINS
f_string(1:c_len) = c_string(1:c_len)
f_string(c_len+1:f_len) =' '
ENDIF
- END SUBROUTINE C2F_string
+ END SUBROUTINE H5_Fortran_string_c2f
+
+ SUBROUTINE H5_Fortran_string_f2c(f_string, c_string)
+
+ USE, INTRINSIC :: ISO_C_BINDING
+ IMPLICIT NONE
+ CHARACTER(LEN=*), INTENT(IN) :: f_string
+ CHARACTER(KIND=C_CHAR, LEN=*), INTENT(OUT) :: c_string
+ INTEGER(SIZE_T) :: c_len, f_len
+
+ c_string = TRIM(f_string)//C_NULL_CHAR
+
+ END SUBROUTINE H5_Fortran_string_f2c
+
+
+! Copy Fortran string to C charater array, assuming the C array is one-char
+! longer for the terminating null char.
+! fstring : the Fortran input string
+! cstring : the C output string (with memory already allocated)
+!!$subroutine MPIR_Fortran_string_f2c(fstring, cstring)
+!!$ implicit none
+!!$ character(len=*), intent(in) :: fstring
+!!$ character(kind=c_char), intent(out) :: cstring(:)
+!!$ integer :: i, j
+!!$ logical :: met_non_blank
+!!$
+!!$ ! Trim the leading and trailing blank characters
+!!$ j = 1
+!!$ met_non_blank = .false.
+!!$ do i = 1, len_trim(fstring)
+!!$ if (met_non_blank) then
+!!$ cstring(j) = fstring(i:i)
+!!$ j = j + 1
+!!$ else if (fstring(i:i) /= ' ') then
+!!$ met_non_blank = .true.
+!!$ cstring(j) = fstring(i:i)
+!!$ j = j + 1
+!!$ end if
+!!$ end do
+!!$
+!!$ cstring(j) = C_NULL_CHAR
+!!$end subroutine MPIR_Fortran_string_f2c
+!!$
+!!$! Copy C charater array to Fortran string
+!!$subroutine MPIR_Fortran_string_c2f(cstring, fstring)
+!!$ implicit none
+!!$ character(kind=c_char), intent(in) :: cstring(:)
+!!$ character(len=*), intent(out) :: fstring
+!!$ integer :: i, j, length
+!!$
+!!$ i = 1
+!!$ do while (cstring(i) /= C_NULL_CHAR)
+!!$ fstring(i:i) = cstring(i)
+!!$ i = i + 1
+!!$ end do
+!!$
+!!$ ! Zero out the trailing characters
+!!$ length = len(fstring)
+!!$ do j = i, length
+!!$ fstring(j:j) = ' '
+!!$ end do
+!!$end subroutine MPIR_Fortran_string_c2f
END MODULE H5GLOBAL