New option for init: file_txt for plain txt input
This commit is contained in:
parent
cbcb39ff19
commit
23e61c143a
13
src/init.c
13
src/init.c
@ -82,7 +82,18 @@ int init_gaussian (
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Initialize from file
|
// Initialize from file
|
||||||
int init_file (
|
// txt input
|
||||||
|
int init_file_txt (
|
||||||
|
_Complex double* u0,
|
||||||
|
int K1,
|
||||||
|
int K2,
|
||||||
|
FILE* initfile
|
||||||
|
){
|
||||||
|
read_u(u0, K1, K2, initfile);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
// binary input
|
||||||
|
int init_file_bin (
|
||||||
_Complex double* u0,
|
_Complex double* u0,
|
||||||
int K1,
|
int K1,
|
||||||
int K2,
|
int K2,
|
||||||
|
@ -11,6 +11,7 @@ int init_random(_Complex double* u0, double init_en, int K1, int K2, double L, i
|
|||||||
int init_gaussian(_Complex double* u0, double init_en, int K1, int K2, double L, bool irreversible);
|
int init_gaussian(_Complex double* u0, double init_en, int K1, int K2, double L, bool irreversible);
|
||||||
|
|
||||||
// Initialize from file
|
// Initialize from file
|
||||||
int init_file (_Complex double* u0, int K1, int K2, FILE* initfile);
|
int init_file_txt (_Complex double* u0, int K1, int K2, FILE* initfile);
|
||||||
|
int init_file_bin (_Complex double* u0, int K1, int K2, FILE* initfile);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
16
src/main.c
16
src/main.c
@ -64,6 +64,7 @@ void sig_handler (int signo);
|
|||||||
#define INIT_RANDOM 1
|
#define INIT_RANDOM 1
|
||||||
#define INIT_GAUSSIAN 2
|
#define INIT_GAUSSIAN 2
|
||||||
#define INIT_FILE 3
|
#define INIT_FILE 3
|
||||||
|
#define INIT_FILE_TXT 4
|
||||||
|
|
||||||
|
|
||||||
// global variable to handle interrupts
|
// global variable to handle interrupts
|
||||||
@ -214,6 +215,9 @@ int print_params(
|
|||||||
case INIT_FILE:
|
case INIT_FILE:
|
||||||
fprintf(file,", init=file:%s", initfile_str);
|
fprintf(file,", init=file:%s", initfile_str);
|
||||||
break;
|
break;
|
||||||
|
case INIT_FILE_TXT:
|
||||||
|
fprintf(file,", init=file_txt:%s", initfile_str);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(file,", init=gaussian");
|
fprintf(file,", init=gaussian");
|
||||||
break;
|
break;
|
||||||
@ -566,6 +570,12 @@ int set_parameter(
|
|||||||
*initfile_str=calloc(sizeof(char), strlen(rhs)-5+1);
|
*initfile_str=calloc(sizeof(char), strlen(rhs)-5+1);
|
||||||
strcpy(*initfile_str, rhs+5);
|
strcpy(*initfile_str, rhs+5);
|
||||||
}
|
}
|
||||||
|
// matches any argument that starts with 'file_txt:'
|
||||||
|
else if (strncmp(rhs,"file_txt:",9)==0){
|
||||||
|
parameters->init=INIT_FILE_TXT;
|
||||||
|
*initfile_str=calloc(sizeof(char), strlen(rhs)-9+1);
|
||||||
|
strcpy(*initfile_str, rhs+9);
|
||||||
|
}
|
||||||
else{
|
else{
|
||||||
fprintf(stderr, "error: unrecognized initial condition '%s'\n",rhs);
|
fprintf(stderr, "error: unrecognized initial condition '%s'\n",rhs);
|
||||||
return(-1);
|
return(-1);
|
||||||
@ -616,7 +626,11 @@ _Complex double* set_init(
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case INIT_FILE:
|
case INIT_FILE:
|
||||||
init_file(u0, parameters.K1, parameters.K2, parameters.initfile);
|
init_file_bin(u0, parameters.K1, parameters.K2, parameters.initfile);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case INIT_FILE_TXT:
|
||||||
|
init_file_txt(u0, parameters.K1, parameters.K2, parameters.initfile);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
Loading…
Reference in New Issue
Block a user