SCALE-RM
scale-rm_pp.f90
Go to the documentation of this file.
1 !-------------------------------------------------------------------------------
11 !-------------------------------------------------------------------------------
13  !-----------------------------------------------------------------------------
14  !
15  !++ used modules
16  !
17  use dc_log, only: &
18  loginit
19  use gtool_file, only: &
21  use scale_precision
22  use scale_stdio
23  use scale_prof
24 
25  use scale_process, only: &
27  prc_mpistart, &
28  prc_mpistop, &
29  prc_mpifinish, &
30  prc_mpisplit, &
33  use mod_rm_prep, only: &
35  use mod_rm_driver, only: &
36  scalerm
37  !-----------------------------------------------------------------------------
38  implicit none
39  !-----------------------------------------------------------------------------
40  !
41  !++ included parameters
42  !
43  !-----------------------------------------------------------------------------
44  !
45  !++ parameters & variables
46  !
47  !=============================================================================
48 
49  logical :: EXECUTE_PREPROCESS = .true. ! execute preprocess tools?
50  logical :: EXECUTE_MODEL = .false. ! execute main model?
51  integer :: NUM_BULKJOB = 1 ! number of bulk jobs
52  integer :: NUM_DOMAIN = 1 ! number of domains
53  integer :: PRC_DOMAINS(prc_domain_nlim) = 0 ! number of total process in each domain
54  character(len=H_LONG) :: CONF_FILES (prc_domain_nlim) = "" ! name of configulation files
55  logical :: ABORT_ALL_JOBS = .false. ! abort all jobs or not?
56  logical :: LOG_SPLIT = .false. ! log-output for mpi splitting?
57  logical :: COLOR_REORDER = .true. ! coloring reorder for mpi splitting?
58 
59  namelist / param_launcher / &
60  execute_preprocess, &
61  execute_model, &
62  num_bulkjob, &
63  num_domain, &
64  prc_domains, &
65  conf_files, &
66  abort_all_jobs, &
67  log_split, &
68  color_reorder
69 
70  integer :: universal_comm ! universal communicator
71  integer :: universal_nprocs ! number of procs in universal communicator
72  logical :: universal_master ! master process in universal communicator?
73  character(len=H_LONG) :: universal_cnf_fname ! config file for launcher
74 
75  integer :: global_comm ! communicator for each member
76  integer :: global_nprocs ! number of procs in global communicator
77  integer :: PRC_BULKJOB(prc_domain_nlim) = 0 ! = global_nprocs
78  character(len=H_LONG) :: dummy1 (prc_domain_nlim) = ""
79  integer :: intercomm_parent_null ! NULL inter communicator with parent
80  integer :: intercomm_child_null ! NULL inter communicator with child
81  character(len=H_LONG) :: bulk_prefix ! dirname of each member
82 
83  integer :: local_comm ! assigned local communicator
84  integer :: intercomm_parent ! inter communicator with parent
85  integer :: intercomm_child ! inter communicator with child
86  character(len=H_LONG) :: local_cnf_fname ! config file for local domain
87 
88  integer :: fid, ierr
89  !-----------------------------------------------------------
90 
91  ! start MPI
92  call prc_mpistart( universal_comm ) ! [OUT]
93 
94  call prc_universal_setup( universal_comm, & ! [IN]
95  universal_nprocs, & ! [OUT]
96  universal_master ) ! [OUT]
97 
98  if( universal_master ) write(*,*) '*** Start Launch System for SCALE-RM'
99 
100  !--- read launcher config
101 
102  universal_cnf_fname = io_arg_getfname( universal_master )
103 
104  fid = io_cnf_open( universal_cnf_fname, & ! [IN]
105  universal_master ) ! [IN]
106 
107  ! set default
108  conf_files(1) = universal_cnf_fname
109 
110  ! read namelist
111  rewind(fid)
112  read(fid,nml=param_launcher,iostat=ierr)
113  if ( ierr < 0 ) then !--- missing
114  ! keep default setting (no members, no nesting)
115  elseif( ierr > 0 ) then !--- fatal error
116  if( universal_master ) write(*,*) 'xxx Not appropriate names in namelist PARAM_LAUNCHER. Check!'
117  call prc_mpistop
118  endif
119 
120  close(fid)
121 
122  if ( execute_preprocess &
123  .OR. execute_model ) then
124  if( universal_master ) write(*,*) "*** Execute preprocess? : ", execute_preprocess
125  if( universal_master ) write(*,*) "*** Execute model? : ", execute_model
126  else
127  if( universal_master ) write(*,*) 'xxx No execution. please check PARAM_LAUNCHER. STOP'
128  call prc_mpistop
129  endif
130 
131  !--- split for bulk jobs
132 
133  if ( mod(universal_nprocs,num_bulkjob) /= 0 ) then !--- fatal error
134  if( universal_master ) write(*,*) 'xxx Total Num of Processes must be divisible by NUM_BULKJOB. Check!'
135  if( universal_master ) write(*,*) 'xxx Total Num of Processes = ', universal_nprocs
136  if( universal_master ) write(*,*) 'xxx NUM_BULKJOB = ', num_bulkjob
137  call prc_mpistop
138  endif
139 
140  global_nprocs = universal_nprocs / num_bulkjob
141  prc_bulkjob(1:num_bulkjob) = global_nprocs
142  if ( num_bulkjob > 1 ) then
143  if( universal_master ) write(*,'(1x,A,I5)') "*** TOTAL BULK JOB NUMBER = ", num_bulkjob
144  if( universal_master ) write(*,'(1x,A,I5)') "*** PROCESS NUM of EACH JOB = ", global_nprocs
145  endif
146 
147  ! communicator split for bulk/ensemble
148  call prc_mpisplit( universal_comm, & ! [IN]
149  num_bulkjob, & ! [IN]
150  prc_bulkjob(:), & ! [IN]
151  dummy1(:), & ! [IN] dummy
152  log_split, & ! [IN]
153  .true., & ! [IN] flag bulk_split
154  .false., & ! [IN] no reordering
155  global_comm, & ! [OUT]
156  intercomm_parent_null, & ! [OUT] null
157  intercomm_child_null, & ! [OUT] null
158  bulk_prefix ) ! [OUT] dir name instead of file name
159 
160  call prc_global_setup( abort_all_jobs, & ! [IN]
161  global_comm ) ! [IN]
162 
163  !--- split for nesting
164 
165  if ( num_domain > 1 ) then
166  if( universal_master ) write(*,'(1x,A,I5)') "*** TOTAL DOMAIN NUMBER = ", num_domain
167  if( universal_master ) write(*,'(1x,A,L5)') "*** Flag of ABORT ALL JOBS = ", abort_all_jobs
168  endif
169 
170  ! communicator split for nesting domains
171  call prc_mpisplit( global_comm, & ! [IN]
172  num_domain, & ! [IN]
173  prc_domains(:), & ! [IN]
174  conf_files(:), & ! [IN]
175  log_split, & ! [IN]
176  .false., & ! [IN] flag bulk_split
177  color_reorder, & ! [IN]
178  local_comm, & ! [OUT]
179  intercomm_parent, & ! [OUT]
180  intercomm_child, & ! [OUT]
181  local_cnf_fname ) ! [OUT]
182 
183  !--- start main routine
184 
185  if ( num_bulkjob > 1 ) then
186  local_cnf_fname = trim(bulk_prefix)//"/"//trim(local_cnf_fname)
187  endif
188 
189  if ( execute_preprocess ) then
190  call scalerm_prep( local_comm, & ! [IN]
191  intercomm_parent_null, & ! [IN]
192  intercomm_child_null, & ! [IN]
193  local_cnf_fname ) ! [IN]
194  endif
195 
196  if ( execute_model ) then
197  call scalerm ( local_comm, & ! [IN]
198  intercomm_parent, & ! [IN]
199  intercomm_child, & ! [IN]
200  local_cnf_fname ) ! [IN]
201  endif
202 
203  ! stop MPI
204  call prc_mpifinish
205 
206  if( universal_master ) write(*,*) '*** End Launch System for SCALE-RM'
207 
208  stop
209 end program scalerm_launcher
module GTOOL_FILE
Definition: gtool_file.f90:17
subroutine, public prc_mpistop
Abort MPI.
module DC_Log
Definition: dc_log.f90:14
subroutine, public scalerm(comm_world, intercomm_parent, intercomm_child, cnf_fname)
Setup.
module STDIO
Definition: scale_stdio.F90:12
subroutine, public prc_universal_setup(comm, nprocs, ismaster)
setup MPI in universal communicator
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.
character(len=h_long) function, public io_arg_getfname(is_master)
get config filename from argument
subroutine, public filecloseall
subroutine, public loginit(fid_conf, fid_log, master)
Definition: dc_log.f90:66
module SCALE-RM (a main routine of regional model)
program scalerm_launcher
Program SCALE-RM (a launcher of main routine)
Definition: scale-rm.f90:12
module PROCESS
subroutine, public prc_global_setup(abortall, comm)
setup MPI in global communicator
subroutine, public scalerm_prep(comm_world, intercomm_parent, intercomm_child, cnf_fname)
Setup.
Definition: mod_rm_prep.f90:67
subroutine, public prc_mpistart(comm)
Start MPI.
module profiler
Definition: scale_prof.F90:10
module PRECISION
integer, parameter, public prc_domain_nlim
max depth of domains
module SCALE-RM prep
Definition: mod_rm_prep.f90:18
subroutine, public prc_mpifinish
Stop MPI peacefully.
integer function, public io_cnf_open(fname, is_master)
open config file