Ian Jauslin
summaryrefslogtreecommitdiff
path: root/src/io.c
diff options
context:
space:
mode:
authorIan Jauslin <ian.jauslin@rutgers.edu>2023-04-12 19:05:01 -0400
committerIan Jauslin <ian.jauslin@rutgers.edu>2023-04-12 19:05:01 -0400
commitc00c3115284691e98d724e630aca7a41087502eb (patch)
treee1f7f43d7c9a08bd2cb4e1ebace506cf2478d0fc /src/io.c
parent0b0894839d190eaba30fa5497838c9a201a21d83 (diff)
Write restart command to savefile
Diffstat (limited to 'src/io.c')
-rw-r--r--src/io.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/io.c b/src/io.c
index 94816f9..cb14029 100644
--- a/src/io.c
+++ b/src/io.c
@@ -1,5 +1,6 @@
#include <stdbool.h>
#include <stdlib.h>
+#include <string.h>
#include "io.h"
#include "navier-stokes.h"
@@ -113,3 +114,41 @@ int read_u(_Complex double* u, int K1, int K2, FILE* file){
return 0;
}
+
+// remove an entry from params string (inplace)
+int remove_entry(
+ char* param_str,
+ char* entry
+){
+ char* ptr;
+ char* rw_ptr;
+ char* bfr;
+ char* entry_ptr=entry;
+ int go=1;
+
+ for(ptr=param_str, rw_ptr=ptr; *ptr!='\0'; ptr++){
+ for(bfr=ptr,entry_ptr=entry; *bfr==*entry_ptr; bfr++, entry_ptr++){
+ // check if reached end of entry
+ if(*(bfr+1)=='=' && *(entry_ptr+1)=='\0'){
+ go=0;
+ break;
+ }
+ }
+ if(go==1){
+ *rw_ptr=*ptr;
+ rw_ptr++;
+ }
+ //reset
+ if(*ptr==';'){
+ go=1;
+ }
+ }
+ *rw_ptr='\0';
+
+ // remove trailing ';'
+ if (param_str[strlen(param_str)-1]==';'){
+ *(param_str+(strlen(param_str)-1))='\0';
+ }
+
+ return 0;
+}