SCALE-RM
Functions/Subroutines | Variables
scale_process Module Reference

module PROCESS More...

Functions/Subroutines

subroutine, public prc_mpistart (comm)
 Start MPI. More...
 
subroutine, public prc_universal_setup (comm, nprocs, ismaster)
 setup MPI in universal communicator More...
 
subroutine, public prc_global_setup (abortall, comm)
 setup MPI in global communicator More...
 
subroutine, public prc_local_setup (comm, myrank, ismaster)
 Setup MPI. More...
 
subroutine, public prc_mpistop
 Abort MPI. More...
 
subroutine, public prc_mpifinish
 Stop MPI peacefully. More...
 
subroutine, public prc_mpisplit (ORG_COMM, NUM_DOMAIN, PRC_DOMAINS, CONF_FILES, LOG_SPLIT, bulk_split, color_reorder, INTRA_COMM, inter_parent, inter_child, fname_local)
 MPI Communicator Split. More...
 
subroutine, public prc_mpisplit_letkf (ORG_COMM, mem_np, nitmax, nprocs, proc2mem, INTRA_COMM)
 MPI Communicator Split for SCALE-LETKF ensemble. More...
 
subroutine, public prc_mpibarrier
 Barrier MPI. More...
 
real(dp) function, public prc_mpitime ()
 Get MPI time. More...
 
subroutine, public prc_mpitimestat (avgvar, maxvar, minvar, maxidx, minidx, var)
 Calc global statistics for timer. More...
 

Variables

integer, parameter, public prc_masterrank = 0
 master process in each communicator More...
 
integer, parameter, public prc_domain_nlim = 10000
 max depth of domains More...
 
integer, public prc_universal_comm_world = -1
 original communicator More...
 
integer, public prc_universal_myrank = -1
 myrank in universal communicator More...
 
integer, public prc_universal_nprocs = -1
 process num in universal communicator More...
 
logical, public prc_universal_ismaster = .false.
 master process in universal communicator? More...
 
integer, public prc_universal_jobid = 0
 my job ID in universal communicator More...
 
integer, public prc_global_comm_world = -1
 global communicator More...
 
integer, public prc_global_myrank = -1
 myrank in global communicator More...
 
integer, public prc_global_nprocs = -1
 process num in global communicator More...
 
logical, public prc_global_ismaster = .false.
 master process in global communicator? More...
 
integer, public prc_global_domainid = 0
 my domain ID in global communicator More...
 
integer, public prc_local_comm_world = -1
 local communicator More...
 
integer, public prc_nprocs = 1
 myrank in local communicator More...
 
integer, public prc_myrank = 0
 process num in local communicator More...
 
logical, public prc_ismaster = .false.
 master process in local communicator? More...
 
logical, public prc_mpi_alive = .false.
 MPI is alive? More...
 
integer, public prc_universal_handler
 error handler in universal communicator More...
 
integer, public prc_abort_comm_world
 communicator for aborting More...
 
integer, public prc_abort_handler
 error handler communicator for aborting More...
 

Detailed Description

module PROCESS

Description
MPI/non-MPI management module
Author
Team SCALE
History
  • 2011-10-11 (R.Yoshida) [new]
  • 2011-11-11 (H.Yashiro) [mod] Integrate to SCALE-LES ver.3

Function/Subroutine Documentation

◆ prc_mpistart()

subroutine, public scale_process::prc_mpistart ( integer, intent(out)  comm)

Start MPI.

Definition at line 108 of file scale_process.F90.

References prc_mpi_alive, and prc_universal_handler.

Referenced by scalerm_launcher().

108  implicit none
109 
110  integer, intent(out) :: comm ! communicator
111 
112  integer :: ierr
113  !---------------------------------------------------------------------------
114 
115  call mpi_init(ierr)
116 
117  prc_mpi_alive = .true.
118  prc_universal_handler = mpi_errhandler_null
119  call mpi_comm_create_errhandler( prc_mpi_errorhandler, prc_universal_handler, ierr )
120 
121  comm = mpi_comm_world
122 
123  return
Here is the caller graph for this function:

◆ prc_universal_setup()

subroutine, public scale_process::prc_universal_setup ( integer, intent(in)  comm,
integer, intent(out)  nprocs,
logical, intent(out)  ismaster 
)

setup MPI in universal communicator

Definition at line 132 of file scale_process.F90.

References prc_abort_comm_world, prc_abort_handler, prc_masterrank, prc_universal_comm_world, prc_universal_handler, prc_universal_ismaster, prc_universal_myrank, and prc_universal_nprocs.

Referenced by scalerm_launcher().

132  implicit none
133 
134  integer, intent(in) :: comm ! communicator
135  integer, intent(out) :: nprocs ! number of procs in this communicator
136  logical, intent(out) :: ismaster ! master process in this communicator?
137 
138  integer :: ierr
139  !---------------------------------------------------------------------------
140 
141  prc_universal_comm_world = comm
142 
143  call mpi_comm_size(prc_universal_comm_world,prc_universal_nprocs,ierr)
144  call mpi_comm_rank(prc_universal_comm_world,prc_universal_myrank,ierr)
145 
146  if ( prc_universal_myrank == prc_masterrank ) then
147  prc_universal_ismaster = .true.
148  else
149  prc_universal_ismaster = .false.
150  endif
151 
152  nprocs = prc_universal_nprocs
153  ismaster = prc_universal_ismaster
154 
155 
156 
157  prc_abort_comm_world = prc_universal_comm_world
158 
159  call mpi_comm_set_errhandler(prc_abort_comm_world,prc_universal_handler,ierr)
160  call mpi_comm_get_errhandler(prc_abort_comm_world,prc_abort_handler ,ierr)
161 
162  return
Here is the caller graph for this function:

◆ prc_global_setup()

subroutine, public scale_process::prc_global_setup ( logical, intent(in)  abortall,
integer, intent(in)  comm 
)

setup MPI in global communicator

Definition at line 170 of file scale_process.F90.

References prc_global_comm_world, prc_global_ismaster, prc_global_myrank, prc_global_nprocs, and prc_masterrank.

Referenced by scalerm_launcher().

170  implicit none
171 
172  logical, intent(in) :: abortall ! abort all jobs?
173  integer, intent(in) :: comm ! communicator
174 
175  integer :: ierr
176  !---------------------------------------------------------------------------
177 
178  prc_global_comm_world = comm
179 
180  call mpi_comm_size(prc_global_comm_world,prc_global_nprocs,ierr)
181  call mpi_comm_rank(prc_global_comm_world,prc_global_myrank,ierr)
182 
183  if ( prc_global_myrank == prc_masterrank ) then
184  prc_global_ismaster = .true.
185  else
186  prc_global_ismaster = .false.
187  endif
188 
189 ! if ( .NOT. abortall ) then
190 ! PRC_ABORT_COMM_WORLD = PRC_GLOBAL_COMM_WORLD
191 !
192 ! call MPI_COMM_SET_ERRHANDLER(PRC_ABORT_COMM_WORLD,PRC_UNIVERSAL_handler,ierr)
193 ! call MPI_COMM_GET_ERRHANDLER(PRC_ABORT_COMM_WORLD,PRC_ABORT_handler ,ierr)
194 ! endif
195 
196  return
Here is the caller graph for this function:

◆ prc_local_setup()

subroutine, public scale_process::prc_local_setup ( integer, intent(in)  comm,
integer, intent(out)  myrank,
logical, intent(out)  ismaster 
)

Setup MPI.

Definition at line 205 of file scale_process.F90.

References prc_ismaster, prc_local_comm_world, prc_masterrank, prc_myrank, and prc_nprocs.

Referenced by mod_rm_driver::scalerm(), and mod_rm_prep::scalerm_prep().

205  implicit none
206 
207  integer, intent(in) :: comm ! communicator
208  integer, intent(out) :: myrank ! myrank in this communicator
209  logical, intent(out) :: ismaster ! master process in this communicator?
210 
211  integer :: ierr
212  !---------------------------------------------------------------------------
213 
214  prc_local_comm_world = comm
215 
216  call mpi_comm_rank(prc_local_comm_world,prc_myrank,ierr)
217  call mpi_comm_size(prc_local_comm_world,prc_nprocs,ierr)
218 
219  if ( prc_myrank == prc_masterrank ) then
220  prc_ismaster = .true.
221  else
222  prc_ismaster = .false.
223  endif
224 
225  myrank = prc_myrank
226  ismaster = prc_ismaster
227 
228  return
Here is the caller graph for this function:

◆ prc_mpistop()

subroutine, public scale_process::prc_mpistop ( )

Abort MPI.

Definition at line 234 of file scale_process.F90.

References prc_mpi_alive, and prc_universal_comm_world.

Referenced by mod_admin_restart::admin_restart_setup(), mod_admin_time::admin_time_setup(), scale_aetracer_kajino13::aetracer_kajino13_setup(), scale_aetracer_none::aetracer_none_setup(), mod_atmos_admin::atmos_admin_getscheme(), mod_atmos_admin::atmos_admin_setup(), scale_atmos_boundary::atmos_boundary_resume(), scale_atmos_boundary::atmos_boundary_resume_file(), scale_atmos_boundary::atmos_boundary_resume_online(), scale_atmos_boundary::atmos_boundary_setup(), scale_atmos_boundary::atmos_boundary_update(), mod_atmos_dyn_driver::atmos_dyn_driver_setup(), scale_atmos_dyn_common::atmos_dyn_filter_setup(), scale_atmos_dyn_fvm_flux::atmos_dyn_fvm_flux_setup(), scale_atmos_dyn::atmos_dyn_setup(), scale_atmos_dyn_tinteg_large_euler::atmos_dyn_tinteg_large_euler_setup(), scale_atmos_dyn_tinteg_large_rk3::atmos_dyn_tinteg_large_rk3_setup(), scale_atmos_dyn_tinteg_large::atmos_dyn_tinteg_large_setup(), scale_atmos_dyn_tinteg_short_rk3::atmos_dyn_tinteg_short_rk3_setup(), scale_atmos_dyn_tinteg_short_rk4::atmos_dyn_tinteg_short_rk4_setup(), scale_atmos_dyn_tinteg_short::atmos_dyn_tinteg_short_setup(), scale_atmos_dyn_tinteg_tracer_euler::atmos_dyn_tinteg_tracer_euler_setup(), scale_atmos_dyn_tinteg_tracer_rk3::atmos_dyn_tinteg_tracer_rk3_setup(), scale_atmos_dyn_tinteg_tracer::atmos_dyn_tinteg_tracer_setup(), scale_atmos_dyn_tstep_large_fvm_heve::atmos_dyn_tstep_large_fvm_heve_setup(), scale_atmos_dyn_tstep_large::atmos_dyn_tstep_large_setup(), scale_atmos_dyn_tstep_short_fvm_heve::atmos_dyn_tstep_short_fvm_heve_regist(), scale_atmos_dyn_tstep_short_fvm_hevi::atmos_dyn_tstep_short_fvm_hevi(), scale_atmos_dyn_tstep_short_fvm_hevi::atmos_dyn_tstep_short_fvm_hevi_regist(), scale_atmos_dyn_tstep_short_fvm_hivi::atmos_dyn_tstep_short_fvm_hivi_regist(), scale_atmos_dyn_tstep_short_fvm_hivi::atmos_dyn_tstep_short_fvm_hivi_setup(), scale_atmos_dyn_tstep_short::atmos_dyn_tstep_short_regist(), scale_atmos_dyn_tstep_tracer_fvm_heve::atmos_dyn_tstep_tracer_fvm_heve_setup(), scale_atmos_dyn_tstep_tracer::atmos_dyn_tstep_tracer_setup(), mod_atmos_dyn_vars::atmos_dyn_vars_setup(), scale_atmos_hydrostatic::atmos_hydrostatic_buildrho_1d(), scale_atmos_hydrostatic::atmos_hydrostatic_buildrho_3d(), scale_atmos_hydrostatic::atmos_hydrostatic_buildrho_atmos_0d(), scale_atmos_hydrostatic::atmos_hydrostatic_buildrho_atmos_1d(), scale_atmos_hydrostatic::atmos_hydrostatic_buildrho_atmos_3d(), scale_atmos_hydrostatic::atmos_hydrostatic_buildrho_atmos_rev_2d(), scale_atmos_hydrostatic::atmos_hydrostatic_buildrho_atmos_rev_3d(), scale_atmos_hydrostatic::atmos_hydrostatic_buildrho_bytemp_1d(), scale_atmos_hydrostatic::atmos_hydrostatic_buildrho_bytemp_3d(), scale_atmos_hydrostatic::atmos_hydrostatic_buildrho_bytemp_atmos_1d(), scale_atmos_hydrostatic::atmos_hydrostatic_buildrho_bytemp_atmos_3d(), scale_atmos_hydrostatic::atmos_hydrostatic_buildrho_real_3d(), scale_atmos_hydrostatic::atmos_hydrostatic_setup(), scale_atmos_phy_ae_dummy::atmos_phy_ae_dummy_setup(), scale_atmos_phy_ae_kajino13::atmos_phy_ae_kajino13_setup(), scale_atmos_phy_ae::atmos_phy_ae_setup(), mod_atmos_phy_ae_vars::atmos_phy_ae_vars_setup(), mod_atmos_phy_ch_vars::atmos_phy_ch_vars_setup(), mod_atmos_phy_cp_vars::atmos_phy_cp_vars_setup(), scale_atmos_phy_mp_convert::atmos_phy_mp_bulk2bin(), scale_atmos_phy_mp_dry::atmos_phy_mp_dry_setup(), scale_atmos_phy_mp_kessler::atmos_phy_mp_kessler_setup(), scale_atmos_phy_mp_common::atmos_phy_mp_saturation_adjustment(), scale_atmos_phy_mp_sdm::atmos_phy_mp_sdm(), scale_atmos_phy_mp_sdm::atmos_phy_mp_sdm_setup(), scale_atmos_phy_mp::atmos_phy_mp_setup(), scale_atmos_phy_mp_sn14::atmos_phy_mp_sn14(), scale_atmos_phy_mp_sn14::atmos_phy_mp_sn14_setup(), scale_atmos_phy_mp_suzuki10::atmos_phy_mp_suzuki10_setup(), scale_atmos_phy_mp_tomita08::atmos_phy_mp_tomita08_setup(), mod_atmos_phy_mp_vars::atmos_phy_mp_vars_setup(), scale_atmos_phy_rd_mstrnx::atmos_phy_rd_mstrnx(), scale_atmos_phy_rd_mstrnx::atmos_phy_rd_mstrnx_setup(), scale_atmos_phy_rd_profile::atmos_phy_rd_profile_setup(), scale_atmos_phy_rd_profile::atmos_phy_rd_profile_setup_zgrid(), scale_atmos_phy_rd::atmos_phy_rd_setup(), mod_atmos_phy_rd_vars::atmos_phy_rd_vars_setup(), scale_atmos_phy_sf_bulk::atmos_phy_sf_bulk_setup(), scale_atmos_phy_sf_bulkcoef::atmos_phy_sf_bulkcoef_setup(), scale_atmos_phy_sf_const::atmos_phy_sf_const_setup(), mod_atmos_phy_sf_driver::atmos_phy_sf_driver_setup(), scale_atmos_phy_sf::atmos_phy_sf_setup(), mod_atmos_phy_sf_vars::atmos_phy_sf_vars_setup(), scale_atmos_phy_tb_d1980::atmos_phy_tb_d1980_setup(), scale_atmos_phy_tb_dns::atmos_phy_tb_dns_setup(), mod_atmos_phy_tb_driver::atmos_phy_tb_driver_setup(), scale_atmos_phy_tb_dummy::atmos_phy_tb_dummy_setup(), scale_atmos_phy_tb_hybrid::atmos_phy_tb_hybrid_setup(), scale_atmos_phy_tb_mynn::atmos_phy_tb_mynn_setup(), scale_atmos_phy_tb::atmos_phy_tb_setup(), scale_atmos_phy_tb_smg::atmos_phy_tb_smg_setup(), mod_atmos_phy_tb_vars::atmos_phy_tb_vars_setup(), scale_atmos_refstate::atmos_refstate_read(), scale_atmos_refstate::atmos_refstate_resume(), scale_atmos_refstate::atmos_refstate_setup(), scale_atmos_saturation::atmos_saturation_setup(), scale_atmos_solarins::atmos_solarins_setup(), scale_atmos_thermodyn::atmos_thermodyn_setup(), mod_atmos_vars::atmos_vars_restart_read(), mod_atmos_vars::atmos_vars_setup(), scale_bulkflux::bulkflux_setup(), scale_calendar::calendar_cfunits2sec(), scale_calendar::calendar_unit2sec(), scale_debug::check(), mod_cnvlanduse::cnvlanduse(), mod_cnvlanduse::cnvlanduse_setup(), mod_cnvtopo::cnvtopo(), mod_cnvtopo::cnvtopo_setup(), scale_comm::comm_vars8_init(), scale_comm::comm_vars_init(), scale_const::const_setup(), mod_convert::convert(), mod_convert::convert_setup(), scale_external_io::convertarrayorderwrf2dsp(), mod_copytopo::copytopo(), mod_cpl_admin::cpl_admin_setup(), mod_mkinit::diag_ds(), scale_external_io::externalfilegetglobalattc(), scale_external_io::externalfilegetshape(), scale_external_io::externalfileread2drealdp(), scale_external_io::externalfileread2drealsp(), scale_external_io::externalfileread3drealdp(), scale_external_io::externalfileread3drealsp(), scale_external_io::externalfileread4drealdp(), scale_external_io::externalfileread4drealsp(), scale_external_io::externalfilereadoffset4drealdp(), scale_external_input::extin_setup(), scale_external_input::extin_update_1d(), scale_external_input::extin_update_2d(), scale_external_input::extin_update_3d(), scale_fileio::fileio_read_1d(), scale_fileio::fileio_read_2d(), scale_fileio::fileio_read_3d(), scale_fileio::fileio_read_4d(), scale_fileio::fileio_write_1d(), scale_fileio::fileio_write_2d(), scale_fileio::fileio_write_3d(), scale_fileio::fileio_write_3d_t(), scale_fileio::fileio_write_4d(), mod_mkinit::flux_setup(), scale_grid::grid_generate(), scale_grid_index::grid_index_setup(), scale_grid::grid_setup(), scale_gridtrans::gtrans_rotcoef(), scale_gridtrans::gtrans_setup(), scale_history::hist_setup(), mod_mkinit::interporation_fact(), scale_interpolation_nest::intrpnest_domain_compatibility(), scale_interpolation_nest::intrpnest_interp_fact_latlon(), scale_interpolation_nest::intrpnest_interp_fact_llz(), scale_interpolation_nest::intrpnest_setup(), mod_land_admin::land_admin_getscheme(), mod_land_admin::land_admin_setup(), scale_land_grid_index::land_grid_index_setup(), scale_land_grid::land_grid_setup(), mod_realinput::land_interporation(), scale_land_phy_matsiro::land_phy_matsiro_setup(), scale_land_phy::land_phy_setup(), scale_land_phy_slab::land_phy_slab_setup(), mod_mkinit::land_setup(), scale_land_sfc::land_sfc_setup(), scale_land_sfc_slab::land_sfc_slab(), scale_land_sfc_slab::land_sfc_slab_setup(), mod_land_vars::land_vars_external_in(), mod_land_vars::land_vars_setup(), scale_landuse::landuse_setup(), mod_mkinit::mkinit(), mod_mkinit::mkinit_setup(), mod_mktopo::mktopo(), mod_mktopo::mktopo_setup(), scale_monitor::monit_setup(), scale_monitor::monit_write(), scale_atmos_phy_mp_suzuki10::mp_suzuki10(), scale_mapproj::mprj_lonlat2xy(), scale_mapproj::mprj_mapfactor(), scale_mapproj::mprj_rotcoef_0d(), scale_mapproj::mprj_rotcoef_2d(), scale_mapproj::mprj_setup(), scale_mapproj::mprj_xy2lonlat(), scale_grid_nest::nest_comm_intercomm_nestdown_3d(), scale_grid_nest::nest_comm_issuer_of_receive_3d(), scale_grid_nest::nest_comm_issuer_of_wait_3d(), scale_grid_nest::nest_comm_nestdown(), scale_grid_nest::nest_comm_recv_cancel(), scale_grid_nest::nest_comm_recvwait_issue(), scale_grid_nest::nest_comm_test(), scale_grid_nest::nest_comm_waitall(), scale_grid_nest::nest_domain_relate(), scale_grid_nest::nest_domain_shape(), scale_grid_nest::nest_setup(), scale_atmos_phy_mp_sn14::nucleation_kij(), mod_ocean_admin::ocean_admin_getscheme(), mod_ocean_admin::ocean_admin_setup(), scale_ocean_phy_file::ocean_phy_file(), scale_ocean_phy_file::ocean_phy_file_setup(), scale_ocean_phy::ocean_phy_setup(), scale_ocean_phy_slab::ocean_phy_slab_setup(), mod_mkinit::ocean_setup(), scale_ocean_sfc::ocean_sfc_setup(), scale_ocean_sfc_slab::ocean_sfc_slab(), scale_ocean_sfc_slab::ocean_sfc_slab_setup(), mod_ocean_vars::ocean_vars_setup(), mod_realinput_grads::parentatominputgrads(), mod_realinput::parentatomsetup(), mod_realinput_grads::parentatomsetupgrads(), mod_realinput_wrfarw::parentatomsetupwrfarw(), mod_realinput_grads::parentlandinputgrads(), mod_realinput_grads::parentlandsetupgrads(), mod_realinput_wrfarw::parentlandsetupwrfarw(), mod_realinput_grads::parentoceaninputgrads(), mod_realinput_grads::parentoceansetupgrads(), mod_realinput_wrfarw::parentoceansetupwrfarw(), prc_mpisplit(), scale_rm_process::prc_setup(), scale_prof::prof_setup(), scale_random::random_setup(), mod_realinput_grads::read_namelist(), mod_mkinit::read_sounding(), scale_grid_real::real_setup(), scale_grid_real::real_update_z(), mod_realinput::realinput_atmos(), mod_realinput::realinput_surface(), mod_mkinit::rect_setup(), mod_realinput::replace_misval_map(), scale_roughness::roughness_setup(), scalerm_launcher(), scale_atmos_refstate::smoothing(), scale_atmos_dyn_tstep_short_fvm_hivi::solve_bicgstab(), scale_atmos_dyn_tstep_short_fvm_hevi::solve_direct(), scale_rm_statistics::stat_setup(), scale_rm_statistics::stat_total_2d(), scale_rm_statistics::stat_total_3d(), scale_topography::topo_fillhalo(), scale_topography::topo_setup(), scale_tracer::tracer_setup(), scale_tracer_suzuki10::tracer_suzuki10_setup(), mod_urban_admin::urban_admin_getscheme(), mod_urban_admin::urban_admin_setup(), scale_urban_grid_index::urban_grid_index_setup(), scale_urban_grid::urban_grid_setup(), scale_urban_phy::urban_phy_setup(), scale_urban_phy_slc::urban_phy_slc(), scale_urban_phy_slc::urban_phy_slc_setup(), mod_mkinit::urban_setup(), mod_urban_vars::urban_vars_setup(), mod_user::user_setup(), mod_user::user_step(), scale_debug::valcheck_1d(), scale_debug::valcheck_2d(), scale_debug::valcheck_3d(), scale_comm::vars8_2d_mpi(), scale_comm::vars8_3d_mpi(), scale_comm::vars_2d_mpi(), scale_comm::vars_3d_mpi_pc(), and scale_comm::vars_init_mpi_pc().

234  implicit none
235 
236  integer :: ierr
237  !---------------------------------------------------------------------------
238 
239  if ( prc_mpi_alive ) then
240  ! tentative approach; input "PRC_UNIVERSAL_COMM_WORLD".
241  call mpi_comm_call_errhandler(prc_universal_comm_world,prc_abort_code,ierr)
242  endif
243 
244  stop

◆ prc_mpifinish()

subroutine, public scale_process::prc_mpifinish ( )

Stop MPI peacefully.

Definition at line 250 of file scale_process.F90.

References scale_stdio::io_fid_conf, scale_stdio::io_fid_log, scale_stdio::io_fid_stdout, scale_stdio::io_l, prc_abort_handler, prc_global_comm_world, prc_local_comm_world, prc_mpi_alive, prc_universal_comm_world, and prc_universal_handler.

Referenced by scalerm_launcher().

250  implicit none
251 
252  integer :: ierr
253  !---------------------------------------------------------------------------
254 
255  if (prc_universal_handler .NE. mpi_errhandler_null) then
256  call mpi_errhandler_free(prc_universal_handler, ierr)
257  endif
258  if (prc_abort_handler .NE. mpi_errhandler_null) then
259  call mpi_errhandler_free(prc_abort_handler, ierr)
260  endif
261 
262  ! Stop MPI
263  if ( prc_mpi_alive ) then
264  if ( io_l ) then
265  write(io_fid_log,*)
266  write(io_fid_log,*) '++++++ Stop MPI'
267  write(io_fid_log,*)
268  endif
269 
270  ! free splitted communicator
271  if ( prc_local_comm_world /= prc_global_comm_world ) then
272  call mpi_comm_free(prc_local_comm_world,ierr)
273  endif
274 
275  call mpi_barrier(prc_universal_comm_world,ierr)
276 
277  call mpi_finalize(ierr)
278  if( io_l ) write(io_fid_log,*) '*** MPI is peacefully finalized'
279  endif
280 
281  ! Close logfile, configfile
282  if ( io_l ) then
283  if( io_fid_log /= io_fid_stdout ) close(io_fid_log)
284  endif
285  close(io_fid_conf)
286 
287  ! Stop program
288  stop
integer, public io_fid_conf
Config file ID.
Definition: scale_stdio.F90:55
Here is the caller graph for this function:

◆ prc_mpisplit()

subroutine, public scale_process::prc_mpisplit ( integer, intent(in)  ORG_COMM,
integer, intent(in)  NUM_DOMAIN,
integer, dimension(:), intent(in)  PRC_DOMAINS,
character(len=h_long), dimension(:), intent(in)  CONF_FILES,
logical, intent(in)  LOG_SPLIT,
logical, intent(in)  bulk_split,
logical, intent(in)  color_reorder,
integer, intent(out)  INTRA_COMM,
integer, intent(out)  inter_parent,
integer, intent(out)  inter_child,
character(len=h_long), intent(out)  fname_local 
)

MPI Communicator Split.

Definition at line 305 of file scale_process.F90.

References prc_masterrank, prc_mpistop(), prc_universal_ismaster, and prc_universal_jobid.

Referenced by scalerm_launcher().

305  implicit none
306 
307  integer, intent(in) :: org_comm
308  integer, intent(in) :: num_domain
309  integer, intent(in) :: prc_domains(:)
310  character(len=H_LONG), intent(in) :: conf_files(:)
311  logical, intent(in) :: log_split
312  logical, intent(in) :: bulk_split
313  logical, intent(in) :: color_reorder
314 
315  integer, intent(out) :: intra_comm
316  integer, intent(out) :: inter_parent
317  integer, intent(out) :: inter_child
318  character(len=H_LONG), intent(out) :: fname_local
319 
320  integer :: parent_col(prc_domain_nlim) ! parent color number
321  integer :: child_col(prc_domain_nlim) ! child color number
322  integer :: prc_root(0:prc_domain_nlim) ! root process in the color
323  integer, allocatable :: color_list(:) ! member list in each color
324  integer, allocatable :: key_list(:) ! local process number in each color
325 
326  integer :: total_nmax
327  integer :: org_myrank ! my rank number in the original communicator
328  integer :: org_nmax ! total rank number in the original communicator
329 
330  logical :: do_create_p(prc_domain_nlim)
331  logical :: do_create_c(prc_domain_nlim)
332  logical :: reordering
333 
334  character(len=H_LONG) :: col_file(0:prc_domain_nlim)
335  character(len=4) :: col_num
336 
337  integer :: i
338  integer :: itag, ierr
339  !---------------------------------------------------------------------------
340 
341  intra_comm = org_comm
342  inter_parent = mpi_comm_null
343  inter_child = mpi_comm_null
344  fname_local = conf_files(1)
345 
346  if ( num_domain > 1 ) then ! multi domain run
347  call mpi_comm_rank(org_comm,org_myrank,ierr)
348  call mpi_comm_size(org_comm,org_nmax, ierr)
349  allocate ( color_list(0:org_nmax-1) )
350  allocate ( key_list(0:org_nmax-1) )
351 
352  total_nmax = 0
353  do i = 1, num_domain
354  total_nmax = total_nmax + prc_domains(i)
355  enddo
356  if ( total_nmax /= org_nmax ) then
357  if ( prc_universal_ismaster ) write (*,*) ""
358  if ( prc_universal_ismaster ) write (*,*) "ERROR: MPI PROCESS NUMBER is INCONSISTENT"
359  if ( prc_universal_ismaster ) write (*,*) "REQUESTED NPROCS = ", total_nmax, " LAUNCHED NPROCS = ", org_nmax
360  call prc_mpistop
361  endif
362 
363  reordering = color_reorder
364  if ( bulk_split ) then
365  reordering = .false.
366  endif
367  call prc_mpicoloring( org_comm, & ! [in ]
368  num_domain, & ! [in ]
369  prc_domains, & ! [in ]
370  conf_files, & ! [in ]
371  reordering, & ! [in ]
372  log_split, & ! [in ]
373  color_list, & ! [out]
374  prc_root, & ! [out]
375  key_list, & ! [out]
376  parent_col, & ! [out]
377  child_col, & ! [out]
378  col_file ) ! [out]
379 
380 
381  ! split comm_world
382  call mpi_comm_split(org_comm, &
383  color_list(org_myrank), &
384  key_list(org_myrank), &
385  intra_comm, ierr)
386  if ( bulk_split ) then
387  write(col_num,'(I4.4)') color_list(org_myrank)
388  fname_local = col_num
389  prc_universal_jobid = color_list(org_myrank)
390  else
391  fname_local = col_file(color_list(org_myrank))
392  endif
393 
394  ! set parent-child relationship
395  do_create_p(:) = .false.
396  do_create_c(:) = .false.
397  if ( .NOT. bulk_split ) then
398  do i = 1, num_domain-1
399  if ( prc_universal_ismaster ) write ( *, '(1X,A,I4)' ) "relationship: ", i
400  if ( prc_universal_ismaster ) write ( *, '(1X,A,I4,A,I4)' ) &
401  "--- parent color = ", parent_col(i), " child color = ", child_col(i)
402  if ( color_list(org_myrank) == parent_col(i) ) then
403  do_create_p(i) = .true.
404  elseif ( color_list(org_myrank) == child_col(i) ) then
405  do_create_c(i) = .true.
406  endif
407  enddo
408  endif
409 
410  ! create inter-commnunicator
411  inter_parent = mpi_comm_null
412  inter_child = mpi_comm_null
413  if ( .NOT. bulk_split ) then
414  do i = 1, num_domain-1
415  itag = i*100
416  if ( do_create_p(i) ) then ! as a parent
417  call mpi_intercomm_create( intra_comm, prc_masterrank, &
418  org_comm, prc_root(child_col(i)), &
419  itag, inter_child, ierr)
420  elseif ( do_create_c(i) ) then ! as a child
421  call mpi_intercomm_create( intra_comm, prc_masterrank, &
422  org_comm, prc_root(parent_col(i)), &
423  itag, inter_parent, ierr)
424  endif
425  call mpi_barrier(org_comm, ierr)
426  enddo
427  endif
428 
429  deallocate ( color_list, key_list )
430 
431  elseif ( num_domain == 1 ) then ! single domain run
432  if ( prc_universal_ismaster ) write (*,*) "*** a single comunicator"
433  else
434  if ( prc_universal_ismaster ) write (*,*) "ERROR: REQUESTED DOMAIN NUMBER IS NOT ACCEPTABLE"
435  call prc_mpistop
436  endif
437 
438  return
subroutine, public prc_mpistop
Abort MPI.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ prc_mpisplit_letkf()

subroutine, public scale_process::prc_mpisplit_letkf ( integer, intent(in)  ORG_COMM,
integer, intent(in)  mem_np,
integer, intent(in)  nitmax,
integer, intent(in)  nprocs,
integer, dimension(2,nitmax,nprocs), intent(in)  proc2mem,
integer, intent(out)  INTRA_COMM 
)

MPI Communicator Split for SCALE-LETKF ensemble.

Definition at line 450 of file scale_process.F90.

References prc_universal_ismaster.

450  implicit none
451 
452  integer, intent(in) :: org_comm
453  integer, intent(in) :: mem_np
454  integer, intent(in) :: nitmax
455  integer, intent(in) :: nprocs
456  integer, intent(in) :: proc2mem(2,nitmax,nprocs)
457  integer, intent(out) :: intra_comm
458 
459  integer :: org_myrank ! my rank number in the original communicator
460  integer :: color, key
461  integer :: ierr
462  !---------------------------------------------------------------------------
463 
464  call mpi_comm_rank( org_comm, org_myrank, ierr)
465 
466  if ( proc2mem(1,1,org_myrank+1) >= 1 ) then
467  color = proc2mem(1,1,org_myrank+1) - 1
468  key = proc2mem(2,1,org_myrank+1)
469  else
470  color = mpi_undefined
471  key = mpi_undefined
472  end if
473 
474  call mpi_comm_split( org_comm, &
475  color, &
476  key, &
477  intra_comm, ierr )
478 
479  return

◆ prc_mpibarrier()

subroutine, public scale_process::prc_mpibarrier ( )

Barrier MPI.

Definition at line 703 of file scale_process.F90.

References prc_local_comm_world, and prc_mpi_alive.

Referenced by scale_prof::prof_rapend(), and scale_prof::prof_rapstart().

703  implicit none
704 
705  integer :: ierr
706  !---------------------------------------------------------------------------
707 
708  if ( prc_mpi_alive ) then
709  call mpi_barrier(prc_local_comm_world,ierr)
710  endif
711 
Here is the caller graph for this function:

◆ prc_mpitime()

real(dp) function, public scale_process::prc_mpitime ( )

Get MPI time.

Returns
time

Definition at line 718 of file scale_process.F90.

References prc_mpi_alive.

Referenced by mod_admin_time::admin_time_advance(), mod_admin_time::admin_time_checkstate(), mod_admin_time::admin_time_setup(), scale_prof::prof_rapend(), and scale_prof::prof_rapstart().

718  implicit none
719 
720  real(DP) :: time
721  !---------------------------------------------------------------------------
722 
723  if ( prc_mpi_alive ) then
724  time = real(MPI_WTIME(), kind=dp)
725  else
726  call cpu_time(time)
727  endif
728 
integer, parameter, public dp
Here is the caller graph for this function:

◆ prc_mpitimestat()

subroutine, public scale_process::prc_mpitimestat ( real(dp), dimension(:), intent(out)  avgvar,
real(dp), dimension(:), intent(out)  maxvar,
real(dp), dimension(:), intent(out)  minvar,
integer, dimension(:), intent(out)  maxidx,
integer, dimension(:), intent(out)  minidx,
real(dp), dimension(:), intent(in)  var 
)

Calc global statistics for timer.

Parameters
[out]avgvaraverage
[out]maxvarmaximum
[out]minvarminimum
[out]maxidxindex of maximum
[out]minidxindex of minimum
[in]varvalues for statistics

Definition at line 740 of file scale_process.F90.

References gtool_file::filecloseall(), scale_stdio::io_fid_conf, scale_stdio::io_fid_log, scale_stdio::io_fid_stdout, scale_stdio::io_l, prc_abort_comm_world, prc_global_domainid, prc_global_myrank, prc_global_nprocs, prc_local_comm_world, prc_mpi_alive, prc_myrank, prc_nprocs, prc_universal_jobid, prc_universal_myrank, and prc_universal_nprocs.

Referenced by scale_prof::prof_rapreport().

740  implicit none
741 
742  real(DP), intent(out) :: avgvar(:)
743  real(DP), intent(out) :: maxvar(:)
744  real(DP), intent(out) :: minvar(:)
745  integer, intent(out) :: maxidx(:)
746  integer, intent(out) :: minidx(:)
747  real(DP), intent(in) :: var(:)
748 
749  real(DP), allocatable :: statval(:,:)
750  integer :: vsize
751 
752  real(DP) :: totalvar
753  integer :: ierr
754  integer :: v, p
755  !---------------------------------------------------------------------------
756 
757  vsize = size(var(:))
758 
759  allocate( statval(vsize,0:prc_nprocs-1) )
760  statval(:,:) = 0.0_dp
761 
762  do v = 1, vsize
763  statval(v,prc_myrank) = var(v)
764  enddo
765 
766  ! MPI broadcast
767  do p = 0, prc_nprocs-1
768  call mpi_bcast( statval(1,p), &
769  vsize, &
770  mpi_double_precision, &
771  p, &
772  prc_local_comm_world, &
773  ierr )
774  enddo
775 
776  do v = 1, vsize
777  totalvar = 0.0_dp
778  do p = 0, prc_nprocs-1
779  totalvar = totalvar + statval(v,p)
780  enddo
781  avgvar(v) = totalvar / prc_nprocs
782 
783  maxvar(v) = maxval(statval(v,:))
784  minvar(v) = minval(statval(v,:))
785  maxidx(v:v) = maxloc(statval(v,:))
786  minidx(v:v) = minloc(statval(v,:))
787  enddo
788 
789  deallocate( statval )
790 
791  return
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ prc_masterrank

integer, parameter, public scale_process::prc_masterrank = 0

◆ prc_domain_nlim

integer, parameter, public scale_process::prc_domain_nlim = 10000

max depth of domains

Definition at line 57 of file scale_process.F90.

Referenced by scalerm_launcher().

57  integer, public, parameter :: prc_domain_nlim = 10000

◆ prc_universal_comm_world

integer, public scale_process::prc_universal_comm_world = -1

original communicator

Definition at line 60 of file scale_process.F90.

Referenced by prc_mpifinish(), prc_mpistop(), scale_rm_process::prc_setup(), and prc_universal_setup().

60  integer, public :: prc_universal_comm_world = -1

◆ prc_universal_myrank

integer, public scale_process::prc_universal_myrank = -1

myrank in universal communicator

Definition at line 61 of file scale_process.F90.

Referenced by prc_mpitimestat(), scale_rm_process::prc_setup(), and prc_universal_setup().

61  integer, public :: prc_universal_myrank = -1

◆ prc_universal_nprocs

integer, public scale_process::prc_universal_nprocs = -1

process num in universal communicator

Definition at line 62 of file scale_process.F90.

Referenced by prc_mpitimestat(), scale_rm_process::prc_setup(), and prc_universal_setup().

62  integer, public :: prc_universal_nprocs = -1

◆ prc_universal_ismaster

logical, public scale_process::prc_universal_ismaster = .false.

master process in universal communicator?

Definition at line 63 of file scale_process.F90.

Referenced by prc_mpisplit(), prc_mpisplit_letkf(), scale_rm_process::prc_setup(), and prc_universal_setup().

63  logical, public :: prc_universal_ismaster = .false.

◆ prc_universal_jobid

integer, public scale_process::prc_universal_jobid = 0

my job ID in universal communicator

Definition at line 65 of file scale_process.F90.

Referenced by prc_mpisplit(), and prc_mpitimestat().

65  integer, public :: prc_universal_jobid = 0

◆ prc_global_comm_world

integer, public scale_process::prc_global_comm_world = -1

global communicator

Definition at line 68 of file scale_process.F90.

Referenced by scale_grid_nest::nest_comm_disconnect(), prc_global_setup(), prc_mpifinish(), and scale_rm_process::prc_setup().

68  integer, public :: prc_global_comm_world = -1

◆ prc_global_myrank

integer, public scale_process::prc_global_myrank = -1

myrank in global communicator

Definition at line 69 of file scale_process.F90.

Referenced by prc_global_setup(), prc_mpitimestat(), and scale_rm_process::prc_setup().

69  integer, public :: prc_global_myrank = -1

◆ prc_global_nprocs

integer, public scale_process::prc_global_nprocs = -1

process num in global communicator

Definition at line 70 of file scale_process.F90.

Referenced by prc_global_setup(), prc_mpitimestat(), and scale_rm_process::prc_setup().

70  integer, public :: prc_global_nprocs = -1

◆ prc_global_ismaster

logical, public scale_process::prc_global_ismaster = .false.

master process in global communicator?

Definition at line 71 of file scale_process.F90.

Referenced by prc_global_setup(), and scale_rm_process::prc_setup().

71  logical, public :: prc_global_ismaster = .false.

◆ prc_global_domainid

integer, public scale_process::prc_global_domainid = 0

my domain ID in global communicator

Definition at line 73 of file scale_process.F90.

Referenced by scale_grid_nest::nest_setup(), and prc_mpitimestat().

73  integer, public :: prc_global_domainid = 0

◆ prc_local_comm_world

integer, public scale_process::prc_local_comm_world = -1

local communicator

Definition at line 76 of file scale_process.F90.

Referenced by scale_comm::comm_setup(), prc_local_setup(), prc_mpibarrier(), prc_mpifinish(), prc_mpitimestat(), and scale_rm_process::prc_setup().

76  integer, public :: prc_local_comm_world = -1

◆ prc_nprocs

integer, public scale_process::prc_nprocs = 1

◆ prc_myrank

integer, public scale_process::prc_myrank = 0

process num in local communicator

Definition at line 78 of file scale_process.F90.

Referenced by mod_admin_time::admin_time_setup(), scale_atmos_boundary::atmos_boundary_resume(), scale_atmos_boundary::atmos_boundary_update(), mod_atmos_vars::atmos_vars_monitor(), mod_atmos_vars::atmos_vars_restart_check(), mod_copytopo::copytopo(), scale_atmos_phy_mp_sn14::debug_tem_kij(), scale_external_input::extin_setup(), scale_external_input::extin_update_1d(), scale_external_input::extin_update_2d(), scale_external_input::extin_update_3d(), scale_fileio::fileio_read_1d(), scale_fileio::fileio_read_2d(), scale_fileio::fileio_read_3d(), scale_fileio::fileio_read_4d(), scale_fileio::fileio_write_1d(), scale_fileio::fileio_write_2d(), scale_fileio::fileio_write_3d(), scale_fileio::fileio_write_3d_t(), scale_fileio::fileio_write_4d(), scale_grid::grid_allocate(), scale_grid::grid_generate(), scale_grid_index::grid_index_setup(), scale_history::hist_setup(), scale_land_grid::land_grid_setup(), scale_land_sfc_slab::land_sfc_slab(), scale_monitor::monit_finalize(), scale_monitor::monit_write(), scale_grid_nest::nest_comm_intercomm_nestdown_3d(), scale_grid_nest::nest_comm_issuer_of_receive_3d(), scale_grid_nest::nest_comm_nestdown(), scale_grid_nest::nest_comm_recv_cancel(), scale_grid_nest::nest_domain_relate(), scale_grid_nest::nest_domain_shape(), prc_local_setup(), prc_mpitimestat(), scale_rm_process::prc_setup(), scale_random::random_setup(), scale_rm_statistics::stat_detail(), scale_rm_statistics::stat_total_2d(), scale_rm_statistics::stat_total_3d(), scale_topography::topo_fillhalo(), scale_urban_grid::urban_grid_setup(), scale_urban_phy_slc::urban_phy_slc(), scale_debug::valcheck_1d(), scale_debug::valcheck_2d(), and scale_debug::valcheck_3d().

78  integer, public :: prc_myrank = 0

◆ prc_ismaster

logical, public scale_process::prc_ismaster = .false.

◆ prc_mpi_alive

logical, public scale_process::prc_mpi_alive = .false.

MPI is alive?

Definition at line 82 of file scale_process.F90.

Referenced by prc_mpibarrier(), prc_mpifinish(), prc_mpistart(), prc_mpistop(), prc_mpitime(), prc_mpitimestat(), and scale_rm_process::prc_setup().

82  logical, public :: prc_mpi_alive = .false.

◆ prc_universal_handler

integer, public scale_process::prc_universal_handler

error handler in universal communicator

Definition at line 83 of file scale_process.F90.

Referenced by prc_mpifinish(), prc_mpistart(), and prc_universal_setup().

83  integer, public :: prc_universal_handler

◆ prc_abort_comm_world

integer, public scale_process::prc_abort_comm_world

communicator for aborting

Definition at line 84 of file scale_process.F90.

Referenced by prc_mpitimestat(), scale_rm_process::prc_setup(), and prc_universal_setup().

84  integer, public :: prc_abort_comm_world

◆ prc_abort_handler

integer, public scale_process::prc_abort_handler

error handler communicator for aborting

Definition at line 85 of file scale_process.F90.

Referenced by prc_mpifinish(), and prc_universal_setup().

85  integer, public :: prc_abort_handler