Commit 53adb18d authored by Victor Yu's avatar Victor Yu
Browse files

Update Forpy initialization

* By default Forpy is no longer initialized with Numpy support, as the
  Numpy features are currently not used.
* Right after initialization, test whether import module works. If not,
  print an error message and stop. Before this commit, the code may
  segfaults without giving any error message.
parent e20e0db3
......@@ -20,19 +20,24 @@ MODULE west_version
!
SAVE
!
CHARACTER (LEN=6) :: west_version_number = 'checkit'
CHARACTER (LEN=512) :: west_git_revision = 'unknown'
CHARACTER (LEN=512) :: west_topdir = 'unset'
CHARACTER(LEN=*), PARAMETER :: west_version_number = 'checkit'
CHARACTER(LEN=*), PARAMETER :: west_git_revision = 'unknown'
CHARACTER(LEN=*), PARAMETER :: west_topdir = 'unset'
LOGICAL, PARAMETER :: forpy_use_numpy = .FALSE.
TYPE(list) :: paths
!
CONTAINS
!
SUBROUTINE start_forpy()
USE forpy_mod, ONLY: forpy_initialize, get_sys_path
!
USE forpy_mod, ONLY: forpy_initialize,get_sys_path,module_py,import_py,forpy_finalize
!
IMPLICIT NONE
!
INTEGER :: IERR
TYPE(module_py) :: pymod
!
IERR = forpy_initialize()
IERR = forpy_initialize(forpy_use_numpy)
IF(IERR/=0) CALL errore('forpy','Err: cannot init forpy',1)
!
IERR = get_sys_path(paths)
......@@ -40,13 +45,26 @@ MODULE west_version
!
IERR = paths%append(TRIM(ADJUSTL(west_topdir))//"/Pytools")
IF(IERR/=0) CALL errore('forpy','Err: cannot append paths',1)
!
! Test: import west_fetch_input
!
IERR = import_py(pymod,'west_fetch_input')
IF(IERR/=0) THEN
CALL forpy_finalize()
CALL errore('forpy','Err: cannot import module',1)
ENDIF
!
END SUBROUTINE
!
SUBROUTINE end_forpy()
!
USE forpy_mod, ONLY: forpy_finalize
!
IMPLICIT NONE
!
CALL paths%destroy()
CALL forpy_finalize()
!
END SUBROUTINE
!
END MODULE
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