diff --git a/Make.Emu b/Make.Emu index 77e39393..24d9d145 100644 --- a/Make.Emu +++ b/Make.Emu @@ -24,10 +24,48 @@ include $(Ppack) DEFINES += -DNUM_FLAVORS=$(NUM_FLAVORS) -DSHAPE_FACTOR_ORDER=$(SHAPE_FACTOR_ORDER) -all: generate $(executable) +all: generate $(objEXETempDir)/AMReX_buildInfo.o $(executable) @echo SUCCESS generate: python3 $(EMU_HOME)/Scripts/symbolic_hermitians/generate_code.py $(NUM_FLAVORS) --emu_home $(EMU_HOME) +#------------------------------------------------------------------------------ +# build info (from Castro/Exec/Make.auto_source) +#------------------------------------------------------------------------------ +CEXE_headers += $(AMREX_HOME)/Tools/C_scripts/AMReX_buildInfo.H +INCLUDE_LOCATIONS += $(AMREX_HOME)/Tools/C_scripts + +# we make AMReX_buildInfo.cpp as we make the .o file, so we can delete +# it immediately. this way if the build is interrupted, we are +# guaranteed to remake it + +objForExecs += $(objEXETempDir)/AMReX_buildInfo.o + +.FORCE: +.PHONE: .FORCE + +# set BUILD_GIT_NAME and BUILD_GIT_DIR if you are building in a +# git-controlled dir not under Castro/ +EXTRA_BUILD_INFO := +ifdef BUILD_GIT_NAME + EXTRA_BUILD_INFO := --build_git_name "$(BUILD_GIT_NAME)" \ + --build_git_dir "$(BUILD_GIT_DIR)" +endif + +$(objEXETempDir)/AMReX_buildInfo.o: .FORCE + echo $(objEXETempDir) + $(AMREX_HOME)/Tools/C_scripts/makebuildinfo_C.py \ + --amrex_home "$(AMREX_HOME)" \ + --COMP "$(COMP)" --COMP_VERSION "$(COMP_VERSION)" \ + --CXX_comp_name "$(CXX)" --CXX_flags "$(CXXFLAGS) $(CPPFLAGS) $(includes)" \ + --F_comp_name "$(F90)" --F_flags "$(F90FLAGS)" \ + --link_flags "$(LDFLAGS)" --libraries "$(libraries)" \ + --MODULES "$(MNAMES)" $(EXTRA_BUILD_INFO) \ + --GIT "$(TOP) $(AMREX_HOME) $(MICROPHYSICS_HOME)" + $(SILENT) $(CCACHE) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $(CXXEXEFLAGS) AMReX_buildInfo.cpp -o $(objEXETempDir)/AMReX_buildInfo.o + $(SILENT) $(RM) AMReX_buildInfo.cpp + + + include $(AMREX_HOME)/Tools/GNUMake/Make.rules diff --git a/Source/IO.H b/Source/IO.H index fd57f6cd..e851f0a2 100644 --- a/Source/IO.H +++ b/Source/IO.H @@ -17,4 +17,10 @@ RecoverParticles (const std::string& dir, FlavoredNeutrinoContainer& neutrinos, amrex::Real& time, int& step); +void +writeBuildInfo (); + +void +writeJobInfo (const std::string& dir, const amrex::Geometry& geom); + #endif diff --git a/Source/IO.cpp b/Source/IO.cpp index 7f291dff..a1b09cea 100644 --- a/Source/IO.cpp +++ b/Source/IO.cpp @@ -1,5 +1,6 @@ #include #include +#include #include "FlavoredNeutrinoContainer.H" #include "IO.H" @@ -31,6 +32,9 @@ WritePlotFile (const amrex::MultiFab& state, auto neutrino_varnames = neutrinos.get_attribute_names(); neutrinos.Checkpoint(plotfilename, "neutrinos", true, neutrino_varnames); } + + // write job information + writeJobInfo (plotfilename, geom); } void @@ -57,3 +61,266 @@ RecoverParticles (const std::string& dir, // print the step/time for the restart amrex::Print() << "Restarting after time step: " << step-1 << " t = " << time << " s. ct = " << PhysConst::c * time << " cm" << std::endl; } + + +// writeBuildInfo and writeJobInfo are copied from Castro/Source/driver/Castro_io.cpp +// and modified by Sherwood Richers +/* +SOURCE CODE LICENSE AGREEMENT +Castro, Copyright (c) 2015, +The Regents of the University of California, +through Lawrence Berkeley National Laboratory +(subject to receipt of any required approvals from the U.S. +Dept. of Energy). All rights reserved." + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + +(1) Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + +(2) Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. + +(3) Neither the name of the University of California, Lawrence +Berkeley National Laboratory, U.S. Dept. of Energy nor the names of +its contributors may be used to endorse or promote products derived +from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +You are under no obligation whatsoever to provide any bug fixes, +patches, or upgrades to the features, functionality or performance of +the source code ("Enhancements") to anyone; however, if you choose to +make your Enhancements available either publicly, or directly to +Lawrence Berkeley National Laboratory, without imposing a separate +written license agreement for such Enhancements, then you hereby grant +the following license: a non-exclusive, royalty-free perpetual +license to install, use, modify, prepare derivative works, incorporate +into other computer software, distribute, and sublicense such +enhancements or derivative works thereof, in binary and source code +form. +*/ +void +writeBuildInfo (){ + std::string PrettyLine = std::string(78, '=') + "\n"; + std::string OtherLine = std::string(78, '-') + "\n"; + std::string SkipSpace = std::string(8, ' '); + + // build information + std::cout << PrettyLine; + std::cout << " Emu Build Information\n"; + std::cout << PrettyLine; + + std::cout << "build date: " << buildInfoGetBuildDate() << "\n"; + std::cout << "build machine: " << buildInfoGetBuildMachine() << "\n"; + std::cout << "build dir: " << buildInfoGetBuildDir() << "\n"; + std::cout << "AMReX dir: " << buildInfoGetAMReXDir() << "\n"; + + std::cout << "\n"; + + std::cout << "COMP: " << buildInfoGetComp() << "\n"; + std::cout << "COMP version: " << buildInfoGetCompVersion() << "\n"; + + std::cout << "\n"; + + std::cout << "C++ compiler: " << buildInfoGetCXXName() << "\n"; + std::cout << "C++ flags: " << buildInfoGetCXXFlags() << "\n"; + + std::cout << "\n"; + + std::cout << "Link flags: " << buildInfoGetLinkFlags() << "\n"; + std::cout << "Libraries: " << buildInfoGetLibraries() << "\n"; + + std::cout << "\n"; + + for (int n = 1; n <= buildInfoGetNumModules(); n++) { + std::cout << buildInfoGetModuleName(n) << ": " << buildInfoGetModuleVal(n) << "\n"; + } + + std::cout << "\n"; + + const char* githash1 = buildInfoGetGitHash(1); + const char* githash2 = buildInfoGetGitHash(2); + if (strlen(githash1) > 0) { + std::cout << "Emu git describe: " << githash1 << "\n"; + } + if (strlen(githash2) > 0) { + std::cout << "AMReX git describe: " << githash2 << "\n"; + } + + const char* buildgithash = buildInfoGetBuildGitHash(); + const char* buildgitname = buildInfoGetBuildGitName(); + if (strlen(buildgithash) > 0){ + std::cout << buildgitname << " git describe: " << buildgithash << "\n"; + } + + std::cout << "\n"< 0) { + jobInfoFile << "Emu git describe: " << githash1 << "\n"; + } + if (strlen(githash2) > 0) { + jobInfoFile << "AMReX git describe: " << githash2 << "\n"; + } + + const char* buildgithash = buildInfoGetBuildGitHash(); + const char* buildgitname = buildInfoGetBuildGitName(); + if (strlen(buildgithash) > 0){ + jobInfoFile << buildgitname << " git describe: " << buildgithash << "\n"; + } + + jobInfoFile << "\n\n"; + + + // grid information + jobInfoFile << PrettyLine; + jobInfoFile << " Grid Information\n"; + jobInfoFile << PrettyLine; + + jobInfoFile << "geometry.is_periodic: "; + for (int idir = 0; idir < AMREX_SPACEDIM; idir++) { + jobInfoFile << geom.isPeriodic(idir) << " "; + } + jobInfoFile << "\n"; + + jobInfoFile << "geometry.coord_sys: " << geom.Coord() << "\n"; + + jobInfoFile << "geometry.prob_lo: "; + for (int idir = 0; idir < AMREX_SPACEDIM; idir++) { + jobInfoFile << geom.ProbLo(idir) << " "; + } + jobInfoFile << "\n"; + + jobInfoFile << "geometry.prob_hi: "; + for (int idir = 0; idir < AMREX_SPACEDIM; idir++) { + jobInfoFile << geom.ProbHi(idir) << " "; + } + jobInfoFile << "\n"; + + jobInfoFile << "amr.n_cell: "; + const int* domain_lo = geom.Domain().loVect(); + const int* domain_hi = geom.Domain().hiVect(); + for (int idir = 0; idir < AMREX_SPACEDIM; idir++) { + jobInfoFile << domain_hi[idir] - domain_lo[idir] + 1 << " "; + } + jobInfoFile << "\n\n"; + + jobInfoFile.close(); + + // now the external parameters + const int jobinfo_file_length = FullPathJobInfoFile.length(); + Vector jobinfo_file_name(jobinfo_file_length); + + for (int i = 0; i < jobinfo_file_length; i++) { + jobinfo_file_name[i] = FullPathJobInfoFile[i]; + } + +} diff --git a/Source/main.cpp b/Source/main.cpp index 6e4eb3fa..edd2d6c3 100644 --- a/Source/main.cpp +++ b/Source/main.cpp @@ -230,6 +230,11 @@ int main(int argc, char* argv[]) { amrex::Initialize(argc,argv); + // write build information to screen + if (ParallelDescriptor::IOProcessor()) { + writeBuildInfo(); + } + // by default amrex initializes rng deterministically // this uses the time for a different run each time amrex::InitRandom(ParallelDescriptor::MyProc()+time(NULL), ParallelDescriptor::NProcs());