commit 6aa480676efe20720260d382c1971767f153788a
parent 0a55899a2866f0ce876650c29d364ab5fe794d96
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Mon, 13 Nov 2017 14:16:36 +0100
Add the solmaps program
Diffstat:
5 files changed, 84 insertions(+), 5 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -1,6 +1,8 @@
solpp
solppraw
solpaths
+solmaps
+output
geom
simul
themis
diff --git a/Makefile b/Makefile
@@ -16,7 +16,7 @@
include Makefile.in
INSTALL_PATH = /usr/local/bin
-SOURCES = solpp.c solppraw.c solpaths.c
+SOURCES = solpp.c solppraw.c solpaths.c solmaps.c
PROG = $(SOURCES:%.c=%)
PROJECTS = themis cyl
diff --git a/Makefile.in b/Makefile.in
@@ -13,4 +13,6 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-CFLAGS = -O2 -std=c99 -pedantic -Wall
+#CFLAGS = -O2 -std=c99 -pedantic -Wall
+CFLAGS = -g -std=c99 -pedantic -Wall
+
diff --git a/solmaps.c b/solmaps.c
@@ -0,0 +1,75 @@
+/* Copyright (C) |Meso|Star> 2017
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include "solpp.h"
+
+int
+main(int argc, char** argv)
+{
+ char s[128];
+ buf_char_T buf = BUF_NULL;
+ FILE* input = stdin;
+ char* line = NULL;
+ double azim = -1;
+ double elev = -1;
+
+ if(argc > 1 && !(input = fopen(argv[1], "r"))) {
+ fprintf(stderr, "Could not open the file `%s'.\n", argv[1]);
+ return 1;
+ }
+
+ line = read_line(&buf, input);
+ while(line) {
+ if(!strncmp(line, "#--- Sun direction:", 19)) {
+ /* Get the solar direction */
+ CHK(sscanf(line+19, "%lf %lf (%*f %*f %*f)", &azim, &elev)==2);
+ line = read_line(&buf, input);
+ } else if(!strncmp(line, "# vtk", 5)) {
+ char* header = NULL;
+ char* rcv_name = NULL;
+ FILE* output;
+
+ CHK(azim > 0 && elev > 0);
+
+ CHK(header = strdup(line)); /* Duplicate the current line */
+ CHK(line = read_line(&buf, input));
+ CHK(rcv_name = strdup(line)); /* Duplicate the line of the receiver name */
+
+ /* Create the name of the destination file */
+ CHK(snprintf(s, sizeof(s), "%g-%g-%s.vtk", azim, elev, rcv_name) < sizeof(s));
+ printf("Writing `%s'\n", s);
+ CHK(output = fopen(s, "w"));
+
+ /* Write the map data into `output' */
+ fprintf(output, "%s\n", header);
+ fprintf(output, "%s\n", rcv_name);
+ while((line = read_line(&buf, input)) && line[0] != '#') {
+ fprintf(output, "%s\n", line);
+ }
+
+ /* Clean up temporary variable and close the destination file */
+ fclose(output);
+ free(header);
+ free(rcv_name);
+ } else {
+ line = read_line(&buf, input);
+ }
+ }
+
+ BUF_RELEASE(buf);
+ if(input && input!=stdin) fclose(input);
+ return 0;
+}
+
diff --git a/themis/Makefile b/themis/Makefile
@@ -15,9 +15,9 @@
include ../Makefile.in
-NEXPERIMENTS=10000
-NPATHS=100
-SUN_DIRS=270,70
+NEXPERIMENTS=1000
+NPATHS=30
+SUN_DIRS=270,30:160,40
RCV=themis-rcv.yaml
INPUT=themis.yaml