Skip to content

Commit

Permalink
Change include mpi.h to use mpi
Browse files Browse the repository at this point in the history
  • Loading branch information
caiohamamura committed Jul 1, 2024
1 parent c189e33 commit 9df6749
Show file tree
Hide file tree
Showing 13 changed files with 279 additions and 49 deletions.
208 changes: 208 additions & 0 deletions ED/build/shell/dependency.mk

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions ED/build/shell/sources.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SOURCES = ED/src/driver/ed_1st.F90 ED/src/driver/ed_driver.F90 ED/src/driver/ed_met_driver.f90 ED/src/driver/ed_model.F90 ED/src/dynamics/bdf2_solver.f90 ED/src/dynamics/canopy_struct_dynamics.f90 ED/src/dynamics/disturbance.f90 ED/src/dynamics/euler_driver.f90 ED/src/dynamics/events.f90 ED/src/dynamics/farq_katul.f90 ED/src/dynamics/farq_leuning.f90 ED/src/dynamics/fire.f90 ED/src/dynamics/forestry.f90 ED/src/dynamics/growth_balive.f90 ED/src/dynamics/heun_driver.f90 ED/src/dynamics/hybrid_driver.f90 ED/src/dynamics/lsm_hyd.f90 ED/src/dynamics/mortality.f90 ED/src/dynamics/multiple_scatter.f90 ED/src/dynamics/old_twostream_rad.f90 ED/src/dynamics/phenology_aux.f90 ED/src/dynamics/phenology_driv.f90 ED/src/dynamics/photosyn_driv.f90 ED/src/dynamics/plant_hydro.f90 ED/src/dynamics/radiate_driver.f90 ED/src/dynamics/reproduction.f90 ED/src/dynamics/rk4_copy_patch.f90 ED/src/dynamics/rk4_derivs.f90 ED/src/dynamics/rk4_driver.F90 ED/src/dynamics/rk4_integ_utils.f90 ED/src/dynamics/rk4_misc.f90 ED/src/dynamics/soil_respiration.f90 ED/src/dynamics/stem_resp_driv.f90 ED/src/dynamics/structural_growth.f90 ED/src/dynamics/twostream_rad.f90 ED/src/dynamics/vegetation_dynamics.f90 ED/src/init/ed_bigleaf_init.f90 ED/src/init/ed_init.F90 ED/src/init/ed_init_atm.F90 ED/src/init/ed_nbg_init.f90 ED/src/init/ed_params.f90 ED/src/init/ed_type_init.f90 ED/src/init/landuse_init.f90 ED/src/init/phenology_startup.f90 ED/src/io/average_utils.f90 ED/src/io/edio.f90 ED/src/io/ed_init_history.f90 ED/src/io/ed_load_namelist.f90 ED/src/io/ed_opspec.F90 ED/src/io/ed_print.F90 ED/src/io/ed_read_ed10_20_history.f90 ED/src/io/ed_read_ed21_history.f90 ED/src/io/ed_xml_config.f90 ED/src/io/h5_output.F90 ED/src/io/leaf_database.f90 ED/src/memory/c34constants.f90 ED/src/memory/canopy_air_coms.f90 ED/src/memory/canopy_layer_coms.f90 ED/src/memory/canopy_radiation_coms.f90 ED/src/memory/consts_coms.F90 ED/src/memory/decomp_coms.f90 ED/src/memory/detailed_coms.f90 ED/src/memory/disturb_coms.f90 ED/src/memory/ed_max_dims.F90 ED/src/memory/ed_mem_alloc.f90 ED/src/memory/ed_misc_coms.f90 ED/src/memory/ed_state_vars.F90 ED/src/memory/ed_var_tables.f90 ED/src/memory/ed_work_vars.f90 ED/src/memory/ename_coms.f90 ED/src/memory/fusion_fission_coms.f90 ED/src/memory/grid_coms.f90 ED/src/memory/hdf5_coms.f90 ED/src/memory/hydrology_coms.f90 ED/src/memory/hydrology_constants.f90 ED/src/memory/mem_polygons.f90 ED/src/memory/met_driver_coms.f90 ED/src/memory/pft_coms.f90 ED/src/memory/phenology_coms.f90 ED/src/memory/physiology_coms.f90 ED/src/memory/rk4_coms.f90 ED/src/memory/soil_coms.F90 ED/src/mpi/ed_mpass_init.F90 ED/src/mpi/ed_node_coms.f90 ED/src/mpi/ed_para_coms.f90 ED/src/mpi/ed_para_init.f90 ED/src/utils/allometry.f90 ED/src/utils/budget_utils.f90 ED/src/utils/charutils.f90 ED/src/utils/dateutils.f90 ED/src/utils/ed_cn_utils.f90 ED/src/utils/ed_filelist.F90 ED/src/utils/ed_grid.f90 ED/src/utils/ed_therm_lib.f90 ED/src/utils/fatal_error.F90 ED/src/utils/fuse_fiss_utils.f90 ED/src/utils/great_circle.f90 ED/src/utils/hdf5_utils.f90 ED/src/utils/hrzshade_utils.f90 ED/src/utils/invmondays.f90 ED/src/utils/lapse.f90 ED/src/utils/libxml2f90.f90_pp.f90 ED/src/utils/numutils.f90 ED/src/utils/radiate_utils.f90 ED/src/utils/random_utils.F90 ED/src/utils/rsys.F90 ED/src/utils/stable_cohorts.f90 ED/src/utils/therm_lib.f90 ED/src/utils/therm_lib8.f90 ED/src/utils/update_derived_utils.f90 ED/src/utils/utils_f.f90 ED/src/utils/utils_c.c
10 changes: 6 additions & 4 deletions ED/src/driver/ed_1st.F90
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ subroutine ed_1st_master (ipara, nnodestotal,nslaves, headnode_num, max_threads,
use ed_state_vars, only : allocate_edglobals & ! subroutine
, filltab_alltypes ! ! subroutine

#if defined(RAMS_MPI)
use mpi
#endif
implicit none

!----- Pre-compiled variables from MPI. ------------------------------------------------!
#if defined(RAMS_MPI)
include 'mpif.h'
#endif
!----- Arguments. ----------------------------------------------------------------------!
integer , intent(in) :: ipara ! 0 if sequential run; 1 if parallel run
integer , intent(in) :: nnodestotal ! total number of nodes on any run
Expand Down Expand Up @@ -176,10 +176,12 @@ end subroutine ed_1st_master
!------------------------------------------------------------------------------------------!
subroutine ed_1st_node()
use ed_mem_alloc, only : ed_memory_allocation ! ! subroutine
#if defined(RAMS_MPI)
use mpi
#endif
implicit none
!----- Pre-compiled variables from MPI. ------------------------------------------------!
#if defined(RAMS_MPI)
include 'mpif.h'
!----- Local variable (MPI only). ------------------------------------------------------!
integer :: ierr
#endif
Expand Down
7 changes: 4 additions & 3 deletions ED/src/driver/ed_driver.F90
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,12 @@ subroutine ed_driver()
use hrzshade_utils , only : init_cci_variables ! ! subroutine
use canopy_radiation_coms, only : ihrzrad ! ! intent(in)
use random_utils , only : init_random_seed ! ! subroutine
implicit none
!----- Included variables. -------------------------------------------------------------!
#if defined(RAMS_MPI)
include 'mpif.h' ! MPI commons
use mpi ! MPI commons
#endif
implicit none

!----- Included variables. -------------------------------------------------------------!
!----- Local variables. ----------------------------------------------------------------!
character(len=12) :: c0
character(len=12) :: c1
Expand Down
5 changes: 2 additions & 3 deletions ED/src/driver/ed_model.F90
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,10 @@ subroutine ed_model()
use vegetation_dynamics , only : veg_dynamics_driver ! ! sub-routine
use ed_type_init , only : ed_init_viable ! ! sub-routine
use soil_respiration , only : zero_litter_inputs ! ! sub-routine
implicit none
!----- Common blocks. ------------------------------------------------------------------!
#if defined(RAMS_MPI)
include 'mpif.h'
use mpi
#endif
implicit none
!----- Local variables. ----------------------------------------------------------------!
type(simtime) :: daybefore
character(len=28) :: fmthead
Expand Down
10 changes: 5 additions & 5 deletions ED/src/driver/edmain.F90
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
!------------------------------------------------------------------------------------------!
program main
!$ use omp_lib
implicit none
#if defined(RAMS_MPI)
use mpi
#endif
implicit none

!---------------------------------------------------------------------------------------!
! Local constants. !
Expand Down Expand Up @@ -49,10 +52,7 @@ program main
integer, dimension(64) :: thread_use
integer, dimension(64) :: cpu_use
integer, external :: findmycpu
!------ MPI interface. -----------------------------------------------------------------!
#if defined(RAMS_MPI)
include 'mpif.h'
#endif

!---------------------------------------------------------------------------------------!


Expand Down
4 changes: 2 additions & 2 deletions ED/src/init/ed_init.F90
Original file line number Diff line number Diff line change
Expand Up @@ -319,10 +319,10 @@ subroutine load_ecosystem_state()
use ed_node_coms , only : mynum ! ! intent(in)
#endif

implicit none
#if defined(RAMS_MPI)
include 'mpif.h'
use mpi
#endif
implicit none
!----- Local variables --------------------------------------------------------------!
integer :: igr
integer :: ping
Expand Down
5 changes: 1 addition & 4 deletions ED/src/init/ed_init_atm.F90
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ subroutine ed_init_atm()
, terminate_cohorts & ! subroutine
, split_cohorts ! ! subroutine
#if defined(RAMS_MPI)
use mpi
use ed_node_coms , only : nnodetot & ! intent(in)
, mynum & ! intent(in)
, sendnum & ! intent(in)
Expand Down Expand Up @@ -95,10 +96,6 @@ subroutine ed_init_atm()
!----- Local variables (MPI only). -----------------------------------------------------!
#if defined(RAMS_MPI)
integer :: ierr
#endif
!----- Add the MPI common block. -------------------------------------------------------!
#if defined(RAMS_MPI)
include 'mpif.h'
#endif
!---------------------------------------------------------------------------------------!

Expand Down
5 changes: 3 additions & 2 deletions ED/src/io/ed_print.F90
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,12 @@ subroutine print_fields(ifm,cgrid)
use ed_var_tables, only : vt_info & ! intent(in)
, num_var ! ! intent(in)
use ed_max_dims , only : str_len_short ! ! intent(in)
implicit none

!----- Standard common blocks. ------------------------------------------------------!
#if defined(RAMS_MPI)
include 'mpif.h'
use mpi
#endif
implicit none
!----- Arguments. -------------------------------------------------------------------!
integer , intent(in) :: ifm
type(edtype) , target :: cgrid
Expand Down
8 changes: 4 additions & 4 deletions ED/src/io/h5_output.F90
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ subroutine h5_output(vtype)
, sitetype & ! structure
, patchtype & ! structure
, gdpy ! ! intent(in)
implicit none

!------ Include standard common blocks. ------------------------------------------------!

!------ Include standard common blocks. ------------------------------------------------!
#if defined(RAMS_MPI)
include 'mpif.h'
use mpi
#endif
implicit none
!------ Arguments. ---------------------------------------------------------------------!
character(len=*) , intent(in) :: vtype
!------ Local variables. ---------------------------------------------------------------!
Expand Down
4 changes: 2 additions & 2 deletions ED/src/memory/ed_state_vars.F90
Original file line number Diff line number Diff line change
Expand Up @@ -12774,11 +12774,11 @@ subroutine filltab_alltypes
#endif
use ed_max_dims , only : maxgrds & ! intent(in)
, maxmach ! ! intent(in)
implicit none

#if defined(RAMS_MPI)
include 'mpif.h'
use mpi
#endif
implicit none
!----- Local variables. -------------------------------------------------------------!
type(edtype) , pointer :: cgrid
type(polygontype) , pointer :: cpoly
Expand Down
53 changes: 36 additions & 17 deletions ED/src/mpi/ed_mpass_init.F90
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ subroutine ed_masterput_processid(nproc,headnode_num,masterworks,par_run)
, master_num & ! intent(out)
, machs ! ! intent(out)
#endif

#if defined(RAMS_MPI)
use mpi
#endif
implicit none
!----- Arguments. ----------------------------------------------------------------------!
integer, intent(in) :: headnode_num
Expand All @@ -38,7 +40,6 @@ subroutine ed_masterput_processid(nproc,headnode_num,masterworks,par_run)
integer :: nm
#if defined(RAMS_MPI)
integer :: ierr
include 'mpif.h'
!---------------------------------------------------------------------------------------!
#endif

Expand Down Expand Up @@ -359,6 +360,9 @@ subroutine ed_masterput_nl(par_run)
, idetailed & ! intent(in)
, patch_keep ! ! intent(in)
use fusion_fission_coms , only : ifusion ! ! intent(in)
#endif
#if defined(RAMS_MPI)
use mpi
#endif
implicit none

Expand All @@ -369,7 +373,6 @@ subroutine ed_masterput_nl(par_run)
integer :: ierr
integer :: n
!------ Pre-compiled options. ----------------------------------------------------------!
include 'mpif.h'
#endif
!---------------------------------------------------------------------------------------!

Expand Down Expand Up @@ -727,6 +730,9 @@ subroutine ed_masterput_met_header(par_run)
, metvars_len ! ! intent(in)
#endif

#if defined(RAMS_MPI)
use mpi
#endif
implicit none
!------ Arguments. ---------------------------------------------------------------------!
integer , intent(in) :: par_run
Expand All @@ -737,7 +743,6 @@ subroutine ed_masterput_met_header(par_run)
integer :: f
integer :: v
!------ Pre-compiled options. ----------------------------------------------------------!
include 'mpif.h'
!---------------------------------------------------------------------------------------!
#endif

Expand Down Expand Up @@ -813,6 +818,10 @@ subroutine ed_masterput_poly_dims(par_run,masterworks)
, npolys_run ! ! intent(in)
use mem_polygons , only : n_ed_region & ! intent(in)
, n_poi ! ! intent(in)

#if defined(RAMS_MPI)
use mpi
#endif
implicit none
!----- Local constants. ----------------------------------------------------------------!
integer , parameter :: nmethods = 3
Expand All @@ -838,7 +847,6 @@ subroutine ed_masterput_poly_dims(par_run,masterworks)
real :: totalwork
#if defined(RAMS_MPI)
integer :: ierr
include 'mpif.h'
#endif
!---------------------------------------------------------------------------------------!

Expand Down Expand Up @@ -1122,6 +1130,9 @@ subroutine ed_masterput_worklist_info(par_run)
, py_off ! ! intent(in)
use mem_polygons , only : maxsite ! ! intent(in)
use ed_mem_alloc , only : ed_memory_allocation ! ! subroutine
#if defined(RAMS_MPI)
use mpi
#endif
implicit none
!------ Arguments. ---------------------------------------------------------------------!
integer , intent(in) :: par_run
Expand All @@ -1139,8 +1150,6 @@ subroutine ed_masterput_worklist_info(par_run)
integer :: mpiid
integer , dimension(:), allocatable :: iscratch
real , dimension(:), allocatable :: rscratch
!------ Pre-compiled options. ----------------------------------------------------------!
include 'mpif.h'
#endif
!---------------------------------------------------------------------------------------!

Expand Down Expand Up @@ -1311,12 +1320,14 @@ subroutine ed_nodeget_processid(init)
use ed_para_coms, only : nthreads ! ! intent(out)
#else
#endif
#if defined(RAMS_MPI)
use mpi
#endif
implicit none
!----- Arguments. ----------------------------------------------------------------------!
integer, intent(in) :: init
!----- Local variables. ----------------------------------------------------------------!
#if defined(RAMS_MPI)
include 'mpif.h'
integer, dimension(MPI_STATUS_SIZE) :: status
#endif
integer :: ierr
Expand Down Expand Up @@ -1599,6 +1610,7 @@ subroutine ed_nodeget_nl
, time2canopy & ! intent(out)
, min_patch_area ! ! intent(out)
use canopy_layer_coms , only : crown_mod ! ! intent(out)

use canopy_radiation_coms, only : icanrad & ! intent(out)
, ihrzrad & ! intent(out)
, ltrans_vis & ! intent(out)
Expand All @@ -1620,9 +1632,12 @@ subroutine ed_nodeget_nl
, patch_keep ! ! intent(out)
use fusion_fission_coms , only : ifusion ! ! intent(out)
#endif
implicit none

#if defined(RAMS_MPI)
use mpi
#endif
implicit none
#if defined(RAMS_MPI)
include 'mpif.h'
!----- Local variables. ----------------------------------------------------------------!
integer :: n
#endif
Expand Down Expand Up @@ -1996,9 +2011,11 @@ subroutine ed_nodeget_met_header()
, met_land_mask ! ! intent(out)
#endif

implicit none
#if defined(RAMS_MPI)
include 'mpif.h'
use mpi
#endif
implicit none
#if defined(RAMS_MPI)
!---- Local variables. -----------------------------------------------------------------!
integer :: ierr
integer :: nsize
Expand Down Expand Up @@ -2084,15 +2101,17 @@ subroutine ed_nodeget_poly_dims
use grid_coms , only : ngrids ! ! intent(in)
#endif

implicit none
#if defined(RAMS_MPI)
use mpi
#endif
implicit none

#if defined(RAMS_MPI)
!----- Local variables. ----------------------------------------------------------------!
integer :: ierr
integer :: ifm
integer :: nm
!------ Pre-compiled options. ----------------------------------------------------------!
include 'mpif.h'
!---------------------------------------------------------------------------------------!
do ifm=1,ngrids
do nm=1,nmachs
Expand Down Expand Up @@ -2131,11 +2150,11 @@ subroutine ed_nodeget_worklist_info
use ed_node_coms , only : master_num ! ! intent(in)
#endif

implicit none
#if defined(RAMS_MPI)
!------ Pre-compiled options. ----------------------------------------------------------!
include 'mpif.h'
!------ Pre-compiled options. ----------------------------------------------------------!
use mpi
#endif
implicit none
!------ Local variables. ---------------------------------------------------------------!
integer :: npolygons
integer :: ifm
Expand Down
8 changes: 5 additions & 3 deletions ED/src/utils/fatal_error.F90
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
subroutine fatal_error(reason,subr,file)
use ed_node_coms , only : nnodetot & ! intent(in)
, mynum ! ! intent(in)

#if defined(RAMS_MPI)
use mpi_f08
#endif
implicit none
!----- Arguments. ----------------------------------------------------------------------!
character(len=*), intent(in) :: reason
Expand All @@ -18,9 +22,7 @@ subroutine fatal_error(reason,subr,file)
logical :: slavenode
!---------------------------------------------------------------------------------------!

#if defined(RAMS_MPI)
include 'mpif.h'
#endif


!---------------------------------------------------------------------------------------!
! Check which type of end we should use. For the main program, this should never !
Expand Down

0 comments on commit 9df6749

Please sign in to comment.