!...................................................................................................................................!:.:.:
!.......................... File: mpi_01_hello.f90           .......................................................................!:.:.:
!===================================================================================================================================
!-----------------------------------------------------------------------------------------------------------------------------------
!
! Compile using the commands:
! mpifort mpi_01_hello.f90 -o m;mpirun -n 4 ./m |  sort -k 4n
!
! If too many processes, then:   mpirun -n 32  -oversubscribe       ./m
! If too many processes, then:   mpirun -n 32 --host $(hostname):32 ./m
!-----------------------------------------------------------------------------------------------------------------------------------
program     mpi_introduction

 use mpi
 implicit none

 integer :: ierr, nprocs, myrank

 call mpi_init(ierr)
 call mpi_comm_size(MPI_COMM_WORLD,nprocs,ierr)
 call mpi_comm_rank(MPI_COMM_WORLD,myrank,ierr)

 !All processes synchronize here:
 call mpi_barrier  (MPI_COMM_WORLD,ierr)

 !There is no standard that sets the order that each process will execute the print statement. 
 !The output can be in any order!
 print *,'I am process: ', myrank, ' of ', nprocs

 call mpi_finalize(ierr)



end program mpi_introduction
!===================================================================================================================================
!-----------------------------------------------------------------------------------------------------------------------------------
!  Copyright by Konstantinos N. Anagnostopoulos, Physics Department, National Technical University of Athens, 2025
!  konstant@mail.ntua.gr, www.physics.ntua.gr/konstant
!  
!  This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 
!  published by the Free Software Foundation, version 3 of the License.
!  
!  This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
!  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
!  
!  You should have received a copy of the GNU General Public Liense along with this program. If not, see http://www.gnu.org/licenses
!-----------------------------------------------------------------------------------------------------------------------------------
