forked from NCAR/musica
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request NCAR#132 from NCAR/develop-host-model
MUSICA Tutorial Chapter 1
- Loading branch information
Showing
21 changed files
with
263 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -124,4 +124,4 @@ endif() | |
# Musica python | ||
if(MUSICA_ENABLE_PYTHON_LIBRARY) | ||
add_subdirectory(python) | ||
endif() | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -111,4 +111,4 @@ endif() | |
|
||
if(MUSICA_BUILD_DOCS) | ||
find_package(Sphinx REQUIRED) | ||
endif() | ||
endif() |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
############### | ||
Getting Started | ||
############### | ||
|
||
.. toctree:: | ||
:maxdepth: 1 | ||
:caption: Contents: | ||
|
||
overview | ||
installation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
Installation | ||
============ | ||
|
||
MUSICA source code may be cloned from its public GitHub repository | ||
and configured and built with the cmake utility. | ||
In brief: | ||
|
||
.. code-block:: console | ||
$ git clone https://github.com/NCAR/musica.git | ||
$ cd musica | ||
$ mkdir build | ||
$ cd build | ||
$ ccmake .. | ||
$ make | ||
$ make install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Overview | ||
======== | ||
|
||
The specific goal of MUSICA is to produce a new model independent infrastructure, | ||
which will enable chemistry and aerosols to be simulated | ||
at a large number of different resolutions in a single, coherent fashion. | ||
At first, MUSICA will be configured within the NCAR Community Earth system Model (CESM) | ||
and through this enable full feedbacks between the atmosphere, ocean and land. | ||
The infrastructure will unify the different chemical transport models | ||
including CAM-Chem, WACCM and WRF-Chem, and NCAR LES with chemistry | ||
and a box model in a single modular framework. | ||
The model infrastructure will be open source, | ||
flexible and computationally efficient in order | ||
to facilitate community co-development and use for scientific and operational purposes. | ||
|
||
At the heart of MUSICA is the standalone Model Independent Chemistry Model (MICM), which is a gas-phase kinetic solver. MICM is made available by the MUSICA wrapper which satisfies the requirements of the Common Community Physics Package (CCPP) | ||
and that can be connected to any CCPP compliant atmosphere model. | ||
MUSICA and MICM will have a flexible design to handle a variety of gas phase and aerosol schemes | ||
and associated chemical modules such as deposition or photolysis. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
Chapter 1 | ||
========= | ||
|
||
First Fortran MUSICA Program | ||
---------------------------- | ||
The MUSICA library can be used within a fortran program. | ||
To get started, let us create a simple program that links | ||
to MUSICA and prints the version of MICM. | ||
|
||
Here are the contents of the program `demo.f90`: | ||
|
||
.. literalinclude:: ../../../fortran/test/fetch_content_integration/test_get_micm_version.F90 | ||
:language: f90 | ||
|
||
From the ``musica_micm`` module, we only need the function ``get_micm_version``, | ||
which returns a derived string type from the ``musica_util`` module, ``string_t``. | ||
The ``string_t`` type will be discussed in more detail in later chapters. | ||
To print the version string we just want the fortran character array, | ||
accessed by ``get_char_array``. | ||
|
||
Now, to build this simple program, | ||
invoke the `gfortran` compiler and link to ``libmusica-fortran``, ``libmusica``, | ||
and the standard C++ library ``libstdc++``. | ||
The full command is | ||
|
||
.. code-block:: bash | ||
gfortran -o demo demo.f90 -I<MUSICA_DIR>/include -L<MUSICA_DIR>/lib -lmusica-fortran -lmusica -lstdc++ | ||
``<MUSICA_DIR>`` is the full path of the MUSICA installation directory, | ||
specified by the option ``CMAKE_INSTALL_PREFIX`` | ||
during the `cmake` configuration process. | ||
Note the include path allows the linker to find the ``musica_micm.mod`` and ``musica_util.mod`` | ||
module definition files. | ||
|
||
When the `demo` program is run it should display the MICM version: | ||
|
||
.. code-block:: bash | ||
$ ./demo | ||
MICM version 3.5.0 | ||
$ | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
######## | ||
Tutorial | ||
######## | ||
|
||
.. toctree:: | ||
:maxdepth: 1 | ||
:caption: Contents: | ||
|
||
chapter1.rst |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
############## | ||
Model Inteface | ||
############## | ||
|
||
Fortran C Interface Example | ||
--------------------------- | ||
|
||
.. code-block:: cpp | ||
#include <stdio.h> | ||
void test_proc_c(int n, double A[3][2]) { | ||
printf("test_proc_c\n"); | ||
printf("n = %d\n", n); | ||
printf("matrix A\n"); | ||
for (int i = 0; i < 2; i++) { | ||
for (int j = 0; j < 3; j++) { | ||
printf("%6.2f ", A[j][i]); | ||
} | ||
printf("\n"); | ||
} | ||
} | ||
.. code-block:: f90 | ||
program demo_fort | ||
use iso_c_binding, only: c_int, c_double | ||
implicit none | ||
integer :: i, j | ||
integer(c_int) :: n_fort = 7 | ||
real(c_double), dimension(2, 3) :: A_fort | ||
interface | ||
subroutine test_proc_c(n_c, A_c) bind(C, name='test_proc_c') | ||
use iso_c_binding, only: c_int, c_double | ||
integer(c_int), intent(in), value :: n_c | ||
real(c_double), dimension(2, 3), intent(in) :: A_c | ||
end subroutine test_proc_c | ||
end interface | ||
do j = 1, 3 | ||
do i = 1, 2 | ||
A_fort(i, j) = real(i + j, c_double) | ||
end do | ||
end do | ||
call test_proc_c(n_fort, A_fort) | ||
end program demo_fort | ||
.. code-block:: bash | ||
all: test_proc_c.o demo_fort.o demo_fort | ||
test_proc_c.o : test_proc_c.c | ||
gcc -c test_proc_c.c | ||
demo_fort.o : demo_fort.f90 | ||
gfortran -c demo_fort.f90 | ||
demo_fort : test_proc_c.o demo_fort.o | ||
gfortran -o demo_fort demo_fort.o test_proc_c.o -lc | ||
clean: | ||
rm -f test_proc_c.o demo_fort.o demo_fort | ||
.. code-block:: console | ||
$ ./demo_fort | ||
test_proc_c | ||
n = 7 | ||
matrix A | ||
2.00 3.00 4.00 | ||
3.00 4.00 5.00 | ||
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
############## | ||
Model Inteface | ||
############## | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
########## | ||
User Guide | ||
########## | ||
|
||
.. toctree:: | ||
:maxdepth: 1 | ||
:caption: Contents: | ||
|
||
model_interface |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
fortran/test/fetch_content_integration/test_get_micm_version.F90
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
program demo | ||
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 demo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.