Canaris was then given intelligence work as a result of having come to the attention of German naval intelligence (likely due to his clever escape from Chile). German plans to establish intelligence operations in the Mediterranean were under way and Canaris seemed a good fit for this role. Eventually he was sent to Spain, where in Madrid his task was to provide clandestine reconnaissance over enemy shipping movements and to establish a supply service for the U-boats in naval warfare in the Mediterranean during World War I. After being assigned to the Inspectorate of Submarines by the Naval Staff on 24 October 1916, he took up training for duty as a U-boat commander and graduated from Submarine School on 11 September 1917.