Skip to content

Commit

Permalink
Use new AMREX_INPUTS_FILE_PREFIX env variable
Browse files Browse the repository at this point in the history
  • Loading branch information
EZoni committed Sep 4, 2024
1 parent af246bc commit ffd4d03
Show file tree
Hide file tree
Showing 116 changed files with 614 additions and 582 deletions.
1 change: 1 addition & 0 deletions .azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ jobs:
cmake -S . -B build \
${AMReX_CMAKE_FLAGS} \
${WARPX_CMAKE_FLAGS} \
-DWarpX_amrex_repo=https://github.com/ax3l/amrex.git -DWarpX_amrex_branch=topic-pp-prefix \ # FIXME remove line
-DWarpX_TEST_CLEANUP=ON \
-DWarpX_TEST_FPETRAP=ON
# build
Expand Down
24 changes: 12 additions & 12 deletions Docs/source/developers/testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ Each test directory must contain a file named ``CMakeLists.txt`` where all tests

A new test can be added by adding a corresponding entry in ``CMakeLists.txt`` as illustrated in the examples below:

* Add the **regular test** ``test_1d_laser_acceleration``, with input file and analysis script in ``Examples/Tests/laser_acceleration/``:
* Add the **regular test** ``test_1d_laser_acceleration``:

.. code-block:: sh
Expand All @@ -104,13 +104,13 @@ A new test can be added by adding a corresponding entry in ``CMakeLists.txt`` as
1 # dims
2 # nprocs
OFF # eb
Examples/Tests/laser_acceleration/inputs_test_1d_laser_acceleration # inputs
Examples/Tests/laser_acceleration/analysis.py # analysis
inputs_test_1d_laser_acceleration # inputs
analysis.py # analysis
diags/diag1000100 # output (plotfile)
OFF # dependency
)
* Add the **PICMI test** ``test_2d_laser_acceleration_picmi``, with input file and analysis script in ``Examples/Tests/laser_acceleration/``:
* Add the **PICMI test** ``test_2d_laser_acceleration_picmi``:

.. code-block:: sh
Expand All @@ -119,13 +119,13 @@ A new test can be added by adding a corresponding entry in ``CMakeLists.txt`` as
2 # dims
2 # nprocs
OFF # eb
Examples/Tests/laser_acceleration/inputs_test_2d_laser_acceleration_picmi.py # inputs
Examples/Tests/laser_acceleration/analysis.py # analysis
inputs_test_2d_laser_acceleration_picmi.py # inputs
analysis.py # analysis
diags/diag1000100 # output (plotfile)
OFF # dependency
)
* Add the **restart test** ``test_3d_laser_acceleration_restart``, with input file in ``Examples/Tests/laser_acceleration/`` and default restart analysis script provided by WarpX:
* Add the **restart test** ``test_3d_laser_acceleration_restart``:

.. code-block:: sh
Expand All @@ -134,15 +134,15 @@ A new test can be added by adding a corresponding entry in ``CMakeLists.txt`` as
3 # dims
2 # nprocs
OFF # eb
Examples/Tests/laser_acceleration/inputs_test_3d_laser_acceleration_restart # inputs
Examples/analysis_default_restart.py # analysis
inputs_test_3d_laser_acceleration_restart # inputs
analysis_default_restart.py # analysis
diags/diag1000100 # output (plotfile)
test_3d_laser_acceleration # dependency
)
Note that the restart has an explicit dependency, namely it can run only provided that the original test, from which the restart checkpoint files will be read, runs first.

* A more complex example. Add the **PICMI test** ``test_rz_laser_acceleration_picmi``, with custom command-line arguments ``--test`` and ``dir``, input file and analysis script in ``Examples/Tests/laser_acceleration/``, and openPMD time series output:
* A more complex example. Add the **PICMI test** ``test_rz_laser_acceleration_picmi``, with custom command-line arguments ``--test`` and ``dir``, and openPMD time series output:

.. code-block:: sh
Expand All @@ -151,8 +151,8 @@ A new test can be added by adding a corresponding entry in ``CMakeLists.txt`` as
RZ # dims
2 # nprocs
OFF # eb
"Examples/Tests/laser_acceleration/inputs_test_rz_laser_acceleration_picmi.py --test --dir 1" # inputs
Examples/Tests/laser_acceleration/analysis.py # analysis
"inputs_test_rz_laser_acceleration_picmi.py --test --dir 1" # inputs
analysis.py # analysis
diags/diag1/ # output (openPMD time series)
OFF # dependency
)
Expand Down
58 changes: 30 additions & 28 deletions Examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ endif()
# eb: needs EB support? (temporary until handled as runtime parameter)
# inputs: inputs file or PICMI script, WarpX_MPI decides w/ or w/o MPI
# analysis: analysis script, always run without MPI
# output: output file (dir) to analyze
# output: output file(s) to analyze
# dependency: name of base test that must run first
#
function(add_warpx_test
Expand Down Expand Up @@ -70,36 +70,35 @@ function(add_warpx_test
file(MAKE_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${name})
set(THIS_WORKING_DIR ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${name})

get_filename_component(INPUTS_ALL ${WarpX_SOURCE_DIR}/${inputs} REALPATH)

# separate input file (full path) and optional command-line arguments
separate_arguments(INPUTS_FILE_ARGS UNIX_COMMAND PROGRAM "${INPUTS_ALL}")

# get input file (full path)
list(GET INPUTS_FILE_ARGS 0 INPUTS_FILE)

# get optional command-line arguments
list(SUBLIST INPUTS_FILE_ARGS 1 -1 INPUTS_ARGS)
list(JOIN INPUTS_FILE_ARGS " " INPUTS_FILE_ARGS)

# get input file's directory
get_filename_component(INPUTS_DIR ${INPUTS_FILE} DIRECTORY)

# copy base input files to run directory
file(GLOB INPUTS_BASE "${INPUTS_DIR}/inputs_base_${SD}*")
file(COPY ${INPUTS_BASE} DESTINATION ${THIS_WORKING_DIR})

# copy test input file to run directory
file(COPY ${INPUTS_FILE} DESTINATION ${THIS_WORKING_DIR})
# get input file/script and optional command-line arguments
separate_arguments(INPUTS_LIST UNIX_COMMAND "${inputs}")
list(GET INPUTS_LIST 0 INPUTS_FILE)
list(LENGTH INPUTS_LIST INPUTS_LIST_LENGTH)
if(INPUTS_LIST_LENGTH GREATER 1)
list(SUBLIST INPUTS_LIST 1 -1 INPUTS_ARGS)
list(JOIN INPUTS_ARGS " " INPUTS_ARGS)
else()
set(INPUTS_ARGS "")
endif()

# for restart tests, copy input file of original test (without "_restart" suffix)
string(REPLACE "_restart" "" INPUTS_FILE_NORESTART ${INPUTS_FILE})
file(COPY ${INPUTS_FILE_NORESTART} DESTINATION ${THIS_WORKING_DIR})
# get analysis script and optional command-line arguments
separate_arguments(ANALYSIS_LIST UNIX_COMMAND "${analysis}")
list(GET ANALYSIS_LIST 0 ANALYSIS_FILE)
cmake_path(SET ANALYSIS_FILE "${CMAKE_CURRENT_SOURCE_DIR}/${ANALYSIS_FILE}")
# TODO Enable lines below to handle command-line arguments
#list(LENGTH ANALYSIS_LIST ANALYSIS_LIST_LENGTH)
#if(ANALYSIS_LIST_LENGTH GREATER 1)
# list(SUBLIST ANALYSIS_LIST 1 -1 ANALYSIS_ARGS)
# list(JOIN ANALYSIS_ARGS " " ANALYSIS_ARGS)
#else()
# set(ANALYSIS_ARGS "")
#endif()

# Python test?
set(python OFF)
if(${INPUTS_FILE} MATCHES ".*\.py$")
set(python ON)
cmake_path(SET INPUTS_FILE "${CMAKE_CURRENT_SOURCE_DIR}/${INPUTS_FILE}")
endif()

# cannot run Python tests w/o Python support
Expand Down Expand Up @@ -137,7 +136,7 @@ function(add_warpx_test
WORKING_DIRECTORY ${THIS_WORKING_DIR}
)
# FIXME Use helper function to handle Windows exceptions
set_property(TEST ${name}.run APPEND PROPERTY ENVIRONMENT "PYTHONPATH=${PYTHONPATH}:${CMAKE_PYTHON_OUTPUT_DIRECTORY}")
set_property(TEST ${name}.run APPEND PROPERTY ENVIRONMENT "PYTHONPATH=$ENV{PYTHONPATH}:${CMAKE_PYTHON_OUTPUT_DIRECTORY}")
else()
# TODO Use these for Python tests too
set(runtime_params
Expand Down Expand Up @@ -170,6 +169,9 @@ function(add_warpx_test
)
endif()

# AMReX ParmParse prefix: FILE = <prefix><filename>
set_property(TEST ${name}.run APPEND PROPERTY ENVIRONMENT "AMREX_INPUTS_FILE_PREFIX=${CMAKE_CURRENT_SOURCE_DIR}/")

# run all tests with 1 OpenMP thread by default
set_property(TEST ${name}.run APPEND PROPERTY ENVIRONMENT "OMP_NUM_THREADS=1")

Expand All @@ -184,14 +186,14 @@ function(add_warpx_test
add_test(
NAME ${name}.analysis
COMMAND
${THIS_Python_SCRIPT_EXE} ${WarpX_SOURCE_DIR}/${analysis}
${THIS_Python_SCRIPT_EXE} ${ANALYSIS_FILE}
${output}
WORKING_DIRECTORY ${THIS_WORKING_DIR}
)
# test analysis depends on test run
set_property(TEST ${name}.analysis APPEND PROPERTY DEPENDS "${name}.run")
# FIXME Use helper function to handle Windows exceptions
set(PYTHONPATH "${PYTHONPATH}:${CMAKE_PYTHON_OUTPUT_DIRECTORY}")
set(PYTHONPATH "$ENV{PYTHONPATH}:${CMAKE_PYTHON_OUTPUT_DIRECTORY}")
# add paths for custom Python modules
set(PYTHONPATH "${PYTHONPATH}:${WarpX_SOURCE_DIR}/Regression/Checksum")
set(PYTHONPATH "${PYTHONPATH}:${WarpX_SOURCE_DIR}/Regression/PostProcessingUtils")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ add_warpx_test(
3 # dims
2 # nprocs
OFF # eb
Examples/Physics_applications/beam_beam_collision/inputs_test_3d_beam_beam_collision # inputs
Examples/analysis_default_openpmd_regression.py # analysis
inputs_test_3d_beam_beam_collision # inputs
analysis_default_openpmd_regression.py # analysis
diags/diag1/ # output
OFF # dependency
)
20 changes: 10 additions & 10 deletions Examples/Physics_applications/capacitive_discharge/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ add_warpx_test(
1 # dims
2 # nprocs
OFF # eb
"Examples/Physics_applications/capacitive_discharge/inputs_base_1d_picmi.py --test --pythonsolver" # inputs
Examples/Physics_applications/capacitive_discharge/analysis_1d.py # analysis
"inputs_base_1d_picmi.py --test --pythonsolver" # inputs
analysis_1d.py # analysis
diags/diag1000050 # output
OFF # dependency
)
Expand All @@ -17,8 +17,8 @@ add_warpx_test(
2 # dims
2 # nprocs
OFF # eb
Examples/Physics_applications/capacitive_discharge/inputs_test_2d_background_mcc # inputs
Examples/analysis_default_regression.py # analysis
inputs_test_2d_background_mcc # inputs
analysis_default_regression.py # analysis
diags/diag1000050 # output
OFF # dependency
)
Expand All @@ -29,8 +29,8 @@ add_warpx_test(
# 2 # dims
# 2 # nprocs
# OFF # eb
# Examples/Physics_applications/capacitive_discharge/inputs_test_2d_background_mcc_dp_psp # inputs
# Examples/analysis_default_regression.py # analysis
# inputs_test_2d_background_mcc_dp_psp # inputs
# analysis_default_regression.py # analysis
# diags/diag1000050 # output
# OFF # dependency
#)
Expand All @@ -40,8 +40,8 @@ add_warpx_test(
2 # dims
2 # nprocs
OFF # eb
Examples/Physics_applications/capacitive_discharge/inputs_test_2d_background_mcc_picmi.py # inputs
Examples/Physics_applications/capacitive_discharge/analysis_2d.py # analysis
inputs_test_2d_background_mcc_picmi.py # inputs
analysis_2d.py # analysis
diags/diag1000050 # output
OFF # dependency
)
Expand All @@ -51,8 +51,8 @@ add_warpx_test(
1 # dims
2 # nprocs
OFF # eb
"Examples/Physics_applications/capacitive_discharge/inputs_base_1d_picmi.py --test --dsmc" # inputs
Examples/Physics_applications/capacitive_discharge/analysis_dsmc.py # analysis
"inputs_base_1d_picmi.py --test --dsmc" # inputs
analysis_dsmc.py # analysis
diags/diag1000050 # output
OFF # dependency
)
Loading

0 comments on commit ffd4d03

Please sign in to comment.