Actual source code: f90_alpha.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_LONG_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            = (char)id;
 41:   ptr->a             = A_VAL;
 42:   ptr->b             = B_VAL;
 43:   ptr->sd            = size;
 44:   ptr->ndim          = 1;
 45:   ptr->dim[0].upper  = len+start;
 46:   ptr->dim[0].mult   = size;
 47:   ptr->dim[0].lower  = start;
 48:   ptr->addr_d         =  (void*)((long)array - (ptr->dim[0].lower*ptr->dim[0].mult));

 50:   return(0);
 51: }

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

 58:   PetscInt size,size_int,id;

 64:   PetscDataTypeGetSize(type,&size);
 65:   F90GetID(type,&id);
 66:   ptr->addr          = array;
 67:   ptr->id            = (char)id;
 68:   ptr->a             = A_VAL;
 69:   ptr->b             = B_VAL;
 70:   ptr->sd            = size;
 71:   ptr->ndim          = 2;
 72:   ptr->dim[1].upper  = len1+start1;
 73:   ptr->dim[1].mult   = size;
 74:   ptr->dim[1].lower  = start1;
 75:   ptr->dim[0].upper  = len2+start2;
 76:   ptr->dim[0].mult   = len1*size;
 77:   ptr->dim[0].lower  = start2;
 78:   ptr->addr_d        = (void*)((long)array -(ptr->dim[0].lower*ptr->dim[0].mult+
 79:                                              ptr->dim[1].lower*ptr->dim[1].mult));
 80:   return(0);
 81: }

 85: PetscErrorCode F90Array3dCreate(void *array,PetscDataType type,PetscInt start1,PetscInt len1,PetscInt start2,PetscInt len2,PetscInt start3,PetscInt len3,F90Array3d *ptr)
 86: {

 88:   PetscInt size,size_int,id;

 94:   PetscDataTypeGetSize(type,&size);
 95:   F90GetID(type,&id);
 96:   ptr->addr          = array;
 97:   ptr->id            = (char)id;
 98:   ptr->a             = A_VAL;
 99:   ptr->b             = B_VAL;
100:   ptr->sd            = size;
101:   ptr->ndim          = 3;
102:   ptr->dim[2].upper  = len1+start1;
103:   ptr->dim[2].mult   = size;
104:   ptr->dim[2].lower  = start1;
105:   ptr->dim[1].upper  = len2+start2;
106:   ptr->dim[1].mult   = len1*size;
107:   ptr->dim[1].lower  = start2;
108:   ptr->dim[0].upper  = len3+start3;
109:   ptr->dim[0].mult   = len2*len1*size;
110:   ptr->dim[0].lower  = start3;
111:   ptr->addr_d        = (void*)((long)array -(ptr->dim[0].lower*ptr->dim[0].mult+
112:                                              ptr->dim[1].lower*ptr->dim[1].mult+
113:                                              ptr->dim[2].lower*ptr->dim[2].mult));
114:   return(0);
115: }

119: PetscErrorCode F90Array4dCreate(void *array,PetscDataType type,PetscInt start1,PetscInt len1,PetscInt start2,PetscInt len2,PetscInt start3,PetscInt len3,PetscInt start4,PetscInt len4,F90Array4d *ptr)
120: {

122:   PetscInt size,size_int,id;

128:   PetscDataTypeGetSize(type,&size);
129:   F90GetID(type,&id);
130:   ptr->addr          = array;
131:   ptr->id            = (char)id;
132:   ptr->a             = A_VAL;
133:   ptr->b             = B_VAL;
134:   ptr->sd            = size;
135:   ptr->ndim          = 4;
136:   ptr->dim[3].upper  = len1+start1;
137:   ptr->dim[3].mult   = size;
138:   ptr->dim[3].lower  = start1;
139:   ptr->dim[2].upper  = len2+start2;
140:   ptr->dim[2].mult   = len1*size;
141:   ptr->dim[2].lower  = start2;
142:   ptr->dim[1].upper  = len3+start3;
143:   ptr->dim[1].mult   = len2*len1*size;
144:   ptr->dim[1].lower  = start4;
145:   ptr->dim[0].upper  = len4+start4;
146:   ptr->dim[0].mult   = len3*len2*len1*size;
147:   ptr->dim[0].lower  = start4;
148:   ptr->addr_d        = (void*)((long)array -(ptr->dim[0].lower*ptr->dim[0].mult+
149:                                              ptr->dim[1].lower*ptr->dim[1].mult+
150:                                              ptr->dim[2].lower*ptr->dim[2].mult+
151:                                              ptr->dim[3].lower*ptr->dim[3].mult));
152:   return(0);
153: }
154: /*-------------------------------------------------------------*/