/************************************************************ This function checks for the correctness of input data. If the input data seem OK, it would leave a note to that effect in the output directory. Else, it would fail, noisily. Author: M. P. Gururajan Copyright (c) 2003 Computational Materials Science Laboratory, Department of Metallurgy, Indian Institute of Science, Bangalore 560 012. INDIA. See the README file for further details. ************************************************************/ #include #include void test_input_data(int n_x, int n_y, double delta_x, double delta_y, double kappa, double A, double delta_t, int time_steps, double c_zero, double noise_str) { /* * File pointer to write the output if the tests are successful */ FILE *fpw; /* * If indicator is not zero at the end, the input values are wrong */ int indicator = 0; /* * Check if the number of points are positive */ if (n_x <= 0 || n_y <= 0) { printf("The number of points can not be negative or zero\n"); indicator = indicator + 1; } /* * Check if the grid spacings are positive */ if (delta_x <= 0.0 || delta_y <= 0.0) { printf("The grid spacing can not be negative or zero\n"); indicator = indicator + 1; } /* * To check if the number and length of time steps are physically * meaningful */ if (delta_t <= 0.0) { printf("The time step should not be zero or negative\n"); indicator = indicator + 1; } if (time_steps <= 0) { printf ("The number of time steps should not be zero or negative\n"); indicator = indicator + 1; } /* * Check kappa and A */ if (A <= 0.0) { printf("The parameter A should not be zero or negative\n"); indicator = indicator + 1; } if (kappa <= 0) { printf("The parameter kappa should not be zero or negative\n"); indicator = indicator + 1; } /* * Check c_zero and noise_str */ if (c_zero <= 0.0) { printf ("The average alloy composition should not be zero or negative\n"); indicator = indicator + 1; } if (c_zero >= 1.0) { printf("The average alloy composition should be less than 1.0\n"); } if (noise_str >= 1.0) { printf("The strength of noise should not be greater than 1.0\n"); indicator = indicator + 1; } /* * Exit if the input values do not make sense else write a note in * output/input_data_test_information */ if (indicator != 0) { printf("Exiting\n"); exit(0); } else { if ((fpw = fopen("output/input_data_test_information", "w")) == NULL) { printf ("Unable to open output/input_data_test_information. Exiting\n"); exit(0); } (void) fprintf(fpw, "All tests passed\n"); (void) fprintf(fpw, "The given input values seem OK\n"); (void) fclose(fpw); } }