I am writing a Fortran 95 code (with gfortran as a compiler). In one of the subroutines, I initialize the Message Passing Interface by calling MPI_Init. I close the interface by calling MPI_Finalize in the same subroutine. Neither in the main program nor in any other subroutines do I use MPI commands.
The code is running well; however, every WRITE(*,*) "text" statement in the main program is executed twice when I run the code (I am testing the code on my laptop with two physical cores). So it seems that both cores are processing all the commands of the main program.
Is this what one should expect? What is the right way of initializing and finalizing the MPI?
I would like one core to process all the sequential tasks and use multicore processing only in the subroutine.