Actual source code: f90_absoft.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:   PetscDataTypeGetSize(PETSC_INT,&size_int);
 39:   F90GetID(type,&id);

 41:   ptr->addr          = array;
 42:   ptr->sd            = size*8;
 43:   ptr->cookie        = F90_COOKIE;
 44:   ptr->dim_id        = 1024*8*1;
 45:   ptr->id            = id;
 46:   ptr->a             = 0;
 47:   ptr->b             = 0;
 48:   ptr->dim[0].extent = len;
 49:   ptr->dim[0].mult   = size/size_int;
 50:   ptr->dim[0].lower  = start;

 52:   return(0);
 53: }

 57: PetscErrorCode F90Array2dCreate(void *array,PetscDataType type,PetscInt start1,PetscInt len1,PetscInt start2,PetscInt len2,F90Array2d *ptr)
 58: {
 59:   PetscInt size,size_int,id;

 65:   PetscDataTypeGetSize(type,&size);
 66:   PetscDataTypeGetSize(PETSC_INT,&size_int);
 67:   F90GetID(type,&id);

 69:   ptr->addr          = array;
 70:   ptr->sd            = size*8;
 71:   ptr->cookie        = F90_COOKIE;
 72:   ptr->dim_id        = 1024*8*2;
 73:   ptr->id            = id;
 74:   ptr->a             = 0;
 75:   ptr->b             = 0;
 76:   ptr->dim[0].extent = len1;
 77:   ptr->dim[0].mult   = size/size_int;
 78:   ptr->dim[0].lower  = start1;
 79:   ptr->dim[1].extent = len2;
 80:   ptr->dim[1].mult   = len1*size/size_int;
 81:   ptr->dim[1].lower  = len2;
 82:   return(0);
 83: }

 87: PetscErrorCode F90Array3dCreate(void *array,PetscDataType type,PetscInt start1,PetscInt len1,PetscInt start2,PetscInt len2,PetscInt start3,PetscInt len3,F90Array3d *ptr)
 88: {
 89:   PetscInt size,size_int,id;

 95:   PetscDataTypeGetSize(type,&size);
 96:   PetscDataTypeGetSize(PETSC_INT,&size_int);
 97:   F90GetID(type,&id);

 99:   ptr->addr          = array;
100:   ptr->sd            = size*8;
101:   ptr->cookie        = F90_COOKIE;
102:   ptr->dim_id        = 1024*8*3;
103:   ptr->id            = id;
104:   ptr->a             = 0;
105:   ptr->b             = 0;
106:   ptr->dim[0].extent = len1;
107:   ptr->dim[0].mult   = size/size_int;
108:   ptr->dim[0].lower  = start1;
109:   ptr->dim[1].extent = len2;
110:   ptr->dim[1].mult   = len1*size/size_int;
111:   ptr->dim[1].lower  = start2;
112:   ptr->dim[2].extent = len3;
113:   ptr->dim[2].mult   = len1*len2*size/size_int;
114:   ptr->dim[2].lower  = start3;
115:   return(0);
116: }

120: PetscErrorCode F90Array4dCreate(void *array,PetscDataType type,PetscInt start1,PetscInt len1,PetscInt start2,PetscInt len2,PetscInt start3,PetscInt len3,PetscInt start4,PetscInt len4,F90Array4d *ptr)
121: {
122:   PetscInt size,size_int,id;

128:   PetscDataTypeGetSize(type,&size);
129:   PetscDataTypeGetSize(PETSC_INT,&size_int);
130:   F90GetID(type,&id);

132:   ptr->addr          = array;
133:   ptr->sd            = size*8;
134:   ptr->cookie        = F90_COOKIE;
135:   ptr->dim_id        = 1024*8*4;
136:   ptr->id            = id;
137:   ptr->a             = 0;
138:   ptr->b             = 0;
139:   ptr->dim[0].extent = len1;
140:   ptr->dim[0].mult   = size/size_int;
141:   ptr->dim[0].lower  = start1;
142:   ptr->dim[1].extent = len2;
143:   ptr->dim[1].mult   = len1*size/size_int;
144:   ptr->dim[1].lower  = start2;
145:   ptr->dim[2].extent = len3;
146:   ptr->dim[2].mult   = len1*len2*size/size_int;
147:   ptr->dim[2].lower  = start3;
148:   ptr->dim[3].extent = len4;
149:   ptr->dim[3].mult   = len1*len2*len3*size/size_int;
150:   ptr->dim[3].lower  = start4;
151:   return(0);
152: }

154: /*-------------------------------------------------------------*/