import os # Get the SGE task ID from the environment variable itask = os.getenv("SGE_TASK_ID") itask = int(itask) if itask is not None else 1 print(f"itask={itask}") # A loop each iteration of which takes a long time to execute # for i in range(1, N+1 ): i = itask print(f"Iteration #{i}") # Code to execute # Save the results