<IMAGE_STATUS Example Program>
Program image_status_example
Use Iso_Fortran_Env
Implicit None
Integer i,istat
If (Num_Images()<4) Error Stop 'Not enough images'
If (This_Image()==3) Fail Image
Sync All(Stat=istat)
If (istat/=Stat_Failed_Image) Error Stop 'Expected failed image stat'
If (This_Image()==2) Stop
Sync All(Stat=istat)
If (istat/=Stat_Stopped_Image) Error Stop 'Expected stopped image stat'
If (This_Image()==1) Then
Do i=1,4
Select Case (Image_Status(i))
Case (0)
Print *,'Image',i,'is active'
Case (Stat_Failed_Image)
Print *,'Image',i,'has failed'
Case (Stat_Stopped_Image)
Print *,'Image',i,'has stopped'
End Select
End Do
End If
If (This_Image()<5) Sync Images([1,4])
End Program
■ Execution Results
Image 1 is active
Image 2 has stopped
Image 3 has failed
Image 4 is active
Warning: 1 image(s) failed