@@ -37,6 +37,8 @@ int main(int argc, char *argv[]) {
3737 bool verbose (true );
3838 bool use_cloned_samples (false );
3939 int number_of_particles (-1 );
40+ bool do_jac (true );
41+ bool do_rhs (true );
4042
4143 // / parse command line arguments
4244 TChem::CommandLineParser opts (" This example computes the net production rates with a given state vector" );
@@ -57,6 +59,9 @@ int main(int argc, char *argv[]) {
5759 opts.set_option <int >(" batch_size" , " number of batches or samples, e.g. 10 " , &nBatch);
5860 opts.set_option <bool >(
5961 " use_cloned_samples" , " If true, one state vector will be cloned." , &use_cloned_samples);
62+ opts.set_option <bool >(" do_jac" , " Evaluate Jacobian matrix" , &do_jac);
63+ opts.set_option <bool >(" do_rhs" , " Evaluate RHS" , &do_rhs);
64+
6065
6166 const bool r_parse = opts.parse (argc, argv);
6267 if (r_parse)
@@ -171,9 +176,8 @@ int main(int argc, char *argv[]) {
171176 Kokkos::deep_copy (num_concentration, num_concentration_host);
172177 }
173178 // output
174- real_type_2d_view_type rhs (" rhs" , nBatch, number_of_equations);
175179 real_type_2d_view_type fac (" fac" , nBatch, number_of_equations);
176- real_type_3d_view_type jacobian ( " jacobian " , nBatch, number_of_equations , number_of_equations);
180+ real_type_2d_view_type rhs ( " rhs " , nBatch, number_of_equations);
177181
178182 using policy_type = typename TChem::UseThisTeamPolicy<TChem::exec_space>::type;
179183
@@ -196,7 +200,9 @@ int main(int argc, char *argv[]) {
196200
197201 Kokkos::Timer timer;
198202 FILE *fout_times = fopen (outputFileTimes.c_str (), " w" );
199- {
203+
204+ if (do_rhs){
205+ printf (" ..evaluating RHS\n " );
200206 fprintf (fout_times, " {\n " );
201207 fprintf (fout_times, " \" Aerosol RHSs\" : \n {\n " );
202208 const ordinal_type level = 1 ;
@@ -273,10 +279,19 @@ int main(int argc, char *argv[]) {
273279 fprintf (fout_times, " %s: %20.14e, \n " ," \" wall_time\" " , t_device_batch);
274280 fprintf (fout_times, " %s: %20.14e, \n " ," \" wall_time_per_sample\" " , t_device_batch / real_type (nBatch));
275281 fprintf (fout_times, " %s: %d \n " ," \" number_of_samples\" " , nBatch);
276- fprintf (fout_times, " }, \n " );// reaction rates
282+
283+ if (do_jac){
284+ fprintf (fout_times, " }, \n " );// reaction rates
285+ }
286+ else {
287+ fprintf (fout_times, " } \n " );// reaction rates
288+ }
289+
277290 }
278291
279- {
292+ if (do_jac){
293+ printf (" ..evaluating Jacobian\n " );
294+ real_type_3d_view_type jacobian (" jacobian" , nBatch, number_of_equations, number_of_equations);
280295 const ordinal_type level = 1 ;
281296 fprintf (fout_times, " \" Aerosol Numerical Jacobian\" : \n {\n " );
282297 const std::string profile_name = " TChem::AerosolChemistry::NumericalJacobian_evaluation" ;
@@ -355,10 +370,11 @@ int main(int argc, char *argv[]) {
355370 fprintf (fout_times, " %s: %d \n " ," \" number_of_samples\" " , nBatch);
356371 fprintf (fout_times, " } \n " );// reaction rates
357372 }
358- if (verbose) {
359373
374+ if (verbose & do_rhs) {
360375
361- if (use_cloned_samples) {
376+
377+ if (use_cloned_samples) {
362378 auto rhs_at_0 = Kokkos::subview (rhs, 0 , Kokkos::ALL ());
363379 auto rhs_host_at_0 = Kokkos::create_mirror_view (rhs_at_0);
364380 Kokkos::deep_copy (rhs_host_at_0, rhs_at_0);
0 commit comments