when reading binary init, only read u unless using the 'resume' command.
In particular, removed the 'init_flow' parameter
This commit is contained in:
parent
89791be6d6
commit
8a1f3987f4
@ -161,11 +161,6 @@ should be a `;` sperated list of `key=value` pairs. The possible keys are
|
||||
be `RK4` for Runge-Kutta 4 (default) or `RK2` for Runge-Kutta 2. Adaptive
|
||||
step algorithms cannot be used for the tangent flow.
|
||||
|
||||
* `init_flow` (`identity` or `file` (default)): if set to `file`, then read the
|
||||
initial condition for the tangent flow (used for the Lyapunov exponent
|
||||
computation) from the init file (the same as for `init`, which needs to be
|
||||
specified). Otherwise, the flow is initialized as the identity matrix.
|
||||
|
||||
|
||||
# Interrupting and resuming the computation
|
||||
|
||||
|
4
src/io.c
4
src/io.c
@ -335,10 +335,6 @@ int save_state(
|
||||
if(savefile==stderr || savefile==stdout){
|
||||
fprintf(savefile,";starting_time=%.15e", time);
|
||||
}
|
||||
// instruction to read init flow from file if computation is lyapunov
|
||||
if(command==COMMAND_LYAPUNOV){
|
||||
fprintf(savefile,";init_flow=file");
|
||||
}
|
||||
fprintf(savefile,"\"");
|
||||
}
|
||||
|
||||
|
45
src/main.c
45
src/main.c
@ -63,7 +63,6 @@ typedef struct nstrophy_parameters {
|
||||
FILE* drivingfile;
|
||||
double lyapunov_reset;
|
||||
unsigned int lyapunov_trigger;
|
||||
bool init_flow_file;
|
||||
bool print_alpha;
|
||||
} nstrophy_parameters;
|
||||
|
||||
@ -85,7 +84,7 @@ _Complex double* set_driving(nstrophy_parameters parameters);
|
||||
// set initial condition
|
||||
_Complex double* set_init(nstrophy_parameters* parameters);
|
||||
// set initial tangent flow for lyapunov exponents
|
||||
int set_lyapunov_flow_init( double** lyapunov_flow0, double** lyapunov_avg0, double* lyapunov_prevtime, double* lyapunov_startingtime, nstrophy_parameters parameters);
|
||||
int set_lyapunov_flow_init( double** lyapunov_flow0, double** lyapunov_avg0, double* lyapunov_prevtime, double* lyapunov_startingtime, bool fromfile, nstrophy_parameters parameters);
|
||||
|
||||
// signal handler
|
||||
void sig_handler (int signo);
|
||||
@ -130,6 +129,7 @@ int main (
|
||||
dstring resumefile_str;
|
||||
FILE* savefile=NULL;
|
||||
FILE* utfile=NULL;
|
||||
bool resume=false;
|
||||
|
||||
command=0;
|
||||
|
||||
@ -169,6 +169,8 @@ int main (
|
||||
|
||||
// if command is 'resume', then read args from file
|
||||
if(command==COMMAND_RESUME){
|
||||
// remember that the original command was resume (to set values from init file)
|
||||
resume=true;
|
||||
ret=args_from_file(¶m_str, &command, &nthreads, &savefile_str, &utfile_str, dstring_to_str_noinit(&resumefile_str));
|
||||
if(ret<0){
|
||||
dstring_free(param_str);
|
||||
@ -232,9 +234,19 @@ int main (
|
||||
g=set_driving(parameters);
|
||||
// set initial condition
|
||||
u0=set_init(¶meters);
|
||||
// read extra values from init file when resuming a computation
|
||||
if(resume){
|
||||
// read start time
|
||||
fread(&(parameters.starting_time), sizeof(double), 1, parameters.initfile);
|
||||
// if adaptive step algorithm
|
||||
if(parameters.algorithm>ALGORITHM_ADAPTIVE_THRESHOLD){
|
||||
// read delta
|
||||
fread(&(parameters.delta), sizeof(double), 1, parameters.initfile);
|
||||
}
|
||||
}
|
||||
// set initial condition for the lyapunov flow
|
||||
if (command==COMMAND_LYAPUNOV){
|
||||
set_lyapunov_flow_init(&lyapunov_flow0, &lyapunov_avg0, &lyapunov_prevtime, &lyapunov_startingtime, parameters);
|
||||
set_lyapunov_flow_init(&lyapunov_flow0, &lyapunov_avg0, &lyapunov_prevtime, &lyapunov_startingtime, resume, parameters);
|
||||
}
|
||||
|
||||
// if init_enstrophy is not set in the parameters, then compute it from the initial condition
|
||||
@ -607,7 +619,6 @@ int set_default_params(
|
||||
parameters->algorithm_lyapunov=ALGORITHM_RK4;
|
||||
// default lyapunov_reset will be print_time (set later) for now set target to 0 to indicate it hasn't been set explicitly
|
||||
parameters->lyapunov_trigger=0;
|
||||
parameters->init_flow_file=false;
|
||||
|
||||
parameters->print_alpha=false;
|
||||
|
||||
@ -686,12 +697,6 @@ int read_params(
|
||||
parameters->lyapunov_reset=parameters->print_freq;
|
||||
}
|
||||
|
||||
// check that if flow_init is used, then so is init
|
||||
if(parameters->init_flow_file && parameters->init!=INIT_FILE){
|
||||
fprintf(stderr, "error: cannot use 'init_flow:file' if 'init' is not a binary file\n");
|
||||
return(-1);
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
@ -1011,16 +1016,6 @@ int set_parameter(
|
||||
return(-1);
|
||||
}
|
||||
}
|
||||
else if (strcmp(lhs,"init_flow")==0){
|
||||
if(strcmp(rhs,"file")==0){
|
||||
parameters->init_flow_file=true;
|
||||
} else if (strcmp(rhs,"identity")==0){
|
||||
parameters->init_flow_file=false;
|
||||
} else {
|
||||
fprintf(stderr, "error: parameter 'init_flow' should be 'file' or 'identity'\n got '%s'\n",rhs);
|
||||
return(-1);
|
||||
}
|
||||
}
|
||||
else{
|
||||
fprintf(stderr, "error: unrecognized parameter '%s'\n",lhs);
|
||||
return(-1);
|
||||
@ -1136,12 +1131,6 @@ _Complex double* set_init(
|
||||
|
||||
case INIT_FILE:
|
||||
init_file_bin(u0, parameters->K1, parameters->K2, parameters->initfile);
|
||||
// read start time
|
||||
fread(&(parameters->starting_time), sizeof(double), 1, parameters->initfile);
|
||||
if(parameters->algorithm>ALGORITHM_ADAPTIVE_THRESHOLD){
|
||||
// read delta
|
||||
fread(&(parameters->delta), sizeof(double), 1, parameters->initfile);
|
||||
}
|
||||
break;
|
||||
|
||||
case INIT_FILE_TXT:
|
||||
@ -1183,12 +1172,14 @@ int set_lyapunov_flow_init(
|
||||
double** lyapunov_avg0,
|
||||
double* lyapunov_prevtime,
|
||||
double* lyapunov_startingtime,
|
||||
bool fromfile, // whether to initialize from file
|
||||
nstrophy_parameters parameters
|
||||
){
|
||||
*lyapunov_flow0=calloc(4*(parameters.K1*(2*parameters.K2+1)+parameters.K2)*(parameters.K1*(2*parameters.K2+1)+parameters.K2),sizeof(double));
|
||||
*lyapunov_avg0=calloc(2*(parameters.K1*(2*parameters.K2+1)+parameters.K2),sizeof(double));
|
||||
|
||||
if(parameters.init_flow_file){
|
||||
// read from file or init from identity matrix
|
||||
if(fromfile){
|
||||
// read flow
|
||||
read_mat2_bin(*lyapunov_flow0, parameters.K1, parameters.K2, parameters.initfile);
|
||||
// read time of last QR decomposition
|
||||
|
Loading…
x
Reference in New Issue
Block a user