Skip to content

Commit f849c52

Browse files
committed
misc: Create getargs Op inside function
1 parent 1b5c3ac commit f849c52

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

devito/petsc/initialize.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,12 @@ def PetscInitialize(clargs=sys.argv):
5555
_petsc_initialized = True
5656

5757

58-
with switchconfig(language='petsc'):
59-
op_get_args = Operator(
60-
[PetscEq(dummy, GetArgs(dummy))],
61-
name='kernel_get_args', opt='noop'
62-
)
63-
64-
6558
def PetscGetArgs():
59+
with switchconfig(language='petsc'):
60+
op_get_args = Operator(
61+
[PetscEq(dummy, GetArgs(dummy))],
62+
name='kernel_get_args', opt='noop'
63+
)
6664
argc_ptr = c_int()
6765
argv_ptr = (POINTER(c_char_p))()
6866
op_get_args.apply(argc=byref(argc_ptr), argv=byref(argv_ptr))

examples/petsc/init_test.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import os
2-
from devito.petsc.initialize import PetscInitialize
2+
from devito.petsc.initialize import PetscInitialize, PetscGetArgs
33
from devito import configuration
44
configuration['compiler'] = 'custom'
55
os.environ['CC'] = 'mpicc'
66

77
PetscInitialize()
88
print("helloworld")
9+
10+
PetscGetArgs()

0 commit comments

Comments
 (0)