Skip to content

Commit 240ded1

Browse files
committed
updated derived types for Fortran 2003, uses doxygen awesome tabs feature
1 parent ab17099 commit 240ded1

File tree

4 files changed

+121
-24
lines changed

4 files changed

+121
-24
lines changed

doxygen/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ if (DOXYGEN_FOUND)
2222
set (DOXYGEN_HTML_HEADER ${HDF5_DOXYGEN_DIR}/hdf5_header.html)
2323
set (DOXYGEN_HTML_FOOTER ${HDF5_DOXYGEN_DIR}/hdf5_footer.html)
2424
set (DOXYGEN_HTML_EXTRA_STYLESHEET "${HDF5_DOXYGEN_DIR}/hdf5doxy.css ${HDF5_DOXYGEN_DIR}/doxygen-awesome.css")
25-
set (DOXYGEN_HTML_EXTRA_FILES "${HDF5_DOXYGEN_DIR}/hdf5_navtree_hacks.js")
25+
set (DOXYGEN_HTML_EXTRA_FILES "${HDF5_DOXYGEN_DIR}/hdf5_navtree_hacks.js ${HDF5_DOXYGEN_DIR}/doxygen-awesome-tabs.js")
2626
set (DOXYGEN_TAG_FILE ${HDF5_BINARY_DIR}/hdf5.tag)
2727
set (DOXYGEN_SERVER_BASED_SEARCH NO)
2828
set (DOXYGEN_EXTERNAL_SEARCH NO)

doxygen/doxygen-awesome-tabs.js

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
/**
2+
3+
Doxygen Awesome
4+
https://github.com/jothepro/doxygen-awesome-css
5+
6+
MIT License
7+
8+
Copyright (c) 2023 jothepro
9+
10+
Permission is hereby granted, free of charge, to any person obtaining a copy
11+
of this software and associated documentation files (the "Software"), to deal
12+
in the Software without restriction, including without limitation the rights
13+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14+
copies of the Software, and to permit persons to whom the Software is
15+
furnished to do so, subject to the following conditions:
16+
17+
The above copyright notice and this permission notice shall be included in all
18+
copies or substantial portions of the Software.
19+
20+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26+
SOFTWARE.
27+
28+
*/
29+
30+
class DoxygenAwesomeTabs {
31+
32+
static init() {
33+
window.addEventListener("load", () => {
34+
document.querySelectorAll(".tabbed:not(:empty)").forEach((tabbed, tabbedIndex) => {
35+
let tabLinkList = []
36+
tabbed.querySelectorAll(":scope > ul > li").forEach((tab, tabIndex) => {
37+
tab.id = "tab_" + tabbedIndex + "_" + tabIndex
38+
let header = tab.querySelector(".tab-title")
39+
let tabLink = document.createElement("button")
40+
tabLink.classList.add("tab-button")
41+
tabLink.appendChild(header)
42+
header.title = header.textContent
43+
tabLink.addEventListener("click", () => {
44+
tabbed.querySelectorAll(":scope > ul > li").forEach((tab) => {
45+
tab.classList.remove("selected")
46+
})
47+
tabLinkList.forEach((tabLink) => {
48+
tabLink.classList.remove("active")
49+
})
50+
tab.classList.add("selected")
51+
tabLink.classList.add("active")
52+
})
53+
tabLinkList.push(tabLink)
54+
if(tabIndex == 0) {
55+
tab.classList.add("selected")
56+
tabLink.classList.add("active")
57+
}
58+
})
59+
let tabsOverview = document.createElement("div")
60+
tabsOverview.classList.add("tabs-overview")
61+
let tabsOverviewContainer = document.createElement("div")
62+
tabsOverviewContainer.classList.add("tabs-overview-container")
63+
tabLinkList.forEach((tabLink) => {
64+
tabsOverview.appendChild(tabLink)
65+
})
66+
tabsOverviewContainer.appendChild(tabsOverview)
67+
tabbed.before(tabsOverviewContainer)
68+
69+
function resize() {
70+
let maxTabHeight = 0
71+
tabbed.querySelectorAll(":scope > ul > li").forEach((tab, tabIndex) => {
72+
let visibility = tab.style.display
73+
tab.style.display = "block"
74+
maxTabHeight = Math.max(tab.offsetHeight, maxTabHeight)
75+
tab.style.display = visibility
76+
})
77+
tabbed.style.height = `${maxTabHeight + 10}px`
78+
}
79+
80+
resize()
81+
new ResizeObserver(resize).observe(tabbed)
82+
})
83+
})
84+
85+
}
86+
87+
static resize(tabbed) {
88+
89+
}
90+
}

doxygen/hdf5_header.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@
2424
<script type="text/javascript" src="$relpath$hdf5_navtree_hacks.js"></script>
2525

2626
<div style="background:#FFDDDD;font-size:120%;text-align:center;margin:0;padding:5px">Please, help us to better serve our user community by answering the following short survey: <a href="https://www.hdfgroup.org/website-survey/">https://www.hdfgroup.org/website-survey/</a></div>
27-
27+
<!-- ... other metadata & script includes ... -->
28+
<script type="text/javascript" src="$relpath^doxygen-awesome-tabs.js"></script>
29+
<script type="text/javascript">
30+
DoxygenAwesomeTabs.init()
31+
</script>
2832
</head>
2933
<body>
3034
<!--BEGIN DISABLE_INDEX-->

src/H5Tmodule.h

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2008,12 +2008,13 @@ filled according to the value of this property. The padding can be:
20082008
* an instance of the struct. The HDF5 C library includes a macro, #HOFFSET (s, m), which
20092009
* calculates the offset of member \Emph{m} within struct \Emph{s}. Alternatively, the
20102010
* `offsetof(s, m)` macro, defined in \Emph{stddef.h}, serves the same purpose as the
2011-
* `HOFFSET` macro. For Fortran users, the HDF5 library provides the function #H5OFFSETOF
2012-
* to determine the offset of a member. Note, in the past, the HDF5 Fortran applications
2013-
* had to calculate offsets by using sizes of members datatypes and by considering the order
2014-
* of members in the Fortran derived type, thuse offsets of fortran structure members
2015-
* corresponded to the offsets within a packed datatype (see explanation below)
2016-
* stored in an HDF5 file.
2011+
* `HOFFSET` macro. For Fortran users, the HDF5 library provides the function
2012+
* \ref h5lib.h5offsetof to determine the offset of a member. To find the size of a
2013+
* scalar derived type, the fortran function equivalant of the \Emph{sizeof} can be used.
2014+
* Note, in the past, the HDF5 Fortran applications had to calculate offsets by using sizes of
2015+
* members datatypes and by considering the order of members in the Fortran derived type, thus
2016+
* offsets of Fortran structure members corresponded to the offsets within a packed datatype
2017+
* (see explanation below) stored in an HDF5 file.
20172018
*
20182019
* Each member of a compound datatype must have a descriptive name which is the key used to
20192020
* uniquely identify the member within the compound datatype. A member name in an HDF5
@@ -2051,7 +2052,10 @@ filled according to the value of this property. The padding can be:
20512052
* and each component is DOUBLE PRECISION. An equivalent Fortran TYPE whose type is defined
20522053
* by the TYPE complex_t is shown.
20532054
*
2054-
* <em>A compound datatype for complex numbers in Fortran 2003</em>
2055+
* <em>A compound datatype for complex numbers in Fortran</em>
2056+
*
2057+
* <div class="tabbed">
2058+
* - <b class="tab-title">Fortran 2003</b>
20552059
* \code
20562060
* TYPE complex_t
20572061
* DOUBLE PRECISION re ! real part
@@ -2066,8 +2070,7 @@ filled according to the value of this property. The padding can be:
20662070
* offset = H5OFFSETOF(C_LOC(cmplx),C_LOC(cmplx%im))
20672071
* CALL h5tinsert_f(type_id, “imaginary”, offset, H5T_NATIVE_DOUBLE, error)
20682072
* \endcode
2069-
*
2070-
* <em>A compound datatype for complex numbers, pre-Fortran2003 (Obsolete)</em>
2073+
* - <b class="tab-title">Fortran (Obsolete)</b>
20712074
* \code
20722075
* TYPE complex_t
20732076
* DOUBLE PRECISION re ! real part
@@ -2083,7 +2086,8 @@ filled according to the value of this property. The padding can be:
20832086
* offset = offset + re_size
20842087
* CALL h5tinsert_f(type_id, “imaginary”, offset, H5T_NATIVE_DOUBLE, error)
20852088
* \endcode
2086-
2089+
* </div>
2090+
*
20872091
* Important Note: The compound datatype is created with a size sufficient to hold all its members.
20882092
* In the C example above, the size of the C struct and the #HOFFSET macro are used as a
20892093
* convenient mechanism to determine the appropriate size and offset. Alternatively, the size and
@@ -2215,7 +2219,6 @@ filled according to the value of this property. The padding can be:
22152219
* to the sum of the sizes of the previous members. However, with the introduction of Fortran 2003,
22162220
* this is no longer the case, and the same considerations that apply to C also apply to Fortran.
22172221
*
2218-
*
22192222
* <em>Create a packed compound datatype in Fortran</em>
22202223
* \code
22212224
* CALL h5tcopy_f(s1_id, s2_id, error)
@@ -2233,7 +2236,6 @@ filled according to the value of this property. The padding can be:
22332236
* The example below shows a C example of creating and writing a dataset with a compound
22342237
* datatype.
22352238
*
2236-
*
22372239
* <em>Create and write a dataset with a compound datatype in C</em>
22382240
* \code
22392241
* typedef struct s1_t {
@@ -2385,10 +2387,12 @@ filled according to the value of this property. The padding can be:
23852387
* }
23862388
* \endcode
23872389
*
2388-
* The preferred example below contains a Fortran 2003 demonstration that creates
2389-
* and writes a dataset using a compound datatype.
2390+
* <em>Create and write a dataset with a compound datatype in Fortran </em>
23902391
*
2391-
* <em>Create and write a dataset with a compound datatype, Fortran 2003</em>
2392+
* <div class="tabbed">
2393+
* - <b class="tab-title">Fortran 2003</b>
2394+
* The following example demonstrates how to create and write a dataset using a compound
2395+
* datatype in Fortran 2003.
23922396
* \code
23932397
* TYPE s1_t
23942398
* INTEGER :: a
@@ -2419,13 +2423,11 @@ filled according to the value of this property. The padding can be:
24192423
* CALL H5Dcreate_f(file_id, “SDScompound.h5”, s1_t, space_id, dataset_id, error)
24202424
* CALL H5Dwrite_f(dataset_id, s1_tid, C_LOC(data(1)), error)
24212425
* \endcode
2422-
*
2423-
* The example below contains a pre-Fortran 2003 (obsolete) example that creates and writes a
2424-
* dataset with a compound datatype. As this example illustrates, writing and reading compound
2425-
* datatypes in Fortran 90 is always done by fields. The content of the written file is the same
2426-
* as shown in the example above.
2427-
*
2428-
* <em>Create and write a dataset with a compound datatype, pre-Fortran 2003 (obsolete)</em>
2426+
* - <b class="tab-title">Fortran (Obsolete)</b>
2427+
* The following example demonstrates creating and writing a dataset with a compound datatype
2428+
* using pre-Fortran 2003 standards. As illustrated in Fortran 90, writing and reading compound
2429+
* datatypes is always done by fields. The content of the written file matches the example
2430+
* provided previously.
24292431
* \code
24302432
* ! One cannot write an array of a derived datatype in
24312433
* ! Fortran 90.
@@ -2521,6 +2523,7 @@ filled according to the value of this property. The padding can be:
25212523
* CALL h5dwrite_f(dset_id, dt2_id, b, data_dims, error, xfer_prp = plist_id)
25222524
* CALL h5dwrite_f(dset_id, dt1_id, a, data_dims, error, xfer_prp = plist_id)
25232525
* \endcode
2526+
* </div>
25242527
*
25252528
* <h4>Reading Datasets with Compound Datatypes</h4>
25262529
*

0 commit comments

Comments
 (0)