Ejemplo n.º 1
0
void
bfam_log_printf(const char *file, int line, int category, int level, ...)
{
  FILE *stream = (bfam_log_stream) ? bfam_log_stream : stdout;
  va_list ap;
  const char * fmt;

  BFAM_ASSERT(level <= BFAM_LL_SILENT && level >= BFAM_LL_ALWAYS);

  if(bfam_log_threshold > level)
    return;

  if(category == BFAM_LC_ROOT && bfam_log_rank != bfam_log_root_rank)
    return;


  if(category == BFAM_LC_ALL)
  {
    fprintf(stream, "[%3d] ", bfam_log_rank);
  }
  else
  {
    fprintf(stream, "[   ] ");
  }
  fprintf(stream, "%s: ", bfam_log_level_names[level]);

  if(level == BFAM_LL_TRACE)
  {

    fprintf(stream, "%s:%3d ", file, line);
  }

  va_start(ap, level);
  fmt = va_arg(ap, const char *);
  vfprintf(stream, fmt, ap);
  fprintf(stream, "\n");
  va_end(ap);
}
Ejemplo n.º 2
0
void bfam_ts_adams_step(bfam_ts_t *a_ts, bfam_long_real_t dt)
{
  /* cast to the proper type */
  bfam_ts_adams_t *ts = (bfam_ts_adams_t *)a_ts;

  bfam_ts_adams_allprefix_t data;
  data.ts = ts;
  data.dt = dt;

  /*
   * start the communication
   */
  bfam_communicator_start(ts->comm);

  /*
   * do the intra work
   */
  bfam_dictionary_allprefixed_ptr(&ts->elems, "", &bfam_ts_adams_intra_rhs,
                                  &data);

  /*
   * finish the communication
   */
  bfam_communicator_finish(ts->comm);

  /*
   * do the inter work
   */
  bfam_dictionary_allprefixed_ptr(&ts->elems, "", &bfam_ts_adams_inter_rhs,
                                  &data);

  if (ts->lsrk)
  {
    /*
     * If we are using RK, we want to tell the RK scheme to use the next rate
     * for storage (not the current rate which is valid
     */
    ts->lsrk->t = ts->t;
    char rate_prefix[BFAM_BUFSIZ];
    snprintf(rate_prefix, BFAM_BUFSIZ, "%s%d_", BFAM_ADAMS_PREFIX,
             (ts->currentStage + 1) % ts->nStages);
    BFAM_LDEBUG("Adams step: RK rate rate_prefix %s", rate_prefix);
    BFAM_ASSERT(ts->lsrk->step_extended);
    ts->lsrk->step_extended((bfam_ts_t *)ts->lsrk, dt, rate_prefix, "", "");
    if (ts->numSteps + 2 >= ts->nStages)
    {
      bfam_ts_lsrk_free(ts->lsrk);
      bfam_free(ts->lsrk);
      ts->lsrk = NULL;
    }
  }
  else
    /* q_{n+1}  := q_{n} + dt \sum_{k=0}^{m} a_{k} dq_{n-k} */
    bfam_dictionary_allprefixed_ptr(&ts->elems, "", &bfam_ts_adams_update,
                                    &data);

  /* shift the stage counter */
  ts->currentStage = (ts->currentStage + 1) % ts->nStages;
  ts->numSteps++;

  /* update the stage time */
  ts->t += dt;
}