|
77 | 77 | #include "ranlxd.h" |
78 | 78 | #include "ranlxs.h" |
79 | 79 | #include "start.h" |
| 80 | +#include "fatal_error.h" |
80 | 81 |
|
81 | 82 | static void gauss_vector(double v[],int n) |
82 | 83 | { |
@@ -838,6 +839,69 @@ void start_ranlux(int level, int seed) |
838 | 839 | rlxd_init(level, loc_seed); |
839 | 840 | } |
840 | 841 |
|
| 842 | +/* read warning in start.h before using this function! */ |
| 843 | +void start_ranlux_from_file(char * const rlxd_state_filename, char * const rlxs_state_filename) { |
| 844 | + FILE * rlxd_state_file; |
| 845 | + FILE * rlxs_state_file; |
| 846 | + |
| 847 | + char error_message[1000]; |
| 848 | + |
| 849 | + rlxd_state_file = fopen(rlxd_state_filename,"r"); |
| 850 | + rlxs_state_file = fopen(rlxs_state_filename,"r"); |
| 851 | + |
| 852 | + if(rlxd_state_file != NULL) { |
| 853 | + int rlxd_state[105]; |
| 854 | + fread(rlxd_state, sizeof(rlxd_state), 1, rlxd_state_file); |
| 855 | + fclose(rlxd_state_file); |
| 856 | + rlxd_reset(rlxd_state); |
| 857 | + } else { |
| 858 | + snprintf(error_message,1000,"Problem reading RLXD state file \"%s\", aborting!",rlxd_state_filename); |
| 859 | + fatal_error(error_message,"start_ranlux_from_file"); |
| 860 | + } |
| 861 | + |
| 862 | + if(rlxs_state_file != NULL) { |
| 863 | + int rlxs_state[105]; |
| 864 | + fread(rlxs_state, sizeof(rlxs_state), 1, rlxs_state_file); |
| 865 | + fclose(rlxs_state_file); |
| 866 | + rlxs_reset(rlxs_state); |
| 867 | + } else { |
| 868 | + snprintf(error_message,1000,"Problem reading RLXS state file \"%s\", aborting!",rlxs_state_filename); |
| 869 | + fatal_error(error_message,"start_ranlux_from_file"); |
| 870 | + } |
| 871 | + |
| 872 | +} |
| 873 | + |
| 874 | +void store_ranlux_state(char * const rlxd_state_filename, char * const rlxs_state_filename) { |
| 875 | + FILE * rlxd_state_file; |
| 876 | + FILE * rlxs_state_file; |
| 877 | + |
| 878 | + char error_message[1000]; |
| 879 | + |
| 880 | + rlxd_state_file = fopen(rlxd_state_filename,"w"); |
| 881 | + rlxs_state_file = fopen(rlxs_state_filename,"w"); |
| 882 | + |
| 883 | + if(rlxd_state_file != NULL) { |
| 884 | + int rlxd_state[105]; |
| 885 | + rlxd_get(rlxd_state); |
| 886 | + fwrite(rlxd_state, sizeof(rlxd_state), 1, rlxd_state_file); |
| 887 | + fclose(rlxd_state_file); |
| 888 | + } else { |
| 889 | + snprintf(error_message,1000,"Problem opening RLXD state file \"%s\" for writing, aborting!",rlxd_state_filename); |
| 890 | + fatal_error(error_message,"store_ranlux_state"); |
| 891 | + } |
| 892 | + |
| 893 | + if(rlxs_state_file != NULL) { |
| 894 | + int rlxs_state[105]; |
| 895 | + rlxs_get(rlxs_state); |
| 896 | + fwrite(rlxs_state, sizeof(rlxs_state), 1, rlxs_state_file); |
| 897 | + fclose(rlxs_state_file); |
| 898 | + } else { |
| 899 | + snprintf(error_message,1000,"Problem opening RLXS state file \"%s\" for writing, aborting!",rlxs_state_filename); |
| 900 | + fatal_error(error_message,"store_ranlux_state"); |
| 901 | + } |
| 902 | + |
| 903 | +} |
| 904 | + |
841 | 905 | void gen_test_spinor_field(spinor * const k, const int eoflag) { |
842 | 906 |
|
843 | 907 | int ix,iy,effvol; |
|
0 commit comments