Fix order of arguments in calloc
This commit is contained in:
parent
41ff1919f0
commit
f93ada07f0
6
src/io.c
6
src/io.c
@ -71,7 +71,7 @@ int read_vec(_Complex double* out, int K1, int K2, FILE* file){
|
|||||||
}
|
}
|
||||||
|
|
||||||
// allocate line buffer
|
// allocate line buffer
|
||||||
line=calloc(sizeof(char), len);
|
line=calloc(len,sizeof(char));
|
||||||
|
|
||||||
while(1){
|
while(1){
|
||||||
c=fgetc(file);
|
c=fgetc(file);
|
||||||
@ -126,7 +126,7 @@ int read_vec(_Complex double* out, int K1, int K2, FILE* file){
|
|||||||
// check that there is room in buffer
|
// check that there is room in buffer
|
||||||
if(pos==len){
|
if(pos==len){
|
||||||
// too short: reallocate
|
// too short: reallocate
|
||||||
line_realloc=calloc(sizeof(char), 2*len);
|
line_realloc=calloc(2*len,sizeof(char));
|
||||||
for(pos=0;pos<len;pos++){
|
for(pos=0;pos<len;pos++){
|
||||||
line_realloc[pos]=line[pos];
|
line_realloc[pos]=line[pos];
|
||||||
}
|
}
|
||||||
@ -258,7 +258,7 @@ int save_state(
|
|||||||
// params
|
// params
|
||||||
// allocate buffer for params
|
// allocate buffer for params
|
||||||
if(params_string!=NULL) {
|
if(params_string!=NULL) {
|
||||||
char* params=calloc(sizeof(char), strlen(params_string)+1);
|
char* params=calloc(strlen(params_string)+1,sizeof(char));
|
||||||
strcpy(params, params_string);
|
strcpy(params, params_string);
|
||||||
remove_entry(params, "starting_time");
|
remove_entry(params, "starting_time");
|
||||||
remove_entry(params, "init");
|
remove_entry(params, "init");
|
||||||
|
@ -301,14 +301,14 @@ int lyapunov_init_tmps(
|
|||||||
){
|
){
|
||||||
ns_init_tmps(u, tmp3, tmp4, tmp5, tmp6, tmp7, tmp8, tmp9, fft1, fft2, ifft, K1, K2, N1, N2, nthreads, algorithm);
|
ns_init_tmps(u, tmp3, tmp4, tmp5, tmp6, tmp7, tmp8, tmp9, fft1, fft2, ifft, K1, K2, N1, N2, nthreads, algorithm);
|
||||||
|
|
||||||
*lyapunov=calloc(sizeof(double),MATSIZE);
|
*lyapunov=calloc(MATSIZE,sizeof(double));
|
||||||
*lyapunov_avg=calloc(sizeof(double),MATSIZE);
|
*lyapunov_avg=calloc(MATSIZE,sizeof(double));
|
||||||
*Du_prod=calloc(sizeof(double),MATSIZE*MATSIZE);
|
*Du_prod=calloc(MATSIZE*MATSIZE,sizeof(double));
|
||||||
*Du=calloc(sizeof(double),MATSIZE*MATSIZE);
|
*Du=calloc(MATSIZE*MATSIZE,sizeof(double));
|
||||||
*prevu=calloc(sizeof(_Complex double),USIZE);
|
*prevu=calloc(USIZE,sizeof(_Complex double));
|
||||||
*tmp1=calloc(sizeof(_Complex double),USIZE);
|
*tmp1=calloc(USIZE,sizeof(_Complex double));
|
||||||
*tmp2=calloc(sizeof(_Complex double),USIZE);
|
*tmp2=calloc(USIZE,sizeof(_Complex double));
|
||||||
*tmp10=calloc(sizeof(double),MATSIZE*MATSIZE);
|
*tmp10=calloc(MATSIZE*MATSIZE,sizeof(double));
|
||||||
|
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
@ -958,7 +958,7 @@ int args_from_file(
|
|||||||
_Complex double* set_driving(
|
_Complex double* set_driving(
|
||||||
nstrophy_parameters parameters
|
nstrophy_parameters parameters
|
||||||
){
|
){
|
||||||
_Complex double* g=calloc(sizeof(_Complex double),parameters.K1*(2*parameters.K2+1)+parameters.K2);
|
_Complex double* g=calloc(parameters.K1*(2*parameters.K2+1)+parameters.K2,sizeof(_Complex double));
|
||||||
|
|
||||||
switch(parameters.driving){
|
switch(parameters.driving){
|
||||||
case DRIVING_ZERO:
|
case DRIVING_ZERO:
|
||||||
@ -987,7 +987,7 @@ _Complex double* set_driving(
|
|||||||
_Complex double* set_init(
|
_Complex double* set_init(
|
||||||
nstrophy_parameters* parameters
|
nstrophy_parameters* parameters
|
||||||
){
|
){
|
||||||
_Complex double* u0=calloc(sizeof(_Complex double),parameters->K1*(2*parameters->K2+1)+parameters->K2);
|
_Complex double* u0=calloc(parameters->K1*(2*parameters->K2+1)+parameters->K2,sizeof(_Complex double));
|
||||||
|
|
||||||
switch(parameters->init){
|
switch(parameters->init){
|
||||||
case INIT_RANDOM:
|
case INIT_RANDOM:
|
||||||
|
@ -346,30 +346,30 @@ int ns_init_tmps(
|
|||||||
unsigned int algorithm
|
unsigned int algorithm
|
||||||
){
|
){
|
||||||
// velocity field
|
// velocity field
|
||||||
*u=calloc(sizeof(_Complex double),K1*(2*K2+1)+K2);
|
*u=calloc(K1*(2*K2+1)+K2,sizeof(_Complex double));
|
||||||
|
|
||||||
// allocate tmp vectors for computation
|
// allocate tmp vectors for computation
|
||||||
if(algorithm==ALGORITHM_RK2){
|
if(algorithm==ALGORITHM_RK2){
|
||||||
*tmp1=calloc(sizeof(_Complex double),K1*(2*K2+1)+K2);
|
*tmp1=calloc(K1*(2*K2+1)+K2,sizeof(_Complex double));
|
||||||
*tmp2=calloc(sizeof(_Complex double),K1*(2*K2+1)+K2);
|
*tmp2=calloc(K1*(2*K2+1)+K2,sizeof(_Complex double));
|
||||||
} else if (algorithm==ALGORITHM_RK4){
|
} else if (algorithm==ALGORITHM_RK4){
|
||||||
*tmp1=calloc(sizeof(_Complex double),K1*(2*K2+1)+K2);
|
*tmp1=calloc(K1*(2*K2+1)+K2,sizeof(_Complex double));
|
||||||
*tmp2=calloc(sizeof(_Complex double),K1*(2*K2+1)+K2);
|
*tmp2=calloc(K1*(2*K2+1)+K2,sizeof(_Complex double));
|
||||||
*tmp3=calloc(sizeof(_Complex double),K1*(2*K2+1)+K2);
|
*tmp3=calloc(K1*(2*K2+1)+K2,sizeof(_Complex double));
|
||||||
} else if (algorithm==ALGORITHM_RKF45 || algorithm==ALGORITHM_RKDP54){
|
} else if (algorithm==ALGORITHM_RKF45 || algorithm==ALGORITHM_RKDP54){
|
||||||
*tmp1=calloc(sizeof(_Complex double),K1*(2*K2+1)+K2);
|
*tmp1=calloc(K1*(2*K2+1)+K2,sizeof(_Complex double));
|
||||||
*tmp2=calloc(sizeof(_Complex double),K1*(2*K2+1)+K2);
|
*tmp2=calloc(K1*(2*K2+1)+K2,sizeof(_Complex double));
|
||||||
*tmp3=calloc(sizeof(_Complex double),K1*(2*K2+1)+K2);
|
*tmp3=calloc(K1*(2*K2+1)+K2,sizeof(_Complex double));
|
||||||
*tmp4=calloc(sizeof(_Complex double),K1*(2*K2+1)+K2);
|
*tmp4=calloc(K1*(2*K2+1)+K2,sizeof(_Complex double));
|
||||||
*tmp5=calloc(sizeof(_Complex double),K1*(2*K2+1)+K2);
|
*tmp5=calloc(K1*(2*K2+1)+K2,sizeof(_Complex double));
|
||||||
*tmp6=calloc(sizeof(_Complex double),K1*(2*K2+1)+K2);
|
*tmp6=calloc(K1*(2*K2+1)+K2,sizeof(_Complex double));
|
||||||
*tmp7=calloc(sizeof(_Complex double),K1*(2*K2+1)+K2);
|
*tmp7=calloc(K1*(2*K2+1)+K2,sizeof(_Complex double));
|
||||||
} else if (algorithm==ALGORITHM_RKBS32){
|
} else if (algorithm==ALGORITHM_RKBS32){
|
||||||
*tmp1=calloc(sizeof(_Complex double),K1*(2*K2+1)+K2);
|
*tmp1=calloc(K1*(2*K2+1)+K2,sizeof(_Complex double));
|
||||||
*tmp2=calloc(sizeof(_Complex double),K1*(2*K2+1)+K2);
|
*tmp2=calloc(K1*(2*K2+1)+K2,sizeof(_Complex double));
|
||||||
*tmp3=calloc(sizeof(_Complex double),K1*(2*K2+1)+K2);
|
*tmp3=calloc(K1*(2*K2+1)+K2,sizeof(_Complex double));
|
||||||
*tmp4=calloc(sizeof(_Complex double),K1*(2*K2+1)+K2);
|
*tmp4=calloc(K1*(2*K2+1)+K2,sizeof(_Complex double));
|
||||||
*tmp5=calloc(sizeof(_Complex double),K1*(2*K2+1)+K2);
|
*tmp5=calloc(K1*(2*K2+1)+K2,sizeof(_Complex double));
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr,"bug: unknown algorithm: %u, contact ian.jauslin@rutgers,edu\n",algorithm);
|
fprintf(stderr,"bug: unknown algorithm: %u, contact ian.jauslin@rutgers,edu\n",algorithm);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user