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

Function CVAllocVectors

externalpackages/PVODE/source/cvode.cpp:1055–1103  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1053**********************************************************************/
1054
1055static boole CVAllocVectors(CVodeMem cv_mem, integer neq, int maxord,
1056 void *machEnv)
1057{
1058 int i, j;
1059
1060 /* Allocate ewt, acor, tempv, ftemp */
1061
1062 ewt = N_VNew(neq, (machEnvType)machEnv);
1063 if (ewt == NULL) return(FALSE);
1064 acor = N_VNew(neq, (machEnvType)machEnv);
1065 if (acor == NULL) {
1066 N_VFree(ewt);
1067 return(FALSE);
1068 }
1069 tempv = N_VNew(neq, (machEnvType)machEnv);
1070 if (tempv == NULL) {
1071 N_VFree(ewt);
1072 N_VFree(acor);
1073 return(FALSE);
1074 }
1075 ftemp = N_VNew(neq, (machEnvType)machEnv);
1076 if (ftemp == NULL) {
1077 N_VFree(tempv);
1078 N_VFree(ewt);
1079 N_VFree(acor);
1080 return(FALSE);
1081 }
1082
1083 /* Allocate zn[0] ... zn[maxord] */
1084
1085 for (j=0; j <= maxord; j++) {
1086 zn[j] = N_VNew(neq, (machEnvType)machEnv);
1087 if (zn[j] == NULL) {
1088 N_VFree(ewt);
1089 N_VFree(acor);
1090 N_VFree(tempv);
1091 N_VFree(ftemp);
1092 for (i=0; i < j; i++) N_VFree(zn[i]);
1093 return(FALSE);
1094 }
1095 }
1096
1097 /* Set solver workspace lengths */
1098
1099 lrw = (maxord + 5)*neq;
1100 liw = 0;
1101
1102 return(TRUE);
1103}
1104
1105/***************** CVFreeVectors *********************************
1106

Callers 1

CVodeMallocFunction · 0.85

Calls 2

N_VNewFunction · 0.85
N_VFreeFunction · 0.85

Tested by

no test coverage detected