Skip to content

Commit ed00a87

Browse files
committed
Setup access to tasks
1 parent 62279ec commit ed00a87

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

fortran/solver/src/task.f90

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ module task_mod
22
implicit none
33
private
44
type :: task_t
5+
character(len=:), allocatable :: API_URL
6+
character(len=:), allocatable :: API_ID
57
character(len=:), allocatable :: name
68
integer :: n_rooms = 0
79
integer :: max_length = 0
@@ -14,6 +16,7 @@ module task_mod
1416
subroutine init(task, name)
1517
class(task_t), intent(inout) :: task
1618
character(len=*) :: name
19+
call setup_API(task)
1720
task%name = trim(name)
1821
select case(task%name)
1922
case ("probatio")
@@ -74,5 +77,25 @@ subroutine init(task, name)
7477
else
7578
error stop "Unknown task kind"
7679
end if
80+
contains
81+
subroutine setup_API(task)
82+
class(task_t), intent(inout) :: task
83+
integer :: envvarlen, stat
84+
call get_environment_variable("SERVER_URL", length = envvarlen, status = stat)
85+
if (stat > 0) then
86+
task%API_URL = "https://31pwr5t6ij.execute-api.eu-west-2.amazonaws.com"
87+
else
88+
allocate(character(len = envvarlen) :: task%API_URL)
89+
call get_environment_variable("SERVER_URL", value = task%API_URL)
90+
end if
91+
92+
call get_environment_variable("ICFPC2025ID", length = envvarlen, status = stat)
93+
if (stat == 0) then
94+
allocate(character(len = envvarlen) :: task%API_ID)
95+
call get_environment_variable("ICFPC2025ID", value = task%API_ID)
96+
else
97+
error stop "Environment variable ICFPC2025ID is not set"
98+
end if
99+
end subroutine setup_API
77100
end subroutine init
78101
end module task_mod

0 commit comments

Comments
 (0)