diff options
-rw-r--r-- | README | 6 | ||||
-rw-r--r-- | par/announce.par | 6 | ||||
-rw-r--r-- | param.ccl | 14 | ||||
-rw-r--r-- | src/announce.cc | 104 |
4 files changed, 124 insertions, 6 deletions
@@ -36,3 +36,9 @@ announce: maybe use <array> for parameter arrays put the output files into the build directory instead of the scratch directory + +output grid variables +register as output method +implement reductions +implement missing data types +output only if value has changed diff --git a/par/announce.par b/par/announce.par index 26a7f2b..faced61 100644 --- a/par/announce.par +++ b/par/announce.par @@ -18,9 +18,3 @@ ActiveThorns = "Formaline" Formaline::announce_to_portal = yes Formaline::store_into_file = yes Formaline::output_source = no - -ActiveThorns = "HTTPD Socket" - -#ActiveThorns = "Announce" -#Announce::portal_username = eschnett -#Announce::app_visibility = public @@ -53,6 +53,20 @@ STRING output_source_subdirectory "Subdirectory, relative to IO::out_dir, for th +# Parameters for outputting Cactus variables + +STRING out_vars "Cactus variables that should be output" +{ + "" :: "space separated list of groups or variables" +} "" + +STRING out_reductions "Reduction operators that should be applied to the output variables" +{ + "" :: "space separated list of reduction operators" +} "minimum maximum norm1 norm2 norm_inf sum" + + + SHARES: IO USES STRING out_dir diff --git a/src/announce.cc b/src/announce.cc index 46936b8..24639fc 100644 --- a/src/announce.cc +++ b/src/announce.cc @@ -566,6 +566,110 @@ Formaline_AnnounceUpdate (CCTK_ARGUMENTS) stores.store ("cctk_iteration", cctk_iteration); stores.store ("cctk_time", cctk_time); } + + + + // Groups and variables + + { + struct args { + cGH * cctkGH; + multistorage * stores; + char const * reductions; + + static void + output_variable (int const varindex, + char const * const options, + void * const theargs0) + { + args * const theargs = (args *) theargs0; + cGH * const cctkGH = theargs->cctkGH; + multistorage & stores = * theargs->stores; + char const * const reductions = theargs->reductions; + + int const groupindex = CCTK_GroupIndexFromVarI (varindex); + assert (groupindex >= 0); + cGroup group; + int const ierr = CCTK_GroupData (groupindex, & group); + assert (! ierr); + + ostringstream keybuf, valbuf; + char * const fullname = CCTK_FullName (varindex); + assert (fullname); + keybuf << "variables/" << fullname; + free (fullname); + string const keystr = keybuf.str(); + char const * const key = keystr.c_str(); + + void const * const varptr + = CCTK_VarDataPtrI (cctkGH, 0, varindex); + if (! varptr) { + // No storage -- do nothing + // TODO: output warning + return; + } + + switch (group.grouptype) + { + case CCTK_SCALAR: + switch (group.vartype) + { + case CCTK_VARIABLE_INT: + { + CCTK_INT const val = * (CCTK_INT const *) varptr; + stores.store (key, val); + } + break; + case CCTK_VARIABLE_REAL: + { + CCTK_REAL const val = * (CCTK_REAL const *) varptr; + stores.store (key, val); + } + break; + case CCTK_VARIABLE_COMPLEX: + { + CCTK_COMPLEX const val = * (CCTK_COMPLEX const *) varptr; + { + ostringstream keyrebuf; + keyrebuf << key << ".Re"; + string const keyrestr = keyrebuf.str(); + char const * const keyre = keyrestr.c_str(); + stores.store (keyre, val.Re); + } + { + ostringstream keyimbuf; + keyimbuf << key << ".Im"; + string const keyimstr = keyimbuf.str(); + char const * const keyim = keyimstr.c_str(); + stores.store (keyim, val.Im); + } + } + break; + default: + ; + // not supported yet + // TODO: output warning + } + break; + case CCTK_ARRAY: + case CCTK_GF: + // not supported yet + // TODO: output warning + break; + default: + CCTK_WARN (0, "internal error"); + } + } + } theargs; + + theargs.cctkGH = cctkGH; + theargs.stores = & stores; + theargs.reductions = out_reductions; + + int const ierr + = CCTK_TraverseString (out_vars, theargs.output_variable, & theargs, + CCTK_GROUP_OR_VAR); + } } |