|
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 | { |
@@ -856,6 +857,69 @@ void start_ranlux(int level, int seed) |
856 | 857 | rlxd_init(level, loc_seed); |
857 | 858 | } |
858 | 859 |
|
| 860 | +/* read warning in start.h before using this function! */ |
| 861 | +void start_ranlux_from_file(char * const rlxd_state_filename, char * const rlxs_state_filename) { |
| 862 | + FILE * rlxd_state_file; |
| 863 | + FILE * rlxs_state_file; |
| 864 | + |
| 865 | + char error_message[1000]; |
| 866 | + |
| 867 | + rlxd_state_file = fopen(rlxd_state_filename,"r"); |
| 868 | + rlxs_state_file = fopen(rlxs_state_filename,"r"); |
| 869 | + |
| 870 | + if(rlxd_state_file != NULL) { |
| 871 | + int rlxd_state[105]; |
| 872 | + fread(rlxd_state, sizeof(rlxd_state), 1, rlxd_state_file); |
| 873 | + fclose(rlxd_state_file); |
| 874 | + rlxd_reset(rlxd_state); |
| 875 | + } else { |
| 876 | + snprintf(error_message,1000,"Problem reading RLXD state file \"%s\", aborting!",rlxd_state_filename); |
| 877 | + fatal_error(error_message,"start_ranlux_from_file"); |
| 878 | + } |
| 879 | + |
| 880 | + if(rlxs_state_file != NULL) { |
| 881 | + int rlxs_state[105]; |
| 882 | + fread(rlxs_state, sizeof(rlxs_state), 1, rlxs_state_file); |
| 883 | + fclose(rlxs_state_file); |
| 884 | + rlxs_reset(rlxs_state); |
| 885 | + } else { |
| 886 | + snprintf(error_message,1000,"Problem reading RLXS state file \"%s\", aborting!",rlxs_state_filename); |
| 887 | + fatal_error(error_message,"start_ranlux_from_file"); |
| 888 | + } |
| 889 | + |
| 890 | +} |
| 891 | + |
| 892 | +void store_ranlux_state(char * const rlxd_state_filename, char * const rlxs_state_filename) { |
| 893 | + FILE * rlxd_state_file; |
| 894 | + FILE * rlxs_state_file; |
| 895 | + |
| 896 | + char error_message[1000]; |
| 897 | + |
| 898 | + rlxd_state_file = fopen(rlxd_state_filename,"w"); |
| 899 | + rlxs_state_file = fopen(rlxs_state_filename,"w"); |
| 900 | + |
| 901 | + if(rlxd_state_file != NULL) { |
| 902 | + int rlxd_state[105]; |
| 903 | + rlxd_get(rlxd_state); |
| 904 | + fwrite(rlxd_state, sizeof(rlxd_state), 1, rlxd_state_file); |
| 905 | + fclose(rlxd_state_file); |
| 906 | + } else { |
| 907 | + snprintf(error_message,1000,"Problem opening RLXD state file \"%s\" for writing, aborting!",rlxd_state_filename); |
| 908 | + fatal_error(error_message,"store_ranlux_state"); |
| 909 | + } |
| 910 | + |
| 911 | + if(rlxs_state_file != NULL) { |
| 912 | + int rlxs_state[105]; |
| 913 | + rlxs_get(rlxs_state); |
| 914 | + fwrite(rlxs_state, sizeof(rlxs_state), 1, rlxs_state_file); |
| 915 | + fclose(rlxs_state_file); |
| 916 | + } else { |
| 917 | + snprintf(error_message,1000,"Problem opening RLXS state file \"%s\" for writing, aborting!",rlxs_state_filename); |
| 918 | + fatal_error(error_message,"store_ranlux_state"); |
| 919 | + } |
| 920 | + |
| 921 | +} |
| 922 | + |
859 | 923 | void gen_test_spinor_field(spinor * const k, const int eoflag) { |
860 | 924 |
|
861 | 925 | int ix,iy,effvol; |
|
0 commit comments