#ifdef _OPENACC subroutine initialisation_openacc USE openacc character(len=6) :: local_rank_env integer :: local_rank_env_status, local_rank ! Initialisation of OpenACC !$acc init ! Recovery of the local rank of the process via the environment variable ! set by Slurm, as MPI_Comm_rank cannot be used here ! because this routine is used BEFORE the initialisation of MPI call get_environment_variable(name="SLURM_LOCALID", value=local_rank_env, status=local_rank_env_status) if (local_rank_env_status == 0) then read(local_rank_env, *) local_rank ! Define the GPU to use via OpenACC call acc_set_device_num(local_rank, acc_get_device_type()) else print *, "Error: impossible to determine the local rank of the process" stop 1 end if end subroutine initialisation_openacc #endif