west_version.f90.in 1.8 KB
Newer Older
Marco Govoni's avatar
Marco Govoni committed
1
!
Victor Yu's avatar
Victor Yu committed
2
! Copyright (C) 2015-2019 M. Govoni
Marco Govoni's avatar
Marco Govoni committed
3
! This file is distributed under the terms of the
Marco Govoni's avatar
Marco Govoni committed
4
! GNU General Public License. See the file `LICENSE'
Marco Govoni's avatar
Marco Govoni committed
5
6
7
! in the root directory of the present distribution,
! or http://www.gnu.org/copyleft/gpl.txt .
!
Marco Govoni's avatar
Marco Govoni committed
8
9
! This file is part of WEST.
!
Victor Yu's avatar
Victor Yu committed
10
! Contributors to this file:
Marco Govoni's avatar
Marco Govoni committed
11
12
13
14
15
16
! Marco Govoni
!
!-----------------------------------------------------------------------
MODULE west_version
  !-----------------------------------------------------------------------
  !
17
18
  USE forpy_mod, ONLY: list
  !
Marco Govoni's avatar
Marco Govoni committed
19
20
21
22
  IMPLICIT NONE
  !
  SAVE
  !
Victor Yu's avatar
Victor Yu committed
23
24
25
26
27
  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
28
29
30
31
  !
  CONTAINS
  !
  SUBROUTINE start_forpy()
Victor Yu's avatar
Victor Yu committed
32
33
34
     !
     USE forpy_mod, ONLY: forpy_initialize,get_sys_path,module_py,import_py,forpy_finalize
     !
35
     IMPLICIT NONE
Victor Yu's avatar
Victor Yu committed
36
     !
37
     INTEGER :: IERR
Victor Yu's avatar
Victor Yu committed
38
     TYPE(module_py) :: pymod
39
     !
Victor Yu's avatar
Victor Yu committed
40
     IERR = forpy_initialize(forpy_use_numpy)
41
42
43
44
45
     IF(IERR/=0) CALL errore('forpy','Err: cannot init forpy',1)
     !
     IERR = get_sys_path(paths)
     IF(IERR/=0) CALL errore('forpy','Err: cannot get_sys_path',1)
     !
Marco Govoni's avatar
Marco Govoni committed
46
     IERR = paths%append(TRIM(ADJUSTL(west_topdir))//"/Pytools")
Victor Yu's avatar
Victor Yu committed
47
48
49
50
51
52
53
54
55
56
     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
     !
57
58
59
  END SUBROUTINE
  !
  SUBROUTINE end_forpy()
Victor Yu's avatar
Victor Yu committed
60
     !
61
     USE forpy_mod, ONLY: forpy_finalize
Victor Yu's avatar
Victor Yu committed
62
     !
63
     IMPLICIT NONE
Victor Yu's avatar
Victor Yu committed
64
     !
65
66
     CALL paths%destroy()
     CALL forpy_finalize()
Victor Yu's avatar
Victor Yu committed
67
     !
68
  END SUBROUTINE
Marco Govoni's avatar
Marco Govoni committed
69
  !
Victor Yu's avatar
Victor Yu committed
70
END MODULE