MCPcopy Create free account
hub / github.com/boutproject/BOUT-dev / N_VNew

Function N_VNew

externalpackages/PVODE/source/nvector.cpp:142–174  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

140
141
142N_Vector N_VNew(integer N, machEnvType machEnv)
143{
144 N_Vector v;
145 int N_local, N_global;
146
147 if (N <= 0) return(NULL);
148 if (machEnv == NULL) return(NULL);
149
150 N_local = machEnv->local_vec_length;
151 N_global = machEnv->global_vec_length;
152
153 v = (N_Vector) malloc(sizeof *v);
154 if (v == NULL) return(NULL);
155
156 v->data = (real *) malloc(N_local * sizeof(real));
157 if (v->data == NULL) {
158 free(v);
159 return(NULL);
160 }
161
162 v->length = N_local;
163 v->global_length = N_global;
164
165 v->machEnv = (machEnvType) malloc(sizeof *machEnv);
166 if (v->machEnv == NULL) {
167 free(v->data);
168 free(v);
169 return(NULL);
170 }
171 memcpy(v->machEnv,machEnv,sizeof *machEnv);
172
173 return(v);
174}
175
176
177void N_VFree(N_Vector x)

Callers 5

initMethod · 0.85
SpgmrMallocFunction · 0.85
CVSpgmrInitFunction · 0.85
CVDiagInitFunction · 0.85
CVAllocVectorsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected