DISPATCH
dispatcher_mod.f90
1 !===============================================================================
2 !> Do not use a dispatcher, but call task_list%execute, which relies on threads
3 !> handling a ready queue.
4 !===============================================================================
6  USE io_mod
7  USE trace_mod
8  USE mpi_mod
9  USE task_list_mod
10  USE dispatcher0_mod
11  USE dispatcher1_mod
12  USE dispatcher2_mod
13  USE dispatcher3_mod
14  USE dispatcher4_mod
15  USE dispatcher5_mod
16  USE dispatcher6_mod
17  USE mpi_mesg_mod
18  USE data_io_mod
19  USE experiment_mod
20  USE list_mod
21  USE task_mesg_mod
22  implicit none
23  private
24  type, public:: dispatcher_t
25  procedure(method0), nopass, pointer:: method => null()
26  contains
27  procedure:: init
28  procedure:: execute
29  procedure, nopass:: method0
30  procedure, nopass:: method1
31  procedure, nopass:: method2
32  procedure, nopass:: method3
33  procedure, nopass:: method4
34  procedure, nopass:: method5
35  end type
36  integer, save:: verbose=0
37  integer, save:: method=0
38  logical, save:: test=.false.
39  real(8):: test_seconds=30.
40  type(dispatcher_t), public:: dispatcher
41 CONTAINS
42 
43 !===============================================================================
44 !> Choose and initialize the dispatcher method. For full flexibility, default
45 !> parameters for mpi_mesg_mod are first set, and may then be overwritten in the
46 !> mpi_mesg%init call.
47 !===============================================================================
48 SUBROUTINE init (self)
49  class(dispatcher_t):: self
50  integer:: iostat
51  namelist /dispatcher_params/ method, verbose, test, test_seconds
52  !-----------------------------------------------------------------------------
53  call trace%begin ('dispatcher_t%init')
54  rewind(io%input)
55  read (io%input, dispatcher_params, iostat=iostat)
56  write (io%output, dispatcher_params)
57  !-----------------------------------------------------------------------------
58  select case (method)
59  case (0)
60  self%method => method0
61  call dispatcher0%init
62  case (1)
63  self%method => method1
64  case (2)
65  self%method => method2
66  case (3)
67  self%method => method3
68  case (4)
69  self%method => method4
70  case (5)
71  self%method => method5
72  case (6)
73  self%method => method6
74  case default
75  call io%abort ('unknown method in dispatcher_mod')
76  end select
77  !-----------------------------------------------------------------------------
78  ! Pass the method choice on to task_method_t, in case it has an impact
79  !-----------------------------------------------------------------------------
80  task_mesg%method = method
81  call mpi_mesg%init
82  call trace%end()
83 END SUBROUTINE init
84 
85 !===============================================================================
86 !===============================================================================
87 SUBROUTINE execute (self, task_list)
88  class(dispatcher_t):: self
89  type(task_list_t), pointer:: task_list
90  class(list_t), pointer:: list
91  class(link_t), pointer:: link
92  !-----------------------------------------------------------------------------
93  call trace%begin ('dispatcher_t%execute')
94  task_list%method = method
95  task_list%dispatcher = .true.
96  if (test) call set_io
97  !-----------------------------------------------------------------------------
98  ! Reset task_list status to re-establish nbor relations, checking consistency
99  !-----------------------------------------------------------------------------
100  call task_list%reset_status (check=.true.)
101  call task_list%init_task_list_pointers (task_list)
102  call task_list%info
103  !-----------------------------------------------------------------------------
104  ! Call the selected dispatcher method
105  !-----------------------------------------------------------------------------
106  call self%method (task_list)
107  call trace%end()
108 END SUBROUTINE execute
109 
110 !===============================================================================
111 !> I/O params for tests
112 !===============================================================================
113 SUBROUTINE set_io
114  io%do_output = .false.
115  io%print_time = 50.
116  io%end_time = 1e10
117  io%job_seconds = test_seconds
118 END SUBROUTINE set_io
119 
120 !===============================================================================
121 !> Execute a task list, using the selected dispatcher method
122 !===============================================================================
123 SUBROUTINE method0 (task_list)
124  type(task_list_t), pointer:: task_list
125  !-----------------------------------------------------------------------------
126  task_list%method = method
127  if (test) call set_io
128  call dispatcher0%execute (task_list, test)
129 END SUBROUTINE method0
130 
131 !===============================================================================
132 SUBROUTINE method1 (task_list)
133  type(task_list_t), pointer:: task_list
134  if (test) call set_io
135  call dispatcher1%execute (task_list, test)
136 END SUBROUTINE method1
137 
138 !===============================================================================
139 SUBROUTINE method2 (task_list)
140  type(task_list_t), pointer:: task_list
141  if (test) call set_io
142  call dispatcher2%execute (task_list, test)
143 END SUBROUTINE method2
144 
145 !===============================================================================
146 SUBROUTINE method3 (task_list)
147  type(task_list_t), pointer:: task_list
148  if (test) call set_io
149  call dispatcher3%execute (task_list, test)
150 END SUBROUTINE method3
151 
152 !===============================================================================
153 SUBROUTINE method4 (task_list)
154  type(task_list_t), pointer:: task_list
155  if (test) call set_io
156  call dispatcher4%execute (task_list, test)
157 END SUBROUTINE method4
158 
159 !===============================================================================
160 SUBROUTINE method5 (task_list)
161  type(task_list_t), pointer:: task_list
162  if (test) call set_io
163  call dispatcher5%execute (task_list, test)
164 END SUBROUTINE method5
165 
166 !===============================================================================
167 SUBROUTINE method6 (task_list)
168  type(task_list_t), pointer:: task_list
169  if (test) call set_io
170  call dispatcher6%execute (task_list, test)
171 END SUBROUTINE method6
172 
173 END MODULE dispatcher_mod
Do not use a dispatcher, but call task_listexecute, which relies on threads handling a ready queue...
Module with list handling for generic class task_t objects.
Definition: list_mod.f90:4
Interface from gpatch_mod to a choice of binary data I/O methods, controlled by the iomethod text str...
Definition: data_io_mod.f90:17
Execute a task list. Since only the master thread is calling check_mpi(), we need to make sure that i...
Message handling for task lists. Some of the methods are only used by dispatcher0_t, so should perhaps be moved over to that file.
Task list data type, with methods for startup and updates. Message handling is inherited from the tas...
Execute a task list. Since only the master thread is calling check_mpi(), we need to make sure that i...
Definition: io_mod.f90:4
Dispatcher method that relies on all threads maintaining a "ready queue", with tasks ready for updati...
Dispatcher method that relies on all threads maintaining a "ready queue", with tasks ready for updati...
A simple task dispatcher, which handles a list of tasks that may be started as background OpenMP task...
Dispatcher method that relies on all threads maintaining a "ready queue", with tasks ready for updati...