@@ -156,6 +156,75 @@ void trim(std::string &s)
156156 s.end ());
157157}
158158
159+ void load_actions (const std::string &file_name, int mpi_comm_id, conduit::Node &actions)
160+ {
161+ int comm_size = 1 ;
162+ int rank = 0 ;
163+
164+ #if defined(ASCENT_REPLAY_MPI)
165+ if (mpi_comm_id == -1 )
166+ {
167+ // do nothing, an error will be thrown later
168+ // so we can respect the exception handling
169+ return ;
170+ }
171+ MPI_Comm mpi_comm = MPI_Comm_f2c (mpi_comm_id);
172+ MPI_Comm_size (mpi_comm, &comm_size);
173+ MPI_Comm_rank (mpi_comm, &rank);
174+ #endif
175+
176+ bool has_file = false ;
177+
178+ if (rank==0 )
179+ {
180+ has_file = conduit::utils::is_file (file_name);
181+ }
182+
183+ #ifdef ASCENT_MPI_ENABLED
184+ MPI_Bcast (&has_file, 1 , MPI_BOOL, 0 , mpi_comm);
185+ #endif
186+
187+ bool actions_file_valid = false ;
188+ std::string file_load_error_msg = " " ;
189+
190+ if (rank==0 && has_file)
191+ {
192+ try
193+ {
194+ std::string curr, next;
195+ conduit::utils::rsplit_string (file_name, " ." , curr, next);
196+
197+ std::string protocol = curr==" yaml" ? " yaml" : " json" ;
198+ actions.load (file_name, protocol);
199+ actions_file_valid = true ;
200+ }
201+ catch (conduit::Error &e)
202+ {
203+ file_load_error_msg = e.message ();
204+ actions_file_valid = false ;
205+ }
206+ }
207+
208+ #ifdef ASCENT_MPI_ENABLED
209+ MPI_Bcast (&actions_file_valid, 1 , MPI_BOOL, 0 , mpi_comm);
210+ #endif
211+
212+ if (!has_file)
213+ {
214+ ASCENT_WARN (" Actions file not found: " << file_name);
215+ }
216+ else if (!actions_file_valid)
217+ {
218+ // Raise Error
219+ ASCENT_ERROR (" Failed to load actions file: " << file_name
220+ << " \n " << file_load_error_msg);
221+ }
222+
223+ #ifdef ASCENT_MPI_ENABLED
224+ relay::mpi::broadcast_using_schema (node, 0 , mpi_comm);
225+ #endif
226+ }
227+
159228// ---------------------------------------------------------------------------//
160229int
161230main (int argc, char *argv[])
@@ -197,16 +266,17 @@ main(int argc, char *argv[])
197266 conduit::Node replay_data;
198267 // replay_data.print();
199268 conduit::Node ascent_opts;
200- ascent_opts[" actions_file" ] = options.m_actions_file ;
201269 ascent_opts[" ascent_info" ] = " verbose" ;
202270#if defined(ASCENT_REPLAY_MPI)
203271 ascent_opts[" mpi_comm" ] = MPI_Comm_c2f (MPI_COMM_WORLD);
204272#endif
205273
206274 //
207- // Blank actions to be populated from actions file
275+ // Populate actions with actions file
208276 //
277+ int mpi_comm = ascent_opts.has_child (" mpi_comm" ) ? ascent_opts[" mpi_comm" ].to_int () : -1 ;
209278 conduit::Node actions;
279+ load_actions (options.m_actions_file , mpi_comm, actions);
210280
211281 ascent::Ascent ascent;
212282 ascent.open (ascent_opts);
0 commit comments