Skip to content

Commit

Permalink
Use mpi module instead of mpif header file.
Browse files Browse the repository at this point in the history
  • Loading branch information
Elliott Sales de Andrade committed Jul 3, 2013
1 parent 4f0a238 commit 29d49cc
Show file tree
Hide file tree
Showing 19 changed files with 397 additions and 242 deletions.
509 changes: 322 additions & 187 deletions configure

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,9 @@ fi
# Checks for header files.

if test "$want_mpi" = yes; then
CIT_FC_MPI_HEADER([$MPIFC], [$FLAGS_CHECK])
CIT_FC_MPI_MODULE([mpif.h], [$MPIFC], [$FLAGS_CHECK], [], [
AC_MSG_FAILURE([cannot compile a trivial MPI program using $MPIFC])
])
fi

# Checks for typedefs, structures, and compiler characteristics.
Expand Down
15 changes: 10 additions & 5 deletions m4/cit_fortran.m4
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,14 @@ AC_LANG_POP(Fortran)
])dnl CIT_FC_STREAM_IO


# CIT_FC_MPI_MODULE(FILENAME, MPIFC, MPIFCFLAGS)
# CIT_FC_MPI_MODULE(FILENAME, MPIFC, MPIFCFLAGS,
# [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
# -----------------------------------------------------
AC_DEFUN([CIT_FC_MPI_MODULE], [
# Use 'mpi' module or 'mpif.h', as appropriate. UNFINISHED. This
# strategy doesn't play well with "implicit none": whether the
# Use 'mpi' module or 'mpif.h', as appropriate. UNFINISHED.
# The default actions are to create FILENAME that either uses the
# appropriate module or includes the existing mpif.h.
# This strategy doesn't play well with "implicit none": whether the
# generated header must be included before or after "implicit none"
# depends upon the result of the test! It might be possible to make
# "use mpi" always work: simply generate an 'mpi' module if the MPI
Expand All @@ -166,6 +169,7 @@ cfgfile="${ofile}T"
trap "rm \"$cfgfile\"; exit 1" 1 2 15
rm -f "$cfgfile"
cit_fc_header=none
cit_fc_save_fc=$FC
cit_fc_save_fcflags=$FCFLAGS
FC=$2
Expand All @@ -181,9 +185,10 @@ AC_COMPILE_IFELSE([
]])
], [
AC_MSG_RESULT(yes)
cit_fc_header="use mpi"
m4_default([$4], [cit_fc_header="use mpi"])
], [
AC_MSG_RESULT(no)
m4_default([$5], [
AC_MSG_CHECKING([whether mpif.h works])
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([], [[
Expand All @@ -206,7 +211,7 @@ dnl to override the system header.
AC_MSG_RESULT(no)
AC_MSG_FAILURE([cannot compile a trivial MPI program using $2])
])
])
])])
if test "$cit_fc_header" != "none"; then
AC_MSG_NOTICE([creating $ofile])
Expand Down
12 changes: 8 additions & 4 deletions src/specfem2D/assemble_MPI.F90
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,11 @@ subroutine assemble_MPI_scalar(array_val1,npoin_val1, &
nibool_interfaces_acoustic,nibool_interfaces_elastic, &
nibool_interfaces_poroelastic,my_neighbours)

use :: mpi

implicit none

include 'constants.h'
include 'mpif.h'

integer, intent(in) :: ninterface
integer, intent(in) :: max_interface_size
Expand Down Expand Up @@ -229,10 +230,11 @@ subroutine assemble_MPI_vector_ac(array_val1,npoin, &
buffer_recv_faces_vector_ac, &
my_neighbours )

use :: mpi

implicit none

include 'constants.h'
include 'mpif.h'
include 'precision.h'

integer, intent(in) :: npoin
Expand Down Expand Up @@ -358,10 +360,11 @@ subroutine assemble_MPI_vector_el(array_val2,npoin, &
buffer_recv_faces_vector_el, &
my_neighbours)

use :: mpi

implicit none

include 'constants.h'
include 'mpif.h'
include 'precision.h'

integer, intent(in) :: npoin
Expand Down Expand Up @@ -465,10 +468,11 @@ subroutine assemble_MPI_vector_po(array_val3,array_val4,npoin, &
buffer_recv_faces_vector_pos,buffer_recv_faces_vector_pow, &
my_neighbours)

use :: mpi

implicit none

include 'constants.h'
include 'mpif.h'
include 'precision.h'

integer, intent(in) :: npoin
Expand Down
6 changes: 3 additions & 3 deletions src/specfem2D/check_stability.F90
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ subroutine check_stability(myrank,time,it,NSTEP,NOISE_TOMOGRAPHY, &

! checks simulation stability and outputs timerun infos

implicit none
include "constants.h"
#ifdef USE_MPI
include "mpif.h"
use :: mpi
#endif
implicit none
include "constants.h"

integer :: myrank,it,NSTEP,NOISE_TOMOGRAPHY

Expand Down
7 changes: 4 additions & 3 deletions src/specfem2D/checkgrid.F90
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,13 @@ subroutine checkgrid(vpext,vsext,rhoext,density,poroelastcoef, &

! check the mesh, stability and number of points per wavelength

#ifdef USE_MPI
use :: mpi
#endif

implicit none

include "constants.h"
#ifdef USE_MPI
include 'mpif.h'
#endif

! option to display only part of the mesh and not the whole mesh,
! for instance to analyze Cuthill-McKee mesh partitioning etc.
Expand Down
4 changes: 2 additions & 2 deletions src/specfem2D/exit_mpi.F90
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@
!-----------------------------------------------
subroutine exit_MPI(error_msg)

implicit none
#ifdef USE_MPI
! standard include of the MPI library
include "mpif.h"
use :: mpi
#endif
implicit none

! identifier for error message file
integer, parameter :: IERROR = 30
Expand Down
3 changes: 2 additions & 1 deletion src/specfem2D/get_MPI.F90
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,11 @@ subroutine get_MPI(nspec,ibool,knods,ngnod,nglob,elastic,poroelastic, &

! sets up the MPI interface for communication between partitions

use :: mpi

implicit none

include "constants.h"
include 'mpif.h'

integer, intent(in) :: nspec, nglob, ngnod
logical, dimension(nspec), intent(in) :: elastic, poroelastic
Expand Down
6 changes: 3 additions & 3 deletions src/specfem2D/initialize_simulation.F90
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@
subroutine initialize_simulation(nproc,myrank,NUMBER_OF_PASSES, &
ninterface_acoustic,ninterface_elastic,ninterface_poroelastic)

implicit none
include "constants.h"
#ifdef USE_MPI
include "mpif.h"
use :: mpi
#endif
implicit none
include "constants.h"

integer :: nproc,myrank,NUMBER_OF_PASSES
integer :: ninterface_acoustic, ninterface_elastic,ninterface_poroelastic
Expand Down
7 changes: 4 additions & 3 deletions src/specfem2D/locate_receivers.F90
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,13 @@ subroutine locate_receivers(ibool,coord,nspec,nglob,xigll,zigll, &
coorg,knods,ngnod,npgeo,ipass, &
x_final_receiver, z_final_receiver)

#ifdef USE_MPI
use :: mpi
#endif

implicit none

include "constants.h"
#ifdef USE_MPI
include "mpif.h"
#endif

integer nrec,nspec,nglob,ngnod,npgeo,ipass
integer, intent(in) :: nproc, myrank
Expand Down
7 changes: 4 additions & 3 deletions src/specfem2D/locate_source_force.F90
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,13 @@ subroutine locate_source_force(ibool,coord,nspec,nglob,xigll,zigll,x_source,z_so
ispec_selected_source,is_proc_source,nb_proc_source,nproc,myrank, &
xi_source,gamma_source,coorg,knods,ngnod,npgeo,ipass,iglob_source)

#ifdef USE_MPI
use :: mpi
#endif

implicit none

include "constants.h"
#ifdef USE_MPI
include "mpif.h"
#endif

integer nspec,nglob,ngnod,npgeo,ipass

Expand Down
7 changes: 4 additions & 3 deletions src/specfem2D/locate_source_moment_tensor.F90
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,13 @@ subroutine locate_source_moment_tensor(ibool,coord,nspec,nglob, &
ispec_selected_source,is_proc_source,nb_proc_source,nproc,myrank, &
xi_source,gamma_source,coorg,knods,ngnod,npgeo,ipass)

#ifdef USE_MPI
use :: mpi
#endif

implicit none

include "constants.h"
#ifdef USE_MPI
include "mpif.h"
#endif

integer nspec,nglob,ngnod,npgeo,ipass

Expand Down
7 changes: 4 additions & 3 deletions src/specfem2D/plotpost.F90
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,13 @@ subroutine plotpost(displ,coord,vpext,x_source,z_source,st_xval,st_zval,it,dt,co
! PostScript display routine
!

#ifdef USE_MPI
use :: mpi
#endif

implicit none

include "constants.h"
#ifdef USE_MPI
include 'mpif.h'
#endif

! color palette
integer, parameter :: NUM_COLORS = 236
Expand Down
8 changes: 4 additions & 4 deletions src/specfem2D/pml_init.F90
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ subroutine pml_init(nspec,nglob,anyabs,ibool,nelemabs,codeabs,numabs,&
read_external_mesh,region_CPML,&
SIMULATION_TYPE,PML_interior_interface,nglob_interface,SAVE_FORWARD,myrank,mask_ibool)

implicit none
include 'constants.h'

#ifdef USE_MPI
include 'mpif.h'
use :: mpi
#endif

implicit none
include 'constants.h'

integer :: SIMULATION_TYPE,nglob_interface,myrank

integer :: nspec,nglob,nelemabs,nspec_PML,NELEM_PML_THICKNESS
Expand Down
12 changes: 6 additions & 6 deletions src/specfem2D/prepare_color_image.F90
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ subroutine prepare_color_image_init(NX_IMAGE_color,NZ_IMAGE_color, &
zmin_color_image,zmax_color_image, &
coord,nglob,npgeo,factor_subsample_image)

implicit none
include "constants.h"
#ifdef USE_MPI
include "mpif.h"
use :: mpi
#endif
implicit none
include "constants.h"

integer :: NX_IMAGE_color,NZ_IMAGE_color

Expand Down Expand Up @@ -297,11 +297,11 @@ subroutine prepare_color_image_vp(nglob,image_color_vp_display,iglob_image_color

! stores P-velocity model in image_color_vp_display

implicit none
include "constants.h"
#ifdef USE_MPI
include "mpif.h"
use :: mpi
#endif
implicit none
include "constants.h"

integer :: nglob,nspec
integer :: NX_IMAGE_color,NZ_IMAGE_color
Expand Down
6 changes: 3 additions & 3 deletions src/specfem2D/prepare_initialfield.F90
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ subroutine prepare_initialfield(myrank,any_acoustic,any_poroelastic,over_critica
A_plane, B_plane, C_plane, &
accel_elastic,veloc_elastic,displ_elastic)

implicit none
include "constants.h"
#ifdef USE_MPI
include "mpif.h"
use :: mpi
#endif
implicit none
include "constants.h"

integer :: myrank
logical :: any_acoustic,any_poroelastic
Expand Down
8 changes: 4 additions & 4 deletions src/specfem2D/read_databases.F90
Original file line number Diff line number Diff line change
Expand Up @@ -687,13 +687,13 @@ subroutine read_databases_absorbing(myrank,ipass,nelemabs,nspec,anyabs, &

! reads in absorbing edges

implicit none
include "constants.h"

#ifdef USE_MPI
include 'mpif.h'
use :: mpi
#endif

implicit none
include "constants.h"

integer :: myrank,ipass,nspec
integer :: nelemabs
integer, dimension(nelemabs) :: numabs,ibegin_edge1,iend_edge1, &
Expand Down
4 changes: 3 additions & 1 deletion src/specfem2D/specfem2D.F90
Original file line number Diff line number Diff line change
Expand Up @@ -356,12 +356,14 @@ program specfem2D
! not work because it would be discontinuous at such an interface and would
! therefore not be consistent with the basis functions.

#ifdef USE_MPI
use :: mpi
#endif

implicit none

include "constants.h"
#ifdef USE_MPI
include "mpif.h"
include "precision.h"
#endif

Expand Down
7 changes: 4 additions & 3 deletions src/specfem2D/write_seismograms.F90
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ subroutine write_seismograms(sisux,sisuz,siscurl,station_name,network_name, &
st_zval,x_source,z_source,SU_FORMAT,save_ASCII_seismograms, &
save_binary_seismograms_single,save_binary_seismograms_double,subsamp_seismos)

#ifdef USE_MPI
use :: mpi
#endif

implicit none

! uncomment this to save the ASCII *.sem* seismograms in binary instead, to save disk space and/or writing time
Expand All @@ -58,9 +62,6 @@ subroutine write_seismograms(sisux,sisuz,siscurl,station_name,network_name, &
! #define PAUL_SAVE_ASCII_IN_BINARY

include "constants.h"
#ifdef USE_MPI
include "mpif.h"
#endif

integer :: nrec,NSTEP,seismotype,subsamp_seismos
integer :: NSTEP_BETWEEN_OUTPUT_SEISMOS,seismo_offset,seismo_current
Expand Down

0 comments on commit 29d49cc

Please sign in to comment.