Actual source code: f90_t3e.c

      2: /*-------------------------------------------------------------*/

      6: PetscErrorCode F90GetID(PetscDataType type,PetscInt *id)
      7: {
      9:   if (type == PETSC_INT) {
     10:     *id = F90_INT_ID;
     11:   } else if (type == PETSC_DOUBLE) {
     12:     *id = F90_DOUBLE_ID;
     13: #if defined(PETSC_USE_COMPLEX)
     14:   } else if (type == PETSC_COMPLEX) {
     15:     *id = F90_COMPLEX_ID;
     16: #endif
     17:   } else if (type == PETSC_LONG) {
     18:     *id = F90_INT_ID;
     19:     /*  } else if (type == PETSC_CHAR) {
     20:     *id = F90_CHAR_ID; */
     21:   } else {
     22:     SETERRQ(PETSC_ERR_ARG_OUTOFRANGE,"Unknown PETSc datatype");
     23:   }
     24:   return(0);
     25: }

     29: PetscErrorCode F90Array1dCreate(void *array,PetscDataType type,PetscInt start,PetscInt len,F90Array1d *ptr)
     30: {
     31:   PetscInt size,size_int,id;

     37:   PetscDataTypeGetSize(type,&size);
     38:   F90GetID(type,&id);
     39:   ptr->addr          = array;
     40:   ptr->id            = id;
     41:   ptr->cookie        = F90_COOKIE;
     42:   ptr->sd            = size*8;
     43:   ptr->ndim          = 1;
     44:   ptr->dim[0].extent = len;
     45:   ptr->dim[0].mult   = 1;
     46:   ptr->dim[0].lower  = start;

     48:   return(0);
     49: }

     53: PetscErrorCode F90Array2dCreate(void *array,PetscDataType type,PetscInt start1,PetscInt len1,PetscInt start2,PetscInt len2,F90Array2d *ptr)
     54: {

     56:   PetscInt size,size_int,id;

     62:   PetscDataTypeGetSize(type,&size);
     63:   F90GetID(type,&id);
     64:   ptr->addr          = array;
     65:   ptr->id            = id;
     66:   ptr->cookie        = F90_COOKIE;
     67:   ptr->sd            = size*8;
     68:   ptr->ndim          = 2;
     69:   ptr->dim[0].extent = len1;
     70:   ptr->dim[0].mult   = 1;
     71:   ptr->dim[0].lower  = start1;
     72:   ptr->dim[1].extent = len2;
     73:   ptr->dim[1].mult   = len1*1;
     74:   ptr->dim[1].lower  = start2;

     76:   return(0);
     77: }
     78: /*-------------------------------------------------------------*/