From 52743e2d10c7f8b10963283f78bffa7a73cf8170 Mon Sep 17 00:00:00 2001 From: Henry Le Berre Date: Fri, 30 Sep 2022 20:02:27 -0700 Subject: [PATCH] Fix #17 #20 #23 #24 --- .gitignore | 6 +- CMakeLists.txt | 22 +- doc/landing/readme.md | 12 +- doc/landing/running.md | 6 +- examples/1D_bubblescreen/run.sh | 8 +- examples/1D_exercise_WENO/run.lsf | 10 +- examples/1D_exercise_WENO/run.sh | 8 +- examples/1D_exp_bubscreen/case.py | 2 +- examples/1D_exp_bubscreen/input_bak.py | 2 +- examples/1D_exp_bubscreen/input_shock.py | 2 +- examples/1D_exp_bubscreen/input_shock2.py | 2 +- examples/1D_exp_bubscreen/input_shock3.py | 2 +- examples/1D_kapilashocktube/run.sh | 8 +- examples/1D_qbmm/srun.sh | 8 +- examples/1D_sodshocktube/run.sh | 8 +- examples/3D_test2/run.lsf | 10 +- examples/3D_test2/run.sh | 8 +- examples/3D_test2/sbatch.sh | 8 +- examples/3D_test2/srun.sh | 8 +- mfc.sh | 203 ++++++++++-------- .../m_compile_specific.f90 | 0 .../m_derived_types.f90 | 0 .../case.fpp | 0 .../m_data_input.f90 | 0 .../m_data_output.f90 | 0 .../m_derived_variables.f90 | 0 .../m_global_parameters.f90 | 0 .../m_mpi_proxy.f90 | 0 .../m_start_up.f90 | 0 .../m_variables_conversion.f90 | 0 .../p_main.f90 | 0 .../case.fpp | 0 .../m_data_output.f90 | 0 .../m_global_parameters.fpp | 0 .../m_grid.f90 | 0 .../m_initial_condition.fpp | 0 .../m_mpi_proxy.f90 | 0 .../m_start_up.fpp | 0 .../m_variables_conversion.f90 | 0 .../p_main.f90 | 0 src/{simulation_code => simulation}/case.fpp | 0 .../m_bubbles.f90 | 0 src/{simulation_code => simulation}/m_cbc.f90 | 0 .../m_data_output.f90 | 0 .../m_derived_variables.f90 | 0 .../m_fftw.fpp | 0 .../m_global_parameters.fpp | 0 .../m_mpi_proxy.fpp | 0 .../m_qbmm.fpp | 0 src/{simulation_code => simulation}/m_rhs.f90 | 0 .../m_riemann_solvers.fpp | 0 .../m_start_up.fpp | 0 .../m_time_steppers.f90 | 0 .../m_variables_conversion.f90 | 0 .../m_weno.fpp | 0 src/{simulation_code => simulation}/nvtx.f90 | 0 .../p_main.fpp | 0 toolchain/main.py | 126 ----------- toolchain/mfc/run/input.py | 2 +- 59 files changed, 176 insertions(+), 295 deletions(-) rename src/{common_code => common}/m_compile_specific.f90 (100%) rename src/{common_code => common}/m_derived_types.f90 (100%) rename src/{post_process_code => post_process}/case.fpp (100%) rename src/{post_process_code => post_process}/m_data_input.f90 (100%) rename src/{post_process_code => post_process}/m_data_output.f90 (100%) rename src/{post_process_code => post_process}/m_derived_variables.f90 (100%) rename src/{post_process_code => post_process}/m_global_parameters.f90 (100%) rename src/{post_process_code => post_process}/m_mpi_proxy.f90 (100%) rename src/{post_process_code => post_process}/m_start_up.f90 (100%) rename src/{post_process_code => post_process}/m_variables_conversion.f90 (100%) rename src/{post_process_code => post_process}/p_main.f90 (100%) rename src/{pre_process_code => pre_process}/case.fpp (100%) rename src/{pre_process_code => pre_process}/m_data_output.f90 (100%) rename src/{pre_process_code => pre_process}/m_global_parameters.fpp (100%) rename src/{pre_process_code => pre_process}/m_grid.f90 (100%) rename src/{pre_process_code => pre_process}/m_initial_condition.fpp (100%) rename src/{pre_process_code => pre_process}/m_mpi_proxy.f90 (100%) rename src/{pre_process_code => pre_process}/m_start_up.fpp (100%) rename src/{pre_process_code => pre_process}/m_variables_conversion.f90 (100%) rename src/{pre_process_code => pre_process}/p_main.f90 (100%) rename src/{simulation_code => simulation}/case.fpp (100%) rename src/{simulation_code => simulation}/m_bubbles.f90 (100%) rename src/{simulation_code => simulation}/m_cbc.f90 (100%) rename src/{simulation_code => simulation}/m_data_output.f90 (100%) rename src/{simulation_code => simulation}/m_derived_variables.f90 (100%) rename src/{simulation_code => simulation}/m_fftw.fpp (100%) rename src/{simulation_code => simulation}/m_global_parameters.fpp (100%) rename src/{simulation_code => simulation}/m_mpi_proxy.fpp (100%) rename src/{simulation_code => simulation}/m_qbmm.fpp (100%) rename src/{simulation_code => simulation}/m_rhs.f90 (100%) rename src/{simulation_code => simulation}/m_riemann_solvers.fpp (100%) rename src/{simulation_code => simulation}/m_start_up.fpp (100%) rename src/{simulation_code => simulation}/m_time_steppers.f90 (100%) rename src/{simulation_code => simulation}/m_variables_conversion.f90 (100%) rename src/{simulation_code => simulation}/m_weno.fpp (100%) rename src/{simulation_code => simulation}/nvtx.f90 (100%) rename src/{simulation_code => simulation}/p_main.fpp (100%) delete mode 100644 toolchain/main.py diff --git a/.gitignore b/.gitignore index b4225b8b35..428ea4d9c1 100644 --- a/.gitignore +++ b/.gitignore @@ -21,9 +21,9 @@ src/*/*.mod src/*/*.o src/*/autogen/ src/common/case.fpp -src/pre_process_code/pre_process -src/simulation_code/simulation -src/post_process_code/post_process +src/pre_process/pre_process +src/simulation/simulation +src/post_process/post_process src/master_scripts/*.pyc src/*/.build src/*/case.* diff --git a/CMakeLists.txt b/CMakeLists.txt index 9a4a0d2a3f..28cfc15680 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -143,19 +143,19 @@ if (CMAKE_BUILD_TYPE STREQUAL "Release") endif() -# This macro locates Fypp files in src/_code/ and instructs CMake how to +# This macro locates Fypp files in src// and instructs CMake how to # preprocess them to generate their .f90 counterparts, should they be requested # by an executable or library. They are preprocessed again if they are modified -# or if src/common_code/case.fpp changes because some #:include it, and produce +# or if src/common/case.fpp changes because some #:include it, and produce # a different .f90 file depending on case.fpp's contents. This macro sets the # _srcs CMake cache variaible the full list of .f90 files, including the # preprocessed Fypp files. macro(HANDLE_FYPP target) - file(GLOB ${target}_f90s "${CMAKE_CURRENT_SOURCE_DIR}/src/${target}_code/*.f90") - file(GLOB ${target}_fpps "${CMAKE_CURRENT_SOURCE_DIR}/src/${target}_code/*.fpp") + file(GLOB ${target}_f90s "${CMAKE_CURRENT_SOURCE_DIR}/src/${target}/*.f90") + file(GLOB ${target}_fpps "${CMAKE_CURRENT_SOURCE_DIR}/src/${target}/*.fpp") - # Create src/_code/autogen folder in which to generate Fypp'd .f90 files. - file(MAKE_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/src/${target}_code/autogen") + # Create src//autogen folder in which to generate Fypp'd .f90 files. + file(MAKE_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/src/${target}/autogen") set(${target}_srcs "${${target}_f90s}") @@ -171,7 +171,7 @@ macro(HANDLE_FYPP target) add_custom_command( OUTPUT "${f90_filepath}" COMMAND "${FYPP_EXE}" "${fpp_filepath}" "${f90_filepath}" - DEPENDS "${fpp_filepath}" "${CMAKE_CURRENT_SOURCE_DIR}/src/${target}_code/case.fpp" + DEPENDS "${fpp_filepath}" "${CMAKE_CURRENT_SOURCE_DIR}/src/${target}/case.fpp" COMMENT "Preprocessing ${fpp_filename}" VERBATIM ) @@ -190,7 +190,7 @@ HANDLE_FYPP(simulation) HANDLE_FYPP(post_process) -# === === src/pre_process_code +# === === src/pre_process if (MFC_BUILD_PRE_PROCESS) add_executable(pre_process "${pre_process_srcs}" "${common_srcs}") @@ -210,7 +210,7 @@ if (MFC_BUILD_PRE_PROCESS) endif() -# === === src/simulation_code +# === === src/simulation if (MFC_BUILD_SIMULATION) add_executable(simulation "${simulation_srcs}" "${common_srcs}") @@ -283,7 +283,7 @@ if (MFC_BUILD_SIMULATION) endif() -# === === src/post_process_code +# === === src/post_process if (MFC_BUILD_POST_PROCESS) add_executable(post_process "${post_process_srcs}" "${common_srcs}") @@ -313,7 +313,7 @@ add_custom_target("doc") macro(GEN_DOCS target name) set(DOXYGEN_PROJECT_NAME "${name}") - set(DOXYGEN_INPUT "${CMAKE_CURRENT_SOURCE_DIR}/src/${target}_code/ ${CMAKE_CURRENT_BINARY_DIR}/doxygen/${target}/") + set(DOXYGEN_INPUT "${CMAKE_CURRENT_SOURCE_DIR}/src/${target}/ ${CMAKE_CURRENT_BINARY_DIR}/doxygen/${target}/") file( COPY "${CMAKE_CURRENT_SOURCE_DIR}/doc/${target}" diff --git a/doc/landing/readme.md b/doc/landing/readme.md index c3c3d3be29..e98a281e7e 100644 --- a/doc/landing/readme.md +++ b/doc/landing/readme.md @@ -1,12 +1,6 @@ +# Welcome to MFC! -## Presentation & User Guide - -- [Authors](authors.md) -- [Building](building.md) -- [Testing](testing.md) -- [Running](running.md) -- [Flow Visualisation](visualisation.md) -- [References](references.md) +The MFC is a fully-documented parallel simulation software for multi-component, multi-phase, and bubbly flows. The source code of MFC is available [on GitHub](https://github.com/MFlowCode/MFC) and is open to contributions! ## Code Documentation @@ -113,7 +107,7 @@ The list of modules offered by a system is subject to change. The aforementioned ### OpenACC Memory Profiling -You can append `-DMFC_MEMORY_DUMP` to `release-gpu`'s Fortran compiler options in [defaults.yaml](defaults.yaml) to make the [simulation code](src/simulation_code/) call `acc_present_dump()` at various stages of program execution to obtain a printout of on-device memory usage. The [mem_parse.sh](misc/mem_parse.sh) script can be given as an argument the path to a file containing MFC's output, in order to aggregate the data and produce tables with formatted output. +You can append `-DMFC_MEMORY_DUMP` to `release-gpu`'s Fortran compiler options in [defaults.yaml](defaults.yaml) to make the [simulation code](src/simulation/) call `acc_present_dump()` at various stages of program execution to obtain a printout of on-device memory usage. The [mem_parse.sh](misc/mem_parse.sh) script can be given as an argument the path to a file containing MFC's output, in order to aggregate the data and produce tables with formatted output. ## License diff --git a/doc/landing/running.md b/doc/landing/running.md index 237eec8523..7bee573440 100644 --- a/doc/landing/running.md +++ b/doc/landing/running.md @@ -473,7 +473,7 @@ computations are done in Python to generate the case. ### Interactive Execution -To run all stages of MFC, that is [pre_process](src/pre_process_code/), [simulation](src/simulation_code/), and [post_process](src/post_process_code/) on the sample case [2D_shockbubble](examples/2D_shockbubble/), +To run all stages of MFC, that is [pre_process](src/pre_process/), [simulation](src/simulation/), and [post_process](src/post_process/) on the sample case [2D_shockbubble](examples/2D_shockbubble/), ```console $ ./mfc.sh run examples/2D_shockbubble/case.py @@ -486,13 +486,13 @@ specified with the `-j` option. For example, -- Running [pre_process](src/pre_process_code/) with 2 cores: +- Running [pre_process](src/pre_process/) with 2 cores: ```console $ ./mfc.sh run examples/2D_shockbubble/case.py -t pre_process -n 2 ``` -- Running [simulation](src/simulation_code/) and [post_process](src/post_process_code/) +- Running [simulation](src/simulation/) and [post_process](src/post_process/) using 4 cores: ```console diff --git a/examples/1D_bubblescreen/run.sh b/examples/1D_bubblescreen/run.sh index 6ead8fa2ef..4f51427b51 100755 --- a/examples/1D_bubblescreen/run.sh +++ b/examples/1D_bubblescreen/run.sh @@ -15,9 +15,9 @@ for proc in 1 do jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 ../../build/___current___/build/bin/pre_process time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 ../../build/___current___/build/bin/simulation - #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 ../src/simulation_code/simulation - #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nsys profile --stats=true ../../src/simulation_code/simulation - #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nv-nsight-cu-cli --set full -k m_weno_s_weno_alt_1341_gpu -f -o profile_anand_weno ../../src/simulation_code/simulation - #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nv-nsight-cu-cli --set full -k m_weno_s_weno_alt_1565_gpu -f -o profile_anand_mp_weno ../../src/simulation_code/simulation + #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 ../src/simulation/simulation + #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nsys profile --stats=true ../../src/simulation/simulation + #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nv-nsight-cu-cli --set full -k m_weno_s_weno_alt_1341_gpu -f -o profile_anand_weno ../../src/simulation/simulation + #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nv-nsight-cu-cli --set full -k m_weno_s_weno_alt_1565_gpu -f -o profile_anand_mp_weno ../../src/simulation/simulation #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nv-nsight-cu-cli --set full -k m_riemann_solvers_s_hllc_riemann_solver_acc_2539_gpu -f -o profile_anand_riemann ../../.mfc/___current___/build/bin/simulation done diff --git a/examples/1D_exercise_WENO/run.lsf b/examples/1D_exercise_WENO/run.lsf index 182af3882a..ce37d31f47 100644 --- a/examples/1D_exercise_WENO/run.lsf +++ b/examples/1D_exercise_WENO/run.lsf @@ -16,9 +16,9 @@ do size=$((32000000 * proc)) sed -i 's/m = .*/m = '"$size"'/' simulation.inp sed -i 's/m = .*/m = '"$size"'/' pre_process.inp - jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 ../../src/pre_process_code/pre_process - time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 ../../src/simulation_code/simulation - #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nsys profile ../../src/simulation_code/simulation - #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nsys profile --stats=true ../../src/simulation_code/simulation - #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nv-nsight-cu-cli --set full -k m_weno_s_weno_902_gpu -f -o profile_anand_alt ../../src/simulation_code/simulation + jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 ../../src/pre_process/pre_process + time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 ../../src/simulation/simulation + #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nsys profile ../../src/simulation/simulation + #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nsys profile --stats=true ../../src/simulation/simulation + #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nv-nsight-cu-cli --set full -k m_weno_s_weno_902_gpu -f -o profile_anand_alt ../../src/simulation/simulation done diff --git a/examples/1D_exercise_WENO/run.sh b/examples/1D_exercise_WENO/run.sh index 3e89e4034d..38084c23bc 100755 --- a/examples/1D_exercise_WENO/run.sh +++ b/examples/1D_exercise_WENO/run.sh @@ -15,9 +15,9 @@ for proc in 1 do jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 ../../.mfc/___current___/build/bin/pre_process time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 ../../.mfc/___current___/build/bin/simulation - #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 ../src/simulation_code/simulation - #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nsys profile --stats=true ../../src/simulation_code/simulation - #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nv-nsight-cu-cli --set full -k m_weno_s_weno_alt_1341_gpu -f -o profile_anand_weno ../../src/simulation_code/simulation - #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nv-nsight-cu-cli --set full -k m_weno_s_weno_alt_1565_gpu -f -o profile_anand_mp_weno ../../src/simulation_code/simulation + #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 ../src/simulation/simulation + #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nsys profile --stats=true ../../src/simulation/simulation + #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nv-nsight-cu-cli --set full -k m_weno_s_weno_alt_1341_gpu -f -o profile_anand_weno ../../src/simulation/simulation + #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nv-nsight-cu-cli --set full -k m_weno_s_weno_alt_1565_gpu -f -o profile_anand_mp_weno ../../src/simulation/simulation #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nv-nsight-cu-cli --set full -k m_riemann_solvers_s_hllc_riemann_solver_acc_2539_gpu -f -o profile_anand_riemann ../../.mfc/___current___/build/bin/simulation done diff --git a/examples/1D_exp_bubscreen/case.py b/examples/1D_exp_bubscreen/case.py index cfe3627f6f..a51ff1bded 100755 --- a/examples/1D_exp_bubscreen/case.py +++ b/examples/1D_exp_bubscreen/case.py @@ -219,7 +219,7 @@ # Preston's model shows up. polytropic = False means complicated Preston model # = True means simpler Rayleigh--Plesset model # if polytropic == False then you will end up calling s_initialize_nonpoly in - # m_global_parameters.f90 in both the pre_process and simulation_code + # m_global_parameters.f90 in both the pre_process and simulation 'polytropic' : 'T', 'polydisperse' : 'F', #'poly_sigma' : 0.3, diff --git a/examples/1D_exp_bubscreen/input_bak.py b/examples/1D_exp_bubscreen/input_bak.py index 599d1eb108..03ecddf865 100644 --- a/examples/1D_exp_bubscreen/input_bak.py +++ b/examples/1D_exp_bubscreen/input_bak.py @@ -216,7 +216,7 @@ # Preston's model shows up. polytropic = False means complicated Preston model # = True means simpler Rayleigh--Plesset model # if polytropic == False then you will end up calling s_initialize_nonpoly in - # m_global_parameters.f90 in both the pre_process and simulation_code + # m_global_parameters.f90 in both the pre_process and simulation 'polytropic' : 'T', \ 'polydisperse' : 'F', \ #'poly_sigma' : 0.3, \ diff --git a/examples/1D_exp_bubscreen/input_shock.py b/examples/1D_exp_bubscreen/input_shock.py index 3034cd44ed..5697fdb84e 100644 --- a/examples/1D_exp_bubscreen/input_shock.py +++ b/examples/1D_exp_bubscreen/input_shock.py @@ -234,7 +234,7 @@ # Preston's model shows up. polytropic = False means complicated Preston model # = True means simpler Rayleigh--Plesset model # if polytropic == False then you will end up calling s_initialize_nonpoly in - # m_global_parameters.f90 in both the pre_process and simulation_code + # m_global_parameters.f90 in both the pre_process and simulation 'polytropic' : 'T', \ 'polydisperse' : 'F', \ #'poly_sigma' : 0.3, \ diff --git a/examples/1D_exp_bubscreen/input_shock2.py b/examples/1D_exp_bubscreen/input_shock2.py index 61923abdf6..b6b67da3e5 100644 --- a/examples/1D_exp_bubscreen/input_shock2.py +++ b/examples/1D_exp_bubscreen/input_shock2.py @@ -243,7 +243,7 @@ # Preston's model shows up. polytropic = False means complicated Preston model # = True means simpler Rayleigh--Plesset model # if polytropic == False then you will end up calling s_initialize_nonpoly in - # m_global_parameters.f90 in both the pre_process and simulation_code + # m_global_parameters.f90 in both the pre_process and simulation 'polytropic' : 'T', \ 'polydisperse' : 'F', \ #'poly_sigma' : 0.3, \ diff --git a/examples/1D_exp_bubscreen/input_shock3.py b/examples/1D_exp_bubscreen/input_shock3.py index d81add715b..2b1f19fbc3 100644 --- a/examples/1D_exp_bubscreen/input_shock3.py +++ b/examples/1D_exp_bubscreen/input_shock3.py @@ -244,7 +244,7 @@ # Preston's model shows up. polytropic = False means complicated Preston model # = True means simpler Rayleigh--Plesset model # if polytropic == False then you will end up calling s_initialize_nonpoly in - # m_global_parameters.f90 in both the pre_process and simulation_code + # m_global_parameters.f90 in both the pre_process and simulation 'polytropic' : 'T', \ 'polydisperse' : 'F', \ #'poly_sigma' : 0.3, \ diff --git a/examples/1D_kapilashocktube/run.sh b/examples/1D_kapilashocktube/run.sh index 3e89e4034d..38084c23bc 100755 --- a/examples/1D_kapilashocktube/run.sh +++ b/examples/1D_kapilashocktube/run.sh @@ -15,9 +15,9 @@ for proc in 1 do jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 ../../.mfc/___current___/build/bin/pre_process time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 ../../.mfc/___current___/build/bin/simulation - #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 ../src/simulation_code/simulation - #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nsys profile --stats=true ../../src/simulation_code/simulation - #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nv-nsight-cu-cli --set full -k m_weno_s_weno_alt_1341_gpu -f -o profile_anand_weno ../../src/simulation_code/simulation - #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nv-nsight-cu-cli --set full -k m_weno_s_weno_alt_1565_gpu -f -o profile_anand_mp_weno ../../src/simulation_code/simulation + #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 ../src/simulation/simulation + #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nsys profile --stats=true ../../src/simulation/simulation + #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nv-nsight-cu-cli --set full -k m_weno_s_weno_alt_1341_gpu -f -o profile_anand_weno ../../src/simulation/simulation + #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nv-nsight-cu-cli --set full -k m_weno_s_weno_alt_1565_gpu -f -o profile_anand_mp_weno ../../src/simulation/simulation #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nv-nsight-cu-cli --set full -k m_riemann_solvers_s_hllc_riemann_solver_acc_2539_gpu -f -o profile_anand_riemann ../../.mfc/___current___/build/bin/simulation done diff --git a/examples/1D_qbmm/srun.sh b/examples/1D_qbmm/srun.sh index 40fa80468d..c387d8df00 100755 --- a/examples/1D_qbmm/srun.sh +++ b/examples/1D_qbmm/srun.sh @@ -9,8 +9,8 @@ export PGI_ACC_DEBUG=0 srun -N 1 -n 1 -G 1 ../../build/___current___/build/bin/pre_process time srun -N 1 -n 1 -G 1 ../../build/___current___/build/bin/simulation -#time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 ../src/simulation_code/simulation -#time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nsys profile --stats=true ../../src/simulation_code/simulation -#time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nv-nsight-cu-cli --set full -k m_weno_s_weno_alt_1341_gpu -f -o profile_anand_weno ../../src/simulation_code/simulation -#time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nv-nsight-cu-cli --set full -k m_weno_s_weno_alt_1565_gpu -f -o profile_anand_mp_weno ../../src/simulation_code/simulation +#time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 ../src/simulation/simulation +#time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nsys profile --stats=true ../../src/simulation/simulation +#time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nv-nsight-cu-cli --set full -k m_weno_s_weno_alt_1341_gpu -f -o profile_anand_weno ../../src/simulation/simulation +#time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nv-nsight-cu-cli --set full -k m_weno_s_weno_alt_1565_gpu -f -o profile_anand_mp_weno ../../src/simulation/simulation #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nv-nsight-cu-cli --set full -k m_riemann_solvers_s_hllc_riemann_solver_acc_2539_gpu -f -o profile_anand_riemann ../../.mfc/___current___/build/bin/simulation diff --git a/examples/1D_sodshocktube/run.sh b/examples/1D_sodshocktube/run.sh index 3e89e4034d..38084c23bc 100755 --- a/examples/1D_sodshocktube/run.sh +++ b/examples/1D_sodshocktube/run.sh @@ -15,9 +15,9 @@ for proc in 1 do jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 ../../.mfc/___current___/build/bin/pre_process time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 ../../.mfc/___current___/build/bin/simulation - #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 ../src/simulation_code/simulation - #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nsys profile --stats=true ../../src/simulation_code/simulation - #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nv-nsight-cu-cli --set full -k m_weno_s_weno_alt_1341_gpu -f -o profile_anand_weno ../../src/simulation_code/simulation - #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nv-nsight-cu-cli --set full -k m_weno_s_weno_alt_1565_gpu -f -o profile_anand_mp_weno ../../src/simulation_code/simulation + #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 ../src/simulation/simulation + #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nsys profile --stats=true ../../src/simulation/simulation + #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nv-nsight-cu-cli --set full -k m_weno_s_weno_alt_1341_gpu -f -o profile_anand_weno ../../src/simulation/simulation + #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nv-nsight-cu-cli --set full -k m_weno_s_weno_alt_1565_gpu -f -o profile_anand_mp_weno ../../src/simulation/simulation #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nv-nsight-cu-cli --set full -k m_riemann_solvers_s_hllc_riemann_solver_acc_2539_gpu -f -o profile_anand_riemann ../../.mfc/___current___/build/bin/simulation done diff --git a/examples/3D_test2/run.lsf b/examples/3D_test2/run.lsf index adebc9de03..6e5a2f3dcd 100644 --- a/examples/3D_test2/run.lsf +++ b/examples/3D_test2/run.lsf @@ -15,9 +15,9 @@ for proc in 1 do jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 ../../.mfc/___current___/build/bin/pre_process time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nsys profile --stats=true ../../.mfc/___current___/build/bin/simulation - #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 ../src/simulation_code/simulation - #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nsys profile --stats=true ../../src/simulation_code/simulation - #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nv-nsight-cu-cli --set full -k m_weno_s_weno_alt_1341_gpu -f -o profile_anand_weno ../../src/simulation_code/simulation - #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nv-nsight-cu-cli --set full -k m_weno_s_weno_alt_1565_gpu -f -o profile_anand_mp_weno ../../src/simulation_code/simulation - #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nv-nsight-cu-cli --set full -k m_riemann_solvers_s_hllc_riemann_solver_acc_4212_gpu -f -o profile_anand_riemann ../../src/simulation_code/simulation + #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 ../src/simulation/simulation + #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nsys profile --stats=true ../../src/simulation/simulation + #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nv-nsight-cu-cli --set full -k m_weno_s_weno_alt_1341_gpu -f -o profile_anand_weno ../../src/simulation/simulation + #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nv-nsight-cu-cli --set full -k m_weno_s_weno_alt_1565_gpu -f -o profile_anand_mp_weno ../../src/simulation/simulation + #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nv-nsight-cu-cli --set full -k m_riemann_solvers_s_hllc_riemann_solver_acc_4212_gpu -f -o profile_anand_riemann ../../src/simulation/simulation done diff --git a/examples/3D_test2/run.sh b/examples/3D_test2/run.sh index 227337ca86..f5305e0d24 100755 --- a/examples/3D_test2/run.sh +++ b/examples/3D_test2/run.sh @@ -15,9 +15,9 @@ for proc in 1 do jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 ../../.mfc/___current___/build/bin/pre_process time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nsys profile --stats=true ../../.mfc/___current___/build/bin/simulation - #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 ../src/simulation_code/simulation - #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nsys profile --stats=true ../../src/simulation_code/simulation - #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nv-nsight-cu-cli --set full -k m_weno_s_weno_alt_1341_gpu -f -o profile_anand_weno ../../src/simulation_code/simulation - #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nv-nsight-cu-cli --set full -k m_weno_s_weno_alt_1565_gpu -f -o profile_anand_mp_weno ../../src/simulation_code/simulation + #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 ../src/simulation/simulation + #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nsys profile --stats=true ../../src/simulation/simulation + #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nv-nsight-cu-cli --set full -k m_weno_s_weno_alt_1341_gpu -f -o profile_anand_weno ../../src/simulation/simulation + #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nv-nsight-cu-cli --set full -k m_weno_s_weno_alt_1565_gpu -f -o profile_anand_mp_weno ../../src/simulation/simulation #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nv-nsight-cu-cli --set full -k m_riemann_solvers_s_hllc_riemann_solver_acc_2539_gpu -f -o profile_anand_riemann ../../.mfc/___current___/build/bin/simulation done diff --git a/examples/3D_test2/sbatch.sh b/examples/3D_test2/sbatch.sh index 43e5996266..d1a4f3f234 100755 --- a/examples/3D_test2/sbatch.sh +++ b/examples/3D_test2/sbatch.sh @@ -14,8 +14,8 @@ module load nvhpc python time srun -N 1 -n 2 -G 2 ../../build/___current___/build/bin/simulation #time srun -N 1 -n 2 -G 2 nsys profile ../../build/___current___/build/bin/simulation #time srun -N 1 -n 2 -G 2 ncu --set full --cache-control none --clock-control none -k m_weno_s_weno_alt_1433_gpu -f -o WENO_V100_TX2 ../../build/___current___/build/bin/simulation - #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 ../src/simulation_code/simulation - #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nsys profile --stats=true ../../src/simulation_code/simulation - #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nv-nsight-cu-cli --set full -k m_weno_s_weno_alt_1341_gpu -f -o profile_anand_weno ../../src/simulation_code/simulation - #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nv-nsight-cu-cli --set full -k m_weno_s_weno_alt_1565_gpu -f -o profile_anand_mp_weno ../../src/simulation_code/simulation + #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 ../src/simulation/simulation + #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nsys profile --stats=true ../../src/simulation/simulation + #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nv-nsight-cu-cli --set full -k m_weno_s_weno_alt_1341_gpu -f -o profile_anand_weno ../../src/simulation/simulation + #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nv-nsight-cu-cli --set full -k m_weno_s_weno_alt_1565_gpu -f -o profile_anand_mp_weno ../../src/simulation/simulation #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nv-nsight-cu-cli --set full -k m_riemann_solvers_s_hllc_riemann_solver_acc_2539_gpu -f -o profile_anand_riemann ../../.mfc/___current___/build/bin/simulation diff --git a/examples/3D_test2/srun.sh b/examples/3D_test2/srun.sh index 76c9bb1ed0..ce782959c0 100755 --- a/examples/3D_test2/srun.sh +++ b/examples/3D_test2/srun.sh @@ -12,8 +12,8 @@ module load nvhpc python #srun -N 1 -n 2 -G 2 ../../build/___current___/build/bin/pre_process time srun -N 1 -n 2 -G 2 nsys profile ../../build/___current___/build/bin/simulation - #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 ../src/simulation_code/simulation - #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nsys profile --stats=true ../../src/simulation_code/simulation - #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nv-nsight-cu-cli --set full -k m_weno_s_weno_alt_1341_gpu -f -o profile_anand_weno ../../src/simulation_code/simulation - #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nv-nsight-cu-cli --set full -k m_weno_s_weno_alt_1565_gpu -f -o profile_anand_mp_weno ../../src/simulation_code/simulation + #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 ../src/simulation/simulation + #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nsys profile --stats=true ../../src/simulation/simulation + #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nv-nsight-cu-cli --set full -k m_weno_s_weno_alt_1341_gpu -f -o profile_anand_weno ../../src/simulation/simulation + #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nv-nsight-cu-cli --set full -k m_weno_s_weno_alt_1565_gpu -f -o profile_anand_mp_weno ../../src/simulation/simulation #time jsrun --smpiargs="-gpu" -r$proc -a1 -c1 -g1 nv-nsight-cu-cli --set full -k m_riemann_solvers_s_hllc_riemann_solver_acc_2539_gpu -f -o profile_anand_riemann ../../.mfc/___current___/build/bin/simulation diff --git a/mfc.sh b/mfc.sh index e0d8178d55..866d649632 100755 --- a/mfc.sh +++ b/mfc.sh @@ -4,14 +4,10 @@ MFC_PYTHON_MIN_MAJOR=3 MFC_PYTHON_MIN_MINOR=6 -MFC_CMAKE_MIN_MAJOR=3 -MFC_CMAKE_MIN_MINOR=18 -MFC_CMAKE_MIN_PATCH=0 -MFC_CMAKE_MIN_VERSION="$(printf %05d%05d%05d $MFC_CMAKE_MIN_MAJOR $MFC_CMAKE_MIN_MINOR $MFC_CMAKE_MIN_PATCH)" - # Check whether this script was called from MFC's root directory. if [ ! -f "$(pwd)/toolchain/mfc.py" ]; then - echo "[mfc.sh] Error: You must call this script from within MFC's root folder." + echo "[mfc.sh]: Error: You must call this script from within MFC's root folder." + exit 1 fi @@ -20,9 +16,7 @@ source "$(pwd)/toolchain/util.sh" # Handle upgrading from older MFC build systems if [ -d "$(pwd)/bootstrap" ] || [ -d "$(pwd)/dependencies" ] || [ -f "$(pwd)/build/mfc.lock.yaml" ]; then - echo -en "$RED" - echo "[mfc.sh] Error: You are upgrading from an older version of MFC. Please remove, if applicable, the dependencies/, bootstrap/, and build/ directories before running this command again." - echo -en "$COLOR_RESET" + echo -e "$CYAN[mfc.sh]$COLOR_RESET:$RED Error: You are upgrading from an older version of MFC. Please remove, if applicable, the dependencies/, bootstrap/, and build/ directories before running this command again.$COLOR_RESET" exit 1 fi @@ -43,19 +37,15 @@ if [ "$1" == "docker" ]; then shift; if ! command -v docker > /dev/null 2>&1; then - echo -en "$RED" - echo "[mfc.sh] Error: Docker is not installed." - echo -en "$COLOR_RESET" + echo -e "$CYAN[mfc.sh]$COLOR_RESET:$RED Error: Docker is not installed.$COLOR_RESET" exit 1 fi - echo "[mfc.sh] Running in Docker mode." + echo "$CYAN[mfc.sh]$COLOR_RESET: Running in Docker mode." echo " - Fetching image..." if ! docker pull henryleberre/mfc; then - echo -en "$RED" - echo "[mfc.sh] Error: Failed to fetch Docker image from Docker Hub." - echo -en "$COLOR_RESET" + echo -e "$CYAN[mfc.sh]$COLOR_RESET:$RED Error: Failed to fetch Docker image from Docker Hub.$COLOR_RESET" exit 1 fi @@ -65,9 +55,7 @@ if [ "$1" == "docker" ]; then --mount type=bind,source="$(pwd)",target=/home/me/MFC \ henryleberre/mfc if (($?)); then - echo -en "$RED" - echo "[mfc.sh] Error: Failed to start Docker container." - echo -en "$COLOR_RESET" + echo -e "$CYAN[mfc.sh]$COLOR_RESET:$RED Error: Failed to start Docker container.$COLOR_RESET" exit 1 fi @@ -75,102 +63,127 @@ if [ "$1" == "docker" ]; then exit 0 fi + mkdir -p "$(pwd)/build" -# CMake -cmake_verstr=$(cmake --version | tr ' ' '\n' | sed -n 3p) -cmake_major=$(echo $cmake_verstr | tr '.' '\n' | sed -n 1p) -cmake_minor=$(echo $cmake_verstr | tr '.' '\n' | sed -n 2p) -cmake_patch=$(echo $cmake_verstr | tr '.' '\n' | sed -n 3p) -cmake_version="$(printf %05d%05d%05d $cmake_major $cmake_minor $cmake_patch)" +# If we downloaded our own version of CMake, let us make it accessible to +# any command we run hereafter. -if [ ! -d "$(pwd)/build/cmake/bin" ]; then - if ! command -v cmake > /dev/null 2>&1 || [ "$cmake_version" -lt "$MFC_CMAKE_MIN_VERSION" ]; then - # Cmake is either not installed or too old for our use +if [ -f "$(pwd)/build/cmake/bin/cmake" ]; then + export PATH="$(pwd)/build/cmake/bin:$PATH" - mkdir -p "$(pwd)/build/cmake" + echo -e "$CYAN[mfc.sh]$COLOR_RESET: Found CMake: $(pwd)/build/cmake/bin/cmake." +fi - version="3.24.2" - filename="cmake-$version-linux-$(uname -m).sh" - url="https://github.com/Kitware/CMake/releases/download/v$version/$filename" +bShouldInstallCMake=false +if ! command -v cmake > /dev/null 2>&1; then + # Not installed + bShouldInstallCMake=true + + echo -e "$CYAN[mfc.sh]$COLOR_RESET:$MAGENTA CMake$YELLOW is not installed.$COLOR_RESET" +else + cmake_verstr=$(cmake --version | tr ' ' '\n' | sed -n 3p) + cmake_major=$(echo $cmake_verstr | tr '.' '\n' | sed -n 1p) + cmake_minor=$(echo $cmake_verstr | tr '.' '\n' | sed -n 2p) + cmake_patch=$(echo $cmake_verstr | tr '.' '\n' | sed -n 3p) + cmake_version="$(printf %05d%05d%05d $cmake_major $cmake_minor $cmake_patch)" + + MFC_CMAKE_MIN_VERSTR=$(cat CMakeLists.txt | head -n 1 | sed 's/[^0-9,.]*//g') + MFC_CMAKE_MIN_MAJOR=$(echo $MFC_CMAKE_MIN_VERSTR | tr '.' '\n' | head -n 1) + MFC_CMAKE_MIN_MINOR=$(echo $MFC_CMAKE_MIN_VERSTR | tr '.' '\n' | head -n 2 | tail -n 1) + MFC_CMAKE_MIN_PATCH=0 + MFC_CMAKE_MIN_VERSION="$(printf %05d%05d%05d $MFC_CMAKE_MIN_MAJOR $MFC_CMAKE_MIN_MINOR $MFC_CMAKE_MIN_PATCH)" + + if [ "$cmake_version" -lt "$MFC_CMAKE_MIN_VERSION" ]; then + # Out of date + bShouldInstallCMake=true + + echo -e "$CYAN[mfc.sh]$COLOR_RESET:$MAGENTA CMake$YELLOW is out of date (current: $MAGENTA$cmake_verstr$YELLOW < minimum: $MAGENTA$MFC_CMAKE_MIN_VERSTR$YELLOW).$COLOR_RESET" + fi +fi - if ! wget -P "$(pwd)/build/cmake" "$url"; then - echo -en "$RED" - echo "[mfc.sh] Error: Failed to download a compatible version of CMake." - echo "CMake is not discoverable or is an older release, incompatible with MFC. Please download" - echo "or install a recent version of CMake to get past this step. If you are currently on a" - echo "managed system like a cluster, provided there is no suitable environment module, you can" - echo "either build it from source, or get it via Spack." - echo "- The minimum required version is currently CMake v$MFC_CMAKE_MIN_MAJOR.$MFC_CMAKE_MIN_MINOR.$MFC_CMAKE_MIN_PATCH." - echo "- We attempted to download CMake v$version from $url." - echo -en "$COLOR_RESET" +if [ "$bShouldInstallCMake" = true ]; then + if [ -d "$(pwd)/build/cmake" ]; then + rm -rf "$(pwd)/build/cmake" + fi - exit 1 - fi + mkdir -p "$(pwd)/build/cmake" - if ! $SHELL "$(pwd)/build/cmake/$filename" "--skip-license" "--prefix=$(pwd)/build/cmake"; then - echo -en "$RED" - echo "[mfc.sh] Error: Failed to install a compatible version of CMake." - echo "CMake is not discoverable or is an older release, incompatible with MFC. Please download" - echo "or install a recent version of CMake to get past this step. If you are currently on a" - echo "managed system like a cluster, provided there is no suitable environment module, you can" - echo "either build it from source, or get it via Spack." - echo "- The minimum required version is currently CMake v$MFC_CMAKE_MIN_MAJOR.$MFC_CMAKE_MIN_MINOR.$MFC_CMAKE_MIN_PATCH." - echo "- We attempted to install CMake v$version from $url." - echo -en "$COLOR_RESET" + version="3.24.2" + arch="$(uname -m)" + filename="cmake-$version-linux-$arch.sh" + repository="https://github.com/Kitware/CMake" + url="$repository/releases/download/v$version/$filename" - exit 1 - fi + echo -e "$CYAN[mfc.sh]$COLOR_RESET: Downloading$MAGENTA CMake v$version$COLOR_RESET for $MAGENTA$arch$COLOR_RESET from $CYAN$repository$COLOR_RESET." - rm "$(pwd)/build/cmake/$filename" + if ! wget -P "$(pwd)/build/cmake" "$url"; then + echo -e "$CYAN[mfc.sh]$COLOR_RESET:$RED Error: Failed to download a compatible version of CMake." + echo "CMake is not discoverable or is an older release, incompatible with MFC. Please download" + echo "or install a recent version of CMake to get past this step. If you are currently on a" + echo "managed system like a cluster, provided there is no suitable environment module, you can" + echo "either build it from source, or get it via Spack." + echo "- The minimum required version is currently CMake v$MFC_CMAKE_MIN_MAJOR.$MFC_CMAKE_MIN_MINOR.$MFC_CMAKE_MIN_PATCH." + echo -e "- We attempted to download CMake v$version from $url.$COLOR_RESET" + + exit 1 fi -fi -# If we downloaded our own version of CMake, let us make it accessible to -# any command we run hereafter. + echo -e "$CYAN[mfc.sh]$COLOR_RESET: Installing$MAGENTA CMake$COLOR_RESET into $MAGENTA$(pwd)/build/cmake$COLOR_RESET." -if [ -d "$(pwd)/build/cmake" ]; then - export PATH="$(pwd)/build/cmake/bin:$PATH" - export MANPATH="$(pwd)/build/cmake/man:$MANPATH" -fi + if ! $SHELL "$(pwd)/build/cmake/$filename" "--skip-license" "--prefix=$(pwd)/build/cmake"; then + echo -e "$CYAN[mfc.sh]$COLOR_RESET:$RED Error: Failed to install a compatible version of CMake." + echo "CMake is not discoverable or is an older release, incompatible with MFC. Please download" + echo "or install a recent version of CMake to get past this step. If you are currently on a" + echo "managed system like a cluster, provided there is no suitable environment module, you can" + echo "either build it from source, or get it via Spack." + echo "- The minimum required version is currently CMake v$MFC_CMAKE_MIN_MAJOR.$MFC_CMAKE_MIN_MINOR.$MFC_CMAKE_MIN_PATCH." + echo -e "- We attempted to install CMake v$version from $url.$COLOR_RESET" -# Check whether python3 is in the $PATH / is accessible. -if ! command -v python3 > /dev/null 2>&1; then - echo -en "$RED" - echo "[mfc.sh] Error: Couldn't find Python. Please ensure it is discoverable." - echo -en "$COLOR_RESET" - - exit 1 -fi + exit 1 + fi -# CHeck Python's version for compatibility -if ! python3 -c "import sys; exit(int(not (sys.version_info[0]==$MFC_PYTHON_MIN_MAJOR and sys.version_info[1] >= $MFC_PYTHON_MIN_MINOR)))"; then - echo -en "$RED" - echo "[mfc.sh] Error: $(python3 --version) is incompatible. Python v$MFC_PYTHON_MIN_MAJOR.$MFC_PYTHON_MIN_MINOR or higher is required." - echo -en "$COLOR_RESET" + rm "$(pwd)/build/cmake/$filename" - exit 1 + echo -e "$CYAN[mfc.sh]$COLOR_RESET: Found$MAGENTA CMake$COLOR_RESET: $MAGENTA$(pwd)/build/cmake/bin/cmake$COLOR_RESET." + export PATH="$(pwd)/build/cmake/bin:$PATH" fi + if [ -f "$(pwd)/build/venv/bin/activate" ]; then # Check Python is still working within the VENV if ! $(pwd)/build/venv/bin/python3 --version > /dev/null 2>&1; then # If not, delete it and install it again - echo -en "$YELLOW" - echo "[mfc.sh]: WARNING: Python is no longer working inside the Virtualenv." - echo " Deleting the Virtualenv and starting from scratch..." - echo -en "$COLOR_RESET" + echo -e "$CYAN[mfc.sh]$COLOR_RESET:$YELLOW WARNING: Python is no longer working inside the Virtualenv." + echo -e " Deleting the Virtualenv and starting from scratch... $COLOR_RESET" rm -r "$(pwd)/build/venv" fi fi if ! command -v pip3 > /dev/null 2>&1 && [ ! -f "$(pwd)/build/venv/bin/activate" ]; then - if ! wget -O "$(pwd)/build/get-pip.py" https://bootstrap.pypa.io/pip/get-pip.py; then - echo -en "$RED" - echo "[mfc.sh] Error: Couldn't download get-pip.py." - echo -en "$COLOR_RESET" + # Check whether python3 is in the $PATH / is accessible. + if ! command -v python3 > /dev/null 2>&1; then + echo -e "$CYAN[mfc.sh]$COLOR_RESET:$RED Error: Couldn't find Python. Please ensure it is discoverable.$COLOR_RESET" + + exit 1 + fi + + # CHeck Python's version for compatibility + if ! python3 -c "import sys; exit(int(not (sys.version_info[0]==$MFC_PYTHON_MIN_MAJOR and sys.version_info[1] >= $MFC_PYTHON_MIN_MINOR)))"; then + echo -e "$CYAN[mfc.sh]$COLOR_RESET:$RED Error: $(python3 --version) is incompatible. Python v$MFC_PYTHON_MIN_MAJOR.$MFC_PYTHON_MIN_MINOR or higher is required.$COLOR_RESET" + + exit 1 + fi + + get_pip_url="https://bootstrap.pypa.io/pip/get-pip.py" + + echo -e "$CYAN[mfc.sh]$YELLOW Python's PIP is not installed.$COLOR_RESET" + echo -e "$CYAN[mfc.sh]$COLOR_RESET: Downloading Python's PIP from $get_pip_url..." + + if ! wget -O "$(pwd)/build/get-pip.py" "$get_pip_url"; then + echo -e "$CYAN[mfc.sh]$COLOR_RESET:$RED Error: Couldn't download get-pip.py.$COLOR_RESET" exit 1 fi @@ -178,9 +191,7 @@ if ! command -v pip3 > /dev/null 2>&1 && [ ! -f "$(pwd)/build/venv/bin/activate" # Suppress PIP version warning (out of date) export PIP_DISABLE_PIP_VERSION_CHECK=1 if ! python3 "$(pwd)/build/get-pip.py" --user; then - echo -en "$RED" - echo "[mfc.sh] Error: Couldn't install pip with get-pip.py." - echo -en "$COLOR_RESET" + echo -e "$CYAN[mfc.sh]$COLOR_RESET:$RED Error: Couldn't install pip with get-pip.py.$COLOR_RESET" exit 1 fi @@ -189,10 +200,10 @@ fi # Create a Python virtualenv if it hasn't already been created if [ ! -f "$(pwd)/build/venv/bin/activate" ]; then + echo -e "$CYAN[mfc.sh]$COLOR_RESET: Creating a Python virtual environment (venv)..." + if ! python3 -m venv "$(pwd)/build/venv"; then - echo -en "$RED" - echo "[mfc.sh] Error: Failed to create a Python virtual environment. Delete the build/venv folder and try again." - echo -en "$COLOR_RESET" + echo -e "$CYAN[mfc.sh]$COLOR_RESET:$RED Error: Failed to create a Python virtual environment. Delete the build/venv folder and try again.$COLOR_RESET" exit 1 fi @@ -225,6 +236,7 @@ fi # Activate the Python venv +echo -e "$CYAN[mfc.sh]$COLOR_RESET: Entering the Python virtual environment (venv)." source "$(pwd)/build/venv/bin/activate" @@ -238,10 +250,10 @@ for module in "${REQUIRED_PYTHON_MODULES[@]}"; do install_name=$(echo $module | tr ',' '\n' | tail -n 1) if ! python3 -c "import $import_name" > /dev/null 2>&1; then + echo -e "$CYAN[mfc.sh]$COLOR_RESET: Installing Python PIP package $MAGENTA$install_name$COLOR_RESET (into venv)." + if ! pip3 install "$install_name"; then - echo -en "$RED" - echo "[mfc.sh] Error: Failed to install $import_name/$install_name through Python3's pip." - echo -en "$COLOR_RESET" + echo -e "$CYAN[mfc.sh]$COLOR_RESET:$RED Error: Failed to install $import_name/$install_name through Python3's pip.$COLOR_RESET" exit 1 fi @@ -255,6 +267,7 @@ code=$? # Deactivate the Python virtualenv in case the user "source"'d this script +echo -e "$CYAN[mfc.sh]$COLOR_RESET: Exiting the Python virtual environment." deactivate diff --git a/src/common_code/m_compile_specific.f90 b/src/common/m_compile_specific.f90 similarity index 100% rename from src/common_code/m_compile_specific.f90 rename to src/common/m_compile_specific.f90 diff --git a/src/common_code/m_derived_types.f90 b/src/common/m_derived_types.f90 similarity index 100% rename from src/common_code/m_derived_types.f90 rename to src/common/m_derived_types.f90 diff --git a/src/post_process_code/case.fpp b/src/post_process/case.fpp similarity index 100% rename from src/post_process_code/case.fpp rename to src/post_process/case.fpp diff --git a/src/post_process_code/m_data_input.f90 b/src/post_process/m_data_input.f90 similarity index 100% rename from src/post_process_code/m_data_input.f90 rename to src/post_process/m_data_input.f90 diff --git a/src/post_process_code/m_data_output.f90 b/src/post_process/m_data_output.f90 similarity index 100% rename from src/post_process_code/m_data_output.f90 rename to src/post_process/m_data_output.f90 diff --git a/src/post_process_code/m_derived_variables.f90 b/src/post_process/m_derived_variables.f90 similarity index 100% rename from src/post_process_code/m_derived_variables.f90 rename to src/post_process/m_derived_variables.f90 diff --git a/src/post_process_code/m_global_parameters.f90 b/src/post_process/m_global_parameters.f90 similarity index 100% rename from src/post_process_code/m_global_parameters.f90 rename to src/post_process/m_global_parameters.f90 diff --git a/src/post_process_code/m_mpi_proxy.f90 b/src/post_process/m_mpi_proxy.f90 similarity index 100% rename from src/post_process_code/m_mpi_proxy.f90 rename to src/post_process/m_mpi_proxy.f90 diff --git a/src/post_process_code/m_start_up.f90 b/src/post_process/m_start_up.f90 similarity index 100% rename from src/post_process_code/m_start_up.f90 rename to src/post_process/m_start_up.f90 diff --git a/src/post_process_code/m_variables_conversion.f90 b/src/post_process/m_variables_conversion.f90 similarity index 100% rename from src/post_process_code/m_variables_conversion.f90 rename to src/post_process/m_variables_conversion.f90 diff --git a/src/post_process_code/p_main.f90 b/src/post_process/p_main.f90 similarity index 100% rename from src/post_process_code/p_main.f90 rename to src/post_process/p_main.f90 diff --git a/src/pre_process_code/case.fpp b/src/pre_process/case.fpp similarity index 100% rename from src/pre_process_code/case.fpp rename to src/pre_process/case.fpp diff --git a/src/pre_process_code/m_data_output.f90 b/src/pre_process/m_data_output.f90 similarity index 100% rename from src/pre_process_code/m_data_output.f90 rename to src/pre_process/m_data_output.f90 diff --git a/src/pre_process_code/m_global_parameters.fpp b/src/pre_process/m_global_parameters.fpp similarity index 100% rename from src/pre_process_code/m_global_parameters.fpp rename to src/pre_process/m_global_parameters.fpp diff --git a/src/pre_process_code/m_grid.f90 b/src/pre_process/m_grid.f90 similarity index 100% rename from src/pre_process_code/m_grid.f90 rename to src/pre_process/m_grid.f90 diff --git a/src/pre_process_code/m_initial_condition.fpp b/src/pre_process/m_initial_condition.fpp similarity index 100% rename from src/pre_process_code/m_initial_condition.fpp rename to src/pre_process/m_initial_condition.fpp diff --git a/src/pre_process_code/m_mpi_proxy.f90 b/src/pre_process/m_mpi_proxy.f90 similarity index 100% rename from src/pre_process_code/m_mpi_proxy.f90 rename to src/pre_process/m_mpi_proxy.f90 diff --git a/src/pre_process_code/m_start_up.fpp b/src/pre_process/m_start_up.fpp similarity index 100% rename from src/pre_process_code/m_start_up.fpp rename to src/pre_process/m_start_up.fpp diff --git a/src/pre_process_code/m_variables_conversion.f90 b/src/pre_process/m_variables_conversion.f90 similarity index 100% rename from src/pre_process_code/m_variables_conversion.f90 rename to src/pre_process/m_variables_conversion.f90 diff --git a/src/pre_process_code/p_main.f90 b/src/pre_process/p_main.f90 similarity index 100% rename from src/pre_process_code/p_main.f90 rename to src/pre_process/p_main.f90 diff --git a/src/simulation_code/case.fpp b/src/simulation/case.fpp similarity index 100% rename from src/simulation_code/case.fpp rename to src/simulation/case.fpp diff --git a/src/simulation_code/m_bubbles.f90 b/src/simulation/m_bubbles.f90 similarity index 100% rename from src/simulation_code/m_bubbles.f90 rename to src/simulation/m_bubbles.f90 diff --git a/src/simulation_code/m_cbc.f90 b/src/simulation/m_cbc.f90 similarity index 100% rename from src/simulation_code/m_cbc.f90 rename to src/simulation/m_cbc.f90 diff --git a/src/simulation_code/m_data_output.f90 b/src/simulation/m_data_output.f90 similarity index 100% rename from src/simulation_code/m_data_output.f90 rename to src/simulation/m_data_output.f90 diff --git a/src/simulation_code/m_derived_variables.f90 b/src/simulation/m_derived_variables.f90 similarity index 100% rename from src/simulation_code/m_derived_variables.f90 rename to src/simulation/m_derived_variables.f90 diff --git a/src/simulation_code/m_fftw.fpp b/src/simulation/m_fftw.fpp similarity index 100% rename from src/simulation_code/m_fftw.fpp rename to src/simulation/m_fftw.fpp diff --git a/src/simulation_code/m_global_parameters.fpp b/src/simulation/m_global_parameters.fpp similarity index 100% rename from src/simulation_code/m_global_parameters.fpp rename to src/simulation/m_global_parameters.fpp diff --git a/src/simulation_code/m_mpi_proxy.fpp b/src/simulation/m_mpi_proxy.fpp similarity index 100% rename from src/simulation_code/m_mpi_proxy.fpp rename to src/simulation/m_mpi_proxy.fpp diff --git a/src/simulation_code/m_qbmm.fpp b/src/simulation/m_qbmm.fpp similarity index 100% rename from src/simulation_code/m_qbmm.fpp rename to src/simulation/m_qbmm.fpp diff --git a/src/simulation_code/m_rhs.f90 b/src/simulation/m_rhs.f90 similarity index 100% rename from src/simulation_code/m_rhs.f90 rename to src/simulation/m_rhs.f90 diff --git a/src/simulation_code/m_riemann_solvers.fpp b/src/simulation/m_riemann_solvers.fpp similarity index 100% rename from src/simulation_code/m_riemann_solvers.fpp rename to src/simulation/m_riemann_solvers.fpp diff --git a/src/simulation_code/m_start_up.fpp b/src/simulation/m_start_up.fpp similarity index 100% rename from src/simulation_code/m_start_up.fpp rename to src/simulation/m_start_up.fpp diff --git a/src/simulation_code/m_time_steppers.f90 b/src/simulation/m_time_steppers.f90 similarity index 100% rename from src/simulation_code/m_time_steppers.f90 rename to src/simulation/m_time_steppers.f90 diff --git a/src/simulation_code/m_variables_conversion.f90 b/src/simulation/m_variables_conversion.f90 similarity index 100% rename from src/simulation_code/m_variables_conversion.f90 rename to src/simulation/m_variables_conversion.f90 diff --git a/src/simulation_code/m_weno.fpp b/src/simulation/m_weno.fpp similarity index 100% rename from src/simulation_code/m_weno.fpp rename to src/simulation/m_weno.fpp diff --git a/src/simulation_code/nvtx.f90 b/src/simulation/nvtx.f90 similarity index 100% rename from src/simulation_code/nvtx.f90 rename to src/simulation/nvtx.f90 diff --git a/src/simulation_code/p_main.fpp b/src/simulation/p_main.fpp similarity index 100% rename from src/simulation_code/p_main.fpp rename to src/simulation/p_main.fpp diff --git a/toolchain/main.py b/toolchain/main.py deleted file mode 100644 index a29cfc49ad..0000000000 --- a/toolchain/main.py +++ /dev/null @@ -1,126 +0,0 @@ -#!/usr/bin/env python3 - -import os -import signal -import getpass -import platform -import itertools - -from mfc.util.common import MFC_LOGO, MFCException, quit, delete_directory, format_list_to_string, does_command_exist -from mfc.util.printer import cons - -from mfc import args -from mfc import build -from mfc.cfg import user -from mfc.cfg import lock - -from mfc.run import run -from mfc.tests import tests - - -class MFCState: - def __init__(self) -> None: - self.user = user.MFCUser() - self.lock = lock.MFCLock(self.user) - self.test = tests.MFCTest(self) - self.args = args.parse(self) - self.run = run.MFCRun(self) - - self.__handle_mode() - self.__print_greeting() - self.__checks() - self.__run() - - - def __handle_mode(self): - # Handle mode change - if self.args["mode"] != self.lock.mode: - cons.print(f"[bold yellow]Switching to [bold magenta]{self.args['mode']}[/bold magenta] mode from [bold magenta]{self.lock.mode}[/bold magenta] mode:[/bold yellow]") - self.lock.mode = self.args["mode"] - self.lock.write() - - for target_name in build.get_mfc_target_names(): - t = build.get_target(target_name) - dirpath = build.get_build_dirpath(t) - cons.print(f"[bold red] - Removing {os.path.relpath(dirpath)}[/bold red]") - delete_directory(dirpath) - - - def __print_greeting(self): - MFC_LOGO_LINES = MFC_LOGO.splitlines() - max_logo_line_length = max([ len(line) for line in MFC_LOGO_LINES ]) - - host_line = f"{getpass.getuser()}@{platform.node()} [{platform.system()}]" - - targets_line = \ - f"[bold]--targets: {format_list_to_string([ f'[magenta]{target}[/magenta]' for target in self.args['targets']], 'None')}[/bold]" - - MFC_SIDEBAR_LINES = [ - "", - f"[bold]{host_line}[/bold]", - '-' * len(host_line), - "", - "", - f"[bold]--jobs: [magenta]{self.args['jobs']}[/magenta][/bold]", - f"[bold]--mode: [magenta]{self.lock.mode}[/magenta][/bold]", - targets_line if self.args["command"] != "test" else "", - "", - "", - "[yellow]$ ./mfc.sh \[build, run, test, clean] --help[/yellow]", - ] - - - for a, b in itertools.zip_longest(MFC_LOGO_LINES, MFC_SIDEBAR_LINES): - lhs = a.ljust(max_logo_line_length) - rhs = b if b is not None else '' - cons.print( - f"[bold blue] {lhs} [/bold blue] {rhs}", - highlight=False - ) - - cons.print() - - - def __checks(self): - if not does_command_exist("cmake"): - raise MFCException("CMake is required to build MFC but couldn't be located on your system. Please ensure it installed and discoverable (e.g in your system's $PATH).") - - if not does_command_exist("mpif90") and not self.args["no_mpi"]: - raise MFCException("mpif90 couldn't be located on your system. We therefore assume MPI is not available on your system. It is required to build MFC. Please ensure it is installed and discoverable (e.g in your system's $PATH).") - - - def __run(self): - if self.args["command"] == "test": - self.test.execute() - elif self.args["command"] == "run": - self.run.run() - elif self.args["command"] == "build": - build.build(self) - elif self.args["command"] == "clean": - for target in self.args["targets"]: - build.clean_target(self, target) - - -if __name__ == "__main__": - try: - MFCState() - except MFCException as exc: - cons.reset() - cons.print(f"""\ - - -[bold red]Error[/bold red]: {str(exc)} -""") - quit(signal.SIGTERM) - except KeyboardInterrupt as exc: - quit(signal.SIGTERM) - except Exception as exc: - cons.reset() - cons.print_exception() - cons.print(f"""\ - - -[bold red]ERROR[/bold red]: An unexpected exception occurred: {str(exc)} -""") - - quit(signal.SIGTERM) diff --git a/toolchain/mfc/run/input.py b/toolchain/mfc/run/input.py index 1989d556e8..435af43848 100644 --- a/toolchain/mfc/run/input.py +++ b/toolchain/mfc/run/input.py @@ -40,7 +40,7 @@ def __generate_fpp(self, target_name: str) -> None: # === case.fpp === use_case_optimization = self.args["case_optimization"] and target_name == "simulation" - filepath = os.path.join(os.getcwd(), "src", f"{target_name}_code", "case.fpp") + filepath = os.path.join(os.getcwd(), "src", target_name, "case.fpp") content = f"""\ ! This file was generated by MFC. It is only used if the --case-optimization ! option is passed to ./mfc.sh run or test, enabling a GPU-oriented optimization