@@ -3,7 +3,7 @@ module API_mod
33 use plan_mod, only: plan_t
44 implicit none
55 private
6- public :: select, explore
6+ public :: select, explore, guess
77contains
88 subroutine select (task )
99 type (task_t), intent (in ) :: task
@@ -104,4 +104,31 @@ subroutine explore(task, plans)
104104 close (lu, status = " delete" )
105105
106106 end subroutine explore
107+ subroutine guess (task , solution )
108+ type (task_t), intent (in ) :: task
109+ character (len=* ), intent (in ) :: solution
110+
111+ character (len= :), allocatable :: command, header, request, data
112+
113+ integer :: lu
114+
115+ open (newunit = lu, file = " guess" , status = " unknown" )
116+ close (lu, status = " delete" )
117+
118+ header = ' --header "Content-Type: application/json" '
119+ request = ' --request POST '
120+ data = ' --data '' { "id": "' // task% API_ID // ' ", ' // solution // ' }'' '
121+
122+ command = ' curl -s ' // header // request // data // task% API_URL // ' /guess > guess'
123+ call execute_command_line(command, wait= .true. )
124+
125+ open (newunit = lu, file = " guess" , status = " old" )
126+ block
127+ integer :: idx
128+ data = repeat (" " , 1024 )
129+ read (lu, ' (A)' ) data
130+ print ' (A,A)' , ' Resolution: ' , trim (data )
131+ end block
132+ close (lu, status = " delete" )
133+ end subroutine guess
107134end module API_mod
0 commit comments