From fcdba9973120a5ae7d0a6c886f6c4479dd1cc398 Mon Sep 17 00:00:00 2001 From: Cheng Li <69489965+chengcli@users.noreply.github.com> Date: Sat, 9 Mar 2024 17:34:18 -0500 Subject: [PATCH] Add basic diagnostics (#126) - add diagnostics that does not depend on communication --- .github/workflows/main.yml | 48 ++++ examples/2019-Li-snap/straka.inp | 7 + patches/24.time_integrator.patch | 34 ++- src/CMakeLists.txt | 3 +- src/astro/celestrial_body.cpp | 10 +- src/astro/celestrial_body.hpp | 3 +- src/common.hpp | 8 - src/diagnostics/CMakeLists.txt | 19 ++ src/{snap => }/diagnostics/buoyancy.cpp | 13 +- src/{snap => }/diagnostics/curl.cpp | 9 +- src/diagnostics/diagnostics.cpp | 46 ++++ src/{snap => }/diagnostics/diagnostics.hpp | 129 ++++++----- src/diagnostics/diagnostics_factory.cpp | 54 +++++ src/{snap => }/diagnostics/divergence.cpp | 19 +- src/diagnostics/hydro_mean.cpp | 85 +++++++ .../todo}/convective_heat_flx.cpp | 39 ++-- .../todo}/eddy_flux.cpp | 14 +- .../todo}/eddy_kinetic_energy.cpp | 12 +- .../todo}/horizontal_divergence.cpp | 7 +- .../todo}/latent_heating.cpp | 17 +- .../todo}/pressure_anomaly.cpp | 9 +- .../todo}/radiative_flux.cpp | 14 +- .../todo/spherical_angular_momentum.cpp} | 23 +- src/diagnostics/todo/temperature_anomaly.cpp | 68 ++++++ .../todo}/tendency.cpp | 15 +- .../todo}/total_flux.cpp | 13 +- src/exchanger/exchanger.cpp | 3 - src/exchanger/linear_exchanger.hpp | 3 - src/harp/radiation.cpp | 7 +- src/harp/radiation.hpp | 3 - src/harp/radiation_band.hpp | 1 - src/harp/spectral_grid.hpp | 8 + src/impl.cpp | 8 +- src/impl.hpp | 2 + src/outputs/load_user_output_data.cpp | 17 ++ src/outputs/netcdf.cpp | 57 +++-- src/outputs/output_utils.cpp | 57 +++-- src/outputs/pnetcdf.cpp | 55 +++-- src/snap/diagnostics/diagnostics.cpp | 214 ------------------ src/snap/diagnostics/hydro_mean.cpp | 75 ------ src/snap/diagnostics/temperature_anomaly.cpp | 40 ---- src/virtual_groups.hpp | 8 + 42 files changed, 715 insertions(+), 561 deletions(-) delete mode 100644 src/common.hpp create mode 100644 src/diagnostics/CMakeLists.txt rename src/{snap => }/diagnostics/buoyancy.cpp (88%) rename src/{snap => }/diagnostics/curl.cpp (97%) create mode 100644 src/diagnostics/diagnostics.cpp rename src/{snap => }/diagnostics/diagnostics.hpp (67%) create mode 100644 src/diagnostics/diagnostics_factory.cpp rename src/{snap => }/diagnostics/divergence.cpp (92%) create mode 100644 src/diagnostics/hydro_mean.cpp rename src/{snap/diagnostics => diagnostics/todo}/convective_heat_flx.cpp (82%) rename src/{snap/diagnostics => diagnostics/todo}/eddy_flux.cpp (92%) rename src/{snap/diagnostics => diagnostics/todo}/eddy_kinetic_energy.cpp (91%) rename src/{snap/diagnostics => diagnostics/todo}/horizontal_divergence.cpp (95%) rename src/{snap/diagnostics => diagnostics/todo}/latent_heating.cpp (91%) rename src/{snap/diagnostics => diagnostics/todo}/pressure_anomaly.cpp (83%) rename src/{snap/diagnostics => diagnostics/todo}/radiative_flux.cpp (88%) rename src/{snap/diagnostics/angular_momentum.cpp => diagnostics/todo/spherical_angular_momentum.cpp} (80%) create mode 100644 src/diagnostics/todo/temperature_anomaly.cpp rename src/{snap/diagnostics => diagnostics/todo}/tendency.cpp (94%) rename src/{snap/diagnostics => diagnostics/todo}/total_flux.cpp (91%) delete mode 100644 src/snap/diagnostics/diagnostics.cpp delete mode 100644 src/snap/diagnostics/hydro_mean.cpp delete mode 100644 src/snap/diagnostics/temperature_anomaly.cpp diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f5442479..5618ec42 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -34,6 +34,54 @@ jobs: - name: Run cpplint run: ./tools/check_style.sh + build-cubed-sphere-2d: + if: github.event.pull_request.draft == false + runs-on: ubuntu-latest + needs: style-checker + + steps: + - name: install dependencies + run: | + sudo apt-get update + sudo apt-get install -y lcov libnetcdf-dev libpnetcdf-dev libeigen3-dev libmpich-dev + + - uses: actions/checkout@v3 + with: + lfs: false + + - name: create build directory + # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. + # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type + run: cmake -B ${{github.workspace}}/build -DTASK=exo2 -DCMAKE_CXX_FLAGS=${{ env.BUILD_FLAG }} -DCMAKE_C_FLAGS=${{ env.BUILD_FLAG }} + + - name: Build + # Build your program with the given configuration + run: cmake --build ${{github.workspace}}/build --config Debug -- -j2 + + build-cubed-sphere-3d: + if: github.event.pull_request.draft == false + runs-on: ubuntu-latest + needs: style-checker + + steps: + - name: install dependencies + run: | + sudo apt-get update + sudo apt-get install -y lcov libnetcdf-dev libpnetcdf-dev libeigen3-dev libmpich-dev + + - uses: actions/checkout@v3 + with: + lfs: false + + - name: create build directory + # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. + # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type + run: cmake -B ${{github.workspace}}/build -DTASK=exo3 -DCMAKE_CXX_FLAGS=${{ env.BUILD_FLAG }} -DCMAKE_C_FLAGS=${{ env.BUILD_FLAG }} + + - name: Build + # Build your program with the given configuration + run: cmake --build ${{github.workspace}}/build --config Debug -- -j2 + build-non-hydrostatic: # The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac. # You can convert this to a matrix build if you need cross-platform coverage. diff --git a/examples/2019-Li-snap/straka.inp b/examples/2019-Li-snap/straka.inp index 330371d7..c908b6f8 100644 --- a/examples/2019-Li-snap/straka.inp +++ b/examples/2019-Li-snap/straka.inp @@ -21,6 +21,11 @@ file_type = netcdf variable = uov dt = 300. + +file_type = netcdf +variable = diag +dt = 300. +