Fixes in cli argument parsing
This commit is contained in:
parent
35d91830a2
commit
c32c52c94a
@ -125,7 +125,6 @@ Therefore,
|
||||
\mathcal F\left(q_x|q|\hat\varphi_q\right)(n)
|
||||
\right)(k)
|
||||
\end{equation}
|
||||
\bigskip
|
||||
|
||||
|
||||
\vfill
|
||||
|
28
src/main.c
28
src/main.c
@ -52,8 +52,8 @@ int print_usage(){
|
||||
// read command line arguments
|
||||
#define CP_FLAG_TIMESTEP 1
|
||||
#define CP_FLAG_NSTEPS 2
|
||||
#define CP_FLAG_MODES 2
|
||||
#define CP_FLAG_NU 3
|
||||
#define CP_FLAG_MODES 3
|
||||
#define CP_FLAG_NU 4
|
||||
int read_args(int argc, const char* argv[], ns_params* params, unsigned int* nsteps, unsigned int* computation_nr){
|
||||
int i;
|
||||
int ret;
|
||||
@ -78,11 +78,11 @@ int read_args(int argc, const char* argv[], ns_params* params, unsigned int* nst
|
||||
params->nu=1./1024/(2*params->K+1);
|
||||
*/
|
||||
params->K=16;
|
||||
//h=2^-13
|
||||
params->h=0.0001220703125;
|
||||
params->h=0.001953125;
|
||||
//nu=2^-11
|
||||
*nsteps=10000000;
|
||||
//params->nu=0.00048828125;
|
||||
params->nu=0.0078125;
|
||||
params->nu=0.00048828125;
|
||||
|
||||
// loop over arguments
|
||||
for(i=1;i<argc;i++){
|
||||
@ -138,14 +138,14 @@ int read_args(int argc, const char* argv[], ns_params* params, unsigned int* nst
|
||||
*nsteps=tmp_uint;
|
||||
flag=0;
|
||||
}
|
||||
// nsteps
|
||||
// modes
|
||||
else if(flag==CP_FLAG_MODES){
|
||||
ret=sscanf(argv[i],"%d",&tmp_int);
|
||||
if(ret!=1){
|
||||
fprintf(stderr, "error: '-K' should be followed by an int\n got '%s'\n",argv[i]);
|
||||
return(-1);
|
||||
}
|
||||
params->K=tmp_uint;
|
||||
params->K=tmp_int;
|
||||
flag=0;
|
||||
}
|
||||
// friction
|
||||
@ -206,6 +206,7 @@ int enstrophy(ns_params params, unsigned int Nsteps){
|
||||
tmp2=calloc(sizeof(_Complex double),params.S*params.S);
|
||||
tmp3=calloc(sizeof(_Complex double),params.S*params.S);
|
||||
|
||||
/*
|
||||
srand(17);
|
||||
|
||||
// initial value
|
||||
@ -236,14 +237,19 @@ int enstrophy(ns_params params, unsigned int Nsteps){
|
||||
u[KLOOKUP(kx,ky,params.S)]=u[KLOOKUP(kx,ky,params.S)]*sqrt(155.1/rescale);
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
/*
|
||||
for(kx=-params.K;kx<=params.K;kx++){
|
||||
for(ky=-params.K;ky<=params.K;ky++){
|
||||
printf("%d %d % .8e % .8e\n",kx,ky, __real__ u[KLOOKUP(kx,ky,params.S)], __imag__ u[KLOOKUP(kx,ky,params.S)]);
|
||||
u[KLOOKUP(kx,ky,params.S)]=1.;
|
||||
}
|
||||
}
|
||||
*/
|
||||
for(kx=-params.K;kx<=params.K;kx++){
|
||||
for(ky=-params.K;ky<=params.K;ky++){
|
||||
u[KLOOKUP(kx,ky,params.S)]=exp(-sqrt(kx*kx+ky*ky));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// driving force
|
||||
@ -294,8 +300,8 @@ int enstrophy(ns_params params, unsigned int Nsteps){
|
||||
}
|
||||
|
||||
if(t>0 && t%1000==0){
|
||||
fprintf(stderr,"%8d % .8e % .8e % .8e % .8e\n",t, __real__ avg, __imag__ avg, __real__ alpha, __imag__ alpha);
|
||||
printf("%8d % .8e % .8e % .8e % .8e\n",t, __real__ avg, __imag__ avg, __real__ alpha, __imag__ alpha);
|
||||
fprintf(stderr,"% .15e % .15e % .15e % .15e % .15e\n",t*params.h, __real__ avg, __imag__ avg, __real__ alpha, __imag__ alpha);
|
||||
printf("% .15e % .15e % .15e % .15e % .15e\n",t*params.h, __real__ avg, __imag__ avg, __real__ alpha, __imag__ alpha);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -87,6 +87,7 @@ int ins_rhs(_Complex double* out, _Complex double* u, ns_params params, fft_vect
|
||||
|
||||
// fft
|
||||
fftw_execute(vects.fft1_plan);
|
||||
|
||||
fftw_execute(vects.fft2_plan);
|
||||
// write to invfft
|
||||
for(kx=-2*params.K;kx<=2*params.K;kx++){
|
||||
|
Loading…
Reference in New Issue
Block a user