diff options
-rw-r--r-- | par/announce.par | 4 | ||||
-rw-r--r-- | par/output_source.par | 6 | ||||
-rw-r--r-- | par/sendrdf.par | 8 | ||||
-rw-r--r-- | src/announce.cc | 10 | ||||
-rw-r--r-- | src/file.cc | 128 | ||||
-rw-r--r-- | src/file.hh | 37 | ||||
-rw-r--r-- | src/make.code.deps | 4 | ||||
-rw-r--r-- | src/make.configuration.deps | 49 | ||||
-rw-r--r-- | src/multistorage.cc | 103 | ||||
-rw-r--r-- | src/multistorage.hh | 62 | ||||
-rw-r--r-- | src/output_source.c | 2 | ||||
-rw-r--r-- | src/portal.cc | 58 | ||||
-rw-r--r-- | src/portal.hh | 34 | ||||
-rw-r--r-- | src/rdf.cc | 27 | ||||
-rw-r--r-- | src/rdf.hh | 12 | ||||
-rw-r--r-- | src/rdf_publisher.cc | 2 | ||||
-rw-r--r-- | src/senddata.cc | 5 | ||||
-rw-r--r-- | src/storage.cc | 24 | ||||
-rw-r--r-- | src/storage.hh | 47 | ||||
-rw-r--r-- | src/util/VERSION | 1 | ||||
-rwxr-xr-x | src/util/git-commit-everything.pl | 2 | ||||
-rwxr-xr-x | src/util/git-gc-repo.pl | 4 | ||||
-rwxr-xr-x | src/util/git-push-everything.pl | 2 | ||||
-rwxr-xr-x | src/util/git-rm-thorn.pl | 4 | ||||
-rwxr-xr-x | src/util/git-rm-unused-thorns.pl | 44 | ||||
-rwxr-xr-x | src/util/makeblob.pl | 129 | ||||
-rwxr-xr-x | src/util/makemetablob.pl | 34 |
27 files changed, 526 insertions, 316 deletions
diff --git a/par/announce.par b/par/announce.par index 390c1a5..4bb2319 100644 --- a/par/announce.par +++ b/par/announce.par @@ -8,11 +8,11 @@ Cactus::cctk_itlast = 0 ActiveThorns = "CoordBase InitBase" ActiveThorns = "IOUtil" -IO::out_dir = $parfile +IO::out_dir = $parfile IOUtil::parfile_write = no ActiveThorns = "PUGH" ActiveThorns = "Formaline" -Formaline::verbose = yes +Formaline::verbose = yes Formaline::announce_to_portal = yes diff --git a/par/output_source.par b/par/output_source.par index db8460a..66baaa6 100644 --- a/par/output_source.par +++ b/par/output_source.par @@ -5,13 +5,13 @@ Cactus::cctk_show_schedule = no Cactus::cctk_itlast = 0 -ActiveThorns = "CoordBase" +ActiveThorns = "CoordBase InitBase" ActiveThorns = "IOUtil" -IO::out_dir = $parfile +IO::out_dir = $parfile IOUtil::parfile_write = no ActiveThorns = "PUGH" ActiveThorns = "Formaline" -Formaline::store_into_file = no +Formaline::store_into_file = no diff --git a/par/sendrdf.par b/par/sendrdf.par index fb5952e..2ad4e56 100644 --- a/par/sendrdf.par +++ b/par/sendrdf.par @@ -5,13 +5,15 @@ Cactus::cctk_show_schedule = no Cactus::cctk_itlast = 0 +ActiveThorns = "LoopControl" + ActiveThorns = "CoordBase InitBase" ActiveThorns = "IOUtil" -IO::out_dir = $parfile +IO::out_dir = $parfile IOUtil::parfile_write = no -ActiveThorns = "PUGH" +ActiveThorns = "CarpetLib Carpet" ActiveThorns = "Formaline" Formaline::verbose = yes @@ -19,3 +21,5 @@ Formaline::publish_level = 2 Formaline::send_as_rdf = yes Formaline::rdf_hostname[0] = "buran.aei.mpg.de" Formaline::rdf_port [0] = 24997 +Formaline::rdf_hostname[1] = "devportal.cct.lsu.edu" +Formaline::rdf_port [1] = 8080 diff --git a/src/announce.cc b/src/announce.cc index 35aa466..bf26933 100644 --- a/src/announce.cc +++ b/src/announce.cc @@ -177,7 +177,8 @@ namespace Formaline void const * const ptr = CCTK_ParameterGet ("cctk_run_title", "Cactus", & type); assert (type == PARAMETER_STRING); - char const * const run_title = * static_cast<char const * const *> (ptr); + char const * const run_title = + * static_cast<char const * const *> (ptr); stores.store ("app_title", run_title); } @@ -284,7 +285,7 @@ namespace Formaline { char parameter_filename [10000]; CCTK_ParameterFilename (sizeof parameter_filename, parameter_filename); - stores.store ("parameter_file", parameter_filename); + stores.store ("parameter_filename", parameter_filename); } { @@ -296,8 +297,9 @@ namespace Formaline } { - // Don't know what this is for - stores.store ("data_directory", ""); + // Don't know exactly what this is for -- send the IO output + // directory + stores.store ("data_directory", out_dir); } { diff --git a/src/file.cc b/src/file.cc index 9300403..cc93ca9 100644 --- a/src/file.cc +++ b/src/file.cc @@ -8,87 +8,104 @@ #include "file.hh" +using namespace std; + namespace Formaline { - - using namespace std; - - - + file:: file (char const * const id, - enum state const st) - : storage (st) + enum state const st, + char const * const p, + file * const par) + : storage (st), path (p), parent (par) { DECLARE_CCTK_PARAMETERS; - + + if (parent) return; + ostringstream filenamebuf; filenamebuf << out_dir << "/" << storage_filename; string const filenamestring = filenamebuf.str(); - + ios::openmode const mode = get_state() == initial ? ios::trunc : ios::app; fil.open (filenamestring.c_str(), mode); - + if (get_state() == initial) { store ("jobid", id); } } - - - + + + file:: ~ file () { - if (get_state() == final) + if (parent) return; + + if (get_state()) { store ("simulation", "done"); } fil.close(); } - - - + + + + file * file:: + open_group (char const * const name) + { + assert (name); + string name1 (name); + if (not name1.empty() and name1[name1.length()-1] != '/') { + name1 = name1 + "/"; + } + return new file (0, get_state (), name1.c_str(), this); + } + + + void file:: store (char const * const key, bool const value) { assert (key); - + ostringstream keybuf; - keybuf << key; + keybuf << path << key; ostringstream valuebuf; valuebuf << (value ? "yes" : "no"); - + ostringstream buf; buf << clean (keybuf.str()) << "=" << clean (valuebuf.str()) << endl; - + write (buf.str()); } - - - + + + void file:: store (char const * const key, CCTK_INT const value) { assert (key); - + ostringstream keybuf; - keybuf << key; + keybuf << path << key; ostringstream valuebuf; valuebuf << value; - + ostringstream buf; buf << clean (keybuf.str()) << "=" << clean (valuebuf.str()) << endl; - + write (buf.str()); } - - - + + + void file:: store (char const * const key, CCTK_REAL const value) @@ -98,7 +115,7 @@ namespace Formaline int const prec = numeric_limits<CCTK_REAL>::digits10; ostringstream keybuf; - keybuf << key; + keybuf << path << key; ostringstream valuebuf; valuebuf << setprecision(prec) << value; @@ -107,43 +124,50 @@ namespace Formaline write (buf.str()); } - - - + + + void file:: store (char const * const key, char const * const value) { assert (key); - + ostringstream keybuf; - keybuf << key; + keybuf << path << key; ostringstream valuebuf; valuebuf << value; - + ostringstream buf; buf << clean (keybuf.str()) << "=" << "\"" << clean (valuebuf.str()) << "\"" << endl; - + write (buf.str()); } - - - + + + void file:: - write (std::string const & msg) + write (string const & msg) { - fil << msg; + if (parent) + { + parent->write (msg); + } + else + { + fil << msg; + } } - - - + + + string file:: clean (string const & txt) const { ostringstream buf; - + for (string::const_iterator p = txt.begin(); p != txt.end(); ++ p) { switch (* p) @@ -154,10 +178,10 @@ namespace Formaline default: buf << * p; } } - + return buf.str(); } - - - + + + } // namespace Formaline diff --git a/src/file.hh b/src/file.hh index 2141d9f..8997114 100644 --- a/src/file.hh +++ b/src/file.hh @@ -12,47 +12,54 @@ namespace Formaline { - + class file : public storage { std::ofstream fil; - + std::string const path; + file * const parent; + public: - + file (char const * id, - enum state st); - + enum state st, + char const * p = "", + file * const par = 0); + virtual ~ file (); - + + virtual file * + open_group (char const * name); + virtual void store (char const * key, bool value); - + virtual void store (char const * key, CCTK_INT value); - + virtual void store (char const * key, CCTK_REAL value); - + virtual void store (char const * key, char const * value); - + private: - + void write (std::string const & msg); - + std::string clean (std::string const & txt) const; }; - - - + + + } // namespace Formaline diff --git a/src/make.code.deps b/src/make.code.deps index 606383d..d9b30a1 100644 --- a/src/make.code.deps +++ b/src/make.code.deps @@ -6,10 +6,10 @@ # file make.configuration.deps because only here the location of the # source directory is known. -FORMALINE_BIN_DIR = $(SCRATCH_BUILD)/formaline-bin +FORMALINE_BIN_DIR = $(SCRATCH_BUILD)/Formaline/bin FORMALINE_TAR_FILES = gethostname.pl makeblob.pl makemetablob.pl -FORMALINE_GIT_FILES = git-add-thorn.pl git-commit-everything.pl git-gc-repo.pl git-init-master-repo.pl git-init-repo.pl git-lock.pl git-push-everything.pl git-rm-thorn.pl +FORMALINE_GIT_FILES = git-add-thorn.pl git-commit-everything.pl git-gc-repo.pl git-init-master-repo.pl git-init-repo.pl git-lock.pl git-push-everything.pl git-rm-unused-thorns.pl git-rm-thorn.pl $(CCTK_TARGET): $(FORMALINE_TAR_FILES:%=$(FORMALINE_BIN_DIR)/%) $(FORMALINE_GIT_FILES:%=$(FORMALINE_BIN_DIR)/%) diff --git a/src/make.configuration.deps b/src/make.configuration.deps index 00873f5..04ec21d 100644 --- a/src/make.configuration.deps +++ b/src/make.configuration.deps @@ -19,8 +19,8 @@ TR_C := $(shell tr -C 'a' 'b' < /dev/null > /dev/null 2> /dev/null && echo 'tr - # Create a tarball of the source code whenever this thorn is linked # into an executable -TARBALL_DIR = $(SCRATCH_BUILD) -FORMALINE_BIN_DIR = $(SCRATCH_BUILD)/formaline-bin +TARBALL_DIR = $(SCRATCH_BUILD)/Formaline +FORMALINE_BIN_DIR = $(SCRATCH_BUILD)/Formaline/bin @@ -77,7 +77,7 @@ $(TOP)/BUILD-ID: $(CCTK_LIBDIR)/$(LIBNAME_PREFIX)$(CCTK_LIBNAME_PREFIX)Formaline .PRECIOUS: $(TARBALL_DIR)/build-id.o $(TARBALL_DIR)/build-id.o: $(TARBALL_DIR)/build-id.c - $(CC) $(CFLAGS) -c -o $@ $^ + cd $(TARBALL_DIR) && $(CC) $(CFLAGS) -c -o $@ $^ .PRECIOUS: $(TARBALL_DIR)/build-id.c $(TARBALL_DIR)/build-id.c: $(TOP)/BUILD-ID @@ -93,7 +93,7 @@ $(TARBALL_DIR)/build-id.c: $(TOP)/BUILD-ID # Meta information $(TARBALL_DIR)/cactus-meta-source.o: $(TARBALL_DIR)/cactus-meta-source.c - $(CC) $(CFLAGS) -c -o $@ $^ + cd $(TARBALL_DIR) && $(CC) $(CFLAGS) -c -o $@ $^ $(TARBALL_DIR)/cactus-meta-source.c: $(TARBALL_DIR)/cactus-flesh-source.c $(patsubst %,$(TARBALL_DIR)/cactus-thorn-source-%.c,$(notdir $(THORNS))) $(FORMALINE_BIN_DIR)/makemetablob.pl Cactus $(notdir $(THORNS)) > $@ @@ -113,10 +113,11 @@ $(TARBALL_DIR)/cactus-meta-source.c: $(TARBALL_DIR)/cactus-flesh-source.c $(pats $(TARBALL_DIR)/cactus-flesh-source.o: $(TARBALL_DIR)/cactus-flesh-source.c @echo "Creating Formaline tarball for the flesh" - $(CC) $(CFLAGS) -c -o $@ $^ + cd $(TARBALL_DIR) && $(CC) $(CFLAGS) -c $^ $(^:%.c=%-????.c) $(TARBALL_DIR)/cactus-flesh-source.c: $(TARBALL_DIR)/cactus-flesh-source.tar.gz $(CCTK_HOME)/arrangements/CactusUtils/Formaline/src/util/VERSION - $(FORMALINE_BIN_DIR)/makeblob.pl '' Cactus < $< > $@ + $(RM) -f $(@:%.c=%-????.c) + $(FORMALINE_BIN_DIR)/makeblob.pl $(@:%.c=%) '' Cactus < $< $(TARBALL_DIR)/cactus-flesh-source.tar.gz: $(TARBALL_DIR)/cactus-flesh-source.files cd $(CCTK_HOME) && \ @@ -145,6 +146,7 @@ $(TARBALL_DIR)/cactus-flesh-source.files: $(CCTK_LIBDIR)/$(LIBNAME_PREFIX)$(CCTK # Make aborts if these dependencies vanish. Therefore mention only files # here that cannot go away. $(TARBALL_DIR)/cactus-flesh-source.ccldeps: + mkdir -p $(TARBALL_DIR) { \ echo "$(@:%.ccldeps=%.files) \\"; \ echo "$@: \\"; \ @@ -163,10 +165,11 @@ $(TARBALL_DIR)/cactus-flesh-source.ccldeps: $(TARBALL_DIR)/cactus-thorn-source-%.o: $(TARBALL_DIR)/cactus-thorn-source-%.c @echo "Creating Formaline tarball for thorn $*" - $(CC) $(CFLAGS) -c -o $@ $^ + cd $(TARBALL_DIR) && $(CC) $(CFLAGS) -c $^ $(^:%.c=%-????.c) $(TARBALL_DIR)/cactus-thorn-source-%.c: $(TARBALL_DIR)/cactus-thorn-source-%.tar.gz $(CCTK_HOME)/arrangements/CactusUtils/Formaline/src/util/VERSION - $(FORMALINE_BIN_DIR)/makeblob.pl $(patsubst %/,%,$(dir $(filter %/$(@:$(TARBALL_DIR)/cactus-thorn-source-%.c=%),$(THORNS)))) $(@:$(TARBALL_DIR)/cactus-thorn-source-%.c=%) < $< > $@ + $(RM) -f $(@:%.c=%-????.c) + $(FORMALINE_BIN_DIR)/makeblob.pl $(@:%.c=%) $(patsubst %/,%,$(dir $(filter %/$(@:$(TARBALL_DIR)/cactus-thorn-source-%.c=%),$(THORNS)))) $(@:$(TARBALL_DIR)/cactus-thorn-source-%.c=%) < $< $(TARBALL_DIR)/cactus-thorn-source-%.tar.gz: $(TARBALL_DIR)/cactus-thorn-source-%.files cd $(CCTK_HOME) && \ @@ -194,6 +197,7 @@ $(TARBALL_DIR)/cactus-thorn-source-%.files: $(CCTK_LIBDIR)/$(LIBNAME_PREFIX)$(CC # Make aborts if these dependencies vanish. Therefore mention only files # here that cannot go away. $(TARBALL_DIR)/cactus-thorn-source-%.ccldeps: + mkdir -p $(TARBALL_DIR) { \ echo "$(@:%.ccldeps=%.files) \\"; \ echo "$@: \\"; \ @@ -284,6 +288,7 @@ git-store-source: git-commit-everything git-push-everything echo "Formaline: If the build process seems to hang, some other command" echo "Formaline: is still running, e.g. the final link stage.)" +GIT-TAG-DIR = $(SCRATCH_BUILD)/Formaline GIT-BIN = $(FORMALINE_BIN_DIR) GIT-ROOT = $(CCTK_HOME) GIT-REPO = $(TOP)/configjar.git @@ -299,34 +304,44 @@ git-push-everything: git-commit-everything $(BUILD-ID-FILE) { \ '$(GIT-BIN)/git-init-master-repo.pl' '$(GIT)' '$(GIT-MASTER-REPO)' && \ if [ -e "$(CCTK_HOME)/cactus.config" ]; then \ - source "$(CCTK_HOME)/cactus.config" && \ - export CACTUS_CENTRAL_GIT_REPO; \ + . "$(CCTK_HOME)/cactus.config"; \ fi && \ + export CACTUS_CENTRAL_GIT_REPO && \ '$(GIT-BIN)/git-push-everything.pl' '$(GIT)' '$(GIT-REPO)' '$(GIT-MASTER-REPO)'; \ } || echo "Formaline: WARNING: Error while pushing to master repository" .PHONY: git-commit-everything -git-commit-everything: $(SCRATCH_BUILD)/cactus-flesh-source.git-tag $(GIT-THORNS:%=$(SCRATCH_BUILD)/cactus-thorn-%.git-tag) $(BUILD-ID-FILE) +git-commit-everything: $(GIT-TAG-DIR)/cactus-flesh-source.git-tag $(GIT-THORNS:%=$(GIT-TAG-DIR)/cactus-thorn-%.git-tag) $(BUILD-ID-FILE) git-rm-unused-thorns { \ '$(GIT-BIN)/git-commit-everything.pl' '$(GIT)' '$(GIT-REPO)' '$(GIT-ROOT)' "$$(cat $(BUILD-ID-FILE))" "$$(cat $(CONFIG-ID-FILE))"; \ } || echo "Formaline: WARNING: Error while committing to repository" -.PRECIOUS: $(SCRATCH_BUILD)/cactus-flesh-source.git-tag -$(SCRATCH_BUILD)/cactus-flesh-source.git-tag: $(TARBALL_DIR)/cactus-flesh-source.files +# Wait until after thorn Formaline has been built, so that its +# utilities are available +.PHONY: git-rm-unused-thorns +git-rm-unused-thorns: $(CCTK_LIBDIR)/$(LIBNAME_PREFIX)$(CCTK_LIBNAME_PREFIX)Formaline$(LIBNAME_SUFFIX) + { \ + '$(GIT-BIN)/git-rm-unused-thorns.pl' '$(GIT)' '$(GIT-REPO)' '$(GIT-ROOT)' $(THORNS); \ + } || echo "Formaline: WARNING: Error while removing unused thorns" + +.PRECIOUS: $(GIT-TAG-DIR)/cactus-flesh-source.git-tag +$(GIT-TAG-DIR)/cactus-flesh-source.git-tag: $(TARBALL_DIR)/cactus-flesh-source.files + mkdir -p $(GIT-TAG-DIR) { \ '$(GIT-BIN)/git-init-repo.pl' '$(GIT)' '$(GIT-REPO)' && \ echo "Formaline: Adding flesh to git repository..." && \ - '$(GIT-BIN)/git-rm-thorn.pl' '$(GIT)' '$(GIT-REPO)' '$(GIT-ROOT)' 'cactus' CONTRIBUTORS COPYRIGHT Makefile lib src configs && \ + '$(GIT-BIN)/git-rm-thorn.pl' '$(GIT)' '$(GIT-REPO)' '$(GIT-ROOT)' 'Cactus' CONTRIBUTORS COPYRIGHT Makefile lib src configs && \ : xargs ls < $(TARBALL_DIR)/cactus-flesh-source.files \ > $(TARBALL_DIR)/cactus-flesh-source.files2 2> /dev/null && \ - xargs '$(GIT-BIN)/git-add-thorn.pl' '$(GIT)' '$(GIT-REPO)' '$(GIT-ROOT)' 'cactus' \ + xargs '$(GIT-BIN)/git-add-thorn.pl' '$(GIT)' '$(GIT-REPO)' '$(GIT-ROOT)' 'Cactus' \ < $(TARBALL_DIR)/cactus-flesh-source.files && \ : rm $(TARBALL_DIR)/cactus-flesh-source.files2 && \ : > $@; \ } || echo "Formaline: WARNING: Error while adding flesh to git repository" -.PRECIOUS: $(SCRATCH_BUILD)/cactus-thorn-%.git-tag -$(SCRATCH_BUILD)/cactus-thorn-%.git-tag: $(TARBALL_DIR)/cactus-thorn-source-%.files +.PRECIOUS: $(GIT-TAG-DIR)/cactus-thorn-%.git-tag +$(GIT-TAG-DIR)/cactus-thorn-%.git-tag: $(TARBALL_DIR)/cactus-thorn-source-%.files + mkdir -p $(GIT-TAG-DIR) { \ '$(GIT-BIN)/git-init-repo.pl' '$(GIT)' '$(GIT-REPO)' && \ echo "Formaline: Adding thorn $* to git repository..." && \ diff --git a/src/multistorage.cc b/src/multistorage.cc index e3329c5..3e79f90 100644 --- a/src/multistorage.cc +++ b/src/multistorage.cc @@ -1,93 +1,109 @@ #include "multistorage.hh" +using namespace std; + namespace Formaline { - - using namespace std; - - - + multistorage:: multistorage () { } - - - + + + multistorage:: ~ multistorage () { - for (list<storage *>::const_iterator it = stores.begin(); - it != stores.end(); - ++ it) + close (); + } + + + + void + multistorage:: + close () + { + for (list<storage *>::const_iterator + it = stores.begin(); it != stores.end(); ++ it) { delete * it; } + stores.clear (); } - - - + + + void multistorage:: add_storage (storage * const s) { stores.push_front (s); } - - - + + + int multistorage:: num_storages () const { return stores.size(); } - - - + + + + void + multistorage::open_group (multistorage & ms, char const * const name) + { + for (list<storage *>::const_iterator + it = stores.begin(); it != stores.end(); ++ it) + { + ms.add_storage ((* it)->open_group (name)); + } + } + + + void multistorage:: store (char const * const key, bool const value) const { - for (list<storage *>::const_iterator it = stores.begin(); - it != stores.end(); - ++ it) + for (list<storage *>::const_iterator + it = stores.begin(); it != stores.end(); ++ it) { (* it)->store (key, value); } } - - - + + + void multistorage:: store (char const * const key, CCTK_INT const value) const { - for (list<storage *>::const_iterator it = stores.begin(); - it != stores.end(); - ++ it) + for (list<storage *>::const_iterator + it = stores.begin(); it != stores.end(); ++ it) { (* it)->store (key, value); } } - - - + + + void multistorage:: store (char const * const key, CCTK_REAL const value) const { - for (list<storage *>::const_iterator it = stores.begin(); - it != stores.end(); - ++ it) + for (list<storage *>::const_iterator + it = stores.begin(); it != stores.end(); ++ it) { (* it)->store (key, value); } } - - - + + + void multistorage:: store (char const * const key, char const * const value) const @@ -95,14 +111,13 @@ namespace Formaline // Ignore null strings if (value == 0) return; - for (list<storage *>::const_iterator it = stores.begin(); - it != stores.end(); - ++ it) + for (list<storage *>::const_iterator + it = stores.begin(); it != stores.end(); ++ it) { (* it)->store (key, value); } } - - - + + + } // namespace Formaline diff --git a/src/multistorage.hh b/src/multistorage.hh index da9da53..5b37a69 100644 --- a/src/multistorage.hh +++ b/src/multistorage.hh @@ -11,51 +11,59 @@ namespace Formaline { - - using namespace std; - - - + class multistorage { - list<storage *> stores; - + std::list<storage *> stores; + multistorage (multistorage const &); - + multistorage operator= (multistorage const &); - + public: - + multistorage (); - + ~ multistorage (); - + + void + close (); + + + void add_storage (storage *); - + int num_storages () const; - + + + + void + open_group (multistorage &, char const * name); + + + void store (char const * key, bool value) const; - + void store (char const * key, CCTK_INT value) const; - + void store (char const * key, CCTK_REAL value) const; - + void store (char const * key, char const * value) const; - - - + + + #ifdef HAVE_CCTK_INT1 # ifndef CCTK_INTEGER_PRECISION_1 void @@ -66,7 +74,7 @@ namespace Formaline } # endif #endif - + #ifdef HAVE_CCTK_INT2 # ifndef CCTK_INTEGER_PRECISION_2 void @@ -77,7 +85,7 @@ namespace Formaline } # endif #endif - + #ifdef HAVE_CCTK_INT4 # ifndef CCTK_INTEGER_PRECISION_4 void @@ -88,7 +96,7 @@ namespace Formaline } # endif #endif - + #ifdef HAVE_CCTK_INT8 # ifndef CCTK_INTEGER_PRECISION_8 void @@ -99,7 +107,7 @@ namespace Formaline } # endif #endif - + #ifdef HAVE_CCTK_REAL4 # ifndef CCTK_REAL_PRECISION_4 void @@ -110,7 +118,7 @@ namespace Formaline } # endif #endif - + #ifdef HAVE_CCTK_REAL8 # ifndef CCTK_REAL_PRECISION_8 void @@ -121,7 +129,7 @@ namespace Formaline } # endif #endif - + #ifdef HAVE_CCTK_REAL16 # ifndef CCTK_REAL_PRECISION_16 void @@ -132,7 +140,7 @@ namespace Formaline } # endif #endif - + }; diff --git a/src/output_source.c b/src/output_source.c index b2bfcb4..cd26f58 100644 --- a/src/output_source.c +++ b/src/output_source.c @@ -51,7 +51,7 @@ Formaline_OutputSource (CCTK_ARGUMENTS) CCTK_CreateDirectory (0755, filename); /* Output all thorns' tarballs */ - for (count = 0; count < cactus_source_length; ++ count) + for (count = 0; cactus_source[count]; ++ count) { snprintf (filename, sizeof filename, "%s/%s/Cactus-source-%s.tar.gz", diff --git a/src/portal.cc b/src/portal.cc index 81b046f..f2513c7 100644 --- a/src/portal.cc +++ b/src/portal.cc @@ -19,15 +19,13 @@ #include "portal.hh" +using namespace std; + namespace Formaline { - - using namespace std; - - static bool is_clean_for_shell (char const * str); @@ -35,11 +33,15 @@ namespace Formaline portal:: portal (char const * const id, - enum state const st) - : storage (st) + enum state const st, + char const * const p, + portal * const par) + : storage (st), path (p), parent (par) { DECLARE_CCTK_PARAMETERS; + if (parent) return; + msgbuf << "<?xml version='1.0' ?>" << "<methodCall><methodName>"; switch (get_state()) @@ -62,15 +64,23 @@ namespace Formaline << "<name>jobid</name>" << "<value><string>" << clean (id) << "</string></value>" << "</member>"; - } - - - + } + + + portal:: ~ portal () { DECLARE_CCTK_PARAMETERS; + if (parent) + { + parent->msgbuf << msgbuf.str(); + return; + } + + + string const socket_script = "socket-client.pl"; string const socket_data = "socket-data"; @@ -115,9 +125,10 @@ namespace Formaline << "my @hostlist = ("; // NUM_PORTAL_ENTRIES must match the size of the - // Formaline::portal_hostname and Formaline::portal_port parameter arrays + // Formaline::portal_hostname and Formaline::portal_port parameter + // arrays #define NUM_PORTAL_ENTRIES 5 - + // add all array parameters which have been set for (int i = 0; i < NUM_PORTAL_ENTRIES; i++) { if (*portal_hostname[i]) { @@ -334,7 +345,20 @@ namespace Formaline remove (datafilename); remove (scriptfilename); } - + + + + portal * portal:: + open_group (char const * const name) + { + assert (name); + string name1 (name); + if (not name1.empty() and name1[name1.length()-1] != '/') { + name1 = name1 + "/"; + } + return new portal (0, get_state (), name1.c_str(), this); + } + void portal:: @@ -344,7 +368,7 @@ namespace Formaline assert (key); ostringstream keybuf; - keybuf << key; + keybuf << path << key; ostringstream valuebuf; valuebuf << (value ? "true" : "false"); @@ -363,7 +387,7 @@ namespace Formaline assert (key); ostringstream keybuf; - keybuf << key; + keybuf << path << key; ostringstream valuebuf; valuebuf << value; @@ -384,7 +408,7 @@ namespace Formaline int const prec = numeric_limits<CCTK_REAL>::digits10; ostringstream keybuf; - keybuf << key; + keybuf << path << key; ostringstream valuebuf; valuebuf << setprecision(prec) << value; @@ -403,7 +427,7 @@ namespace Formaline assert (key); ostringstream keybuf; - keybuf << key; + keybuf << path << key; ostringstream valuebuf; valuebuf << value; diff --git a/src/portal.hh b/src/portal.hh index 27c6d22..faa787b 100644 --- a/src/portal.hh +++ b/src/portal.hh @@ -10,47 +10,51 @@ namespace Formaline { - - - + class portal : public storage { - std::ostringstream msgbuf; + std::string const path; + portal * const parent; public: - + portal (char const * id, - enum state st); - + enum state st, + char const * p = "", + portal * const par = 0); + virtual ~ portal (); - + + virtual portal * + open_group (char const * name); + virtual void store (char const * key, bool value); - + virtual void store (char const * key, CCTK_INT value); - + virtual void store (char const * key, CCTK_REAL value); - + virtual void store (char const * key, char const * value); - + private: std::string clean (std::string const & txt) const; }; - - - + + + } // namespace Formaline @@ -33,7 +33,8 @@ namespace Formaline { using namespace std; - // the jobID is shared between this source file and PublishAsRDF.cc + // The jobID is shared between this source file and PublishAsRDF.cc + // ES 2008-04-29: Check this, I think this is wrong string jobID; @@ -56,9 +57,13 @@ namespace Formaline rdf:: rdf (char const * const id, enum state const st, - cGH const * const cctkGH) - : storage (st) + cGH const * const cctkGH, + char const * const n, + rdf * const par) + : storage (st), groupname (n), parent (par) { + if (parent) return; + // set the unique ID for this simulation jobID = clean (string (id)); @@ -452,6 +457,14 @@ namespace Formaline { DECLARE_CCTK_PARAMETERS; + if (parent) + { + parent->msgbuf << "<cctk:" << groupname << ">" << endl + << msgbuf.str() + << "</cctk:" << groupname << ">" << endl; + return; + } + // check if anything needs to be done if (msgbuf.str().empty()) return; @@ -526,6 +539,14 @@ namespace Formaline + rdf * rdf:: + open_group (char const * const name) + { + return new rdf (0, get_state (), 0, name, this); + } + + + void rdf:: store (char const * const key, bool const value) @@ -42,7 +42,7 @@ namespace Formaline // buffer to keep RDF metadata until the next Update() call extern std::vector<rdfPublishItem> rdfPublishList; - // the jobID string + // the jobID std::string extern std::string jobID; std::string clean (std::string const & txt); @@ -53,17 +53,23 @@ namespace Formaline class rdf : public storage { - std::ostringstream msgbuf; + std::string const groupname; + rdf * const parent; public: rdf (char const * id, enum state st, - cGH const * cctkGH); + cGH const * cctkGH, // this should probably go away + char const * n = "", + rdf * par = 0); virtual ~ rdf (); + + virtual rdf * + open_group (char const * name); virtual void store (char const * key, diff --git a/src/rdf_publisher.cc b/src/rdf_publisher.cc index 77b48db..a256668 100644 --- a/src/rdf_publisher.cc +++ b/src/rdf_publisher.cc @@ -296,7 +296,7 @@ static void ParameterSetNotify (void *, extern "C" -void Formaline_RegisterPublishRDF_Callbacks (void) +void Formaline_RegisterPublishRDF_Callbacks (CCTK_ARGUMENTS) { int registered = 0; diff --git a/src/senddata.cc b/src/senddata.cc index 41834cf..09dcf89 100644 --- a/src/senddata.cc +++ b/src/senddata.cc @@ -36,6 +36,11 @@ namespace Formaline { DECLARE_CCTK_PARAMETERS; + if (verbose) { + CCTK_VInfo (CCTK_THORNSTRING, + "Announcing to %s:%d", hostname.c_str(), port); + } + #if 0 // pair<,> is not a standard STL class typedef pair <string, int> destination_t; diff --git a/src/storage.cc b/src/storage.cc index 4e0dd24..4e4abff 100644 --- a/src/storage.cc +++ b/src/storage.cc @@ -6,33 +6,29 @@ namespace Formaline { - - using namespace std; - - - + storage:: storage (enum state const st) : m_state (st) { } - - - + + + storage:: ~ storage () { } - - - + + + enum storage::state storage:: get_state () const { return m_state; } - - - + + + } // namespace Formaline diff --git a/src/storage.hh b/src/storage.hh index e0b5ddb..08f400f 100644 --- a/src/storage.hh +++ b/src/storage.hh @@ -7,55 +7,58 @@ namespace Formaline { - - - + class storage { public: - + enum state { initial, update, final }; - + private: - + enum state m_state; - + public: - + storage (enum state); - + virtual ~ storage (); - + enum state get_state () const; - + + virtual storage * + open_group (char const * name) + = 0; + virtual void store (char const * key, bool value) - = 0; - + = 0; + virtual void store (char const * key, CCTK_INT value) - = 0; - + = 0; + virtual void store (char const * key, CCTK_REAL value) - = 0; - + = 0; + virtual void store (char const * key, char const * value) - = 0; + = 0; + }; - - - + + + } // namespace Formaline -#endif // ifndef FORMALINE_STORAGE_HH +#endif // #ifndef FORMALINE_STORAGE_HH diff --git a/src/util/VERSION b/src/util/VERSION index 9945293..d23d03d 100644 --- a/src/util/VERSION +++ b/src/util/VERSION @@ -3,3 +3,4 @@ Each auto-generated file depends on this file. Thus, whenever this file changes, all auto-generated files are recreated. 2005-08-22: Change layout of struct sourceinfo +2010-06-23: Move thorn to a new arrangement diff --git a/src/util/git-commit-everything.pl b/src/util/git-commit-everything.pl index d972218..96a06f2 100755 --- a/src/util/git-commit-everything.pl +++ b/src/util/git-commit-everything.pl @@ -12,7 +12,7 @@ $#ARGV == 4 or die; my ($git_cmd, $git_repo, $git_root, $build_id, $config_id) = @ARGV; # Path where the git-*.pl commands are installed -my $bindir = $ENV{'SCRATCH_BUILD'} . '/formaline-bin'; +my $bindir = $ENV{'SCRATCH_BUILD'} . '/Formaline/bin'; my $silent = $ENV{'SILENT'}; $silent = 'yes' if ! defined $silent; diff --git a/src/util/git-gc-repo.pl b/src/util/git-gc-repo.pl index 21bb03f..b02d5a4 100755 --- a/src/util/git-gc-repo.pl +++ b/src/util/git-gc-repo.pl @@ -42,7 +42,9 @@ if (! defined $oldreposize) { $oldreposize = 0; } -my $maxreposize = 10 * $oldreposize; +# Collect garbage once the repository has grown by more than a factor +# of two +my $maxreposize = 2 * $oldreposize; if ($reposize > $maxreposize) { print "Formaline: Optimising git repository (slow only the first time)...\n"; diff --git a/src/util/git-push-everything.pl b/src/util/git-push-everything.pl index ee39ab4..8f5f111 100755 --- a/src/util/git-push-everything.pl +++ b/src/util/git-push-everything.pl @@ -15,7 +15,7 @@ my ($git_cmd, $git_repo, $git_master_repo) = @ARGV; my $git_central_repo = $ENV{'CACTUS_CENTRAL_GIT_REPO'}; # Path where the git-*.pl commands are installed -my $bindir = $ENV{'SCRATCH_BUILD'} . '/formaline-bin'; +my $bindir = $ENV{'SCRATCH_BUILD'} . '/Formaline/bin'; my $silent = $ENV{'SILENT'}; $silent = 'yes' if ! defined $silent; diff --git a/src/util/git-rm-thorn.pl b/src/util/git-rm-thorn.pl index 9d5342b..75769f1 100755 --- a/src/util/git-rm-thorn.pl +++ b/src/util/git-rm-thorn.pl @@ -1,6 +1,6 @@ #! /usr/bin/perl -w -# Remote a Cactus thorn from the repository index, if and wherever it +# Remove a Cactus thorn from the repository index, if and wherever it # exists # 2010-01-29 Erik Schnetter <schnetter@cct.lsu.edu> @@ -9,7 +9,7 @@ use strict; -$#ARGV >= 3 or die; +$#ARGV >= 4 or die; my ($git_cmd, $git_repo, $git_root, $thorn, @files) = @ARGV; my $silent = $ENV{'SILENT'}; diff --git a/src/util/git-rm-unused-thorns.pl b/src/util/git-rm-unused-thorns.pl new file mode 100755 index 0000000..1c8b4c9 --- /dev/null +++ b/src/util/git-rm-unused-thorns.pl @@ -0,0 +1,44 @@ +#! /usr/bin/perl -w + +# Remove all Cactus thorns from the repository index unless they are +# in the thorn list + +# 2010-04-08 Erik Schnetter <schnetter@cct.lsu.edu> + +use strict; + + + +$#ARGV >= 3 or die; +my ($git_cmd, $git_repo, $git_root, @thorns) = @ARGV; + +my $silent = $ENV{'SILENT'}; +$silent = 'yes' if ! defined $silent; +$silent = $silent !~ /^no$/i; +my $silencer = $silent ? '> /dev/null 2>&1' : ''; + + + +# Ensure that the repository exists +die unless -e "$git_repo/.git"; +$ENV{'GIT_DIR'} = "$git_repo/.git"; + + + +my @files = split m{\n}, `$git_cmd ls-files arrangements 2> /dev/null`; + +# Remove the files one by one because we want to ignore errors, but +# git aborts after the first error +file: for my $file (@files) { + for my $thorn (@thorns) { + next file if $file =~ m{^arrangements/$thorn/}; + } + + print "Executing: $git_cmd rm --cached -r $file\n" + unless $silent; + system "$git_cmd rm --cached -r $file > /dev/null 2>&1"; + # Ignore errors + #if ($?) { + # die "Could not remove file $file from git repository"; + #} +} diff --git a/src/util/makeblob.pl b/src/util/makeblob.pl index 14fd49c..55badce 100755 --- a/src/util/makeblob.pl +++ b/src/util/makeblob.pl @@ -1,20 +1,94 @@ #! /usr/bin/perl -w +use diagnostics; +use warnings; use strict; my $items_per_line = 16; my $items_per_file = 128 * 1024; -$#ARGV == 1 or die; +$#ARGV == 2 or die "ARGV=@ARGV"; -my $arrangement = $ARGV[0]; -my $thorn = $ARGV[1]; +my $basename = $ARGV[0]; +my $arrangement = $ARGV[1]; +my $thorn = $ARGV[2]; $thorn ne '' or die; -print <<EOF; + + +# Write several files, each with a maximum length + +my $done = 0; +for (my $count = 0; ! $done; ++ $count) { + my $fcount = sprintf "%04d", $count; + my $fcount_next = sprintf "%04d", $count + 1; + + open FILE, "> $basename-$fcount.c" or die; + print FILE <<EOF; /* This is an auto-generated file -- do not edit */ \#include <stddef.h> +\#include <stdlib.h> + +struct datainfo +{ + unsigned char const * data; + size_t length; + struct datainfo const * next; +}; + +EOF + + print FILE "static unsigned char const data_${fcount} [] = {"; + my $bytes; + for ($bytes = 0; $bytes < $items_per_file; ++ $bytes) { + my $ch = getc; + if (! defined $ch) { + $done = 1; + last; + } + if ($bytes != 0) { + printf FILE ","; + } + if ($bytes % $items_per_line == 0) { + printf FILE "\n"; + printf FILE " "; + } + printf FILE "%3d", ord $ch; + } + printf FILE "\n"; + printf FILE "};\n"; + + print FILE "\n"; + if (! $done) { + print FILE "struct datainfo const cactus_data_${fcount_next}_${thorn};\n"; + } + print FILE "struct datainfo const cactus_data_${fcount}_${thorn} =\n"; + print FILE "{\n"; + print FILE " data_${fcount},\n"; + print FILE " ${bytes}UL,\n"; + if (! $done) { + print FILE " & cactus_data_${fcount_next}_${thorn}\n"; + } + else { + print FILE " NULL\n"; + } + print FILE "};\n"; + + close FILE; +} + + + +# Write meta-file + +{ + open FILE, "> $basename.c" or die; + printf FILE <<EOF; +/* This is an auto-generated file -- do not edit */ + +\#include <stddef.h> +\#include <stdlib.h> struct datainfo { @@ -38,50 +112,5 @@ struct sourceinfo const cactus_source_$thorn = \"$thorn\" }; EOF - -my $done = 0; -for (my $fcount = 0; ! $done; ++ $fcount) -{ - printf "\n"; - printf "static unsigned char const data_%04d [] = {", $fcount; - my $count; - for ($count = 0; $count < $items_per_file; ++ $count) - { - my $ch = getc; - if (! defined $ch) - { - $done = 1; - last; - } - if ($count != 0) - { - printf ","; - } - if ($count % $items_per_line == 0) - { - printf "\n"; - printf " "; - } - printf "%3d", ord $ch; - } - printf "\n"; - printf "};\n"; - printf "\n"; - if (! $done) - { - printf "struct datainfo const cactus_data_%04d_%s;\n", $fcount + 1, $thorn; - } - printf "struct datainfo const cactus_data_%04d_%s =\n", $fcount, $thorn; - printf "{\n"; - printf " data_%04d,\n", $fcount; - printf " %dUL,\n", $count; - if (! $done) - { - printf " & cactus_data_%04d_%s\n", $fcount + 1, $thorn; - } - else - { - printf " NULL\n"; - } - printf "};\n"; + close FILE; } diff --git a/src/util/makemetablob.pl b/src/util/makemetablob.pl index f1349b2..530e187 100755 --- a/src/util/makemetablob.pl +++ b/src/util/makemetablob.pl @@ -1,11 +1,12 @@ #! /usr/bin/perl -w use strict; - + print <<EOF; /* This is an auto-generated file -- do not edit */ \#include <stddef.h> +\#include <stdlib.h> struct datainfo { @@ -23,21 +24,20 @@ struct sourceinfo EOF -for (my $count = 0; $count <= $#ARGV; ++ $count) -{ - printf "extern struct sourceinfo cactus_source_%s;\n", $ARGV[$count]; +foreach my $argv (@ARGV) { + print "extern struct sourceinfo const cactus_source_${argv};\n"; } -printf "\n"; -printf "struct sourceinfo const * const cactus_source [] = {"; -for (my $count = 0; $count <= $#ARGV; ++ $count) -{ - if ($count != 0) - { - printf ","; - } - printf "\n"; - printf " & cactus_source_%s", $ARGV[$count]; + +print <<EOF; + +struct sourceinfo const * const cactus_source [] = { +EOF + +foreach my $argv (@ARGV) { + print " & cactus_source_${argv},\n"; } -printf "\n"; -printf "};\n"; -printf "size_t const cactus_source_length = %d;\n", $#ARGV + 1; + +print <<EOF; + NULL +}; +EOF |