Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add proper error checking.
[simgrid.git] / examples / smpi / energy / f90 / sef90.f90
index 59b3fbf..833bf73 100644 (file)
@@ -1,3 +1,9 @@
+! Copyright (c) 2013-2014. The SimGrid Team.
+! All rights reserved.
+
+! This program is free software; you can redistribute it and/or modify it
+! under the terms of the license (GNU LGPL) which comes with this package.
+
 program main
   use mpi
 
@@ -7,7 +13,16 @@ program main
   double precision p, t, e
 
   call MPI_Init(ierr)
+  if (ierr .ne. MPI_SUCCESS) then
+     print *, 'MPI_Init failed:', ierr
+     stop 1
+  endif
   call MPI_Comm_rank(MPI_COMM_WORLD, rank, ierr)
+  if (ierr .ne. MPI_SUCCESS) then
+     print *, 'MPI_Comm_rank failed:', ierr
+     call MPI_Abort(MPI_COMM_WORLD, 1, ierr)
+     stop 1
+  endif
 
   pstates = smpi_get_host_nb_pstates()
 
@@ -34,5 +49,10 @@ program main
   end do
 
   call MPI_Finalize(ierr)
+  if (ierr .ne. MPI_SUCCESS) then
+     print *, 'MPI_Finalize failed:', ierr
+     call MPI_Abort(MPI_COMM_WORLD, 1, ierr)
+     stop 1
+  endif
 
 end program main