Beispiel #1
0
void FNV_INITP_Q(MPI_Fint *comm, int *code, long int *Lq, long int *Nq, int *ier)
{
    MPI_Comm F2C_comm;

#ifdef SUNDIALS_MPI_COMM_F2C
    F2C_comm = MPI_Comm_f2c(*comm);
#else
    F2C_comm = MPI_COMM_WORLD;
#endif

    *ier = 0;

    switch(*code) {
    case FCMIX_CVODE:
        F2C_CVODE_vecQ = NULL;
        F2C_CVODE_vecQ = N_VNewEmpty_Parallel(F2C_comm, *Lq, *Nq);
        if (F2C_CVODE_vecQ == NULL) *ier = -1;
        break;
    case FCMIX_IDA:
        F2C_IDA_vecQ = NULL;
        F2C_IDA_vecQ = N_VNewEmpty_Parallel(F2C_comm, *Lq, *Nq);
        if (F2C_IDA_vecQ == NULL) *ier = -1;
        break;
    default:
        *ier = -1;
    }
}
N_Vector N_VNew_Parallel(MPI_Comm comm, 
                         long int local_length,
                         long int global_length)
{
  N_Vector v;
  realtype *data;

  v = NULL;
  v = N_VNewEmpty_Parallel(comm, local_length, global_length);
  if (v == NULL) return(NULL);

  /* Create data */
  if(local_length > 0) {

    /* Allocate memory */
    data = NULL;
    data = (realtype *) malloc(local_length * sizeof(realtype));
    if(data == NULL) { N_VDestroy_Parallel(v); return(NULL); }

    /* Attach data */
    NV_OWN_DATA_P(v) = TRUE;
    NV_DATA_P(v)     = data; 

  }

  return(v);
}
N_Vector N_VMake_Parallel(MPI_Comm comm, 
                          long int local_length,
                          long int global_length,
                          realtype *v_data)
{
  N_Vector v;

  v = NULL;
  v = N_VNewEmpty_Parallel(comm, local_length, global_length);
  if (v == NULL) return(NULL);

  if (local_length > 0) {
    /* Attach data */
    NV_OWN_DATA_P(v) = FALSE;
    NV_DATA_P(v)     = v_data;
  }

  return(v);
}