Skip to content

Commit

Permalink
Update interface of prif_init based on latest design doc choices.
Browse files Browse the repository at this point in the history
  • Loading branch information
ktras committed Dec 13, 2023
1 parent a7c77d6 commit 26350b5
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 12 deletions.
5 changes: 3 additions & 2 deletions example/hello.f90
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ program hello_world
use prif, only : prif_init, this_image => prif_this_image, num_images => prif_num_images, prif_stop
implicit none

integer :: me, num_imgs
integer :: init_exit_code, me, num_imgs

if (prif_init() /= 0) error stop "caffeinate returned a non-zero exit code"
call prif_init(init_exit_code)
if (init_exit_code /= 0) error stop "caffeinate returned a non-zero exit code"

call this_image(image_index=me)
call num_images(image_count=num_imgs)
Expand Down
5 changes: 4 additions & 1 deletion example/support-test/error_stop_character_code.f90
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ program error_stop_character_code
use prif, only : prif_init, prif_error_stop
implicit none

if (prif_init() /= 0) error stop "caffeinate returned a non-zero exit_code"
integer :: init_exit_code

call prif_init(init_exit_code)
if (init_exit_code /= 0) error stop "caffeinate returned a non-zero exit_code"

call prif_error_stop(stop_code_char="Oh snap!")

Expand Down
5 changes: 4 additions & 1 deletion example/support-test/error_stop_integer_code.f90
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ program error_stop_integer_code
use prif, only : prif_init, prif_error_stop
implicit none

if (prif_init() /= 0) error stop "caffeinate returned a non-zero exit_code"
integer :: init_exit_code

call prif_init(init_exit_code)
if (init_exit_code /= 0) error stop "caffeinate returned a non-zero exit_code"

call prif_error_stop(1)

Expand Down
5 changes: 4 additions & 1 deletion example/support-test/stop_with_integer_code.f90
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ program stop_with_no_code
use prif, only : prif_init, prif_stop
implicit none

if (prif_init() /= 0) error stop "caffeinate returned a non-zero exit_code"
integer :: init_exit_code

call prif_init(init_exit_code)
if (init_exit_code /= 0) error stop "caffeinate returned a non-zero exit_code"

call prif_stop(1)

Expand Down
5 changes: 4 additions & 1 deletion example/support-test/stop_with_no_code.f90
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ program stop_with_no_code
use prif, only : prif_init, prif_stop
implicit none

if (prif_init() /= 0) error stop "caffeinate returned a non-zero exit_code"
integer :: init_exit_code

call prif_init(init_exit_code)
if (init_exit_code /= 0) error stop "caffeinate returned a non-zero exit_code"

call prif_stop

Expand Down
9 changes: 5 additions & 4 deletions src/caffeine/program_startup_m.f90
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
! Copyright (c), The Regents of the University of California
! Terms of use are as specified in LICENSE.txt
module program_startup_m
use iso_c_binding, only : c_int
use team_type_m, only: prif_team_type
implicit none

Expand All @@ -11,10 +12,10 @@ module program_startup_m

interface

module function prif_init() result(exit_code)
implicit none
integer exit_code
end function
module subroutine prif_init(exit_code)
implicit none
integer(c_int), intent(out) :: exit_code
end subroutine

end interface

Expand Down
2 changes: 1 addition & 1 deletion src/caffeine/program_startup_s.F90
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
! Copyright (c), The Regents of the University of California
! Terms of use are as specified in LICENSE.txt
submodule(program_startup_m) program_startup_s
use iso_c_binding, only : c_int, c_loc, c_char, c_null_char
use iso_c_binding, only : c_loc, c_char, c_null_char
use synchronization_m, only : prif_sync_all
use caffeine_h_m, only : caf_caffeinate, caf_decaffeinate
use program_termination_m, only: prif_error_stop
Expand Down
4 changes: 3 additions & 1 deletion test/a00_caffeinate_test.f90
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ function check_caffeination() result(result_)
type(result_t) :: result_

integer, parameter :: successful_initiation = 0
integer :: init_exit_code

result_ = assert_that(prif_init() == successful_initiation)
call prif_init(init_exit_code)
result_ = assert_that(init_exit_code == successful_initiation)
end function

end module a00_caffeinate_test

0 comments on commit 26350b5

Please sign in to comment.