Commit 56c95fb4 authored by Kim, Jungwon's avatar Kim, Jungwon

dimension -> c_ptr in fortran

parent ec22bf4b
......@@ -24,7 +24,7 @@ MODULE PAPYRUS
USE, INTRINSIC :: ISO_C_BINDING
INTEGER(C_INT), VALUE, INTENT(IN) :: ARGC
TYPE(C_PTR), VALUE, INTENT(IN) :: ARGV
CHARACTER(C_CHAR), DIMENSION(*), INTENT(IN) :: REPOSITORY
TYPE(C_PTR), VALUE, INTENT(IN) :: REPOSITORY
END FUNCTION PAPYRUSKV_INIT_CBIND
INTEGER(C_INT) FUNCTION PAPYRUSKV_FINALIZE_CBIND() &
......@@ -35,7 +35,7 @@ MODULE PAPYRUS
INTEGER(C_INT) FUNCTION PAPYRUSKV_OPEN_CBIND(NAME, FLAGS, OPT, DB) &
BIND(C, NAME='papyruskv_open')
USE, INTRINSIC :: ISO_C_BINDING
CHARACTER(C_CHAR), DIMENSION(*), INTENT(IN) :: NAME
TYPE(C_PTR), VALUE, INTENT(IN) :: NAME
INTEGER(C_INT), VALUE, INTENT(IN) :: FLAGS
TYPE(C_PTR), VALUE, INTENT(IN) :: OPT
INTEGER(C_INT), INTENT(OUT) :: DB
......@@ -51,9 +51,9 @@ MODULE PAPYRUS
BIND(C, NAME='papyruskv_put')
USE, INTRINSIC :: ISO_C_BINDING
INTEGER(C_INT), VALUE, INTENT(IN) :: DB
CHARACTER(C_CHAR), DIMENSION(*), INTENT(IN) :: KEY
TYPE(C_PTR), VALUE, INTENT(IN) :: KEY
INTEGER(C_SIZE_T), VALUE, INTENT(IN) :: KEYLEN
CHARACTER(C_CHAR), DIMENSION(*), INTENT(IN) :: VAL
TYPE(C_PTR), VALUE, INTENT(IN) :: VAL
INTEGER(C_SIZE_T), VALUE, INTENT(IN) :: VALLEN
END FUNCTION PAPYRUSKV_PUT_CBIND
......@@ -61,7 +61,7 @@ MODULE PAPYRUS
BIND(C, NAME='papyruskv_get')
USE, INTRINSIC :: ISO_C_BINDING
INTEGER(C_INT), VALUE, INTENT(IN) :: DB
CHARACTER(C_CHAR), DIMENSION(*), INTENT(IN) :: KEY
TYPE(C_PTR), VALUE, INTENT(IN) :: KEY
INTEGER(C_SIZE_T), VALUE, INTENT(IN) :: KEYLEN
TYPE(C_PTR), INTENT(OUT) :: VAL
INTEGER(C_SIZE_T), INTENT(OUT) :: VALLEN
......@@ -71,7 +71,7 @@ MODULE PAPYRUS
BIND(C, NAME='papyruskv_delete')
USE, INTRINSIC :: ISO_C_BINDING
INTEGER(C_INT), VALUE, INTENT(IN) :: DB
CHARACTER(C_CHAR), DIMENSION(*), INTENT(IN) :: KEY
TYPE(C_PTR), VALUE, INTENT(IN) :: KEY
INTEGER(C_SIZE_T), VALUE, INTENT(IN) :: KEYLEN
END FUNCTION PAPYRUSKV_DELETE_CBIND
......@@ -99,7 +99,7 @@ MODULE PAPYRUS
BIND(C, NAME='papyruskv_signal_notify')
USE, INTRINSIC :: ISO_C_BINDING
INTEGER(C_INT), VALUE, INTENT(IN) :: SIGNUM
INTEGER(C_INT), DIMENSION(*), INTENT(IN) :: RANKS
TYPE(C_PTR), VALUE, INTENT(IN) :: RANKS
INTEGER(C_INT), VALUE, INTENT(IN) :: COUNT
END FUNCTION PAPYRUSKV_SIGNAL_NOTIFY_CBIND
......@@ -107,7 +107,7 @@ MODULE PAPYRUS
BIND(C, NAME='papyruskv_signal_wait')
USE, INTRINSIC :: ISO_C_BINDING
INTEGER(C_INT), VALUE, INTENT(IN) :: SIGNUM
INTEGER(C_INT), DIMENSION(*), INTENT(IN) :: RANKS
TYPE(C_PTR), VALUE, INTENT(IN) :: RANKS
INTEGER(C_INT), VALUE, INTENT(IN) :: COUNT
END FUNCTION PAPYRUSKV_SIGNAL_WAIT_CBIND
......@@ -136,15 +136,15 @@ MODULE PAPYRUS
BIND(C, NAME='papyruskv_checkpoint')
USE, INTRINSIC :: ISO_C_BINDING
INTEGER(C_INT), VALUE, INTENT(IN) :: DB
CHARACTER(C_CHAR), DIMENSION(*), INTENT(IN) :: PATH
TYPE(C_PTR), VALUE, INTENT(IN) :: PATH
INTEGER(C_INT), INTENT(OUT) :: EVENT
END FUNCTION PAPYRUSKV_CHECKPOINT_CBIND
INTEGER(C_INT) FUNCTION PAPYRUSKV_RESTART_CBIND(PATH, NAME, FLAGS, OPT, DB, EVENT) &
BIND(C, NAME='papyruskv_restart')
USE, INTRINSIC :: ISO_C_BINDING
CHARACTER(C_CHAR), DIMENSION(*), INTENT(IN) :: PATH
CHARACTER(C_CHAR), DIMENSION(*), INTENT(IN) :: NAME
TYPE(C_PTR), VALUE, INTENT(IN) :: PATH
TYPE(C_PTR), VALUE, INTENT(IN) :: NAME
INTEGER(C_INT), VALUE, INTENT(IN) :: FLAGS
TYPE(C_PTR), VALUE, INTENT(IN) :: OPT
INTEGER(C_INT), INTENT(OUT) :: DB
......@@ -165,7 +165,9 @@ MODULE PAPYRUS
SUBROUTINE PAPYRUSKV_INIT(REPOSITORY, IERROR)
CHARACTER, DIMENSION(*), INTENT(IN) :: REPOSITORY
INTEGER, INTENT(OUT) :: IERROR
IERROR = PAPYRUSKV_INIT_CBIND(0, C_NULL_PTR, REPOSITORY)
TYPE(C_PTR) :: REPOSITORY_CPTR
REPOSITORY_CPTR = C_LOC(REPOSITORY)
IERROR = PAPYRUSKV_INIT_CBIND(0, C_NULL_PTR, REPOSITORY_CPTR)
END SUBROUTINE PAPYRUSKV_INIT
SUBROUTINE PAPYRUSKV_FINALIZE(IERROR)
......@@ -178,7 +180,9 @@ MODULE PAPYRUS
INTEGER, INTENT(IN) :: FLAGS
INTEGER, INTENT(OUT) :: DB
INTEGER, INTENT(OUT) :: IERROR
IERROR = PAPYRUSKV_OPEN_CBIND(NAME, FLAGS, C_NULL_PTR, DB)
TYPE(C_PTR) :: NAME_C_PTR
NAME_C_PTR = C_LOC(NAME)
IERROR = PAPYRUSKV_OPEN_CBIND(NAME_C_PTR, FLAGS, C_NULL_PTR, DB)
END SUBROUTINE PAPYRUSKV_OPEN
SUBROUTINE PAPYRUSKV_CLOSE(DB, IERROR)
......@@ -194,7 +198,7 @@ MODULE PAPYRUS
CHARACTER, DIMENSION(*), INTENT(IN) :: VAL
INTEGER(KIND=8), INTENT(IN) :: VALLEN
INTEGER, INTENT(OUT) :: IERROR
IERROR = PAPYRUSKV_PUT_CBIND(DB, KEY, KEYLEN, VAL, VALLEN)
IERROR = PAPYRUSKV_PUT_CBIND(DB, C_LOC(KEY), KEYLEN, C_LOC(VAL), VALLEN)
END SUBROUTINE PAPYRUSKV_PUT
SUBROUTINE PAPYRUSKV_GET(DB, KEY, KEYLEN, VAL, VALLEN, IERROR)
......@@ -213,7 +217,7 @@ MODULE PAPYRUS
VAL_CPTR = C_NULL_PTR
VAL_NULL_PTR = .TRUE.
END IF
IERROR = PAPYRUSKV_GET_CBIND(DB, KEY, KEYLEN, VAL_CPTR, VALLEN)
IERROR = PAPYRUSKV_GET_CBIND(DB, C_LOC(KEY), KEYLEN, VAL_CPTR, VALLEN)
IF (VAL_NULL_PTR) THEN
CALL C_F_POINTER(VAL_CPTR, VAL, [VALLEN])
END IF
......@@ -224,15 +228,14 @@ MODULE PAPYRUS
CHARACTER, DIMENSION(*), INTENT(IN) :: KEY
INTEGER(KIND=8), INTENT(IN) :: KEYLEN
INTEGER, INTENT(OUT) :: IERROR
IERROR = PAPYRUSKV_DELETE_CBIND(DB, KEY, KEYLEN)
IERROR = PAPYRUSKV_DELETE_CBIND(DB, C_LOC(KEY), KEYLEN)
END SUBROUTINE PAPYRUSKV_DELETE
SUBROUTINE PAPYRUSKV_FREE(VAL, IERROR)
CHARACTER, POINTER, INTENT(INOUT) :: VAL(:)
INTEGER, INTENT(OUT) :: IERROR
TYPE(C_PTR) :: VAL_CPTR
VAL_CPTR = C_LOC(VAL)
IERROR = PAPYRUSKV_FREE_CBIND(VAL_CPTR)
IERROR = PAPYRUSKV_FREE_CBIND(C_LOC(VAL))
NULLIFY(VAL)
END SUBROUTINE PAPYRUSKV_FREE
......@@ -255,7 +258,7 @@ MODULE PAPYRUS
INTEGER, DIMENSION(*), INTENT(IN) :: RANKS
INTEGER, INTENT(IN) :: COUNT
INTEGER, INTENT(OUT) :: IERROR
IERROR = PAPYRUSKV_SIGNAL_NOTIFY_CBIND(SIGNUM, RANKS, COUNT)
IERROR = PAPYRUSKV_SIGNAL_NOTIFY_CBIND(SIGNUM, C_LOC(RANKS), COUNT)
END SUBROUTINE PAPYRUSKV_SIGNAL_NOTIFY
SUBROUTINE PAPYRUSKV_SIGNAL_WAIT(SIGNUM, RANKS, COUNT, IERROR)
......@@ -263,7 +266,7 @@ MODULE PAPYRUS
INTEGER, DIMENSION(*), INTENT(IN) :: RANKS
INTEGER, INTENT(IN) :: COUNT
INTEGER, INTENT(OUT) :: IERROR
IERROR = PAPYRUSKV_SIGNAL_WAIT_CBIND(SIGNUM, RANKS, COUNT)
IERROR = PAPYRUSKV_SIGNAL_WAIT_CBIND(SIGNUM, C_LOC(RANKS), COUNT)
END SUBROUTINE PAPYRUSKV_SIGNAL_WAIT
SUBROUTINE PAPYRUSKV_CONSISTENCY(DB, CONSISTENCY, IERROR)
......@@ -292,7 +295,7 @@ MODULE PAPYRUS
CHARACTER, DIMENSION(*), INTENT(IN) :: PATH
INTEGER, INTENT(OUT) :: EVENT
INTEGER, INTENT(OUT) :: IERROR
IERROR = PAPYRUSKV_CHECKPOINT_CBIND(DB, PATH, EVENT)
IERROR = PAPYRUSKV_CHECKPOINT_CBIND(DB, C_LOC(PATH), EVENT)
END SUBROUTINE PAPYRUSKV_CHECKPOINT
SUBROUTINE PAPYRUSKV_RESTART(PATH, NAME, FLAGS, DB, EVENT, IERROR)
......@@ -302,7 +305,7 @@ MODULE PAPYRUS
INTEGER, INTENT(OUT) :: DB
INTEGER, INTENT(OUT) :: EVENT
INTEGER, INTENT(OUT) :: IERROR
IERROR = PAPYRUSKV_RESTART_CBIND(PATH, NAME, FLAGS, C_NULL_PTR, DB, EVENT)
IERROR = PAPYRUSKV_RESTART_CBIND(C_LOC(PATH), C_LOC(NAME), FLAGS, C_NULL_PTR, DB, EVENT)
END SUBROUTINE PAPYRUSKV_RESTART
SUBROUTINE PAPYRUSKV_WAIT(DB, EVENT, IERROR)
......
......@@ -11,7 +11,7 @@ PROGRAM TEST14_FORTRAN
INTEGER(KIND=8) :: KEYLEN, VALLEN
CALL MPI_INIT_THREAD(MPI_THREAD_MULTIPLE, PROVIDED, IERROR)
CALL PAPYRUSKV_INIT('./pkv_repo'//CHAR(0), IERROR)
CALL PAPYRUSKV_INIT('./pkv_repo', IERROR)
IF (IERROR /= PAPYRUSKV_OK) THEN
PRINT*, 'FAILED'
ENDIF
......@@ -38,7 +38,7 @@ PROGRAM TEST14_FORTRAN
PEER = RANK + 1
ENDIF
CALL PAPYRUSKV_OPEN('TEST_DB'//CHAR(0), IOR(PAPYRUSKV_CREATE, PAPYRUSKV_RDWR), DB, IERROR)
CALL PAPYRUSKV_OPEN('TEST_DB', IOR(PAPYRUSKV_CREATE, PAPYRUSKV_RDWR), DB, IERROR)
IF (IERROR /= PAPYRUSKV_OK) THEN
PRINT*, 'FAILED'
ENDIF
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment