fortrangoingonforty/fgof-jobs / ca87d2d

Browse files

Add jobs examples

Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
ca87d2df98617419318e8f2d4c3dddd5d6fc69b9
Parents
76140d5
Tree
1211aef

4 changed files

StatusFile+-
M .github/workflows/ci.yml 9 0
A example/job_lifecycle_demo.f90 23 0
A example/pipeline_tracking_demo.f90 31 0
M fpm.toml 1 0
.github/workflows/ci.ymlmodified
@@ -68,3 +68,12 @@ jobs:
6868
 
6969
       - name: Run test suite
7070
         run: fpm test --verbose
71
+
72
+      - name: Run examples
73
+        run: |
74
+          lifecycle_bin=$(find build -type f -path '*/example/job_lifecycle_demo' | head -n 1)
75
+          pipeline_bin=$(find build -type f -path '*/example/pipeline_tracking_demo' | head -n 1)
76
+          test -n "$lifecycle_bin"
77
+          test -n "$pipeline_bin"
78
+          "$lifecycle_bin"
79
+          "$pipeline_bin"
example/job_lifecycle_demo.f90added
@@ -0,0 +1,23 @@
1
+program job_lifecycle_demo
2
+  use fgof_jobs, only : &
3
+    attach_job, &
4
+    complete_job, &
5
+    configure_job, &
6
+    job_exit_result, &
7
+    job_is_finished, &
8
+    job_needs_cleanup, &
9
+    make_job_spec
10
+  use fgof_jobs_types, only : job_handle, job_spec
11
+  implicit none
12
+
13
+  type(job_spec) :: spec
14
+  type(job_handle) :: handle
15
+
16
+  spec = make_job_spec("worker")
17
+  call configure_job(handle, spec)
18
+  call attach_job(handle, 41)
19
+  call complete_job(handle, job_exit_result(0, pid=41, process_group=41))
20
+
21
+  write (*, '(a,l1)') "finished=", job_is_finished(handle)
22
+  write (*, '(a,l1)') "cleanup=", job_needs_cleanup(handle)
23
+end program job_lifecycle_demo
example/pipeline_tracking_demo.f90added
@@ -0,0 +1,31 @@
1
+program pipeline_tracking_demo
2
+  use fgof_jobs, only : &
3
+    FGOF_JOBS_SIGNAL_SCOPE_GROUP, &
4
+    attach_job, &
5
+    attach_pipeline_members, &
6
+    complete_job, &
7
+    configure_job, &
8
+    job_exit_result, &
9
+    job_is_finished, &
10
+    job_stop_result, &
11
+    make_job_spec, &
12
+    observe_wait_result, &
13
+    pipeline_member_count
14
+  use fgof_jobs_types, only : job_handle, job_spec
15
+  implicit none
16
+
17
+  type(job_spec) :: spec
18
+  type(job_handle) :: handle
19
+
20
+  spec = make_job_spec("pipeline-head", signal_scope=FGOF_JOBS_SIGNAL_SCOPE_GROUP)
21
+  call configure_job(handle, spec)
22
+  call attach_job(handle, 101)
23
+  call attach_pipeline_members(handle, [101, 102, 103])
24
+  call observe_wait_result(handle, job_stop_result(20, pid=102, process_group=101))
25
+  call complete_job(handle, job_exit_result(0, pid=101, process_group=101))
26
+  call complete_job(handle, job_exit_result(0, pid=102, process_group=101))
27
+  call complete_job(handle, job_exit_result(0, pid=103, process_group=101))
28
+
29
+  write (*, '(a,i0)') "members=", pipeline_member_count(handle)
30
+  write (*, '(a,l1)') "finished=", job_is_finished(handle)
31
+end program pipeline_tracking_demo
fpm.tomlmodified
@@ -9,6 +9,7 @@ description = "Background job and wait-model helpers for modern Fortran"
99
 [build]
1010
 auto-executables = false
1111
 auto-tests = true
12
+auto-examples = true
1213
 
1314
 [install]
1415
 library = true