From e9b7bc6c83b531c06ca2280a012fd30039263572 Mon Sep 17 00:00:00 2001 From: David Fillmore Date: Tue, 4 Jun 2024 14:08:39 -0600 Subject: [PATCH 01/20] Start on test_micm_box_model.F90. --- .../fetch_content_integration/CMakeLists.txt | 16 ++++++++++++++++ .../test_micm_box_model.F90 | 8 ++++++++ fortran/test/unit/CMakeLists.txt | 1 + 3 files changed, 25 insertions(+) create mode 100644 fortran/test/fetch_content_integration/test_micm_box_model.F90 diff --git a/fortran/test/fetch_content_integration/CMakeLists.txt b/fortran/test/fetch_content_integration/CMakeLists.txt index f9a32dbc..cf039bbc 100644 --- a/fortran/test/fetch_content_integration/CMakeLists.txt +++ b/fortran/test/fetch_content_integration/CMakeLists.txt @@ -65,6 +65,22 @@ if (MUSICA_ENABLE_MICM) COMMAND $ WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ) + + target_link_libraries(test_micm_box_model + PRIVATE + musica::musica-fortran + ) + + set_target_properties(test_micm_box_model + PROPERTIES + LINKER_LANGUAGE Fortran + ) + + add_test( + NAME test_micm_box_model + COMMAND $ + WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} + ) endif() # API Test diff --git a/fortran/test/fetch_content_integration/test_micm_box_model.F90 b/fortran/test/fetch_content_integration/test_micm_box_model.F90 new file mode 100644 index 00000000..cfcc6506 --- /dev/null +++ b/fortran/test/fetch_content_integration/test_micm_box_model.F90 @@ -0,0 +1,8 @@ +program test_micm_box_model + use musica_util, only: string_t + use musica_micm, only: get_micm_version + implicit none + type(string_t) :: micm_version + micm_version = get_micm_version() + print *, "MICM version ", micm_version%get_char_array() +end program test_micm_box_model diff --git a/fortran/test/unit/CMakeLists.txt b/fortran/test/unit/CMakeLists.txt index 2d5e274a..27b0de76 100644 --- a/fortran/test/unit/CMakeLists.txt +++ b/fortran/test/unit/CMakeLists.txt @@ -5,6 +5,7 @@ create_standard_test_fortran(NAME fortran_util SOURCES util.F90) if (MUSICA_ENABLE_MICM) create_standard_test_fortran(NAME micm_fortran_api SOURCES ../fetch_content_integration/test_micm_api.F90) create_standard_test_fortran(NAME get_micm_version SOURCES ../fetch_content_integration/test_get_micm_version.F90) + create_standard_test_fortran(NAME micm_box_model SOURCES ../fetch_content_integration/test_micm_box_model.F90) endif() if (MUSICA_ENABLE_TUVX) From 4a3c9bd29764f5d90aef2a2e5d73e918fa92e4d4 Mon Sep 17 00:00:00 2001 From: David Fillmore Date: Tue, 4 Jun 2024 14:45:17 -0600 Subject: [PATCH 02/20] Start on test_micm_box_model.F90. --- .../test_micm_box_model.F90 | 27 +++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/fortran/test/fetch_content_integration/test_micm_box_model.F90 b/fortran/test/fetch_content_integration/test_micm_box_model.F90 index cfcc6506..c60ce9d3 100644 --- a/fortran/test/fetch_content_integration/test_micm_box_model.F90 +++ b/fortran/test/fetch_content_integration/test_micm_box_model.F90 @@ -1,8 +1,25 @@ program test_micm_box_model - use musica_util, only: string_t - use musica_micm, only: get_micm_version + + use, intrinsic :: iso_c_binding + use, intrinsic :: ieee_arithmetic + + use musica_micm, only: micm_t + use musica_util, only: error_t, string_t, mapping_t + implicit none - type(string_t) :: micm_version - micm_version = get_micm_version() - print *, "MICM version ", micm_version%get_char_array() + + call box_model() + +contains + + subroutine box_model() + + real(c_double) :: time_step + real(c_double) :: temperature + real(c_double) :: pressure + + real(c_double), dimension(3) :: concentrations + + end subroutine box_model + end program test_micm_box_model From 66d509132d0a4eaa9dc9c890e5f0d758a89d6efd Mon Sep 17 00:00:00 2001 From: David Fillmore Date: Tue, 4 Jun 2024 14:56:39 -0600 Subject: [PATCH 03/20] In test_micm_box_model, create micm_t solver. --- .../test_micm_box_model.F90 | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/fortran/test/fetch_content_integration/test_micm_box_model.F90 b/fortran/test/fetch_content_integration/test_micm_box_model.F90 index c60ce9d3..737fc3ed 100644 --- a/fortran/test/fetch_content_integration/test_micm_box_model.F90 +++ b/fortran/test/fetch_content_integration/test_micm_box_model.F90 @@ -3,8 +3,8 @@ program test_micm_box_model use, intrinsic :: iso_c_binding use, intrinsic :: ieee_arithmetic - use musica_micm, only: micm_t use musica_util, only: error_t, string_t, mapping_t + use musica_micm, only: micm_t implicit none @@ -14,12 +14,23 @@ program test_micm_box_model subroutine box_model() + character(len=256) :: config_path + real(c_double) :: time_step real(c_double) :: temperature real(c_double) :: pressure real(c_double), dimension(3) :: concentrations + type(error_t) :: error + + type(micm_t), pointer :: micm + + config_path = "" + + write(*,*) "Creating MICM solver..." + micm => micm_t(config_path, error) + end subroutine box_model end program test_micm_box_model From 73f997d9b345f2180f17a54921fefe289807f632 Mon Sep 17 00:00:00 2001 From: David Fillmore Date: Tue, 4 Jun 2024 17:49:47 -0600 Subject: [PATCH 04/20] Initialize some variables. --- .../fetch_content_integration/test_micm_box_model.F90 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/fortran/test/fetch_content_integration/test_micm_box_model.F90 b/fortran/test/fetch_content_integration/test_micm_box_model.F90 index 737fc3ed..f883bf5d 100644 --- a/fortran/test/fetch_content_integration/test_micm_box_model.F90 +++ b/fortran/test/fetch_content_integration/test_micm_box_model.F90 @@ -20,14 +20,20 @@ subroutine box_model() real(c_double) :: temperature real(c_double) :: pressure + integer(c_int) :: num_concentrations = 3 real(c_double), dimension(3) :: concentrations type(error_t) :: error - type(micm_t), pointer :: micm + integer :: i + config_path = "" + time_step = 200 + temperature = 273.0 + pressure = 1.0e5 + write(*,*) "Creating MICM solver..." micm => micm_t(config_path, error) From de422c2ff56ff5e2d2987626e7060807d729646c Mon Sep 17 00:00:00 2001 From: David Fillmore Date: Wed, 5 Jun 2024 09:18:27 -0600 Subject: [PATCH 05/20] Use configs/analytical. --- .../fetch_content_integration/test_micm_box_model.F90 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/fortran/test/fetch_content_integration/test_micm_box_model.F90 b/fortran/test/fetch_content_integration/test_micm_box_model.F90 index f883bf5d..e84d3737 100644 --- a/fortran/test/fetch_content_integration/test_micm_box_model.F90 +++ b/fortran/test/fetch_content_integration/test_micm_box_model.F90 @@ -28,7 +28,7 @@ subroutine box_model() integer :: i - config_path = "" + config_path = "configs/analytical" time_step = 200 temperature = 273.0 @@ -37,6 +37,12 @@ subroutine box_model() write(*,*) "Creating MICM solver..." micm => micm_t(config_path, error) + do i = 1, size( micm%species_ordering ) + associate(the_mapping => micm%species_ordering(i)) + print *, "Species Name:", the_mapping%name(), ", Index:", the_mapping%index() + end associate + end do + end subroutine box_model end program test_micm_box_model From 5e097cc3dc1a0e497a95fc4153a4cf08ff45e550 Mon Sep 17 00:00:00 2001 From: David Fillmore Date: Wed, 5 Jun 2024 09:38:22 -0600 Subject: [PATCH 06/20] Use configs/analytical. --- .../test/fetch_content_integration/test_micm_box_model.F90 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fortran/test/fetch_content_integration/test_micm_box_model.F90 b/fortran/test/fetch_content_integration/test_micm_box_model.F90 index e84d3737..7c437d32 100644 --- a/fortran/test/fetch_content_integration/test_micm_box_model.F90 +++ b/fortran/test/fetch_content_integration/test_micm_box_model.F90 @@ -23,12 +23,16 @@ subroutine box_model() integer(c_int) :: num_concentrations = 3 real(c_double), dimension(3) :: concentrations + integer(c_int) :: num_user_defined_reaction_rates = 3 + real(c_double), dimension(3) :: user_defined_reaction_rates + type(error_t) :: error type(micm_t), pointer :: micm integer :: i config_path = "configs/analytical" + user_defined_reaction_rates = (/ 0.1, 0.2, 0.3 /) time_step = 200 temperature = 273.0 From 1ecd9ba7181b77b0b4f46f66d61c9c09c6456481 Mon Sep 17 00:00:00 2001 From: David Fillmore Date: Wed, 5 Jun 2024 09:59:31 -0600 Subject: [PATCH 07/20] Added micm solve. --- .../test_micm_box_model.F90 | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/fortran/test/fetch_content_integration/test_micm_box_model.F90 b/fortran/test/fetch_content_integration/test_micm_box_model.F90 index 7c437d32..ca05de18 100644 --- a/fortran/test/fetch_content_integration/test_micm_box_model.F90 +++ b/fortran/test/fetch_content_integration/test_micm_box_model.F90 @@ -23,8 +23,8 @@ subroutine box_model() integer(c_int) :: num_concentrations = 3 real(c_double), dimension(3) :: concentrations - integer(c_int) :: num_user_defined_reaction_rates = 3 - real(c_double), dimension(3) :: user_defined_reaction_rates + integer(c_int) :: num_user_defined_reaction_rates = 0 + real(c_double), dimension(:), allocatable :: user_defined_reaction_rates type(error_t) :: error type(micm_t), pointer :: micm @@ -32,12 +32,14 @@ subroutine box_model() integer :: i config_path = "configs/analytical" - user_defined_reaction_rates = (/ 0.1, 0.2, 0.3 /) + ! user_defined_reaction_rates = (/ 0.1, 0.2, 0.3 /) time_step = 200 temperature = 273.0 pressure = 1.0e5 + concentrations = (/ 1.0, 1.0, 1.0 /) + write(*,*) "Creating MICM solver..." micm => micm_t(config_path, error) @@ -47,6 +49,11 @@ subroutine box_model() end associate end do + write(*,*) "Solving starts..." + call micm%solve(time_step, temperature, pressure, num_concentrations, concentrations, & + num_user_defined_reaction_rates, user_defined_reaction_rates, error) + write(*,*) "After solving, concentrations", concentrations + end subroutine box_model end program test_micm_box_model From 10ac01b49fe9fcc4ae0d38738adf231b09bb640c Mon Sep 17 00:00:00 2001 From: David Fillmore Date: Wed, 5 Jun 2024 10:15:27 -0600 Subject: [PATCH 08/20] Start on Chapter 2. --- docs/source/tutorial/chapter2.rst | 9 +++++++++ docs/source/tutorial/tutorial.rst | 1 + 2 files changed, 10 insertions(+) create mode 100644 docs/source/tutorial/chapter2.rst diff --git a/docs/source/tutorial/chapter2.rst b/docs/source/tutorial/chapter2.rst new file mode 100644 index 00000000..642bb60d --- /dev/null +++ b/docs/source/tutorial/chapter2.rst @@ -0,0 +1,9 @@ +Chapter 2 +========= + +An ABC MICM Fortran Example +--------------------------- +.. code-block:: f90 + + program micm_abc + end program micm_abc diff --git a/docs/source/tutorial/tutorial.rst b/docs/source/tutorial/tutorial.rst index e4206e3d..7d22728a 100644 --- a/docs/source/tutorial/tutorial.rst +++ b/docs/source/tutorial/tutorial.rst @@ -7,3 +7,4 @@ Tutorial :caption: Contents: chapter1.rst + chapter2.rst From b30c177958c579aa94489d1307a8245ef58bbc51 Mon Sep 17 00:00:00 2001 From: David Fillmore Date: Wed, 5 Jun 2024 11:35:36 -0600 Subject: [PATCH 09/20] Literal include for test_micm_box_model. --- docs/source/tutorial/chapter2.rst | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/source/tutorial/chapter2.rst b/docs/source/tutorial/chapter2.rst index 642bb60d..19939b29 100644 --- a/docs/source/tutorial/chapter2.rst +++ b/docs/source/tutorial/chapter2.rst @@ -3,7 +3,6 @@ Chapter 2 An ABC MICM Fortran Example --------------------------- -.. code-block:: f90 - program micm_abc - end program micm_abc + .. literalinclude:: ../../../fortran/test/fetch_content_integration/test_micm_box_model.F90 + :language: f90 From fba18d3824b8f7c7e331cab6a1356c556e7461aa Mon Sep 17 00:00:00 2001 From: David Fillmore Date: Wed, 5 Jun 2024 11:43:03 -0600 Subject: [PATCH 10/20] Literal include json configs. --- docs/source/tutorial/chapter2.rst | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/docs/source/tutorial/chapter2.rst b/docs/source/tutorial/chapter2.rst index 19939b29..5ebec9b0 100644 --- a/docs/source/tutorial/chapter2.rst +++ b/docs/source/tutorial/chapter2.rst @@ -4,5 +4,14 @@ Chapter 2 An ABC MICM Fortran Example --------------------------- + .. literalinclude:: ../../../configs/analytical/config.json + :language: json + + .. literalinclude:: ../../../configs/analytical/species.json + :language: json + + .. literalinclude:: ../../../configs/analytical/reactions.json + :language: json + .. literalinclude:: ../../../fortran/test/fetch_content_integration/test_micm_box_model.F90 :language: f90 From 76d90f27253f5599011406c5dca422e3a3489bbf Mon Sep 17 00:00:00 2001 From: David Fillmore Date: Wed, 5 Jun 2024 15:02:28 -0600 Subject: [PATCH 11/20] Updated CMakeLists.txt. --- docs/source/tutorial/chapter2.rst | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/docs/source/tutorial/chapter2.rst b/docs/source/tutorial/chapter2.rst index 5ebec9b0..22d31a13 100644 --- a/docs/source/tutorial/chapter2.rst +++ b/docs/source/tutorial/chapter2.rst @@ -4,9 +4,20 @@ Chapter 2 An ABC MICM Fortran Example --------------------------- +In this next MUSICA Fortran example, +we will setup a MICM solver, starting with a set of MICM configuration files, +and run the solver for a single integration time step. + +The MICM configuration is specified in a top-level ``config.json`` file, +which simply lists the chemical species configuration file followed by +the reactions configuration file. + .. literalinclude:: ../../../configs/analytical/config.json :language: json +For this example, we will have a system of three chemical species +`A`, `B`, and `C`, defined in the JSON file ``species.json`` as follows: + .. literalinclude:: ../../../configs/analytical/species.json :language: json From a1276238ae4e2259b5204aa8c7529daf1b3ba793 Mon Sep 17 00:00:00 2001 From: David Fillmore Date: Wed, 5 Jun 2024 15:16:18 -0600 Subject: [PATCH 12/20] Add config file description. --- docs/source/tutorial/chapter2.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/source/tutorial/chapter2.rst b/docs/source/tutorial/chapter2.rst index 22d31a13..c8091cef 100644 --- a/docs/source/tutorial/chapter2.rst +++ b/docs/source/tutorial/chapter2.rst @@ -21,6 +21,12 @@ For this example, we will have a system of three chemical species .. literalinclude:: ../../../configs/analytical/species.json :language: json +The ``reactions.json`` specifies a mechanism, or a set of reactions for the system. +Here, we will introduce two Arrhenius type reactions, the first +with B evolving to C, and specifying all five reaction parameters, +and the second reaction with B evolving to C and using only two reaction parameters. +The reactions configuration might then be: + .. literalinclude:: ../../../configs/analytical/reactions.json :language: json From c9bb25b6d6a78bb2b220778056cc631ddb561b90 Mon Sep 17 00:00:00 2001 From: David Fillmore Date: Wed, 5 Jun 2024 15:47:48 -0600 Subject: [PATCH 13/20] Tutorial Chapter 2. --- docs/source/tutorial/chapter2.rst | 22 ++++++++++++++++--- .../test_micm_box_model.F90 | 1 - 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/docs/source/tutorial/chapter2.rst b/docs/source/tutorial/chapter2.rst index c8091cef..adf5cbf9 100644 --- a/docs/source/tutorial/chapter2.rst +++ b/docs/source/tutorial/chapter2.rst @@ -1,8 +1,8 @@ Chapter 2 ========= -An ABC MICM Fortran Example ---------------------------- +An MICM Box Model Fortran Example +--------------------------------- In this next MUSICA Fortran example, we will setup a MICM solver, starting with a set of MICM configuration files, @@ -25,10 +25,26 @@ The ``reactions.json`` specifies a mechanism, or a set of reactions for the syst Here, we will introduce two Arrhenius type reactions, the first with B evolving to C, and specifying all five reaction parameters, and the second reaction with B evolving to C and using only two reaction parameters. -The reactions configuration might then be: +The mechanism configuration might then be set up as: .. literalinclude:: ../../../configs/analytical/reactions.json :language: json +The Fortran example code is shown in full: + .. literalinclude:: ../../../fortran/test/fetch_content_integration/test_micm_box_model.F90 :language: f90 + +From the `musica_util` module we need the Fortran types +``error_t``, ``string_t``, and ``mapping_t``. +A pointer to a ``musica_micm::micm_t`` will serve as the interface to the MICM solver +(in the example the pointer name is ``micm``). +Note that the ``config_path`` in the code sample has been set to ``configs/analytical``, +so that subdir should be created relative to the main program and contain +the MICM JSON configuration files, +or otherwise the ``config_path`` should be modified appropriately. +The initial species concentrations are initialized in the ``concentrations`` array, +which is an argument to the MICM solver. + +Finally, a single time step solution is obtained through a call to ``micm%solve``, +after which the updated concentrations may be displayed. diff --git a/fortran/test/fetch_content_integration/test_micm_box_model.F90 b/fortran/test/fetch_content_integration/test_micm_box_model.F90 index ca05de18..1056b6a0 100644 --- a/fortran/test/fetch_content_integration/test_micm_box_model.F90 +++ b/fortran/test/fetch_content_integration/test_micm_box_model.F90 @@ -32,7 +32,6 @@ subroutine box_model() integer :: i config_path = "configs/analytical" - ! user_defined_reaction_rates = (/ 0.1, 0.2, 0.3 /) time_step = 200 temperature = 273.0 From c482ec9a9b0c10f0fa3880e180f21e2e05b5e505 Mon Sep 17 00:00:00 2001 From: David Fillmore Date: Wed, 5 Jun 2024 15:49:19 -0600 Subject: [PATCH 14/20] Tutorial Chapter 2. --- docs/source/tutorial/chapter2.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/tutorial/chapter2.rst b/docs/source/tutorial/chapter2.rst index adf5cbf9..b10142a7 100644 --- a/docs/source/tutorial/chapter2.rst +++ b/docs/source/tutorial/chapter2.rst @@ -35,7 +35,7 @@ The Fortran example code is shown in full: .. literalinclude:: ../../../fortran/test/fetch_content_integration/test_micm_box_model.F90 :language: f90 -From the `musica_util` module we need the Fortran types +From the ``musica_util`` module we need the Fortran types ``error_t``, ``string_t``, and ``mapping_t``. A pointer to a ``musica_micm::micm_t`` will serve as the interface to the MICM solver (in the example the pointer name is ``micm``). From 4d2a500729795a9b22fd7baa8b165616b7058e78 Mon Sep 17 00:00:00 2001 From: David Fillmore Date: Wed, 5 Jun 2024 15:51:00 -0600 Subject: [PATCH 15/20] Minor formatting. --- docs/source/tutorial/chapter2.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/source/tutorial/chapter2.rst b/docs/source/tutorial/chapter2.rst index b10142a7..a1d8ec6d 100644 --- a/docs/source/tutorial/chapter2.rst +++ b/docs/source/tutorial/chapter2.rst @@ -23,8 +23,8 @@ For this example, we will have a system of three chemical species The ``reactions.json`` specifies a mechanism, or a set of reactions for the system. Here, we will introduce two Arrhenius type reactions, the first -with B evolving to C, and specifying all five reaction parameters, -and the second reaction with B evolving to C and using only two reaction parameters. +with `B` evolving to `C`, and specifying all five reaction parameters, +and the second reaction with `B` evolving to `C` and using only two reaction parameters. The mechanism configuration might then be set up as: .. literalinclude:: ../../../configs/analytical/reactions.json From 00416172996192589bba4ef8e9294640f880e75c Mon Sep 17 00:00:00 2001 From: David Fillmore Date: Wed, 5 Jun 2024 15:52:07 -0600 Subject: [PATCH 16/20] Minor formatting. --- docs/source/tutorial/chapter2.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/tutorial/chapter2.rst b/docs/source/tutorial/chapter2.rst index a1d8ec6d..8cc27059 100644 --- a/docs/source/tutorial/chapter2.rst +++ b/docs/source/tutorial/chapter2.rst @@ -24,7 +24,7 @@ For this example, we will have a system of three chemical species The ``reactions.json`` specifies a mechanism, or a set of reactions for the system. Here, we will introduce two Arrhenius type reactions, the first with `B` evolving to `C`, and specifying all five reaction parameters, -and the second reaction with `B` evolving to `C` and using only two reaction parameters. +and the second reaction with `A` evolving to `B` and using only two reaction parameters. The mechanism configuration might then be set up as: .. literalinclude:: ../../../configs/analytical/reactions.json From 6e38172974c85c8a95ceaff7350a179d020a1d7e Mon Sep 17 00:00:00 2001 From: David Fillmore Date: Tue, 18 Jun 2024 09:26:45 -0600 Subject: [PATCH 17/20] Added link to MICM docs, test program output. --- docs/source/tutorial/chapter2.rst | 17 ++++++++++++++++- src/micm/micm.cpp | 1 + 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/docs/source/tutorial/chapter2.rst b/docs/source/tutorial/chapter2.rst index 8cc27059..519ffa20 100644 --- a/docs/source/tutorial/chapter2.rst +++ b/docs/source/tutorial/chapter2.rst @@ -30,7 +30,10 @@ The mechanism configuration might then be set up as: .. literalinclude:: ../../../configs/analytical/reactions.json :language: json -The Fortran example code is shown in full: +More information on MICM configurations and reactions can be found in the MICM documentation +at `https://ncar.github.io/micm/user_guide/`_ + +The Fortran example code is shown below in full: .. literalinclude:: ../../../fortran/test/fetch_content_integration/test_micm_box_model.F90 :language: f90 @@ -48,3 +51,15 @@ which is an argument to the MICM solver. Finally, a single time step solution is obtained through a call to ``micm%solve``, after which the updated concentrations may be displayed. + +.. code-block:: bash + + $ ./test_micm_box_model + Creating MICM solver... + Species Name:A, Index: 1 + Species Name:B, Index: 2 + Species Name:C, Index: 3 + Solving starts... + After solving, concentrations 0.38 1.61E-009 2.62 + $ + diff --git a/src/micm/micm.cpp b/src/micm/micm.cpp index be4daaaa..6538d700 100644 --- a/src/micm/micm.cpp +++ b/src/micm/micm.cpp @@ -9,6 +9,7 @@ #include #include + #include #include From d63422f18686c4a18dc287e3590cd18df085730d Mon Sep 17 00:00:00 2001 From: David Fillmore Date: Thu, 27 Jun 2024 11:17:05 -0600 Subject: [PATCH 18/20] Added test_micm_box_model executable. --- fortran/test/fetch_content_integration/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/fortran/test/fetch_content_integration/CMakeLists.txt b/fortran/test/fetch_content_integration/CMakeLists.txt index e43df186..6739d6bc 100644 --- a/fortran/test/fetch_content_integration/CMakeLists.txt +++ b/fortran/test/fetch_content_integration/CMakeLists.txt @@ -36,6 +36,7 @@ enable_testing() if (MUSICA_ENABLE_MICM) add_executable(test_micm_fortran_api test_micm_api.F90) add_executable(test_get_micm_version test_get_micm_version.F90) + add_executable(test_micm_box_model test_micm_box_model.F90) target_link_libraries(test_micm_fortran_api PRIVATE From 498d34cb74d998b83f1118f69a829b264b4b30b7 Mon Sep 17 00:00:00 2001 From: David Fillmore Date: Thu, 27 Jun 2024 11:34:09 -0600 Subject: [PATCH 19/20] Updated test_micm_box_model with new micm solve. --- .../test_micm_box_model.F90 | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/fortran/test/fetch_content_integration/test_micm_box_model.F90 b/fortran/test/fetch_content_integration/test_micm_box_model.F90 index 1056b6a0..41cac1d9 100644 --- a/fortran/test/fetch_content_integration/test_micm_box_model.F90 +++ b/fortran/test/fetch_content_integration/test_micm_box_model.F90 @@ -4,7 +4,7 @@ program test_micm_box_model use, intrinsic :: ieee_arithmetic use musica_util, only: error_t, string_t, mapping_t - use musica_micm, only: micm_t + use musica_micm, only: micm_t, solver_stats_t implicit none @@ -16,9 +16,12 @@ subroutine box_model() character(len=256) :: config_path + real(c_double), parameter :: GAS_CONSTANT = 8.31446261815324_c_double ! J mol-1 K-1 + real(c_double) :: time_step real(c_double) :: temperature real(c_double) :: pressure + real(c_double) :: air_density integer(c_int) :: num_concentrations = 3 real(c_double), dimension(3) :: concentrations @@ -26,7 +29,10 @@ subroutine box_model() integer(c_int) :: num_user_defined_reaction_rates = 0 real(c_double), dimension(:), allocatable :: user_defined_reaction_rates - type(error_t) :: error + type(string_t) :: solver_state + type(solver_stats_t) :: solver_stats + type(error_t) :: error + type(micm_t), pointer :: micm integer :: i @@ -36,6 +42,7 @@ subroutine box_model() time_step = 200 temperature = 273.0 pressure = 1.0e5 + air_density = pressure / (GAS_CONSTANT * temperature) concentrations = (/ 1.0, 1.0, 1.0 /) @@ -49,8 +56,10 @@ subroutine box_model() end do write(*,*) "Solving starts..." - call micm%solve(time_step, temperature, pressure, num_concentrations, concentrations, & - num_user_defined_reaction_rates, user_defined_reaction_rates, error) + ! call micm%solve(time_step, temperature, pressure, num_concentrations, concentrations, & + ! num_user_defined_reaction_rates, user_defined_reaction_rates, error) + call micm%solve(time_step, temperature, pressure, air_density, num_concentrations, concentrations, & + num_user_defined_reaction_rates, user_defined_reaction_rates, solver_state, solver_stats, error) write(*,*) "After solving, concentrations", concentrations end subroutine box_model From 156e2cc3019593e2165a9d052d49ba19505d8615 Mon Sep 17 00:00:00 2001 From: David Fillmore Date: Thu, 27 Jun 2024 11:44:55 -0600 Subject: [PATCH 20/20] Added deallocate( micm ) in test_micm_box_model. --- fortran/test/fetch_content_integration/test_micm_box_model.F90 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fortran/test/fetch_content_integration/test_micm_box_model.F90 b/fortran/test/fetch_content_integration/test_micm_box_model.F90 index 41cac1d9..dfdc5aab 100644 --- a/fortran/test/fetch_content_integration/test_micm_box_model.F90 +++ b/fortran/test/fetch_content_integration/test_micm_box_model.F90 @@ -62,6 +62,8 @@ subroutine box_model() num_user_defined_reaction_rates, user_defined_reaction_rates, solver_state, solver_stats, error) write(*,*) "After solving, concentrations", concentrations + deallocate( micm ) + end subroutine box_model end program test_micm_box_model