Ian Jauslin
summaryrefslogtreecommitdiff
path: root/src/io.c
diff options
context:
space:
mode:
authorIan Jauslin <ian.jauslin@rutgers.edu>2023-04-11 18:45:45 -0400
committerIan Jauslin <ian.jauslin@rutgers.edu>2023-04-11 18:45:45 -0400
commitd16c42d9f5a40b94406a859fa510bba96480d5e8 (patch)
treeceada7d5d31cf813aa8b9b8a7e33d10418b03f17 /src/io.c
parentbca217e69837e2ecb788511b786f4adc9a74769e (diff)
Only store u[kx,ky] with kx>=0
Diffstat (limited to 'src/io.c')
-rw-r--r--src/io.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/io.c b/src/io.c
index 5cdfc54..049f310 100644
--- a/src/io.c
+++ b/src/io.c
@@ -12,9 +12,9 @@ int write_u(_Complex double* u, int K1, int K2, FILE* file){
return 0;
}
- for(kx=-K1;kx<=K1;kx++){
+ for(kx=0;kx<=K1;kx++){
for (ky=-K2;ky<=K2;ky++){
- fprintf(file,"%d %d % .15e % .15e\n",kx,ky,__real__ u[klookup(kx,ky,2*K1+1,2*K2+1)],__imag__ u[klookup(kx,ky,2*K1+1,2*K2+1)]);
+ fprintf(file,"%d %d % .15e % .15e\n",kx,ky,__real__ u[klookup_sym(kx,ky,K2)],__imag__ u[klookup_sym(kx,ky,K2)]);
}
}
@@ -63,15 +63,18 @@ int read_u(_Complex double* u, int K1, int K2, FILE* file){
// errors
if(ret!=4){
- fprintf(stderr, "warning: line %d does not match the input format: '%s'\n", counter, line);
+ fprintf(stderr, "warning: line %d does not match the input format: '%s', skipping\n", counter, line);
}
else{
if(kx>K1 || kx<-K1 || ky>K2 || ky<-K2){
- fprintf(stderr, "warning: reading line %d: kx or ky out of bounds: %d,%d\n", counter, kx, ky);
+ fprintf(stderr, "warning: reading line %d: kx or ky out of bounds: %d,%d, skipping\n", counter, kx, ky);
+ }
+ else if (kx<0){
+ fprintf(stderr, "warning: reading line %d: kx should be >=0, skipping\n", counter);
}
else{
// set u
- u[klookup(kx, ky, 2*K1+1, 2*K2+1)]=r+i*I;
+ u[klookup_sym(kx, ky, K2)]=r+i*I;
}
}
}