To: J3 J3/23-100r1 From: Yasuharu Hayashi & John Reid Subject: Simplification of the C.7.8 example Date: 2023-February-23 Introduction ^^^^^^^^^^^^ The code in C.7.8, written to allow for recovery from image failures, is hard to follow. It ensures that each active image keeps the same image index in the team of active images. The code can be simplified if this is not required. The allocatable arrays failures, old_failures, and map are not needed and the scalar coarrays local_index and team_number can be found during execution of a simple do loop over the image indexes, testing for failed images. As well as being simpler, the new code is shorter: 76 lines instead of 109 lines. Our edit proposes new code to replace the existing code. Edit to the DIS ^^^^^^^^^^^^^^^ Replace the code in C.7.8 by the following PROGRAM possibly_recoverable_simulation USE, INTRINSIC :: ISO_FORTRAN_ENV, ONLY:TEAM_TYPE, STAT_FAILED_IMAGE IMPLICIT NONE INTEGER :: images_spare ! Number of spare images. INTEGER :: images_used ! Number of images used. INTEGER :: j, k ! Temporaries INTEGER :: status ! STAT= value INTEGER :: team_number [*] ! 1 if in working team; 2 otherwise. INTEGER :: local_index [*] ! Index of the image in the team. TYPE (TEAM_TYPE) :: simulation_team LOGICAL :: done [*] ! True if computation finished on the image. ! Keep 1% spare images if we have a lot, just 1 if 10-199 images, ! 0 if <10. images_spare = MAX(NUM_IMAGES()/100,0,MIN(NUM_IMAGES()-9,1)) images_used = NUM_IMAGES () - images_spare SYNC ALL (STAT=status) outer : DO IF (status/=0 .AND. status/=STAT_FAILED_IMAGE) EXIT outer IF (IMAGE_STATUS (1) == STAT_FAILED_IMAGE) & ERROR STOP "cannot recover" IF (THIS_IMAGE () == 1) THEN j = 0 DO k = 1, NUM_IMAGES () IF (IMAGE_STATUS (k) == 0) THEN j = j+1 IF (j<=images_used) THEN local_index[k] = j team_number [k] = 1 ELSE local_index[k] = j - images_used team_number [k] = 2 END IF END IF END DO IF (j