Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #pragma ident "@(#) libfi/array/shape.c 92.2 07/07/99 15:52:02"
00038 #include <liberrno.h>
00039 #include <stddef.h>
00040 #include <cray/dopevec.h>
00041 #include <cray/portdefs.h>
00042
00043 #include <stdlib.h>
00044
00045 #define BITS_PER_BYTE (BITS_PER_WORD / BYTES_PER_WORD)
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056 void
00057 _SHAPE (DopeVectorType * result,
00058 DopeVectorType * source)
00059 {
00060 int rank;
00061 int numbytes;
00062 int *destarry;
00063 _f_int4 *resptr4;
00064 _f_int8 *resptr8;
00065 int loopj;
00066
00067
00068
00069 if (source->p_or_a && !source->assoc)
00070 _lerror ( _LELVL_ABORT, FENMPTAR, "SHAPE");
00071
00072
00073 rank = source->n_dim;
00074
00075
00076 if (!result->assoc) {
00077 result->base_addr.a.ptr = (void *) NULL;
00078 result->dimension[0].extent = rank;
00079 result->dimension[0].low_bound = 1;
00080 result->dimension[0].stride_mult =
00081 result->type_lens.int_len / (sizeof(_f_int) *
00082 BITS_PER_BYTE);
00083 numbytes = rank * BYTES_PER_WORD;
00084 if (rank != 0) {
00085
00086 destarry = (void *) malloc (numbytes);
00087 if (destarry == NULL)
00088 _lerror(_LELVL_ABORT,FENOMEMY);
00089 result->base_addr.a.ptr = (void *) destarry;
00090 }
00091 result->orig_base = result->base_addr.a.ptr;
00092 result->orig_size = numbytes << 3;
00093 result->assoc = 1;
00094 }
00095
00096 if (result->type_lens.kind_or_star == 0) {
00097 if (result->type_lens.int_len == 64) {
00098 resptr8 = (_f_int8 *) result->base_addr.a.ptr;
00099
00100 for (loopj = 0; loopj < rank; loopj++)
00101 resptr8[loopj] = (_f_int8)
00102 source->dimension[loopj].extent;
00103 } else {
00104 resptr4 = (_f_int4 *) result->base_addr.a.ptr;
00105
00106 for (loopj = 0; loopj < rank; loopj++)
00107 resptr4[loopj] = (_f_int4)
00108 source->dimension[loopj].extent;
00109 }
00110 } else {
00111 if (result->type_lens.dec_len == 8) {
00112 resptr8 = (_f_int8 *) result->base_addr.a.ptr;
00113
00114 for (loopj = 0; loopj < rank; loopj++)
00115 resptr8[loopj] = (_f_int8)
00116 source->dimension[loopj].extent;
00117 } else if (result->type_lens.dec_len == 4) {
00118 resptr4 = (_f_int4 *) result->base_addr.a.ptr;
00119
00120 for (loopj = 0; loopj < rank; loopj++)
00121 resptr4[loopj] = (_f_int4)
00122 source->dimension[loopj].extent;
00123 }
00124 }
00125 }