Skip to content

Commit 79a2d4a

Browse files
committed
Split chic integration into subsection and add variable descriptions.
1 parent 2a4f078 commit 79a2d4a

File tree

2 files changed

+40
-37
lines changed

2 files changed

+40
-37
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
(part:API_manual:chap:API_FFI:sec:Fortran_interface:subsec:CHIC_integration)=
2+
3+
CHIC Integration
4+
=================
5+
6+
To illustrate how the World Builder interface can be used, the following section outlines what is done in CHIC:
7+
8+
1. **Initialize the World Builder**:
9+
```fortran
10+
call create_world(cworld, 'path/to/world_file.wb', .false., '', 12345)
11+
```
12+
- the path to the `.wb` file has to be passed as an input to CHIC
13+
14+
2. **Query Temperature and Composition**:
15+
- pass domain boundaries as input to CHIC (analogous to the `.grid` files used for the gwb-grid app {ref}`part:user_manual:chap:how_to_use_the_apps:sec:gwb-grid_app`)
16+
- parse grid in given boundaries
17+
- overwrite values of temperature and composition at each position:
18+
```fortran
19+
! Query temperature at the given position
20+
call temperature_3d(cworld, x, y, z, depth, temperature)
21+
! Query composition at the given position
22+
call composition_3d(cworld, x, y, z, depth, composition_number, composition)
23+
```
24+
3. **Release the World Builder**:
25+
```fortran
26+
call release_world(cworld)
27+
```

doc/sphinx/api_manual/API_FFI/Fortran_interface.md renamed to doc/sphinx/api_manual/API_FFI/Fortran_interface/index.md

Lines changed: 13 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
(part:API_manual:chap:API_FFI:sec:Fortran_interface)=
1+
(part:API_manual:chap:API_FFI:sec:Fortran_interface:subsec:Fortran_integration)=
22
FORTRAN interface
33
===========
44

5-
Explanation of wrapper subroutines
6-
-----------
7-
85
The interface functions are defined in the Fortran wrapper module (`source/world_builder/wrapper_fortran.f90`). Here we provide short explanations for each function (subroutines in Fortran).
96

107
```{important}
@@ -13,14 +10,15 @@ To start the World Builder and create a world from a given `.wb` file, the `crea
1310

1411
```{code}
1512
subroutine create_world(cworld, file_name, has_output_dir, output_dir, random_number_seed)
13+
1614
Interface with the World Builder to create a world with a given `.wb` file
1715
18-
PARAMETERS
19-
cworld (C_PTR) - variable that points to the world pointer of the world builder
20-
file_name (string) - name of the `.wb` file to be used
21-
has_output_dir
22-
output_dir
23-
random_number_seed (long) - random seed used in creating the world
16+
Parameters:
17+
cworld (C_PTR) - Variable that points to the world pointer of the world builder
18+
file_name (C_CHAR) - Name of the `.wb` file to be used
19+
has_output_dir (C_BOOL) - If true, the World Builder gains permission to write files into the given directory (`output_dir`). Currently, these are the World Builder json schema and declarations file.
20+
output_dir (C_CHAR) - Path to directory where the files should be written into.
21+
random_number_seed (C_LONG) - Random seed used in creating the world
2422
```
2523

2624
After calling `create_world`, the world builder can be queried to output temperature and composition values at a given position. The subroutines for temperature and composition, each have a 2D and 3D variant. Each subroutine creates an interface with a c function of the world builder of the same name.
@@ -51,34 +49,12 @@ Output:
5149

5250
- value (of temperature or composition) at the position specified with x, (y,) z, depth
5351

54-
Example (CHIC)
55-
-----------
56-
57-
To illustrate how the World Builder interface can be used, the following section outlines what is done in CHIC:
58-
59-
1. **Initialize the World Builder**:
60-
```fortran
61-
call create_world(cworld, 'path/to/world_file.wb', .false., '', 12345)
62-
```
63-
- the path to the `.wb` file has to be passed as an input to CHIC
64-
65-
2. **Query Temperature and Composition**:
66-
- pass domain boundaries as input to CHIC (analogous to the `.grid` files used for the gwb-grid app {ref}`part:user_manual:chap:how_to_use_the_apps:sec:gwb-grid_app`)
67-
- parse grid in given boundaries
68-
- overwrite values of temperature and composition at each position:
69-
```fortran
70-
! Query temperature at the given position
71-
call temperature_3d(cworld, x, y, z, depth, temperature)
72-
! Query composition at the given position
73-
call composition_3d(cworld, x, y, z, depth, composition_number, composition)
74-
```
75-
3. **Release the World Builder**:
76-
```fortran
77-
call release_world(cworld)
78-
```
79-
8052
```{important}
81-
The `release_world` subroutine has to be called afterwards, in order to clean up the memory used by the World Builder.
53+
When done with the World Builder, the `release_world` subroutine has to be called to clean up the memory used by the World Builder.
54+
```
55+
56+
```{hint}
57+
A short explanation of how the World Builder is integrated into the Mantle Convection code CHIC can be found on the next page {ref}`part:API_manual:chap:API_FFI:sec:Fortran_interface:subsec:CHIC_integration`
8258
```
8359

8460
<!-- With the sphinx Fortran extension, the following syntax would be possible

0 commit comments

Comments
 (0)