├── code └── .gitkeep ├── data └── .gitkeep ├── fig ├── .gitkeep ├── 2_performance │ ├── balance.jpg │ ├── neigh_list.jpg │ └── start_sim_box.jpg └── 5_replica_exchange │ ├── RG.png │ ├── polymer.png │ ├── structures.png │ ├── traversal.png │ ├── phase_space.png │ └── metropolis_exchange.png ├── img ├── .gitkeep ├── epcc_logo.jpg └── archer2_logo.png ├── _episodes ├── .gitkeep ├── 031-lunch.md ├── 111-lunch.md ├── 011-break.md ├── 051-break.md ├── 091-break.md ├── 131-break.md ├── 12-type-parameters.md └── 13-intrinsic-modules.md ├── _extras ├── .gitkeep ├── about.md ├── guide.md ├── discuss.md └── figures.md ├── exercises ├── .gitkeep ├── 09-abstract-types │ ├── file_module.f90 │ ├── example1.f90 │ └── solutions │ │ ├── example1.f90 │ │ ├── example2.f90 │ │ └── file_module.f90 ├── 01-arrays │ ├── bounds-compile-time.f90 │ ├── problem2.f90 │ ├── problem3.f90 │ ├── bounds-run-time.f90 │ └── problem1.f90 ├── 03-more-on-pointers │ ├── example2.f90 │ ├── external.f90 │ ├── example1.f90 │ └── solutions │ │ ├── example2.f90 │ │ └── example1.f90 ├── 05-interfaces-overloading │ ├── my_vector_type.f90 │ ├── example3.f90 │ ├── example1.f90 │ ├── example2.f90 │ └── my_array_type.f90 ├── 04-derived-types │ ├── example1.f90 │ ├── solutions │ │ ├── example1.f90 │ │ ├── example2.f90 │ │ ├── my_semi_opaque_type.f90 │ │ └── my_array_type.f90 │ ├── example2.f90 │ ├── my_semi_opaque_type.f90 │ └── my_array_type.f90 ├── 14-interoperability-with-c │ ├── c_array.c │ ├── c_snprintf.c │ ├── solutions │ │ ├── c_struct_to_fortran.c │ │ ├── f_array.f90 │ │ ├── f_array_t.f90 │ │ └── f_snprintf.f90 │ └── print_iso_c_binding.f90 ├── 10-modules-again │ ├── example_submodule.f90 │ ├── example_module.f90 │ └── solutions │ │ ├── example2.f90 │ │ ├── file_submodule.f90 │ │ ├── file_module.f90 │ │ ├── file_formatted.f90 │ │ └── file_unformatted.f90 ├── 06-type-extension-polypmorphism │ ├── object_type.f90 │ ├── example2.f90 │ ├── example1.f90 │ └── solutions │ │ ├── example1.f90 │ │ ├── example2.f90 │ │ └── object_type.f90 ├── 08-generic-io-for-derived-types │ ├── date_program.f90 │ ├── solutions │ │ ├── date_program.f90 │ │ └── date_module.f90 │ └── date_module.f90 ├── 02-arrays-as-arguments │ ├── example2.f90 │ ├── example1.f90 │ └── solutions │ │ └── exercise1.f90 ├── 07-type-bound-procedures │ ├── object_type.f90 │ ├── example1.f90 │ └── solutions │ │ ├── example1.f90 │ │ └── object_type.f90 ├── 11-unlimited-polymorphic-entities │ ├── example1.f90 │ ├── key_value_program.f90 │ ├── solutions │ │ └── key_value_program.f90 │ └── key_value_module.f90 ├── 12-type-parameters │ └── example1.f90 └── 13-intrinsic-modules │ └── print_iso_fortran_env.f90 ├── _episodes_rmd ├── .gitkeep └── data │ └── .gitkeep ├── AUTHORS ├── bin ├── boilerplate │ ├── CITATION │ ├── AUTHORS │ ├── setup.md │ ├── _extras │ │ ├── discuss.md │ │ ├── guide.md │ │ ├── about.md │ │ └── figures.md │ ├── reference.md │ ├── _episodes │ │ └── 01-introduction.md │ ├── index.md │ ├── README.md │ ├── .travis.yml │ ├── aio.md │ └── _config.yml ├── knit_lessons.sh ├── markdown_ast.rb ├── test_lesson_check.py ├── lesson_initialize.py ├── generate_md_episodes.R └── chunk-options.R ├── reference.md ├── CITATION ├── _layouts ├── page.html ├── reference.html ├── lesson.html ├── break.html ├── episode.html ├── base.html └── workshop.html ├── assets ├── img │ ├── lc-icon-black.png │ ├── lc-logo-black.png │ ├── swc-logo-blue.png │ ├── swc-logo-white.png │ ├── cp-logo-blue.svg │ └── swc-icon-blue.svg ├── favicons │ ├── cp │ │ ├── favicon.ico │ │ ├── favicon-128.png │ │ ├── favicon-16x16.png │ │ ├── favicon-32x32.png │ │ ├── favicon-96x96.png │ │ ├── mstile-144x144.png │ │ ├── mstile-150x150.png │ │ ├── mstile-310x150.png │ │ ├── mstile-310x310.png │ │ ├── mstile-70x70.png │ │ ├── favicon-196x196.png │ │ ├── apple-touch-icon-114x114.png │ │ ├── apple-touch-icon-120x120.png │ │ ├── apple-touch-icon-144x144.png │ │ ├── apple-touch-icon-152x152.png │ │ ├── apple-touch-icon-57x57.png │ │ ├── apple-touch-icon-60x60.png │ │ ├── apple-touch-icon-72x72.png │ │ └── apple-touch-icon-76x76.png │ ├── dc │ │ ├── favicon.ico │ │ ├── favicon-128.png │ │ ├── favicon-16x16.png │ │ ├── favicon-32x32.png │ │ ├── favicon-96x96.png │ │ ├── mstile-144x144.png │ │ ├── mstile-150x150.png │ │ ├── mstile-310x150.png │ │ ├── mstile-310x310.png │ │ ├── mstile-70x70.png │ │ ├── favicon-196x196.png │ │ ├── apple-touch-icon-114x114.png │ │ ├── apple-touch-icon-120x120.png │ │ ├── apple-touch-icon-144x144.png │ │ ├── apple-touch-icon-152x152.png │ │ ├── apple-touch-icon-57x57.png │ │ ├── apple-touch-icon-60x60.png │ │ ├── apple-touch-icon-72x72.png │ │ └── apple-touch-icon-76x76.png │ ├── lc │ │ ├── favicon.ico │ │ ├── favicon-128.png │ │ ├── favicon-16x16.png │ │ ├── favicon-32x32.png │ │ ├── favicon-96x96.png │ │ ├── mstile-144x144.png │ │ ├── mstile-150x150.png │ │ ├── mstile-310x150.png │ │ ├── mstile-310x310.png │ │ ├── mstile-70x70.png │ │ ├── favicon-196x196.png │ │ ├── apple-touch-icon-114x114.png │ │ ├── apple-touch-icon-120x120.png │ │ ├── apple-touch-icon-144x144.png │ │ ├── apple-touch-icon-152x152.png │ │ ├── apple-touch-icon-57x57.png │ │ ├── apple-touch-icon-60x60.png │ │ ├── apple-touch-icon-72x72.png │ │ └── apple-touch-icon-76x76.png │ └── swc │ │ ├── favicon.ico │ │ ├── favicon-128.png │ │ ├── favicon-16x16.png │ │ ├── favicon-32x32.png │ │ ├── favicon-96x96.png │ │ ├── mstile-70x70.png │ │ ├── favicon-196x196.png │ │ ├── mstile-144x144.png │ │ ├── mstile-150x150.png │ │ ├── mstile-310x150.png │ │ ├── mstile-310x310.png │ │ ├── apple-touch-icon-57x57.png │ │ ├── apple-touch-icon-60x60.png │ │ ├── apple-touch-icon-72x72.png │ │ ├── apple-touch-icon-76x76.png │ │ ├── apple-touch-icon-114x114.png │ │ ├── apple-touch-icon-120x120.png │ │ ├── apple-touch-icon-144x144.png │ │ └── apple-touch-icon-152x152.png ├── fonts │ ├── glyphicons-halflings-regular.eot │ ├── glyphicons-halflings-regular.ttf │ ├── glyphicons-halflings-regular.woff │ └── glyphicons-halflings-regular.woff2 ├── js │ └── lesson.js └── css │ └── syntax.css ├── README.md ├── _includes ├── episode_title.html ├── dc │ ├── who.html │ ├── intro.html │ ├── schedule.html │ └── syllabus.html ├── sc │ ├── who.html │ ├── intro.html │ ├── schedule.html │ └── syllabus.html ├── main_title.html ├── lc │ ├── who.html │ ├── intro.html │ ├── schedule.html │ └── syllabus.html ├── episode_keypoints.html ├── figure.html ├── episode_break.html ├── workshop_calendar.html ├── all_keypoints.html ├── javascript.html ├── workshop_footer.html ├── life_cycle.html ├── episode_overview.html ├── workshop_ad.html ├── base_path.html ├── episode_navbar.html ├── gh_variables.html ├── lesson_footer.html ├── favicons.html ├── syllabus.html ├── navbar.html ├── carpentries.html └── links.md ├── CODE_OF_CONDUCT.md ├── setup.md ├── aio.md ├── LICENSE.md ├── _config.yml ├── Makefile └── CONTRIBUTING.md /code/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /data/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fig/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /img/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /_episodes/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /_extras/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /exercises/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /_episodes_rmd/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /_episodes_rmd/data/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | EPCC, The University of Edinburgh 2 | -------------------------------------------------------------------------------- /bin/boilerplate/CITATION: -------------------------------------------------------------------------------- 1 | FIXME: describe how to cite this lesson. -------------------------------------------------------------------------------- /bin/boilerplate/AUTHORS: -------------------------------------------------------------------------------- 1 | FIXME: list authors' names and email addresses. -------------------------------------------------------------------------------- /reference.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: reference 3 | --- 4 | 5 | {% include links.md %} 6 | -------------------------------------------------------------------------------- /CITATION: -------------------------------------------------------------------------------- 1 | This lesson is not official and is unlikely to be a good target for citation. 2 | -------------------------------------------------------------------------------- /_episodes/031-lunch.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Lunch" 3 | break: 60 4 | --- 5 | 6 | Lunch break. 7 | -------------------------------------------------------------------------------- /_episodes/111-lunch.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Lunch" 3 | break: 60 4 | --- 5 | 6 | Lunch break. 7 | -------------------------------------------------------------------------------- /_episodes/011-break.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Break" 3 | break: 30 4 | --- 5 | 6 | Comfort break. 7 | -------------------------------------------------------------------------------- /_episodes/051-break.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Break" 3 | break: 15 4 | --- 5 | 6 | Comfort break. 7 | -------------------------------------------------------------------------------- /_episodes/091-break.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Break" 3 | break: 30 4 | --- 5 | 6 | Comfort break. 7 | -------------------------------------------------------------------------------- /_episodes/131-break.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Break" 3 | break: 30 4 | --- 5 | 6 | Comfort break. 7 | -------------------------------------------------------------------------------- /bin/boilerplate/setup.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Setup 3 | --- 4 | FIXME 5 | 6 | 7 | {% include links.md %} 8 | -------------------------------------------------------------------------------- /img/epcc_logo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/img/epcc_logo.jpg -------------------------------------------------------------------------------- /_extras/about.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: About 3 | --- 4 | {% include carpentries.html %} 5 | {% include links.md %} 6 | -------------------------------------------------------------------------------- /bin/boilerplate/_extras/discuss.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Discussion 3 | --- 4 | FIXME 5 | 6 | {% include links.md %} 7 | -------------------------------------------------------------------------------- /img/archer2_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/img/archer2_logo.png -------------------------------------------------------------------------------- /bin/boilerplate/_extras/guide.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Instructor Notes" 3 | --- 4 | FIXME 5 | 6 | {% include links.md %} 7 | -------------------------------------------------------------------------------- /exercises/09-abstract-types/file_module.f90: -------------------------------------------------------------------------------- 1 | module file_module 2 | 3 | implicit none 4 | 5 | end module file_module 6 | -------------------------------------------------------------------------------- /bin/boilerplate/_extras/about.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: About 3 | --- 4 | {% include carpentries.html %} 5 | {% include links.md %} 6 | -------------------------------------------------------------------------------- /_layouts/page.html: -------------------------------------------------------------------------------- 1 | --- 2 | layout: base 3 | --- 4 | {% include main_title.html %} 5 |
6 | {{content}} 7 |
8 | -------------------------------------------------------------------------------- /_layouts/reference.html: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: "Reference" 4 | --- 5 | {% include all_keypoints.html %} 6 | {{content}} 7 | -------------------------------------------------------------------------------- /assets/img/lc-icon-black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/img/lc-icon-black.png -------------------------------------------------------------------------------- /assets/img/lc-logo-black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/img/lc-logo-black.png -------------------------------------------------------------------------------- /assets/img/swc-logo-blue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/img/swc-logo-blue.png -------------------------------------------------------------------------------- /assets/img/swc-logo-white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/img/swc-logo-white.png -------------------------------------------------------------------------------- /fig/2_performance/balance.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/fig/2_performance/balance.jpg -------------------------------------------------------------------------------- /fig/5_replica_exchange/RG.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/fig/5_replica_exchange/RG.png -------------------------------------------------------------------------------- /assets/favicons/cp/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/cp/favicon.ico -------------------------------------------------------------------------------- /assets/favicons/dc/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/dc/favicon.ico -------------------------------------------------------------------------------- /assets/favicons/lc/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/lc/favicon.ico -------------------------------------------------------------------------------- /assets/favicons/swc/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/swc/favicon.ico -------------------------------------------------------------------------------- /fig/2_performance/neigh_list.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/fig/2_performance/neigh_list.jpg -------------------------------------------------------------------------------- /_extras/guide.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Instructor Notes" 3 | --- 4 | There are no specific instructor notes yet. 5 | 6 | {% include links.md %} 7 | -------------------------------------------------------------------------------- /assets/favicons/cp/favicon-128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/cp/favicon-128.png -------------------------------------------------------------------------------- /assets/favicons/dc/favicon-128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/dc/favicon-128.png -------------------------------------------------------------------------------- /assets/favicons/lc/favicon-128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/lc/favicon-128.png -------------------------------------------------------------------------------- /fig/5_replica_exchange/polymer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/fig/5_replica_exchange/polymer.png -------------------------------------------------------------------------------- /assets/favicons/cp/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/cp/favicon-16x16.png -------------------------------------------------------------------------------- /assets/favicons/cp/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/cp/favicon-32x32.png -------------------------------------------------------------------------------- /assets/favicons/cp/favicon-96x96.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/cp/favicon-96x96.png -------------------------------------------------------------------------------- /assets/favicons/cp/mstile-144x144.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/cp/mstile-144x144.png -------------------------------------------------------------------------------- /assets/favicons/cp/mstile-150x150.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/cp/mstile-150x150.png -------------------------------------------------------------------------------- /assets/favicons/cp/mstile-310x150.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/cp/mstile-310x150.png -------------------------------------------------------------------------------- /assets/favicons/cp/mstile-310x310.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/cp/mstile-310x310.png -------------------------------------------------------------------------------- /assets/favicons/cp/mstile-70x70.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/cp/mstile-70x70.png -------------------------------------------------------------------------------- /assets/favicons/dc/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/dc/favicon-16x16.png -------------------------------------------------------------------------------- /assets/favicons/dc/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/dc/favicon-32x32.png -------------------------------------------------------------------------------- /assets/favicons/dc/favicon-96x96.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/dc/favicon-96x96.png -------------------------------------------------------------------------------- /assets/favicons/dc/mstile-144x144.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/dc/mstile-144x144.png -------------------------------------------------------------------------------- /assets/favicons/dc/mstile-150x150.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/dc/mstile-150x150.png -------------------------------------------------------------------------------- /assets/favicons/dc/mstile-310x150.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/dc/mstile-310x150.png -------------------------------------------------------------------------------- /assets/favicons/dc/mstile-310x310.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/dc/mstile-310x310.png -------------------------------------------------------------------------------- /assets/favicons/dc/mstile-70x70.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/dc/mstile-70x70.png -------------------------------------------------------------------------------- /assets/favicons/lc/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/lc/favicon-16x16.png -------------------------------------------------------------------------------- /assets/favicons/lc/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/lc/favicon-32x32.png -------------------------------------------------------------------------------- /assets/favicons/lc/favicon-96x96.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/lc/favicon-96x96.png -------------------------------------------------------------------------------- /assets/favicons/lc/mstile-144x144.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/lc/mstile-144x144.png -------------------------------------------------------------------------------- /assets/favicons/lc/mstile-150x150.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/lc/mstile-150x150.png -------------------------------------------------------------------------------- /assets/favicons/lc/mstile-310x150.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/lc/mstile-310x150.png -------------------------------------------------------------------------------- /assets/favicons/lc/mstile-310x310.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/lc/mstile-310x310.png -------------------------------------------------------------------------------- /assets/favicons/lc/mstile-70x70.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/lc/mstile-70x70.png -------------------------------------------------------------------------------- /assets/favicons/swc/favicon-128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/swc/favicon-128.png -------------------------------------------------------------------------------- /assets/favicons/swc/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/swc/favicon-16x16.png -------------------------------------------------------------------------------- /assets/favicons/swc/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/swc/favicon-32x32.png -------------------------------------------------------------------------------- /assets/favicons/swc/favicon-96x96.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/swc/favicon-96x96.png -------------------------------------------------------------------------------- /assets/favicons/swc/mstile-70x70.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/swc/mstile-70x70.png -------------------------------------------------------------------------------- /bin/boilerplate/reference.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: reference 3 | --- 4 | 5 | ## Glossary 6 | 7 | FIXME 8 | 9 | {% include links.md %} 10 | -------------------------------------------------------------------------------- /fig/2_performance/start_sim_box.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/fig/2_performance/start_sim_box.jpg -------------------------------------------------------------------------------- /fig/5_replica_exchange/structures.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/fig/5_replica_exchange/structures.png -------------------------------------------------------------------------------- /fig/5_replica_exchange/traversal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/fig/5_replica_exchange/traversal.png -------------------------------------------------------------------------------- /assets/favicons/cp/favicon-196x196.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/cp/favicon-196x196.png -------------------------------------------------------------------------------- /assets/favicons/dc/favicon-196x196.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/dc/favicon-196x196.png -------------------------------------------------------------------------------- /assets/favicons/lc/favicon-196x196.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/lc/favicon-196x196.png -------------------------------------------------------------------------------- /assets/favicons/swc/favicon-196x196.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/swc/favicon-196x196.png -------------------------------------------------------------------------------- /assets/favicons/swc/mstile-144x144.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/swc/mstile-144x144.png -------------------------------------------------------------------------------- /assets/favicons/swc/mstile-150x150.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/swc/mstile-150x150.png -------------------------------------------------------------------------------- /assets/favicons/swc/mstile-310x150.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/swc/mstile-310x150.png -------------------------------------------------------------------------------- /assets/favicons/swc/mstile-310x310.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/swc/mstile-310x310.png -------------------------------------------------------------------------------- /fig/5_replica_exchange/phase_space.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/fig/5_replica_exchange/phase_space.png -------------------------------------------------------------------------------- /_layouts/lesson.html: -------------------------------------------------------------------------------- 1 | --- 2 | layout: base 3 | --- 4 | {% include main_title.html %} 5 |
6 | {{ content }} 7 |
8 | {% include syllabus.html %} 9 | -------------------------------------------------------------------------------- /assets/favicons/cp/apple-touch-icon-114x114.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/cp/apple-touch-icon-114x114.png -------------------------------------------------------------------------------- /assets/favicons/cp/apple-touch-icon-120x120.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/cp/apple-touch-icon-120x120.png -------------------------------------------------------------------------------- /assets/favicons/cp/apple-touch-icon-144x144.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/cp/apple-touch-icon-144x144.png -------------------------------------------------------------------------------- /assets/favicons/cp/apple-touch-icon-152x152.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/cp/apple-touch-icon-152x152.png -------------------------------------------------------------------------------- /assets/favicons/cp/apple-touch-icon-57x57.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/cp/apple-touch-icon-57x57.png -------------------------------------------------------------------------------- /assets/favicons/cp/apple-touch-icon-60x60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/cp/apple-touch-icon-60x60.png -------------------------------------------------------------------------------- /assets/favicons/cp/apple-touch-icon-72x72.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/cp/apple-touch-icon-72x72.png -------------------------------------------------------------------------------- /assets/favicons/cp/apple-touch-icon-76x76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/cp/apple-touch-icon-76x76.png -------------------------------------------------------------------------------- /assets/favicons/dc/apple-touch-icon-114x114.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/dc/apple-touch-icon-114x114.png -------------------------------------------------------------------------------- /assets/favicons/dc/apple-touch-icon-120x120.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/dc/apple-touch-icon-120x120.png -------------------------------------------------------------------------------- /assets/favicons/dc/apple-touch-icon-144x144.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/dc/apple-touch-icon-144x144.png -------------------------------------------------------------------------------- /assets/favicons/dc/apple-touch-icon-152x152.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/dc/apple-touch-icon-152x152.png -------------------------------------------------------------------------------- /assets/favicons/dc/apple-touch-icon-57x57.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/dc/apple-touch-icon-57x57.png -------------------------------------------------------------------------------- /assets/favicons/dc/apple-touch-icon-60x60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/dc/apple-touch-icon-60x60.png -------------------------------------------------------------------------------- /assets/favicons/dc/apple-touch-icon-72x72.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/dc/apple-touch-icon-72x72.png -------------------------------------------------------------------------------- /assets/favicons/dc/apple-touch-icon-76x76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/dc/apple-touch-icon-76x76.png -------------------------------------------------------------------------------- /assets/favicons/lc/apple-touch-icon-114x114.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/lc/apple-touch-icon-114x114.png -------------------------------------------------------------------------------- /assets/favicons/lc/apple-touch-icon-120x120.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/lc/apple-touch-icon-120x120.png -------------------------------------------------------------------------------- /assets/favicons/lc/apple-touch-icon-144x144.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/lc/apple-touch-icon-144x144.png -------------------------------------------------------------------------------- /assets/favicons/lc/apple-touch-icon-152x152.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/lc/apple-touch-icon-152x152.png -------------------------------------------------------------------------------- /assets/favicons/lc/apple-touch-icon-57x57.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/lc/apple-touch-icon-57x57.png -------------------------------------------------------------------------------- /assets/favicons/lc/apple-touch-icon-60x60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/lc/apple-touch-icon-60x60.png -------------------------------------------------------------------------------- /assets/favicons/lc/apple-touch-icon-72x72.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/lc/apple-touch-icon-72x72.png -------------------------------------------------------------------------------- /assets/favicons/lc/apple-touch-icon-76x76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/lc/apple-touch-icon-76x76.png -------------------------------------------------------------------------------- /assets/favicons/swc/apple-touch-icon-57x57.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/swc/apple-touch-icon-57x57.png -------------------------------------------------------------------------------- /assets/favicons/swc/apple-touch-icon-60x60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/swc/apple-touch-icon-60x60.png -------------------------------------------------------------------------------- /assets/favicons/swc/apple-touch-icon-72x72.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/swc/apple-touch-icon-72x72.png -------------------------------------------------------------------------------- /assets/favicons/swc/apple-touch-icon-76x76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/swc/apple-touch-icon-76x76.png -------------------------------------------------------------------------------- /assets/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /assets/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /assets/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /assets/fonts/glyphicons-halflings-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/fonts/glyphicons-halflings-regular.woff2 -------------------------------------------------------------------------------- /fig/5_replica_exchange/metropolis_exchange.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/fig/5_replica_exchange/metropolis_exchange.png -------------------------------------------------------------------------------- /assets/favicons/swc/apple-touch-icon-114x114.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/swc/apple-touch-icon-114x114.png -------------------------------------------------------------------------------- /assets/favicons/swc/apple-touch-icon-120x120.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/swc/apple-touch-icon-120x120.png -------------------------------------------------------------------------------- /assets/favicons/swc/apple-touch-icon-144x144.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/swc/apple-touch-icon-144x144.png -------------------------------------------------------------------------------- /assets/favicons/swc/apple-touch-icon-152x152.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EPCCed/2025-05-22-MO-Fortran-inter/gh-pages/assets/favicons/swc/apple-touch-icon-152x152.png -------------------------------------------------------------------------------- /_extras/discuss.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Discussion 3 | --- 4 | There will hopefully be discussion to add after the session has been run at ResBaz 2019 Dunedin. 5 | 6 | {% include links.md %} 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ARCHER2 Advanced use of LAMMPS (31 March 2022) 2 | 3 | ## Course timetable 4 | 5 | This is a one-day advanced use of LAMMPS course. 6 | 7 | The rendered course is available at TODO 8 | -------------------------------------------------------------------------------- /exercises/01-arrays/bounds-compile-time.f90: -------------------------------------------------------------------------------- 1 | program bounds_check1 2 | 3 | ! Compile time error 4 | implicit none 5 | real :: array(3) 6 | 7 | print *, "First array element ", array(0) 8 | 9 | end program bounds_check1 10 | -------------------------------------------------------------------------------- /exercises/03-more-on-pointers/example2.f90: -------------------------------------------------------------------------------- 1 | program example2 2 | 3 | implicit none 4 | 5 | procedure (integer) :: array_size 6 | real :: a(13) 7 | 8 | print *, "size of a is: ", array_size(a) 9 | 10 | end program example2 11 | -------------------------------------------------------------------------------- /exercises/03-more-on-pointers/external.f90: -------------------------------------------------------------------------------- 1 | function array_size(a) result(isize) 2 | 3 | real, dimension(:), intent(in) :: a 4 | integer :: isize 5 | 6 | isize = size(a) 7 | 8 | end function array_size 9 | -------------------------------------------------------------------------------- /_includes/episode_title.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |
5 |

{{ page.title }}

6 |
7 |
8 |
9 |
10 | -------------------------------------------------------------------------------- /exercises/03-more-on-pointers/example1.f90: -------------------------------------------------------------------------------- 1 | program example1 2 | 3 | implicit none 4 | 5 | 6 | ! print pointer lower bound lbound() 7 | ! print pointer upper bound ubound() 8 | ! check size and elements 9 | 10 | end program example1 11 | -------------------------------------------------------------------------------- /bin/knit_lessons.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Only try running R to translate files if there are some files present. 4 | # The Makefile passes in the names of files. 5 | 6 | if [ $# -eq 2 ] ; then 7 | Rscript -e "source('bin/generate_md_episodes.R')" "$@" 8 | fi 9 | -------------------------------------------------------------------------------- /exercises/05-interfaces-overloading/my_vector_type.f90: -------------------------------------------------------------------------------- 1 | module my_vector_type 2 | 3 | implicit none 4 | public 5 | 6 | type, public :: my_vector_t 7 | integer :: x, y, z 8 | end type my_vector_t 9 | 10 | contains 11 | 12 | end module my_vector_type 13 | -------------------------------------------------------------------------------- /exercises/01-arrays/problem2.f90: -------------------------------------------------------------------------------- 1 | program problem2 2 | 3 | implicit none 4 | 5 | ! Initialise t(1:3) to the initial values 10, 20, 40 6 | 7 | real :: t(3) = [ (2.0*(i**2 + 1), i = 1,3) ] 8 | 9 | print *, "Initial values ", t(1:3) 10 | 11 | end program problem2 12 | -------------------------------------------------------------------------------- /_includes/dc/who.html: -------------------------------------------------------------------------------- 1 |

2 | Who: 3 | The course is aimed at graduate students and other researchers. 4 | 5 | You don't need to have any previous knowledge of the tools 6 | that will be presented at the workshop. 7 | 8 |

9 | -------------------------------------------------------------------------------- /_includes/sc/who.html: -------------------------------------------------------------------------------- 1 |

2 | Who: 3 | The course is aimed at graduate students and other researchers. 4 | 5 | You don't need to have any previous knowledge of the tools 6 | that will be presented at the workshop. 7 | 8 |

9 | -------------------------------------------------------------------------------- /_includes/main_title.html: -------------------------------------------------------------------------------- 1 | {% comment %} 2 | Main title for lesson pages. 3 | {% endcomment %} 4 | 5 | {% include base_path.html %} 6 | 7 |

{{ site.title }}{% if page.title %}: {{ page.title }}{% endif %}

8 | -------------------------------------------------------------------------------- /_includes/lc/who.html: -------------------------------------------------------------------------------- 1 |

2 | Who: 3 | The course is for people working in library- and information-related roles. 4 | 5 | You don't need to have any previous knowledge of the tools that 6 | will be presented at the workshop. 7 | 8 |

9 | -------------------------------------------------------------------------------- /_layouts/break.html: -------------------------------------------------------------------------------- 1 | --- 2 | layout: base 3 | --- 4 | {% include episode_navbar.html episode_navbar_title=true %} 5 |
6 | {% include episode_title.html %} 7 | {% include episode_break.html %} 8 | {{content}} 9 |
10 | {% include episode_navbar.html episode_navbar_title=false %} 11 | -------------------------------------------------------------------------------- /bin/markdown_ast.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | # Use Kramdown parser to produce AST for Markdown document. 4 | 5 | require "kramdown" 6 | require "json" 7 | 8 | markdown = STDIN.read() 9 | doc = Kramdown::Document.new(markdown) 10 | tree = doc.to_hash_a_s_t 11 | puts JSON.pretty_generate(tree) 12 | -------------------------------------------------------------------------------- /exercises/04-derived-types/example1.f90: -------------------------------------------------------------------------------- 1 | program example1 2 | 3 | use my_semi_opaque_type 4 | implicit none 5 | 6 | type (my_semi_opaque_t) :: a 7 | type (my_semi_opaque_t) :: b 8 | 9 | b = my_semi_opaque(2, 3) 10 | a = b 11 | 12 | call my_semi_opaque_print("a", a) 13 | 14 | end program example1 15 | -------------------------------------------------------------------------------- /_includes/episode_keypoints.html: -------------------------------------------------------------------------------- 1 | {% comment %} 2 | Display key points for an episode. 3 | {% endcomment %} 4 |
5 |

Key Points

6 | 11 |
12 | -------------------------------------------------------------------------------- /exercises/04-derived-types/solutions/example1.f90: -------------------------------------------------------------------------------- 1 | program example1 2 | 3 | use my_semi_opaque_type 4 | implicit none 5 | 6 | type (my_semi_opaque_t) :: a 7 | type (my_semi_opaque_t) :: b 8 | 9 | b = my_semi_opaque(2, 3) 10 | a = b 11 | 12 | call my_semi_opaque_print("a", a) 13 | 14 | end program example1 15 | -------------------------------------------------------------------------------- /exercises/01-arrays/problem3.f90: -------------------------------------------------------------------------------- 1 | program problem1 2 | 3 | implicit none 4 | 5 | ! Use an array constructor to assign elements to values 1.0, 2.0, 3.0 6 | 7 | real, allocatable :: a(:) 8 | 9 | a(:) = [ 1.0, 2.0, 3.0 ] 10 | 11 | print *, "Status ", allocated(a) 12 | print *, "Values ", a(:) 13 | 14 | end program problem1 15 | -------------------------------------------------------------------------------- /_layouts/episode.html: -------------------------------------------------------------------------------- 1 | --- 2 | layout: base 3 | --- 4 | {% include episode_navbar.html episode_navbar_title=true %} 5 |
6 | {% include episode_title.html %} 7 | {% include episode_overview.html %} 8 | {{content}} 9 | {% include episode_keypoints.html %} 10 |
11 | {% include episode_navbar.html episode_navbar_title=false %} 12 | -------------------------------------------------------------------------------- /exercises/01-arrays/bounds-run-time.f90: -------------------------------------------------------------------------------- 1 | program bounds_check1 2 | 3 | ! Run time error 4 | implicit none 5 | 6 | real :: array(3) 7 | integer :: i 8 | 9 | write (*, '(a)', advance = 'no') "Input an array index " 10 | read (*, *) i 11 | 12 | print *, "Selected array element ", array(i) 13 | 14 | end program bounds_check1 15 | -------------------------------------------------------------------------------- /exercises/14-interoperability-with-c/c_array.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | void c_array(int mlen, int nlen, int idata[][mlen]) { 5 | 6 | for (int n = 0; n < nlen; n++) { 7 | for (int m = 0; m < mlen; m++) { 8 | printf("Element [%1d][%1d] %2d %2d\n", n, m, n*mlen + m, idata[n][m]); 9 | } 10 | } 11 | return; 12 | } 13 | -------------------------------------------------------------------------------- /bin/boilerplate/_episodes/01-introduction.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Introduction" 3 | teaching: 0 4 | exercises: 0 5 | questions: 6 | - "Key question (FIXME)" 7 | objectives: 8 | - "First learning objective. (FIXME)" 9 | keypoints: 10 | - "First key point. Brief Answer to questions. (FIXME)" 11 | --- 12 | FIXME 13 | 14 | {% include links.md %} 15 | 16 | -------------------------------------------------------------------------------- /exercises/14-interoperability-with-c/c_snprintf.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | int c_snprintf_float(char * str, size_t size, const char * format, float x) { 5 | 6 | return snprintf(str, size, format, x); 7 | } 8 | 9 | int c_snprintf_double(char * str, size_t size, const char * format, double x) { 10 | 11 | return snprintf(str, size, format, x); 12 | } 13 | -------------------------------------------------------------------------------- /exercises/10-modules-again/example_submodule.f90: -------------------------------------------------------------------------------- 1 | submodule (example_module) example_submodule 2 | 3 | implicit none 4 | 5 | contains 6 | 7 | function example_int_t(ival) result(e) 8 | 9 | integer, intent(in) :: ival 10 | type (example_t) :: e 11 | 12 | e%data = ival 13 | 14 | end function example_int_t 15 | 16 | end submodule example_submodule 17 | -------------------------------------------------------------------------------- /_includes/figure.html: -------------------------------------------------------------------------------- 1 |
2 | {% if include.url != "" %} 3 | 4 | {% endif %} 5 | {{ include.alt | relative_url}} 7 | {% if include.url != "" %} 8 | 9 | {% endif %} 10 |
{{ include.caption }}
11 |
12 | -------------------------------------------------------------------------------- /_includes/episode_break.html: -------------------------------------------------------------------------------- 1 | {% comment %} 2 | Display a break's timings in a box similar to a learning episode's. 3 | {% endcomment %} 4 |
5 |

Overview

6 | 7 |
8 |
9 | Break: {{ page.break }} min 10 |
11 |
12 |
13 |
14 | 15 |
16 | -------------------------------------------------------------------------------- /exercises/06-type-extension-polypmorphism/object_type.f90: -------------------------------------------------------------------------------- 1 | module object_type 2 | 3 | implicit none 4 | public 5 | 6 | type, public :: object_t 7 | real :: rho = 1.0 ! density 8 | real :: x(3) = 0.0 ! position of centre of mass 9 | end type object_t 10 | 11 | type, extends(object_t), public :: sphere_t 12 | real :: a = 1.0 ! radius 13 | end type sphere_t 14 | 15 | end module object_type 16 | -------------------------------------------------------------------------------- /bin/boilerplate/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: lesson 3 | root: . # Is the only page that doesn't follow the pattern /:path/index.html 4 | permalink: index.html # Is the only page that doesn't follow the pattern /:path/index.html 5 | --- 6 | FIXME: home page introduction 7 | 8 | 9 | 10 | {% comment %} This is a comment in Liquid {% endcomment %} 11 | 12 | > ## Prerequisites 13 | > 14 | > FIXME 15 | {: .prereq} 16 | 17 | {% include links.md %} 18 | -------------------------------------------------------------------------------- /exercises/10-modules-again/example_module.f90: -------------------------------------------------------------------------------- 1 | module example_module 2 | 3 | implicit none 4 | public 5 | 6 | type, public :: example_t 7 | private 8 | integer :: data = 0 9 | end type example_t 10 | 11 | interface example_t 12 | module function example_int_t(ival) result(e) 13 | integer, intent(in) :: ival 14 | type (example_t) :: e 15 | end function example_int_t 16 | end interface example_t 17 | 18 | end module example_module 19 | -------------------------------------------------------------------------------- /exercises/08-generic-io-for-derived-types/date_program.f90: -------------------------------------------------------------------------------- 1 | program date_program 2 | 3 | use date_module 4 | implicit none 5 | 6 | type (my_type) :: date 7 | 8 | date%day = 21 9 | date%month = 4 10 | date%year = 2022 11 | 12 | ! Some valid date examples ... 13 | 14 | print *, "List directed date output: ", date 15 | ! print "(a,dt)", "Default dt format: ", date 16 | ! print "(a,dt(2,4,5))", "vlist dt format: ", date 17 | 18 | end program date_program 19 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: "Contributor Code of Conduct" 4 | --- 5 | As contributors and maintainers of this project, 6 | we pledge to follow the [Carpentry Code of Conduct][coc]. 7 | 8 | Instances of abusive, harassing, or otherwise unacceptable behavior 9 | may be reported by following our [reporting guidelines][coc-reporting]. 10 | 11 | Participants are required to abide by the [ARCHER2 Training Code of Conduct][archer2-tcoc]. 12 | 13 | {% include links.md %} 14 | -------------------------------------------------------------------------------- /exercises/08-generic-io-for-derived-types/solutions/date_program.f90: -------------------------------------------------------------------------------- 1 | program date_program 2 | 3 | use date_module 4 | implicit none 5 | 6 | type (my_type) :: date 7 | 8 | date%day = 21 9 | date%month = 4 10 | date%year = 2022 11 | 12 | ! Some valid date examples ... 13 | 14 | print *, "List directed date output: ", date 15 | print "(a,dt)", "Default dt format: ", date 16 | print "(a,dt(2,4,5))", "vlist dt format: ", date 17 | 18 | end program date_program 19 | -------------------------------------------------------------------------------- /exercises/09-abstract-types/example1.f90: -------------------------------------------------------------------------------- 1 | program example1 2 | 3 | ! Write a file using the concrete class for formatted output. 4 | ! Compile with: ftn file_module.f90 example1.f90 5 | 6 | use file_module 7 | implicit none 8 | 9 | type (file_formatted_writer_t) :: f 10 | integer :: data(4) = [ 3.0, 5.0, 7.0, 9.0 ] 11 | integer :: ierr 12 | 13 | ! Open a file, say "file_formatted.dat" 14 | ! Write `data` to the file 15 | ! Close the file 16 | 17 | end program example1 18 | -------------------------------------------------------------------------------- /exercises/09-abstract-types/solutions/example1.f90: -------------------------------------------------------------------------------- 1 | program example1 2 | 3 | ! Write a file using the concrete class for formatted output. 4 | ! Compile with: ftn file_module.f90 example1.f90 5 | 6 | use file_module 7 | implicit none 8 | 9 | type (file_formatted_writer_t) :: f 10 | integer :: data(4) = [ 3.0, 5.0, 7.0, 9.0 ] 11 | integer :: ierr 12 | 13 | ierr = f%open("file_formatted.dat") 14 | ierr = f%write(data) 15 | ierr = f%close() 16 | 17 | end program example1 18 | -------------------------------------------------------------------------------- /exercises/01-arrays/problem1.f90: -------------------------------------------------------------------------------- 1 | program array_sections 2 | 3 | implicit none 4 | 5 | ! Given the following arrays ... 6 | 7 | integer :: a(10) = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] 8 | integer :: b(2, 3) = reshape( [1,2,3,4,5,6], shape = [2,3]) 9 | 10 | ! Write an array section to print ... 11 | 12 | ! a. elements 1, 2 and 7 of a 13 | 14 | ! b. all elements of a with odd index 15 | 16 | ! c. elements b(1, 1), b(2, 1), b(1, 3) and b(2, 3) 17 | 18 | end program array_sections 19 | -------------------------------------------------------------------------------- /exercises/02-arrays-as-arguments/example2.f90: -------------------------------------------------------------------------------- 1 | program example2 2 | 3 | implicit none 4 | 5 | real :: a(5) = [ 1.0, 2.0, 3.0, 4.0, 5.0 ] 6 | 7 | call my_array_operation(a(1:5:2)) 8 | print "(a,5(1x,f5.2))", "Final values ", a(1:5) 9 | 10 | contains 11 | 12 | subroutine my_array_operation(b) 13 | 14 | real, intent(inout) :: b(:) 15 | 16 | print *, "shape(b): ", shape(b) 17 | 18 | b(:) = 0.0 19 | 20 | end subroutine my_array_operation 21 | 22 | end program example2 23 | -------------------------------------------------------------------------------- /exercises/04-derived-types/example2.f90: -------------------------------------------------------------------------------- 1 | program example2 2 | 3 | use my_array_type 4 | implicit none 5 | 6 | type (my_array_t), target :: a 7 | type (my_array_t) :: b 8 | type (my_array_pointer_t) :: c 9 | 10 | b = my_array_allocate(3) 11 | a = b 12 | 13 | print *, "State of a ", a%nlen, allocated(a%values) 14 | 15 | c%nlen = a%nlen 16 | c%values => a%values 17 | 18 | print *, "State of c ", c%nlen, associated(c%values), c%values 19 | 20 | end program example2 21 | -------------------------------------------------------------------------------- /exercises/03-more-on-pointers/solutions/example2.f90: -------------------------------------------------------------------------------- 1 | program example2 2 | 3 | implicit none 4 | 5 | interface 6 | function array_size(a) result(isize) 7 | real, dimension(:), intent(in) :: a 8 | integer :: isize 9 | end function array_size 10 | end interface 11 | 12 | procedure (array_size), pointer :: f => array_size 13 | real :: a(13) 14 | 15 | print *, "size of a is: ", array_size(a) 16 | print *, "size of a is: ", f(a) 17 | 18 | end program example2 19 | -------------------------------------------------------------------------------- /exercises/03-more-on-pointers/solutions/example1.f90: -------------------------------------------------------------------------------- 1 | program example1 2 | 3 | implicit none 4 | 5 | integer, target :: a(10) 6 | integer, pointer :: p(:) 7 | integer :: i 8 | 9 | p => a(2:10:2) 10 | a = [ (i, i = 1, 10) ] 11 | 12 | ! print pointer lower bound lbound() 13 | print *, "Lower bound: ", lbound(p) ! => 1 14 | 15 | ! print pointer upper bound ubound() 16 | print *, "Upper bound: ", ubound(p) ! => 5 17 | 18 | ! check size and elements 19 | print *, "Size: ", size(p) ! => 5 20 | print *, "p(4) = ", p(4) ! => 8 21 | 22 | end program example1 23 | -------------------------------------------------------------------------------- /exercises/07-type-bound-procedures/object_type.f90: -------------------------------------------------------------------------------- 1 | module object_type 2 | 3 | implicit none 4 | public 5 | 6 | type, public :: object_t 7 | real :: rho = 1.0 ! density 8 | real :: x(3) = 0.0 ! position of centre of mass 9 | end type object_t 10 | 11 | type, extends(object_t), public :: sphere_t 12 | real :: a = 1.0 ! radius 13 | end type sphere_t 14 | 15 | type, extends(sphere_t), public :: charged_sphere_t 16 | real :: q = -1.0 ! charge 17 | end type charged_sphere_t 18 | 19 | contains 20 | 21 | end module object_type 22 | -------------------------------------------------------------------------------- /exercises/11-unlimited-polymorphic-entities/example1.f90: -------------------------------------------------------------------------------- 1 | program example1 2 | 3 | use iso_fortran_env 4 | implicit none 5 | 6 | real (real32), target :: r32 = 32.0 7 | real (real64), target :: r64 = 64.0 8 | real (real32), pointer :: p32 => null() 9 | real (real64), pointer :: p64 => null() 10 | 11 | class (*), pointer :: p => null() 12 | 13 | p32 => r32 14 | p32 => r64 15 | p => r32 16 | p => r64 17 | 18 | p32 = 0.0 19 | p = 0.0 20 | 21 | p32 => p 22 | 23 | print *, "Result ", p32, p64 24 | print *, "Result ", p 25 | 26 | end program example1 27 | -------------------------------------------------------------------------------- /_includes/workshop_calendar.html: -------------------------------------------------------------------------------- 1 | Add to your Google Calendar. 2 | -------------------------------------------------------------------------------- /exercises/04-derived-types/solutions/example2.f90: -------------------------------------------------------------------------------- 1 | program example2 2 | 3 | use my_array_type 4 | implicit none 5 | 6 | type (my_array_t), target :: a 7 | type (my_array_t) :: b 8 | type (my_array_pointer_t) :: c 9 | 10 | b = my_array_allocate(3) 11 | a = b 12 | 13 | print *, "State of a ", a%nlen, allocated(a%values) 14 | 15 | c%nlen = a%nlen 16 | c%values => a%values 17 | 18 | print *, "State of c ", c%nlen, associated(c%values), c%values 19 | 20 | call my_array_destroy(a) 21 | 22 | print *, "State of c ", c%nlen, associated(c%values), c%values 23 | 24 | end program example2 25 | -------------------------------------------------------------------------------- /exercises/10-modules-again/solutions/example2.f90: -------------------------------------------------------------------------------- 1 | program example1 2 | 3 | use file_module 4 | implicit none 5 | 6 | class (file_writer_t), pointer :: f => null() 7 | integer :: data(4) = [ 2, 4, 6, 8 ] 8 | integer :: ierr 9 | 10 | f => file_writer_from_string("formatted") 11 | 12 | ierr = f%open("data_formatted.dat") 13 | ierr = f%write(data) 14 | ierr = f%close() 15 | 16 | deallocate(f) 17 | 18 | f => file_writer_from_string("unformatted") 19 | 20 | ierr = f%open("data_unformatted.dat") 21 | ierr = f%write(data) 22 | ierr = f%close() 23 | 24 | deallocate(f) 25 | 26 | end program example1 27 | -------------------------------------------------------------------------------- /exercises/02-arrays-as-arguments/example1.f90: -------------------------------------------------------------------------------- 1 | program assumed_shape 2 | 3 | implicit none 4 | 5 | ! The program should print out the values 0.0, 1.0, ..., 3.0 6 | 7 | real :: a(0:3) 8 | 9 | call initialise(a) 10 | 11 | print *, "Values are: ", a(:) 12 | 13 | contains 14 | 15 | subroutine initialise(array) 16 | 17 | real, intent(inout) :: array(:) 18 | 19 | ! Initialise the values to the corresponding index 20 | 21 | integer :: i 22 | 23 | do i = lbound(array, dim = 1), ubound(array, dim = 1) 24 | array(i) = 1.0*i 25 | end do 26 | 27 | end subroutine initialise 28 | 29 | end program assumed_shape 30 | -------------------------------------------------------------------------------- /exercises/04-derived-types/my_semi_opaque_type.f90: -------------------------------------------------------------------------------- 1 | module my_semi_opaque_type 2 | 3 | ! An example dervided type 4 | 5 | implicit none 6 | public 7 | 8 | type, public :: my_semi_opaque_t 9 | private 10 | integer :: idata 11 | integer, public :: ndata 12 | end type my_semi_opaque_t 13 | 14 | contains 15 | 16 | function my_semi_opaque(idata, ndata) result(res) 17 | 18 | integer, intent(in) :: idata 19 | integer, intent(in) :: ndata 20 | type (my_semi_opaque_t) :: res 21 | 22 | res%idata = idata 23 | res%ndata = ndata 24 | 25 | end function my_semi_opaque 26 | 27 | end module my_semi_opaque_type 28 | -------------------------------------------------------------------------------- /exercises/05-interfaces-overloading/example3.f90: -------------------------------------------------------------------------------- 1 | program example3 2 | 3 | use my_vector_type 4 | implicit none 5 | 6 | type (my_vector_t) :: i = my_vector_t(1, 0, 0) 7 | type (my_vector_t) :: j = my_vector_t(0, 1, 0) 8 | type (my_vector_t) :: k = my_vector_t(0, 0, 1) 9 | 10 | ! scalar products 11 | ! i .dot. i should be 1 12 | ! i .dot. j should be 0 13 | 14 | ! vector products 15 | ! i .x. j should be k 16 | ! j .x. k should be i 17 | ! k .x. j should be -i 18 | 19 | ! scalar triple product 20 | ! i .dot. j .x. k should be 1 21 | 22 | ! vector triple product 23 | ! j .x. (i .x. j) should be (1, 0, 0) 24 | 25 | end program example3 26 | -------------------------------------------------------------------------------- /exercises/08-generic-io-for-derived-types/date_module.f90: -------------------------------------------------------------------------------- 1 | module date_module 2 | 3 | ! A module which defines a simple date type, and overrides the 4 | ! default formatted write. 5 | 6 | implicit none 7 | 8 | type :: my_type 9 | integer :: day = 0 10 | integer :: month = 0 11 | integer :: year = 0 12 | end type my_type 13 | 14 | ! Define some months, so we can produce formats like "12 Dec 2022" 15 | character (len = 3), dimension(12), parameter :: months = & 16 | [character (len = 3) :: "Jan", "Feb", "Mar", "Apr", "May", "Jun", & 17 | "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ] 18 | 19 | end module date_module 20 | -------------------------------------------------------------------------------- /exercises/11-unlimited-polymorphic-entities/key_value_program.f90: -------------------------------------------------------------------------------- 1 | program key_value_program 2 | 3 | ! Generate three key value pairs of different types. 4 | ! If the list is implemented they could be added to 5 | ! a list. 6 | 7 | use key_value_module 8 | implicit none 9 | 10 | type (key_value_t) :: kv1 = key_value_t() 11 | type (key_value_t) :: kv2 = key_value_t() 12 | type (key_value_t) :: kv3 = key_value_t() 13 | 14 | 15 | kv1 = key_value_t("kv1", 2) 16 | kv2 = key_value_t("kv2", 3.141) 17 | kv3 = key_value_t("kv3", "foo") 18 | 19 | call key_value_print(kv1) 20 | call key_value_print(kv2) 21 | call key_value_print(kv3) 22 | 23 | end program key_value_program 24 | -------------------------------------------------------------------------------- /exercises/05-interfaces-overloading/example1.f90: -------------------------------------------------------------------------------- 1 | program example1 2 | 3 | ! Exercise (see also my_array_type.f90) to 4 | ! 5 | ! 1. replace my_array_allocate(3) to a call with the overloaded 6 | ! my_array_t(3) 7 | ! 8 | ! 2. write an additional generic procedure to allow, e.g., 9 | ! a = my_array_t(nlen, iconstant) which allocates a%values(nlen) 10 | ! and initialises all values to scalar integer iconstant 11 | 12 | use my_array_type 13 | implicit none 14 | 15 | type (my_array_t) :: a 16 | 17 | a = my_array_allocate(3) 18 | 19 | print *, "State of a ", a%nlen, allocated(a%values), a%values(:) 20 | 21 | call my_array_destroy(a) 22 | 23 | end program example1 24 | -------------------------------------------------------------------------------- /setup.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: Setup 4 | --- 5 | 6 | Please try to complete the following setup tasks ahead of the lesson. 7 | 8 | ## Create appropriate SAFE accounts 9 | 10 | Course attendees should have received instructions on how to set up an Archer SAFE account. 11 | Details are available in the [ARCHER2 documentation][archer2-quickstart]. 12 | 13 | This will allow you to obtain a machine account which will be used for the course. 14 | (If you already have a machine account, it is possible to use that, although you may not have access to the course queue reservation.) 15 | 16 | Any problems encountered will be addressed as the first part of the course. 17 | 18 | 19 | {% include links.md %} 20 | -------------------------------------------------------------------------------- /_includes/all_keypoints.html: -------------------------------------------------------------------------------- 1 | {% comment %} 2 | Display key points of all episodes for reference. 3 | {% endcomment %} 4 | 5 | {% include base_path.html %} 6 | 7 |

Key Points

8 | 9 | {% for episode in site.episodes %} 10 | {% unless episode.break %} 11 | 12 | 15 | 22 | 23 | {% endunless %} 24 | {% endfor %} 25 |
13 | {{ episode.title }} 14 | 16 |
    17 | {% for keypoint in episode.keypoints %} 18 |
  • {{ keypoint|markdownify }}
  • 19 | {% endfor %} 20 |
21 |
26 | -------------------------------------------------------------------------------- /exercises/09-abstract-types/solutions/example2.f90: -------------------------------------------------------------------------------- 1 | program example1 2 | 3 | ! Write two files via abstract mechanism. 4 | ! Compile: ftn file_module.f90 example2.f90 5 | 6 | use file_module 7 | implicit none 8 | 9 | class (file_writer_t), pointer :: f => null() 10 | integer :: data(4) = [ 2, 4, 6, 8 ] 11 | integer :: ierr 12 | 13 | f => file_writer_from_string("formatted") 14 | 15 | ierr = f%open("data_formatted.dat") 16 | ierr = f%write(data) 17 | ierr = f%close() 18 | 19 | deallocate(f) 20 | 21 | f => file_write_from_string("unformatted") 22 | 23 | ierr = f%open("data_unformatted.dat") 24 | ierr = f%write(data) 25 | ierr = f%close() 26 | 27 | deallocate(f) 28 | 29 | end program example1 30 | -------------------------------------------------------------------------------- /bin/test_lesson_check.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import unittest 4 | 5 | import lesson_check 6 | import util 7 | 8 | 9 | class TestFileList(unittest.TestCase): 10 | def setUp(self): 11 | self.reporter = util.Reporter() # TODO: refactor reporter class. 12 | 13 | def test_file_list_has_expected_entries(self): 14 | # For first pass, simply assume that all required files are present 15 | all_filenames = [filename.replace('%', '') 16 | for filename in lesson_check.REQUIRED_FILES] 17 | 18 | lesson_check.check_fileset('', self.reporter, all_filenames) 19 | self.assertEqual(len(self.reporter.messages), 0) 20 | 21 | 22 | if __name__ == "__main__": 23 | unittest.main() 24 | -------------------------------------------------------------------------------- /exercises/05-interfaces-overloading/example2.f90: -------------------------------------------------------------------------------- 1 | module example2 2 | 3 | ! An example of an ambiguous interface. (Compile only required. No link.) 4 | ! How can the situation be resolved? 5 | public 6 | 7 | interface my_print 8 | module procedure my_print_a, my_print_b 9 | end interface my_print 10 | 11 | contains 12 | 13 | subroutine my_print_a(a, i) 14 | 15 | real, intent(in) :: a 16 | integer, intent(in) :: i 17 | 18 | print *, "real32 integer ", a, i 19 | 20 | end subroutine my_print_a 21 | 22 | subroutine my_print_b(i, a) 23 | 24 | integer, intent(in) :: i 25 | real, intent(in) :: a 26 | 27 | print *, "integer real32 ", i, a 28 | 29 | end subroutine my_print_b 30 | 31 | end module example2 32 | -------------------------------------------------------------------------------- /_includes/javascript.html: -------------------------------------------------------------------------------- 1 | {% comment %} 2 | JavaScript used in lesson and workshop pages. 3 | {% endcomment %} 4 | 5 | 6 | 7 | 15 | -------------------------------------------------------------------------------- /_includes/dc/intro.html: -------------------------------------------------------------------------------- 1 |

2 | Data Carpentry 3 | aims to help researchers get their work done 4 | in less time and with less pain 5 | by teaching them basic research computing skills. 6 | This hands-on workshop will cover basic concepts and tools, 7 | including program design, version control, data management, 8 | and task automation. 9 | Participants will be encouraged to help one another 10 | and to apply what they have learned to their own research problems. 11 |

12 |

13 | 14 | For more information on what we teach and why, 15 | please see our paper 16 | "Best Practices for Scientific Computing". 17 | 18 |

19 | -------------------------------------------------------------------------------- /exercises/14-interoperability-with-c/solutions/c_struct_to_fortran.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | typedef struct array_s { 5 | int nlen; 6 | float * data; 7 | } array_t; 8 | 9 | extern void f_subroutine(const array_t * a); 10 | 11 | int main() { 12 | // Allocate and fill the array 13 | array_t a; 14 | a.nlen = 10; 15 | a.data = (float *)malloc(a.nlen * sizeof(float)); 16 | printf("C array of size %2d:\n", a.nlen); 17 | for (int i = 0; i < a.nlen; ++i) { 18 | a.data[i] = 2 * i + 1.0f; 19 | printf("Element [%1d] %2.1f\n", i, a.data[i]); 20 | } 21 | 22 | // Call the Fortran subroutine, passing a by reference. 23 | f_subroutine(&a); 24 | 25 | // Free the allocated memory in a. 26 | free(a.data); 27 | a.data = NULL; 28 | 29 | return 0; 30 | } -------------------------------------------------------------------------------- /_includes/sc/intro.html: -------------------------------------------------------------------------------- 1 |

2 | Software Carpentry 3 | aims to help researchers get their work done 4 | in less time and with less pain 5 | by teaching them basic research computing skills. 6 | This hands-on workshop will cover basic concepts and tools, 7 | including program design, version control, data management, 8 | and task automation. 9 | Participants will be encouraged to help one another 10 | and to apply what they have learned to their own research problems. 11 |

12 |

13 | 14 | For more information on what we teach and why, 15 | please see our paper 16 | "Best Practices for Scientific Computing". 17 | 18 |

19 | -------------------------------------------------------------------------------- /_includes/workshop_footer.html: -------------------------------------------------------------------------------- 1 | {% comment %} 2 | Footer for a standard workshop. 3 | {% endcomment %} 4 | 27 | -------------------------------------------------------------------------------- /exercises/02-arrays-as-arguments/solutions/exercise1.f90: -------------------------------------------------------------------------------- 1 | program exercise1 2 | 3 | implicit none 4 | 5 | real, allocatable :: a(:) 6 | 7 | a = [ 1.0, 2.0, 3.0, 4.0, 5.0 ] 8 | print *, "Initial values ", a 9 | 10 | call my_array_operation(a) 11 | ! call my_array_operation(a(1:5:2)) 12 | ! a = alloc_arr() 13 | 14 | print *, "Final values ", a 15 | 16 | contains 17 | 18 | subroutine my_array_operation(b) 19 | 20 | real, allocatable, intent(out) :: b(:) 21 | 22 | if (.not. allocated(b)) then 23 | print *, "The argument b is unallocated" 24 | return 25 | end if 26 | 27 | print *, "shape(b): ", shape(b) 28 | 29 | b(:) = 0.0 30 | 31 | end subroutine my_array_operation 32 | 33 | function alloc_arr() result(arr) 34 | 35 | integer, allocatable :: arr(:) 36 | 37 | end function alloc_arr 38 | 39 | end program exercise1 40 | -------------------------------------------------------------------------------- /exercises/06-type-extension-polypmorphism/example2.f90: -------------------------------------------------------------------------------- 1 | program example2 2 | 3 | use object_type 4 | implicit none 5 | 6 | type (object_t), target :: obj = object_t() 7 | type (sphere_t), target :: s = sphere_t() 8 | type (charged_sphere_t), target :: cs 9 | 10 | class (object_t), pointer :: p => null() 11 | 12 | obj = object_t(rho = 1.0, x = [1.0, 2.0, 3.0]) 13 | s = sphere_t(object_t = obj, a = 2.5) 14 | cs = charged_sphere_t(sphere_t = s, q = -1.0) 15 | 16 | p => obj 17 | 18 | print *, "object density ", p%rho 19 | print *, "object position ", p%x(:) 20 | print *, "object radius ", p%a 21 | 22 | p => s 23 | 24 | print *, "sphere density ", p%rho 25 | print *, "sphere position ", p%x(:) 26 | print *, "sphere radius ", p%a 27 | 28 | p => cs 29 | print *, "sphere charge ", p%q 30 | 31 | end program example2 32 | -------------------------------------------------------------------------------- /exercises/05-interfaces-overloading/my_array_type.f90: -------------------------------------------------------------------------------- 1 | module my_array_type 2 | 3 | implicit none 4 | public 5 | 6 | type, public :: my_array_t 7 | integer :: nlen = 0 8 | real, allocatable :: values(:) 9 | end type my_array_t 10 | 11 | contains 12 | 13 | function my_array_allocate(nlen) result(a) 14 | 15 | integer, intent(in) :: nlen 16 | type (my_array_t) :: a 17 | integer :: i 18 | 19 | a%nlen = nlen 20 | a%values = [ (1.0*i, i = 1, nlen) ] 21 | 22 | end function my_array_allocate 23 | 24 | !---------------------------------------------------------------------------- 25 | 26 | subroutine my_array_destroy(a) 27 | 28 | type (my_array_t), intent(inout) :: a 29 | 30 | a%nlen = 0 31 | if (allocated(a%values)) deallocate(a%values) 32 | 33 | end subroutine my_array_destroy 34 | 35 | end module my_array_type 36 | -------------------------------------------------------------------------------- /_includes/lc/intro.html: -------------------------------------------------------------------------------- 1 |

2 | Library Carpentry 3 | is made by people working in library- and information-related roles to help you: 4 |

5 |
    6 |
  • automate repetitive, boring, error-prone tasks
  • 7 |
  • create, maintain and analyze sustainable and reusable data
  • 8 |
  • work effectively with IT and systems colleagues
  • 9 |
  • better understand the use of software in research
  • 10 |
  • and much more...
  • 11 |
12 |

13 | 14 | Library Carpentry introduces you to the fundamentals of computing 15 | and provides you with a platform for further self-directed learning. 16 | For more information on what we teach and why, please see our paper 17 | "Library Carpentry: software skills training for library professionals". 18 | 19 |

20 | -------------------------------------------------------------------------------- /exercises/06-type-extension-polypmorphism/example1.f90: -------------------------------------------------------------------------------- 1 | program test1 2 | 3 | use object_type 4 | implicit none 5 | 6 | type (object_t) :: obj 7 | type (sphere_t) :: s 8 | real :: rho = 1.0 9 | real :: x(3) = [ 2.0, 3.0, 4.0 ] 10 | real :: radius = 1.5 11 | 12 | s = sphere_t(rho, x, radius) 13 | 14 | print *, "Sphere density ", s%object_t%rho 15 | print *, "Sphere density ", s%rho 16 | print *, "Sphere radius ", s%a 17 | 18 | s = sphere_t(a = radius, rho = rho , x = x) 19 | 20 | print *, "Sphere density ", s%object_t%rho 21 | print *, "Sphere density ", s%rho 22 | print *, "Sphere radius ", s%a 23 | 24 | obj = object_t(2.5, [1.0, 1.0, 1.0]) 25 | s = sphere_t(obj, radius) 26 | 27 | print *, "Sphere density ", s%rho 28 | print *, "Sphere position: ", s%x 29 | print *, "Sphere radius ", s%a 30 | 31 | end program test1 32 | -------------------------------------------------------------------------------- /exercises/06-type-extension-polypmorphism/solutions/example1.f90: -------------------------------------------------------------------------------- 1 | program test1 2 | 3 | use object_type 4 | implicit none 5 | 6 | type (object_t) :: obj 7 | type (sphere_t) :: s 8 | real :: rho = 1.0 9 | real :: x(3) = [ 2.0, 3.0, 4.0 ] 10 | real :: radius = 1.5 11 | 12 | s = sphere_t(rho, x, radius) 13 | 14 | print *, "Sphere density ", s%object_t%rho 15 | print *, "Sphere density ", s%rho 16 | print *, "Sphere radius ", s%a 17 | 18 | s = sphere_t(a = radius, rho = rho , x = x) 19 | 20 | print *, "Sphere density ", s%object_t%rho 21 | print *, "Sphere density ", s%rho 22 | print *, "Sphere radius ", s%a 23 | 24 | obj = object_t(2.5, [1.0, 1.0, 1.0]) 25 | s = sphere_t(obj, radius) 26 | 27 | print *, "Sphere density ", s%rho 28 | print *, "Sphere position: ", s%x 29 | print *, "Sphere radius ", s%a 30 | 31 | end program test1 32 | -------------------------------------------------------------------------------- /_includes/life_cycle.html: -------------------------------------------------------------------------------- 1 | 2 | {% if site.life_cycle == "pre-alpha" %} 3 | 4 |
5 |
6 | This lesson is still being designed and assembled (Pre-Alpha version) 7 |
8 |
9 | 10 | 11 | {% elsif site.life_cycle == "alpha" %} 12 | 13 |
14 |
15 | This lesson is in the early stages of development (Alpha version) 16 |
17 |
18 | 19 | 20 | {% elsif site.life_cycle == "beta" %} 21 | 22 |
23 |
24 | This lesson is being piloted (Beta version) 25 |
26 |
27 | 28 | {% elsif site.life_cycle == "stable" %} 29 | 30 | {% comment %} 31 | We don't do anything special for now 32 | {% endcomment %} 33 | 34 | {% endif %} 35 | -------------------------------------------------------------------------------- /exercises/12-type-parameters/example1.f90: -------------------------------------------------------------------------------- 1 | program exmaple1 2 | 3 | use iso_fortran_env 4 | implicit none 5 | 6 | type :: my_array_t(kr, nlen) 7 | integer, kind :: kr 8 | integer, len :: nlen 9 | real (kr) :: data(nlen) 10 | end type my_array_t 11 | 12 | integer :: kr 13 | integer :: nlen 14 | type (my_array_t(kr = real64, nlen = 1000)) :: a 15 | 16 | print *, "kind a", a%kr 17 | print *, "nlen a", a%nlen 18 | 19 | write (*, "(a)", advance = "no") "kind: " 20 | read (*, *) kr 21 | write (*, "(a)", advance = "no") "nlen: " 22 | read (*, *) nlen 23 | 24 | call defer_me(kr, nlen) 25 | 26 | contains 27 | 28 | subroutine defer_me(kr, nlen) 29 | 30 | integer, intent(in) :: kr 31 | integer, intent(in) :: nlen 32 | type (my_array_t(kr, nlen)) :: b 33 | 34 | print *, "Defer me ", b%kr 35 | print *, "Length ", b%nlen 36 | 37 | end subroutine defer_me 38 | 39 | end program exmaple1 40 | -------------------------------------------------------------------------------- /_includes/episode_overview.html: -------------------------------------------------------------------------------- 1 | {% comment %} 2 | Display an episode's timings and learning objectives. 3 | {% endcomment %} 4 |
5 |

Overview

6 | 7 |
8 |
9 | Teaching: {{ page.teaching }} min 10 |
11 | Exercises: {{ page.exercises }} min 12 |
13 |
14 | Questions 15 |
    16 | {% for question in page.questions %} 17 |
  • {{ question|markdownify }}
  • 18 | {% endfor %} 19 |
20 |
21 |
22 | 23 |
24 |
25 |
26 |
27 | Objectives 28 |
    29 | {% for objective in page.objectives %} 30 |
  • {{ objective|markdownify }}
  • 31 | {% endfor %} 32 |
33 |
34 |
35 | 36 |
37 | -------------------------------------------------------------------------------- /exercises/07-type-bound-procedures/example1.f90: -------------------------------------------------------------------------------- 1 | program test1 2 | 3 | use object_type 4 | implicit none 5 | 6 | type (object_t) :: obj 7 | type (sphere_t) :: s 8 | real :: rho = 1.0 9 | real :: x(3) = [ 2.0, 3.0, 4.0 ] 10 | real :: radius = 1.5 11 | 12 | s = sphere_t(rho, x, radius) 13 | 14 | print *, "Sphere density ", s%object_t%rho 15 | print *, "Sphere density ", s%rho 16 | print *, "Sphere radius ", s%a 17 | 18 | s = sphere_t(a = radius, rho = rho , x = x) 19 | 20 | print *, "Sphere density ", s%object_t%rho 21 | print *, "Sphere density ", s%rho 22 | print *, "Sphere radius ", s%a 23 | 24 | obj = object_t(2.5, [1.0, 1.0, 1.0]) 25 | s = sphere_t(obj, radius) 26 | 27 | print *, "Sphere density ", s%rho 28 | print *, "Sphere position: ", s%x 29 | print *, "Sphere radius ", s%a 30 | 31 | print *, "Object volume ", obj%volume() 32 | !print *, "Sphere volume ", s%volume() 33 | 34 | end program test1 35 | -------------------------------------------------------------------------------- /_includes/workshop_ad.html: -------------------------------------------------------------------------------- 1 | {% comment %} 2 | Advertising box at the top of a workshop website home page. 3 | {% endcomment %} 4 |
5 |
6 |
7 |

{{page.venue}}

8 |
9 |
10 |

{{page.humandate}}

11 |

{% if page.humantime %}{{page.humantime}}{% endif %}

12 |
13 |
14 |

15 | Instructors: 16 | {% if page.instructor %} 17 | {{page.instructor | join: ', ' %}} 18 | {% else %} 19 | to be announced. 20 | {% endif %} 21 |

22 | {% if page.helper %} 23 |

24 | Helpers: 25 | {{page.helper | join: ', ' %}} 26 |

27 | {% endif %} 28 |
29 |
30 |
31 |
32 |
33 | -------------------------------------------------------------------------------- /bin/boilerplate/README.md: -------------------------------------------------------------------------------- 1 | # FIXME Lesson title 2 | 3 | [![Create a Slack Account with us](https://img.shields.io/badge/Create_Slack_Account-The_Carpentries-071159.svg)](https://swc-slack-invite.herokuapp.com/) 4 | 5 | FIXME 6 | 7 | ## Contributing 8 | 9 | We welcome all contributions to improve the lesson! Maintainers will do their best to help you if you have any 10 | questions, concerns, or experience any difficulties along the way. 11 | 12 | We'd like to ask you to familiarize yourself with our [Contribution Guide](CONTRIBUTING.md) and have a look at 13 | the [more detailed guidelines][lesson-example] on proper formatting, ways to render the lesson locally, and even 14 | how to write new episodes. 15 | 16 | ## Maintainer(s) 17 | 18 | * FIXME 19 | 20 | ## Authors 21 | 22 | A list of contributors to the lesson can be found in [AUTHORS](AUTHORS) 23 | 24 | ## Citation 25 | 26 | To cite this lesson, please consult with [CITATION](CITATION) 27 | 28 | [lesson-example]: https://carpentries.github.io/lesson-example 29 | -------------------------------------------------------------------------------- /bin/boilerplate/.travis.yml: -------------------------------------------------------------------------------- 1 | # dist: trusty # Ubuntu 14.04 2 | language: python 3 | python: 3.7 4 | branches: 5 | only: 6 | - gh-pages 7 | - /.*/ 8 | before_install: 9 | - sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E084DAB9 10 | - echo "deb https://cran.rstudio.com/bin/linux/ubuntu trusty/" | sudo tee -a /etc/apt/sources.list 11 | - sudo apt-get update -y 12 | - sudo apt-get install -y r-base 13 | - sudo Rscript -e "install.packages('knitr', repos = 'https://', dependencies = TRUE)" 14 | - sudo Rscript -e "install.packages('stringr', repos = 'https://cran.rstudio.com', dependencies = TRUE)" 15 | - sudo Rscript -e "install.packages('checkpoint', repos = 'https://cran.rstudio.com', dependencies = TRUE)" 16 | - sudo Rscript -e "install.packages('ggplot2', repos = 'https://cran.rstudio.com', dependencies = TRUE)" 17 | - rvm default 18 | - gem install json kramdown jekyll 19 | install: 20 | - pip install pyyaml 21 | script: 22 | - make lesson-check-all 23 | - make --always-make site 24 | -------------------------------------------------------------------------------- /_includes/lc/schedule.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |

Day 1

4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
09:00 Data Intro for Librarians
10:30 Coffee
12:00 Lunch break
13:00 Shell Lessons for Libraries
14:30 Coffee
16:00 Wrap-up
12 |
13 |
14 |

Day 2

15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 |
09:00 Git Intro for Librarians
10:30 Coffee
12:00 Lunch break
13:00 OpenRefine for Librarians
14:30 Coffee
16:00 Wrap-up
23 |
24 |
25 | -------------------------------------------------------------------------------- /_includes/base_path.html: -------------------------------------------------------------------------------- 1 | {% comment %} 2 | This is adapted from: https://ricostacruz.com/til/relative-paths-in-jekyll 3 | 4 | `page.url` gives the URL of the current page with a leading /: 5 | 6 | - when the URL ends with the extension (e.g., /foo/bar.html) then we can get 7 | the depth by counting the number of / and remove - 1 8 | - when the URL ends with a / (e.g. /foo/bar/) then the number / gives the depth 9 | directly 10 | {% endcomment %} 11 | 12 | {% assign relative_root_path = '' %} 13 | 14 | {% assign last_char = page.url | slice: -1 %} 15 | 16 | {% if last_char == "/"} 17 | {% assign offset = 0 %} 18 | {% else %} 19 | {% assign offset = 1 %} 20 | {% endif %} 21 | 22 | {% assign depth = page.url | split: '/' | size | minus: offset %} 23 | {% if depth <= 1 %}{% assign relative_root_path = '.' %} 24 | {% elsif depth == 2 %}{% assign relative_root_path = '..' %} 25 | {% elsif depth == 3 %}{% assign relative_root_path = '../..' %} 26 | {% elsif depth == 4 %}{% assign relative_root_path = '../../..' %} 27 | {% endif %} 28 | -------------------------------------------------------------------------------- /_includes/dc/schedule.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |

Day 1

4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
09:00 Automating tasks with the Unix shell
10:30 Coffee
12:00 Lunch break
13:00 Building programs with Python
14:30 Coffee
16:00 Wrap-up
12 |
13 |
14 |

Day 2

15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 |
09:00 Version control with Git
10:30 Coffee
12:00 Lunch break
13:00 Managing data with SQL
14:30 Coffee
16:00 Wrap-up
23 |
24 |
25 | -------------------------------------------------------------------------------- /_includes/sc/schedule.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |

Day 1

4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
09:00 Automating tasks with the Unix shell
10:30 Coffee
12:00 Lunch break
13:00 Building programs with Python
14:30 Coffee
16:00 Wrap-up
12 |
13 |
14 |

Day 2

15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 |
09:00 Version control with Git
10:30 Coffee
12:00 Lunch break
13:00 Managing data with SQL
14:30 Coffee
16:00 Wrap-up
23 |
24 |
25 | -------------------------------------------------------------------------------- /exercises/04-derived-types/my_array_type.f90: -------------------------------------------------------------------------------- 1 | module my_array_type 2 | 3 | implicit none 4 | public 5 | 6 | type, public :: my_array_t 7 | integer :: nlen = 0 8 | real, allocatable :: values(:) 9 | end type my_array_t 10 | 11 | type, public :: my_array_pointer_t 12 | integer :: nlen = 0 13 | real, pointer :: values(:) 14 | end type my_array_pointer_t 15 | 16 | contains 17 | 18 | function my_array_allocate(nlen) result(a) 19 | 20 | integer, intent(in) :: nlen 21 | type (my_array_t) :: a 22 | integer :: i 23 | 24 | a%nlen = nlen 25 | a%values = [ (1.0*i, i = 1, nlen) ] 26 | 27 | end function my_array_allocate 28 | 29 | !---------------------------------------------------------------------------- 30 | 31 | subroutine my_array_destroy(a) 32 | 33 | type (my_array_t), intent(inout) :: a 34 | 35 | a%nlen = 0 36 | if (allocated(a%values)) deallocate(a%values) 37 | 38 | end subroutine my_array_destroy 39 | 40 | end module my_array_type 41 | -------------------------------------------------------------------------------- /exercises/04-derived-types/solutions/my_semi_opaque_type.f90: -------------------------------------------------------------------------------- 1 | module my_semi_opaque_type 2 | 3 | ! An example dervided type 4 | 5 | implicit none 6 | public 7 | 8 | type, public :: my_semi_opaque_t 9 | private 10 | integer :: idata 11 | integer, public :: ndata 12 | end type my_semi_opaque_t 13 | 14 | contains 15 | 16 | function my_semi_opaque(idata, ndata) result(res) 17 | 18 | integer, intent(in) :: idata 19 | integer, intent(in) :: ndata 20 | type (my_semi_opaque_t) :: res 21 | 22 | res%idata = idata 23 | res%ndata = ndata 24 | 25 | end function my_semi_opaque 26 | 27 | !---------------------------------------------------------------------------- 28 | 29 | subroutine my_semi_opaque_print(label, a) 30 | 31 | character (len = *), intent(in) :: label 32 | type (my_semi_opaque_t), intent(in) :: a 33 | 34 | print *, "(var, idata, ndata): ", label, a%idata, a%ndata 35 | 36 | end subroutine my_semi_opaque_print 37 | 38 | end module my_semi_opaque_type 39 | -------------------------------------------------------------------------------- /exercises/06-type-extension-polypmorphism/solutions/example2.f90: -------------------------------------------------------------------------------- 1 | program example2 2 | 3 | use object_type 4 | implicit none 5 | 6 | type (object_t), target :: obj = object_t() 7 | type (sphere_t), target :: s = sphere_t() 8 | type (charged_sphere_t), target :: cs 9 | 10 | class (object_t), pointer :: p => null() 11 | ! no can do ... 12 | !class (charged_sphere_t), pointer :: p => null() 13 | 14 | 15 | obj = object_t(rho = 1.0, x = [1.0, 2.0, 3.0]) 16 | s = sphere_t(object_t = obj, a = 2.5) 17 | cs = charged_sphere_t(sphere_t = s, q = -1.0) 18 | 19 | p => obj 20 | 21 | print *, "object density ", p%rho 22 | print *, "object position ", p%x(:) 23 | !print *, "object radius ", p%a 24 | 25 | call object_info(p) 26 | 27 | p => s 28 | 29 | print *, "sphere density ", p%rho 30 | print *, "sphere position ", p%x(:) 31 | !print *, "sphere radius ", p%a 32 | 33 | call object_info(p) 34 | 35 | p => cs 36 | !print *, "sphere charge ", p%q 37 | 38 | call object_info(p) 39 | 40 | end program example2 41 | -------------------------------------------------------------------------------- /exercises/06-type-extension-polypmorphism/solutions/object_type.f90: -------------------------------------------------------------------------------- 1 | module object_type 2 | 3 | implicit none 4 | public 5 | 6 | type, public :: object_t 7 | real :: rho = 1.0 ! density 8 | real :: x(3) = 0.0 ! position of centre of mass 9 | end type object_t 10 | 11 | type, extends(object_t), public :: sphere_t 12 | real :: a = 1.0 ! radius 13 | end type sphere_t 14 | 15 | type, extends(sphere_t), public :: charged_sphere_t 16 | real :: q = -1.0 ! charge 17 | end type charged_sphere_t 18 | 19 | contains 20 | 21 | subroutine object_info(p) 22 | 23 | class(object_t), pointer, intent(in) :: p 24 | 25 | select type (p) 26 | type is (charged_sphere_t) 27 | print *, "Charge = ", p%q 28 | class is (sphere_t) 29 | print *, "Radius = ", p%a 30 | class is (object_t) 31 | print *, "Density = ", p%rho 32 | print *, "Position = ", p%x 33 | class default 34 | print *, "Unknown object type!" 35 | end select 36 | 37 | end subroutine object_info 38 | 39 | end module object_type 40 | -------------------------------------------------------------------------------- /exercises/14-interoperability-with-c/solutions/f_array.f90: -------------------------------------------------------------------------------- 1 | module f_array_module 2 | use, intrinsic :: iso_c_binding 3 | implicit none 4 | public 5 | 6 | interface 7 | subroutine c_array (mlen, nlen, idata) & 8 | bind(c, name = "c_array") 9 | use iso_c_binding, only : c_int 10 | integer (kind = c_int), value, intent(in) :: mlen, nlen 11 | integer (kind = c_int), intent(in) :: idata(mlen, *) 12 | end subroutine c_array 13 | end interface 14 | 15 | end module f_array_module 16 | 17 | 18 | program test_array 19 | use f_array_module 20 | implicit none 21 | 22 | integer, parameter :: mlen = 2, nlen = 3 23 | integer :: idata(mlen, nlen) 24 | 25 | integer :: i, j 26 | 27 | do j = 1, nlen 28 | do i = 1, mlen 29 | idata(i, j) = i + (j - 1) * mlen 30 | end do 31 | end do 32 | 33 | ! printing - check correct in memory order 34 | do j = 1, mlen 35 | write(*,*) "Row ", j, ": ", idata(j, 1:nlen) 36 | end do 37 | print *, idata 38 | 39 | call c_array(mlen, nlen, idata) 40 | end program test_array -------------------------------------------------------------------------------- /exercises/14-interoperability-with-c/solutions/f_array_t.f90: -------------------------------------------------------------------------------- 1 | module f_array_t 2 | 3 | use iso_c_binding, only : c_int, c_float, c_ptr, c_f_pointer 4 | use iso_fortran_env, only : output_unit 5 | implicit none 6 | 7 | ! Interoperable Fortran counterpart to the C array_t. 8 | type, bind(c) :: array_t 9 | integer (c_int) :: nlen 10 | type (c_ptr) :: data 11 | end type array_t 12 | 13 | contains 14 | 15 | subroutine f_subroutine(a) bind(c) 16 | implicit none 17 | 18 | type (array_t), intent(in) :: a 19 | real (c_float), pointer :: data(:) 20 | 21 | integer :: i 22 | 23 | ! Get a Fortran pointer counterpart to the C pointer. 24 | ! As it's a pointer to an array, we need to provide its size. 25 | call c_f_pointer(a%data, data, [ a%nlen ]) 26 | 27 | ! Print the array's contents. It should match what was 28 | ! printed from the C code. 29 | write(output_unit, "('Fortran pointer to array of size ', i2, ':')") a%nlen 30 | do i = 1, a%nlen 31 | write (output_unit, "('Element (',i2,')',x,f4.1)") i, data(i) 32 | end do 33 | 34 | end subroutine f_subroutine 35 | 36 | end module f_array_t -------------------------------------------------------------------------------- /assets/img/cp-logo-blue.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /bin/lesson_initialize.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | """Initialize a newly-created repository.""" 4 | 5 | 6 | import sys 7 | import os 8 | import shutil 9 | 10 | BOILERPLATE = ( 11 | '.travis.yml', 12 | 'AUTHORS', 13 | 'CITATION', 14 | 'CONTRIBUTING.md', 15 | 'README.md', 16 | '_config.yml', 17 | '_episodes/01-introduction.md', 18 | '_extras/about.md', 19 | '_extras/discuss.md', 20 | '_extras/figures.md', 21 | '_extras/guide.md', 22 | 'aio.md', 23 | 'index.md', 24 | 'reference.md', 25 | 'setup.md', 26 | ) 27 | 28 | 29 | def main(): 30 | """Check for collisions, then create.""" 31 | 32 | # Check. 33 | errors = False 34 | for path in BOILERPLATE: 35 | if os.path.exists(path): 36 | print('Warning: {0} already exists.'.format(path), file=sys.stderr) 37 | errors = True 38 | if errors: 39 | print('**Exiting without creating files.**', file=sys.stderr) 40 | sys.exit(1) 41 | 42 | # Create. 43 | for path in BOILERPLATE: 44 | shutil.copyfile( 45 | "bin/boilerplate/{}".format(path), 46 | path 47 | ) 48 | 49 | 50 | if __name__ == '__main__': 51 | main() 52 | -------------------------------------------------------------------------------- /exercises/07-type-bound-procedures/solutions/example1.f90: -------------------------------------------------------------------------------- 1 | program test1 2 | 3 | use object_type 4 | implicit none 5 | 6 | type (object_t), target :: obj 7 | type (sphere_t), target :: s 8 | real :: rho = 1.0 9 | real :: x(3) = [ 2.0, 3.0, 4.0 ] 10 | real :: radius = 1.5 11 | 12 | class (object_t), pointer :: p => null() 13 | 14 | s = sphere_t(rho, x, radius) 15 | 16 | print *, "Sphere density ", s%object_t%rho 17 | print *, "Sphere density ", s%rho 18 | print *, "Sphere radius ", s%a 19 | 20 | s = sphere_t(a = radius, rho = rho , x = x) 21 | 22 | print *, "Sphere density ", s%object_t%rho 23 | print *, "Sphere density ", s%rho 24 | print *, "Sphere radius ", s%a 25 | 26 | obj = object_t(2.5, [1.0, 1.0, 1.0]) 27 | s = sphere_t(obj, radius) 28 | 29 | print *, "Sphere density ", s%rho 30 | print *, "Sphere position: ", s%x 31 | print *, "Sphere radius ", s%a 32 | 33 | print *, "Object volume ", obj%volume() 34 | print *, "Sphere volume ", s%volume() 35 | print *, "Sphere mass ", s%mass() 36 | 37 | p => s 38 | print *, "Sphere volume ", p%volume() 39 | print *, "Sphere mass ", p%mass() 40 | 41 | end program test1 42 | -------------------------------------------------------------------------------- /exercises/11-unlimited-polymorphic-entities/solutions/key_value_program.f90: -------------------------------------------------------------------------------- 1 | program key_value_program 2 | 3 | ! Generate three key value pairs of different types, then 4 | ! add then to a list. 5 | 6 | use key_value_module 7 | implicit none 8 | 9 | type (key_value_t) :: kv1 = key_value_t() 10 | type (key_value_t) :: kv2 = key_value_t() 11 | type (key_value_t) :: kv3 = key_value_t() 12 | type (key_value_t) :: kv4 13 | type (key_value_t) :: kv5 14 | 15 | type (key_value_list_t) :: alist 16 | 17 | kv1 = key_value_t("kv1", 2) 18 | kv2 = key_value_t("kv2", 3.141) 19 | kv3 = key_value_t("kv3", "foo") 20 | 21 | kv4 = key_value_t("kv4", 2.7) 22 | kv5 = key_value_t("kv5", kv4) 23 | 24 | call key_value_print(kv1) 25 | call key_value_print(kv2) 26 | call key_value_print(kv3) 27 | call key_value_print(kv4) 28 | call key_value_print(kv5) 29 | 30 | alist = key_value_list_t() 31 | 32 | call key_value_list_add_kv(alist, kv1) 33 | call key_value_list_add_kv(alist, kv2) 34 | call key_value_list_add_kv(alist, kv3) 35 | 36 | call key_value_release(kv3) 37 | call key_value_release(kv2) 38 | call key_value_release(kv1) 39 | 40 | call key_value_list_print(alist) 41 | 42 | end program key_value_program 43 | -------------------------------------------------------------------------------- /exercises/10-modules-again/solutions/file_submodule.f90: -------------------------------------------------------------------------------- 1 | submodule (file_module) file_submodule 2 | 3 | use file_formatted 4 | use file_unformatted 5 | implicit none 6 | 7 | contains 8 | 9 | function create_file_formatted_writer_t() result(fp) 10 | 11 | class (file_formatted_writer_t), pointer :: fp 12 | allocate(fp) 13 | 14 | end function create_file_formatted_writer_t 15 | 16 | function create_file_unformatted_writer_t() result(fp) 17 | 18 | class (file_unformatted_writer_t), pointer :: fp 19 | allocate(fp) 20 | 21 | end function create_file_unformatted_writer_t 22 | 23 | !---------------------------------------------------------------------------- 24 | 25 | module function file_writer_from_string(str) result(fp) 26 | 27 | character (len = *), intent(in) :: str 28 | class (file_writer_t), pointer :: fp 29 | 30 | ! We haven't reached typed allocation yet, hence the extra 31 | ! routines to return a pointer of the right type. 32 | fp => null() 33 | select case (str) 34 | case ("formatted") 35 | fp => create_file_formatted_writer_t() 36 | case ("unformatted") 37 | fp => create_file_unformatted_writer_t() 38 | case default 39 | print *, "Not recognised ", str 40 | end select 41 | 42 | end function file_writer_from_string 43 | 44 | end submodule file_submodule 45 | -------------------------------------------------------------------------------- /aio.md: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | 4 | {% include base_path.html %} 5 | 6 | 32 | {% comment %} 33 | Create an anchor for every episode. 34 | {% endcomment %} 35 | {% for episode in site.episodes %} 36 |
37 | {% endfor %} 38 | -------------------------------------------------------------------------------- /bin/boilerplate/aio.md: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | 4 | {% include base_path.html %} 5 | 6 | 32 | {% comment %} 33 | Create an anchor for every episode. 34 | {% endcomment %} 35 | {% for episode in site.episodes %} 36 |
37 | {% endfor %} 38 | -------------------------------------------------------------------------------- /exercises/04-derived-types/solutions/my_array_type.f90: -------------------------------------------------------------------------------- 1 | module my_array_type 2 | 3 | implicit none 4 | public 5 | 6 | type, public :: my_array_t 7 | integer :: nlen = 0 8 | real, allocatable :: values(:) 9 | end type my_array_t 10 | 11 | type, public :: my_array_pointer_t 12 | integer :: nlen = 0 13 | real, pointer :: values(:) 14 | end type my_array_pointer_t 15 | 16 | interface assignment (=) 17 | module procedure my_assignment 18 | end interface assignment (=) 19 | 20 | contains 21 | 22 | function my_array_allocate(nlen) result(a) 23 | 24 | integer, intent(in) :: nlen 25 | type (my_array_t) :: a 26 | integer :: i 27 | 28 | a%nlen = nlen 29 | a%values = [ (1.0*i, i = 1, nlen) ] 30 | 31 | end function my_array_allocate 32 | 33 | !---------------------------------------------------------------------------- 34 | 35 | subroutine my_array_destroy(a) 36 | 37 | type (my_array_t), intent(inout) :: a 38 | 39 | a%nlen = 0 40 | if (allocated(a%values)) deallocate(a%values) 41 | 42 | end subroutine my_array_destroy 43 | 44 | !---------------------------------------------------------------------------- 45 | 46 | subroutine my_assignment(a, b) 47 | 48 | type (my_array_pointer_t), intent(out) :: a 49 | type (my_array_t), target, intent(in) :: b 50 | 51 | a%nlen = b%nlen 52 | a%values => b%values 53 | 54 | end subroutine my_assignment 55 | 56 | end module my_array_type 57 | -------------------------------------------------------------------------------- /exercises/07-type-bound-procedures/solutions/object_type.f90: -------------------------------------------------------------------------------- 1 | module object_type 2 | 3 | implicit none 4 | public 5 | 6 | type, public :: object_t 7 | real :: rho = 1.0 ! density 8 | real :: x(3) = 0.0 ! position of centre of mass 9 | contains 10 | procedure, pass :: volume => object_volume 11 | end type object_t 12 | 13 | type, extends(object_t), public :: sphere_t 14 | real :: a = 1.0 ! radius 15 | contains 16 | procedure, pass, non_overridable :: volume => sphere_volume 17 | procedure, pass :: mass => sphere_mass 18 | end type sphere_t 19 | 20 | type, extends(sphere_t), public :: charged_sphere_t 21 | real :: q = -1.0 ! charge 22 | end type charged_sphere_t 23 | 24 | contains 25 | 26 | function object_volume(self) result(volume) 27 | 28 | class (object_t), intent(in) :: self 29 | real :: volume 30 | 31 | volume = 0.0 32 | 33 | end function object_volume 34 | 35 | function sphere_volume(self) result(volume) 36 | 37 | class (sphere_t), intent(in) :: self 38 | real :: volume 39 | 40 | volume = (4.0/3.0)*(4.0*atan(1.0))*self%a**3 41 | 42 | end function sphere_volume 43 | 44 | function sphere_mass(self) result(mass) 45 | 46 | class (sphere_t), intent(in) :: self 47 | real :: mass 48 | 49 | mass = self%rho*self%volume() 50 | 51 | end function sphere_mass 52 | 53 | end module object_type 54 | -------------------------------------------------------------------------------- /exercises/10-modules-again/solutions/file_module.f90: -------------------------------------------------------------------------------- 1 | module file_module 2 | 3 | implicit none 4 | public 5 | 6 | type, abstract, public :: file_writer_t 7 | contains 8 | procedure (if_open), pass, deferred :: open 9 | procedure (if_write), pass, deferred :: write 10 | procedure (if_close), pass, deferred :: close 11 | end type file_writer_t 12 | 13 | abstract interface 14 | function if_open(self, filename) result(ierr) 15 | import file_writer_t 16 | class (file_writer_t), intent(inout) :: self 17 | character (len = *), intent(in) :: filename 18 | integer :: ierr 19 | end function if_open 20 | 21 | function if_write(self, data) result(ierr) 22 | import file_writer_t 23 | class (file_writer_t), intent(inout) :: self 24 | integer, intent(in) :: data(:) 25 | integer :: ierr 26 | end function if_write 27 | 28 | function if_close(self) result(ierr) 29 | import file_writer_t 30 | class (file_writer_t), intent(inout) :: self 31 | integer :: ierr 32 | end function if_close 33 | end interface 34 | 35 | ! Factory method 36 | 37 | interface 38 | module function file_writer_from_string(str) result(fp) 39 | character (len = *), intent(in) :: str 40 | class (file_writer_t), pointer :: fp 41 | end function file_writer_from_string 42 | end interface 43 | 44 | end module file_module 45 | -------------------------------------------------------------------------------- /_includes/episode_navbar.html: -------------------------------------------------------------------------------- 1 | {% comment %} 2 | For some reason, the relative_root_path seems out of scope in this file, so we 3 | need to re-assign it here 4 | {% endcomment %} 5 | 6 | {% include base_path.html %} 7 | 8 | {% comment %} 9 | Navigation bar for an episode. 10 | {% endcomment %} 11 | 12 |
13 |
14 |

15 | {% if page.previous.url %} 16 | previous episode 17 | {% else %} 18 | lesson home 19 | {% endif %} 20 |

21 |
22 |
23 | {% if include.episode_navbar_title %} 24 |

{{ site.title }}

25 | {% endif %} 26 |
27 |
28 |

29 | {% if page.next.url %} 30 | next episode 31 | {% else %} 32 | lesson home 33 | {% endif %} 34 |

35 |
36 |
37 | -------------------------------------------------------------------------------- /exercises/13-intrinsic-modules/print_iso_fortran_env.f90: -------------------------------------------------------------------------------- 1 | program print_iso_fortran_env 2 | 3 | use, intrinsic :: iso_fortran_env 4 | implicit none 5 | 6 | character (len = *), parameter :: compiler = compiler_version() 7 | character (len = *), parameter :: options = compiler_options() 8 | 9 | print "('Error unit ', i8)", error_unit 10 | print "('Input unit ', i8)", input_unit 11 | print "('Output unit ', i8)", output_unit 12 | 13 | print "('iostat_end ', i8)", iostat_end 14 | print "('iostat_eor ', i8)", iostat_eor 15 | 16 | print "('character storage size ', i8)", character_storage_size 17 | print "('file storage size ', i8)", file_storage_size 18 | print "('numerical storage size ', i8)", numeric_storage_size 19 | 20 | print "('int8 ', i8)", int8 21 | print "('int16 ', i8)", int16 22 | print "('int32 ', i8)", int32 23 | print "('int64 ', i8)", int64 24 | print "('size(integer_kinds) ', i8)", size(integer_kinds) 25 | 26 | print "('real32 ', i8)", real32 27 | print "('real64 ', i8)", real64 28 | print "('real128 ', i8)", real128 29 | print "('size(real_kinds) ', i8)", size(real_kinds) 30 | 31 | print "('size(logical_kinds) ', i8)", size(logical_kinds) 32 | print "('size(character_kinds) ', i8)", size(character_kinds) 33 | 34 | print "('compiler_version(): ', a)", compiler 35 | print "('compiler_options(): ', a)", options 36 | 37 | end program print_iso_fortran_env 38 | -------------------------------------------------------------------------------- /exercises/10-modules-again/solutions/file_formatted.f90: -------------------------------------------------------------------------------- 1 | module file_formatted 2 | 3 | use file_module 4 | implicit none 5 | private 6 | 7 | type, extends(file_writer_t), public :: file_formatted_writer_t 8 | private 9 | integer :: myunit 10 | contains 11 | procedure, pass :: open => open_formatted 12 | procedure, pass :: write => write_formatted 13 | procedure, pass :: close => close_formatted 14 | end type file_formatted_writer_t 15 | 16 | contains 17 | 18 | !---------------------------------------------------------------------------- 19 | 20 | function open_formatted(self, filename) result(ierr) 21 | 22 | class (file_formatted_writer_t), intent(inout) :: self 23 | character (len = *), intent(in) :: filename 24 | integer :: ierr 25 | 26 | open (newunit = self%myunit, file = filename, form = 'formatted', & 27 | status = "replace", action = 'write', iostat = ierr) 28 | 29 | end function open_formatted 30 | 31 | function write_formatted(self, data) result(ierr) 32 | 33 | class (file_formatted_writer_t), intent(inout) :: self 34 | integer, intent(in) :: data(:) 35 | integer :: ierr 36 | 37 | write (unit = self%myunit, fmt = *, iostat = ierr) data(:) 38 | 39 | end function write_formatted 40 | 41 | function close_formatted(self) result(ierr) 42 | 43 | class (file_formatted_writer_t), intent(inout) :: self 44 | integer :: ierr 45 | 46 | close (unit = self%myunit, status = 'keep', iostat = ierr) 47 | 48 | end function close_formatted 49 | 50 | end module file_formatted 51 | -------------------------------------------------------------------------------- /exercises/14-interoperability-with-c/print_iso_c_binding.f90: -------------------------------------------------------------------------------- 1 | program print_iso_c_binding 2 | 3 | ! The contents of iso_c_binding 4 | 5 | use iso_c_binding 6 | implicit none 7 | 8 | print "('c_int ', i8)", c_int 9 | print "('c_short ', i8)", c_short 10 | print "('c_long ', i8)", c_long 11 | print "('c_long_long ', i8)", c_long_long 12 | print "('c_signed_char ', i8)", c_signed_char 13 | print "('c_size_t ', i8)", c_size_t 14 | print "('c_int8_t ', i8)", c_int8_t 15 | print "('c_int32_t ', i8)", c_int32_t 16 | print "('c_int64_t ', i8)", c_int64_t 17 | print "('c_int_least8_t ', i8)", c_int_least8_t 18 | print "('c_int_least16_t ', i8)", c_int_least16_t 19 | print "('c_int_least32_t ', i8)", c_int_least32_t 20 | print "('c_int_least64_t ', i8)", c_int_least64_t 21 | print "('c_int_fast8_t ', i8)", c_int_fast8_t 22 | print "('c_int_fast16_t ', i8)", c_int_fast16_t 23 | print "('c_int_fast32_t ', i8)", c_int_fast32_t 24 | print "('c_int_fast64_t ', i8)", c_int_fast64_t 25 | print "('c_intmax_t ', i8)", c_intmax_t 26 | print "('c_intptr_t ', i8)", c_intptr_t 27 | 28 | print "('c_float ', i8)", c_float 29 | print "('c_double ', i8)", c_double 30 | print "('c_long_double ', i8)", c_long_double 31 | 32 | print "('c_float_complex ', i8)", c_float_complex 33 | print "('c_double_complex ', i8)", c_double_complex 34 | print "('c_long_double_complex ', i8)", c_long_double_complex 35 | 36 | print "('c_bool ', i8)", c_bool 37 | print "('c_char ', i8)", c_char 38 | 39 | end program print_iso_c_binding 40 | -------------------------------------------------------------------------------- /_includes/gh_variables.html: -------------------------------------------------------------------------------- 1 | {% comment %} 2 | When rendering websites locally, `site.github.url` doesn't get resolved properly 3 | unless a GitHub Personal Access Token is set up and available in the 4 | environment. This leads to warnings and errors when trying to serve the site 5 | locally. To work around this, we use the `jekyll.environment` variable which is 6 | set to `development` when rendering the site locally, and set to `production` on 7 | GitHub where `site.github.url` is defined. 8 | {% endcomment %} 9 | 10 | {% if jekyll.environment == "production" %} 11 | 12 | {% comment %} 13 | First, get the name of the repository 14 | {% endcomment %} 15 | {% assign repo_name = site.github.repository_name %} 16 | 17 | {% comment %} 18 | `site.github.public_repositories` contains comprehensive information for all public repositories for the organization. We use `where` to extract the part 19 | of the metadata that is relevant to the present repository. 20 | {% endcomment %} 21 | {% assign repo_info = site.github.public_repositories | where: "name", repo_name %} 22 | 23 | {% comment %} 24 | Now, we can extract the default branch for the repo 25 | {% endcomment %} 26 | {% assign default_branch = repo_info[0].default_branch %} 27 | 28 | {% comment %} 29 | Other variables requested by the template 30 | {% endcomment %} 31 | {% assign repo_url = site.github.repository_url %} 32 | {% assign search_domain_url = site.github.url %} 33 | {% assign project_title = site.github.project_title %} 34 | {% assign source_branch = site.github.source.branch %} 35 | 36 | {% elsif jekyll.environment == "development" %} 37 | 38 | {% assign repo_name = "" %} 39 | {% assign repo_url = "" %} 40 | {% assign default_branch = "" %} 41 | {% assign search_domain_url = "" %} 42 | {% assign project_title = "" %} 43 | {% assign source_branch = "" %} 44 | 45 | {% endif %} 46 | -------------------------------------------------------------------------------- /_layouts/base.html: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | {% include base_path.html %} 4 | {% include gh_variables.html %} 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | {% include favicons.html %} 21 | 22 | 23 | 24 | 28 | {{ site.title }}{% if page.title %}: {{ page.title }}{% endif %} 29 | 30 | 31 | 32 | {% include life_cycle.html %} 33 | 34 |
35 | {% include navbar.html %} 36 | {{ content }} 37 | {% if site.kind == "workshop" %} 38 | {% include workshop_footer.html %} 39 | {% else %} 40 | {% include lesson_footer.html %} 41 | {% endif %} 42 |
43 | {% include javascript.html %} 44 | 45 | 46 | -------------------------------------------------------------------------------- /assets/js/lesson.js: -------------------------------------------------------------------------------- 1 | // Make all tables striped by default. 2 | $("table").addClass("table table-striped"); 3 | 4 | 5 | // Handle foldable challenges and solutions (on click and at start). 6 | $(".solution").click(function(event) { 7 | var trigger = $(event.target).has(".fold-unfold").size() > 0 8 | || $(event.target).filter(".fold-unfold").size() > 0; 9 | if (trigger) { 10 | $(">*:not(h2)", this).toggle(400); 11 | $(">h2>span.fold-unfold", this).toggleClass("glyphicon-collapse-down glyphicon-collapse-up"); 12 | event.stopPropagation(); 13 | } 14 | }); 15 | $(".solution").each(function() { 16 | $(">*:not(h2)", this).toggle(); 17 | var h2 = $("h2:first", this); 18 | h2.append(""); 19 | }); 20 | 21 | 22 | // Handle searches. 23 | // Relies on document having 'meta' element with name 'search-domain'. 24 | function google_search() { 25 | var query = document.getElementById("google-search").value; 26 | var domain = $("meta[name=search-domain]").attr("value"); 27 | window.open("https://www.google.com/search?q=" + query + "+site:" + domain); 28 | } 29 | 30 | // function to shrink the life cycle bar when scrolling 31 | $(function(){ 32 | $('#life-cycle').data('size','big'); 33 | }); 34 | 35 | $(window).scroll(function(){ 36 | if($(document).scrollTop() > 0) 37 | { 38 | if($('#life-cycle').data('size') == 'big') 39 | { 40 | $('#life-cycle').data('size','small'); 41 | $('#life-cycle').stop().animate({ 42 | padding: '5px' 43 | },100); 44 | } 45 | } 46 | else 47 | { 48 | if($('#life-cycle').data('size') == 'small') 49 | { 50 | $('#life-cycle').data('size','big'); 51 | $('#life-cycle').stop().animate({ 52 | padding: '15px' 53 | },100); 54 | } 55 | } 56 | }); 57 | -------------------------------------------------------------------------------- /exercises/10-modules-again/solutions/file_unformatted.f90: -------------------------------------------------------------------------------- 1 | module file_unformatted 2 | 3 | use file_module 4 | implicit none 5 | private 6 | 7 | type, extends(file_writer_t), public :: file_unformatted_writer_t 8 | private 9 | integer :: myunit 10 | contains 11 | procedure, pass :: open => open_unformatted 12 | procedure, pass :: write => write_unformatted 13 | procedure, pass :: close => close_unformatted 14 | end type file_unformatted_writer_t 15 | 16 | contains 17 | 18 | !---------------------------------------------------------------------------- 19 | 20 | function open_unformatted(self, filename) result(ierr) 21 | 22 | class (file_unformatted_writer_t), intent(inout) :: self 23 | character (len = *), intent(in) :: filename 24 | integer :: ierr 25 | 26 | open (newunit = self%myunit, file = filename, form = 'unformatted', & 27 | status = "replace", action = 'write', iostat = ierr) 28 | 29 | end function open_unformatted 30 | 31 | function write_unformatted(self, data) result(ierr) 32 | 33 | class (file_unformatted_writer_t), intent(inout) :: self 34 | integer, intent(in) :: data(:) 35 | integer :: ierr 36 | 37 | write (unit = self%myunit, iostat = ierr) data(:) 38 | 39 | end function write_unformatted 40 | 41 | function close_unformatted(self) result(ierr) 42 | 43 | class (file_unformatted_writer_t), intent(inout) :: self 44 | integer :: ierr 45 | 46 | close (unit = self%myunit, status = 'keep', iostat = ierr) 47 | 48 | end function close_unformatted 49 | 50 | !---------------------------------------------------------------------------- 51 | 52 | function create_file_unformatted_writer_t() result(fp) 53 | 54 | class (file_unformatted_writer_t), pointer :: fp 55 | allocate(fp) 56 | 57 | end function create_file_unformatted_writer_t 58 | 59 | end module file_unformatted 60 | -------------------------------------------------------------------------------- /bin/generate_md_episodes.R: -------------------------------------------------------------------------------- 1 | generate_md_episodes <- function() { 2 | 3 | library("methods") 4 | 5 | if (!require("remotes", quietly = TRUE)) { 6 | install.packages("remotes", repos = c(CRAN = "https://cloud.r-project.org/")) 7 | } 8 | 9 | if (!require("requirements", quietly = TRUE)) { 10 | remotes::install_github("hadley/requirements") 11 | } 12 | 13 | required_pkgs <- unique(c( 14 | ## Packages for episodes 15 | requirements:::req_dir("_episodes_rmd"), 16 | ## Pacakges for tools 17 | requirements:::req_dir("bin") 18 | )) 19 | 20 | missing_pkgs <- setdiff(required_pkgs, rownames(installed.packages())) 21 | 22 | if (length(missing_pkgs)) { 23 | message("Installing missing required packages: ", 24 | paste(missing_pkgs, collapse=", ")) 25 | install.packages(missing_pkgs) 26 | } 27 | 28 | if (require("knitr") && packageVersion("knitr") < '1.9.19') 29 | stop("knitr must be version 1.9.20 or higher") 30 | 31 | ## get the Rmd file to process from the command line, and generate the path for their respective outputs 32 | args <- commandArgs(trailingOnly = TRUE) 33 | if (!identical(length(args), 2L)) { 34 | stop("input and output file must be passed to the script") 35 | } 36 | 37 | src_rmd <- args[1] 38 | dest_md <- args[2] 39 | 40 | ## knit the Rmd into markdown 41 | knitr::knit(src_rmd, output = dest_md) 42 | 43 | # Read the generated md files and add comments advising not to edit them 44 | vapply(dest_md, function(y) { 45 | con <- file(y) 46 | mdfile <- readLines(con) 47 | if (mdfile[1] != "---") 48 | stop("Input file does not have a valid header") 49 | mdfile <- append(mdfile, "# Please do not edit this file directly; it is auto generated.", after = 1) 50 | mdfile <- append(mdfile, paste("# Instead, please edit", 51 | basename(y), "in _episodes_rmd/"), after = 2) 52 | writeLines(mdfile, con) 53 | close(con) 54 | return(paste("Warning added to YAML header of", y)) 55 | }, 56 | character(1)) 57 | } 58 | 59 | generate_md_episodes() 60 | -------------------------------------------------------------------------------- /exercises/08-generic-io-for-derived-types/solutions/date_module.f90: -------------------------------------------------------------------------------- 1 | module date_module 2 | 3 | ! A module which defines a simple date type, and overrides the 4 | ! default formatted write. 5 | 6 | implicit none 7 | 8 | type :: my_type 9 | integer :: day = 0 10 | integer :: month = 0 11 | integer :: year = 0 12 | contains 13 | procedure :: write_my_type 14 | generic :: write(formatted) => write_my_type 15 | end type my_type 16 | 17 | ! Define some months, so we can produce formats like "12 Dec 2022" 18 | character (len = 3), dimension(12), parameter :: months = & 19 | [character (len = 3) :: "Jan", "Feb", "Mar", "Apr", "May", "Jun", & 20 | "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ] 21 | contains 22 | 23 | subroutine write_my_type(self, unit, iotype, vlist, iostat, iomsg) 24 | 25 | class (my_type), intent(in) :: self 26 | integer, intent(in) :: unit 27 | character (len = *), intent(in) :: iotype 28 | integer, intent(in) :: vlist(:) 29 | integer, intent(out) :: iostat 30 | character (len = *), intent(inout) :: iomsg 31 | 32 | character (len = *), parameter :: dfmt = "(i2.2,'/',i2.2,'/',i4)" 33 | iostat = 0 ! we will assume no errors occur (iomsg is unchanged) 34 | 35 | if (iotype == "LISTDIRECTED") then 36 | write(unit, fmt = dfmt, iostat = iostat) self%day, self%month, self%year 37 | else 38 | ! A dt-style format 39 | ! We will only consider the case of vlist(3) 40 | if (size(vlist) == 3) then 41 | block 42 | character (len = 20) :: userfmt 43 | write (userfmt, "(a,i1,a,i2,a,i1,a)") & 44 | "(i", vlist(1), ",a", vlist(2), ",i", vlist(3), ")" 45 | write(unit, userfmt, iostat = iostat) & 46 | self%day, months(self%month), self%year 47 | end block 48 | else 49 | ! Handle other conditions; we will just use the default format 50 | write (unit, dfmt, iostat = iostat) self%day, self%month, self%year 51 | end if 52 | end if 53 | 54 | end subroutine write_my_type 55 | 56 | end module date_module 57 | -------------------------------------------------------------------------------- /exercises/14-interoperability-with-c/solutions/f_snprintf.f90: -------------------------------------------------------------------------------- 1 | program example1 2 | 3 | use iso_c_binding, only : c_int, c_char, c_size_t, c_float, c_double, c_null_char 4 | implicit none 5 | 6 | interface 7 | function f_snprintf_float(str, sz, cformat, x) & 8 | bind(c, name = "c_snprintf_float") result(nchar) 9 | use iso_c_binding, only : c_int, c_char, c_size_t, c_float 10 | character (kind = c_char, len = 1), intent(out) :: str(*) 11 | integer (kind = c_size_t), value, intent(in) :: sz 12 | character (kind = c_char, len = 1), intent(in) :: cformat(*) 13 | real (kind = c_float), value, intent(in) :: x 14 | integer (kind = c_int) :: nchar 15 | end function f_snprintf_float 16 | 17 | function f_snprintf_double(str, sz, cformat, x) & 18 | bind(c, name = "c_snprintf_double") result(nchar) 19 | use iso_c_binding, only : c_int, c_char, c_size_t, c_double 20 | character (kind = c_char, len = 1), intent(out) :: str(*) 21 | integer (kind = c_size_t), value, intent(in) :: sz 22 | character (kind = c_char, len = 1), intent(in) :: cformat(*) 23 | real (kind = c_double), value, intent(in) :: x 24 | integer (kind = c_int) :: nchar 25 | end function f_snprintf_double 26 | end interface 27 | 28 | integer (c_size_t), parameter :: sz = 80 29 | character (kind = c_char, len = sz) :: str = "" 30 | character (kind = c_char, len = 10) :: cformat 31 | real (c_float) :: x = 3.14e0 32 | real (c_double) :: y = 2.71d0 33 | 34 | integer (c_int) :: nwrite = 0 35 | 36 | print *, "Single precision:" 37 | cformat = "%5.3f" 38 | print *, "Format ", cformat 39 | nwrite = f_snprintf_float(str, sz, trim(cformat), x) 40 | print *, "Return value ", nwrite 41 | print *, "Index of null ", index(str, c_null_char) 42 | print *, "String ", trim(str), len_trim(str) 43 | 44 | print *, "Double precision:" 45 | cformat = "%22.15e" 46 | print *, "Format ", cformat 47 | nwrite = f_snprintf_double(str, sz, trim(cformat), y) 48 | print *, "Return value ", nwrite 49 | print *, "Index of null ", index(str, c_null_char) 50 | print *, "String ", trim(str), len_trim(str) 51 | 52 | end program example1 53 | -------------------------------------------------------------------------------- /_extras/figures.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Figures 3 | --- 4 | 5 | {% include base_path.html %} 6 | 7 | 61 | {% comment %} 62 | Create anchor for each one of the episodes. 63 | {% endcomment %} 64 | {% for episode in site.episodes %} 65 |
66 | {% endfor %} 67 | 68 | {% include links.md %} 69 | -------------------------------------------------------------------------------- /bin/boilerplate/_extras/figures.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Figures 3 | --- 4 | 5 | {% include base_path.html %} 6 | 7 | 61 | {% comment %} 62 | Create anchor for each one of the episodes. 63 | {% endcomment %} 64 | {% for episode in site.episodes %} 65 |
66 | {% endfor %} 67 | 68 | {% include links.md %} 69 | -------------------------------------------------------------------------------- /bin/chunk-options.R: -------------------------------------------------------------------------------- 1 | # These settings control the behavior of all chunks in the novice R materials. 2 | # For example, to generate the lessons with all the output hidden, simply change 3 | # `results` from "markup" to "hide". 4 | # For more information on available chunk options, see 5 | # http://yihui.name/knitr/options#chunk_options 6 | 7 | library("knitr") 8 | 9 | fix_fig_path <- function(pth) file.path("..", pth) 10 | 11 | 12 | ## We set the path for the figures globally below, so if we want to 13 | ## customize it for individual episodes, we can append a prefix to the 14 | ## global path. For instance, if we call knitr_fig_path("01-") in the 15 | ## first episode of the lesson, it will generate the figures in 16 | ## `fig/rmd-01-` 17 | knitr_fig_path <- function(prefix) { 18 | new_path <- paste0(opts_chunk$get("fig.path"), 19 | prefix) 20 | opts_chunk$set(fig.path = new_path) 21 | } 22 | 23 | ## We use the rmd- prefix for the figures generated by the lessons so 24 | ## they can be easily identified and deleted by `make clean-rmd`. The 25 | ## working directory when the lessons are generated is the root so the 26 | ## figures need to be saved in fig/, but when the site is generated, 27 | ## the episodes will be one level down. We fix the path using the 28 | ## `fig.process` option. 29 | 30 | opts_chunk$set(tidy = FALSE, results = "markup", comment = NA, 31 | fig.align = "center", fig.path = "fig/rmd-", 32 | fig.process = fix_fig_path, 33 | fig.width = 8.5, fig.height = 8.5, 34 | fig.retina = 2) 35 | 36 | # The hooks below add html tags to the code chunks and their output so that they 37 | # are properly formatted when the site is built. 38 | 39 | hook_in <- function(x, options) { 40 | stringr::str_c("\n\n~~~\n", 41 | paste0(x, collapse="\n"), 42 | "\n~~~\n{: .language-r}\n\n") 43 | } 44 | 45 | hook_out <- function(x, options) { 46 | x <- gsub("\n$", "", x) 47 | stringr::str_c("\n\n~~~\n", 48 | paste0(x, collapse="\n"), 49 | "\n~~~\n{: .output}\n\n") 50 | } 51 | 52 | hook_error <- function(x, options) { 53 | x <- gsub("\n$", "", x) 54 | stringr::str_c("\n\n~~~\n", 55 | paste0(x, collapse="\n"), 56 | "\n~~~\n{: .error}\n\n") 57 | } 58 | 59 | knit_hooks$set(source = hook_in, output = hook_out, warning = hook_error, 60 | error = hook_error, message = hook_out) 61 | -------------------------------------------------------------------------------- /_layouts/workshop.html: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | {% include base_path.html %} 4 | {% include gh_variables.html %} 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 26 | {% endif %} 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | {% include favicons.html %} 38 | 39 | 40 | 41 | 45 | {{ page.venue }}: {{ page.humandate }} 46 | 47 | 48 |
49 | {% include navbar.html %} 50 | {% include workshop_ad.html %} 51 | {{ content }} 52 | {% include workshop_footer.html %} 53 |
54 | {% include javascript.html %} 55 | 56 | 57 | -------------------------------------------------------------------------------- /_includes/lesson_footer.html: -------------------------------------------------------------------------------- 1 | {% comment %} 2 | Footer for lesson pages. 3 | {% endcomment %} 4 | 5 | {% include gh_variables.html %} 6 | 7 | 57 | -------------------------------------------------------------------------------- /_includes/favicons.html: -------------------------------------------------------------------------------- 1 | {% assign favicon_url = relative_root_path | append: '/assets/favicons/' | append: site.carpentry %} 2 | 3 | {% if site.carpentry == 'swc' %} 4 | {% assign carpentry = 'Software Carpentry' %} 5 | {% elsif site.carpentry == 'dc' %} 6 | {% assign carpentry = 'Data Carpentry' %} 7 | {% elsif site.carpentry == 'lc' %} 8 | {% assign carpentry = 'Library Carpentry' %} 9 | {% elsif site.carpentry == 'cp' %} 10 | {% assign carpentry = 'The Carpentries' %} 11 | {% endif %} 12 | 13 | 35 | -------------------------------------------------------------------------------- /_includes/lc/syllabus.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |

Data Intro

4 |
    5 |
  • Intro to data
  • 6 |
  • Jargon busting
  • 7 |
  • Keyboard shortcuts
  • 8 |
  • Plain text formats
  • 9 |
  • Naming files
  • 10 |
  • Regular expressions
  • 11 |
  • Reference...
  • 12 |
13 |
14 |
15 |

The Unix Shell

16 |
    17 |
  • Files and directories
  • 18 |
  • History and tab completion
  • 19 |
  • Counting and sorting contents in files
  • 20 |
  • Pipes and redirection
  • 21 |
  • Mining or searching in files
  • 22 |
  • Reference...
  • 23 |
24 |
25 | 26 |
27 | 28 |
29 |
30 |

Version Control with Git

31 |
    32 |
  • Creating a repository
  • 33 |
  • Configuring git
  • 34 |
  • Recording changes to files: add, commit, ...
  • 35 |
  • Viewing state changes with status
  • 36 |
  • Working on the web: clone, pull, push, ...
  • 37 |
  • Where to host work, and why
  • 38 |
  • Reference...
  • 39 |
40 |
41 |
42 |
43 |

Open Refine

44 |
    45 |
  • Introduction to OpenRefine
  • 46 |
  • Importing data
  • 47 |
  • Basic functions
  • 48 |
  • Advanced Functions
  • 49 |
  • Reference...
  • 50 |
51 |
52 |
53 |
54 | 70 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: "Licences" 4 | root: . 5 | --- 6 | 7 | ### Context 8 | This is not an official lesson of the Carpentries, however the licencing approach that the Carpentries take is ideal, so much of the material below resembles the Carpentries' documentation, where this is appropriate. 9 | 10 | ### Instructional Material 11 | 12 | All of the instructional material is 13 | made available under the [Creative Commons Attribution 14 | license][cc-by-human]. The following is a human-readable summary of 15 | (and not a substitute for) the [full legal text of the CC BY 4.0 16 | license][cc-by-legal]. 17 | 18 | You are free: 19 | 20 | * to **Share**---copy and redistribute the material in any medium or format 21 | * to **Adapt**---remix, transform, and build upon the material 22 | 23 | for any purpose, even commercially. 24 | 25 | The licensor cannot revoke these freedoms as long as you follow the 26 | license terms. 27 | 28 | Under the following terms: 29 | 30 | * **Attribution**---You must give appropriate credit (mentioning that 31 | your work is derived from work that is Copyright © Software 32 | Carpentry and, where practical, linking to 33 | http://software-carpentry.org/), provide a [link to the 34 | license][cc-by-human], and indicate if changes were made. You may do 35 | so in any reasonable manner, but not in any way that suggests the 36 | licensor endorses you or your use. 37 | 38 | **No additional restrictions**---You may not apply legal terms or 39 | technological measures that legally restrict others from doing 40 | anything the license permits. With the understanding that: 41 | 42 | Notices: 43 | 44 | * You do not have to comply with the license for elements of the 45 | material in the public domain or where your use is permitted by an 46 | applicable exception or limitation. 47 | * No warranties are given. The license may not give you all of the 48 | permissions necessary for your intended use. For example, other 49 | rights such as publicity, privacy, or moral rights may limit how you 50 | use the material. 51 | 52 | ### Software 53 | 54 | The example programs within this lesson is made available under the 55 | [OSI][osi]-approved 56 | [MIT license][mit-license]. 57 | 58 | Permission is hereby granted, free of charge, to any person obtaining 59 | a copy of this software and associated documentation files (the 60 | "Software"), to deal in the Software without restriction, including 61 | without limitation the rights to use, copy, modify, merge, publish, 62 | distribute, sublicense, and/or sell copies of the Software, and to 63 | permit persons to whom the Software is furnished to do so, subject to 64 | the following conditions: 65 | 66 | The above copyright notice and this permission notice shall be 67 | included in all copies or substantial portions of the Software. 68 | 69 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 70 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 71 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 72 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 73 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 74 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 75 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 76 | 77 | [cc-by-human]: https://creativecommons.org/licenses/by/4.0/ 78 | [cc-by-legal]: https://creativecommons.org/licenses/by/4.0/legalcode 79 | [mit-license]: https://opensource.org/licenses/mit-license.html 80 | [ci]: http://communityin.org/ 81 | [osi]: https://opensource.org 82 | -------------------------------------------------------------------------------- /_includes/syllabus.html: -------------------------------------------------------------------------------- 1 | {% include base_path.html %} 2 | 3 | {% comment %} 4 | Display syllabus in tabular form. 5 | Days are displayed if at least one episode has 'start = true'. 6 | {% endcomment %} 7 |
8 |

Schedule

9 | 10 | {% assign lesson_number = 0 %} 11 | {% assign day = 0 %} 12 | {% assign multiday = false %} 13 | {% for episode in site.episodes %} 14 | {% if episode.start %}{% assign multiday = true %}{% break %}{% endif %} 15 | {% endfor %} 16 | {% assign current = site.start_time %} 17 | 18 | 19 | 20 | {% if multiday %}{% endif %} 21 | 22 | 23 | 24 | 25 | {% for episode in site.episodes %} 26 | {% if episode.start %} {% comment %} Starting a new day? {% endcomment %} 27 | {% assign day = day | plus: 1 %} 28 | {% if day > 1 %} {% comment %} If about to start day 2 or later, show finishing time for previous day {% endcomment %} 29 | {% assign hours = current | divided_by: 60 %} 30 | {% assign minutes = current | modulo: 60 %} 31 | 32 | {% if multiday %}{% endif %} 33 | 34 | 35 | 36 | 37 | {% endif %} 38 | {% assign current = site.start_time %} {% comment %}Re-set start time of this episode to general daily start time {% endcomment %} 39 | {% endif %} 40 | {% assign hours = current | divided_by: 60 %} 41 | {% assign minutes = current | modulo: 60 %} 42 | 43 | {% if multiday %}{% endif %} 44 | 45 | 49 | 63 | 64 | {% assign current = current | plus: episode.teaching | plus: episode.exercises | plus: episode.break %} 65 | {% endfor %} 66 | {% assign hours = current | divided_by: 60 %} 67 | {% assign minutes = current | modulo: 60 %} 68 | 69 | {% if multiday %}{% endif %} 70 | 71 | 72 | 73 | 74 |
SetupDownload files required for the lesson
{% if hours < 10 %}0{% endif %}{{ hours }}:{% if minutes < 10 %}0{% endif %}{{ minutes }}Finish
{% if episode.start %}Day {{ day }}{% endif %}{% if hours < 10 %}0{% endif %}{{ hours }}:{% if minutes < 10 %}0{% endif %}{{ minutes }} 46 | {% assign lesson_number = lesson_number | plus: 1 %} 47 | {{ lesson_number }}. {{ episode.title }} 48 | 50 | {% if episode.break %} 51 | Break 52 | {% else %} 53 | {% if episode.questions %} 54 | {% for question in episode.questions %} 55 | {{question|markdownify|strip_html}} 56 | {% unless forloop.last %} 57 |
58 | {% endunless %} 59 | {% endfor %} 60 | {% endif %} 61 | {% endif %} 62 |
{% if hours < 10 %}0{% endif %}{{ hours }}:{% if minutes < 10 %}0{% endif %}{{ minutes }}Finish
75 | 76 |

77 | The actual schedule may vary slightly depending on the topics and exercises chosen by the instructor. 78 |

79 | 80 |
81 | -------------------------------------------------------------------------------- /_includes/dc/syllabus.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |

The Unix Shell

4 |
    5 |
  • Files and directories
  • 6 |
  • History and tab completion
  • 7 |
  • Pipes and redirection
  • 8 |
  • Looping over files
  • 9 |
  • Creating and running shell scripts
  • 10 |
  • Finding things
  • 11 |
  • Reference...
  • 12 |
13 |
14 |
15 |

Programming in Python

16 |
    17 |
  • Using libraries
  • 18 |
  • Working with arrays
  • 19 |
  • Reading and plotting data
  • 20 |
  • Creating and using functions
  • 21 |
  • Loops and conditionals
  • 22 |
  • Defensive programming
  • 23 |
  • Using Python from the command line
  • 24 |
  • Reference...
  • 25 |
26 |
27 | 40 | 53 |
54 | 55 |
56 |
57 |

Version Control with Git

58 |
    59 |
  • Creating a repository
  • 60 |
  • Recording changes to files: add, commit, ...
  • 61 |
  • Viewing changes: status, diff, ...
  • 62 |
  • Ignoring files
  • 63 |
  • Working on the web: clone, pull, push, ...
  • 64 |
  • Resolving conflicts
  • 65 |
  • Open licenses
  • 66 |
  • Where to host work, and why
  • 67 |
  • Reference...
  • 68 |
69 |
70 | 86 |
87 |

Open Refine

88 |
    89 |
  • Introduction to OpenRefine
  • 90 |
  • Importing data
  • 91 |
  • Basic functions
  • 92 |
  • Advanced Functions
  • 93 |
  • Reference...
  • 94 |
95 |
96 |
97 | -------------------------------------------------------------------------------- /_includes/sc/syllabus.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |

The Unix Shell

4 |
    5 |
  • Files and directories
  • 6 |
  • History and tab completion
  • 7 |
  • Pipes and redirection
  • 8 |
  • Looping over files
  • 9 |
  • Creating and running shell scripts
  • 10 |
  • Finding things
  • 11 |
  • Reference...
  • 12 |
13 |
14 |
15 |

Programming in Python

16 |
    17 |
  • Using libraries
  • 18 |
  • Working with arrays
  • 19 |
  • Reading and plotting data
  • 20 |
  • Creating and using functions
  • 21 |
  • Loops and conditionals
  • 22 |
  • Defensive programming
  • 23 |
  • Using Python from the command line
  • 24 |
  • Reference...
  • 25 |
26 |
27 | 40 | 53 |
54 | 55 |
56 |
57 |

Version Control with Git

58 |
    59 |
  • Creating a repository
  • 60 |
  • Recording changes to files: add, commit, ...
  • 61 |
  • Viewing changes: status, diff, ...
  • 62 |
  • Ignoring files
  • 63 |
  • Working on the web: clone, pull, push, ...
  • 64 |
  • Resolving conflicts
  • 65 |
  • Open licenses
  • 66 |
  • Where to host work, and why
  • 67 |
  • Reference...
  • 68 |
69 |
70 | 86 |
87 |

Open Refine

88 |
    89 |
  • Introduction to OpenRefine
  • 90 |
  • Importing data
  • 91 |
  • Basic functions
  • 92 |
  • Advanced Functions
  • 93 |
  • Reference...
  • 94 |
95 |
96 |
97 | -------------------------------------------------------------------------------- /_includes/navbar.html: -------------------------------------------------------------------------------- 1 | {% comment %} 2 | Lesson navigation bar. 3 | {% endcomment %} 4 | 5 | {% include gh_variables.html %} 6 | 7 | 76 | -------------------------------------------------------------------------------- /_includes/carpentries.html: -------------------------------------------------------------------------------- 1 | {% comment %} 2 | General description of Software, Data, and Library Carpentry. 3 | {% endcomment %} 4 | 5 | {% include base_path.html %} 6 | 7 |
8 |
9 | The Carpentries logo 10 |
11 |
12 |

The Carpentries comprises 13 | Software Carpentry, Data Carpentry, and Library Carpentry communities of Instructors, Trainers, 14 | Maintainers, helpers, and supporters who share a mission to teach 15 | foundational coding and data science skills to researchers and people 16 | working in library- and information-related roles. In January, 17 | 2018, The Carpentries was formed by the merger of Software Carpentry and 18 | Data Carpentry. Library Carpentry became an official Carpentries Lesson Program in November 2018.

19 | 20 |

While individual lessons and workshops continue to be run under each 21 | lesson project, The Carpentries provide overall staffing and governance, as 22 | well as support for assessment, instructor training and mentoring. 23 | Memberships are joint, and the Carpentries project maintains a shared Code 24 | of Conduct. The Carpentries is a fiscally sponsored project of Community 25 | Initiatives, a registered 501(c)3 non-profit based in California, USA.

26 |
27 |
28 |
29 |
30 | Software Carpentry logo 31 |
32 |
33 |

Since 1998, Software Carpentry has 34 | been teaching researchers across all disciplines the foundational coding 35 | skills they need to get more done in less time and with less pain. Its 36 | volunteer instructors have run hundreds of events for thousands of learners 37 | around the world. Now that all research involves some degree of 38 | computational work, whether with big data, cloud computing, or simple task 39 | automation, these skills are needed more than ever.

40 |
41 |
42 |
43 |
44 |
45 | Data Carpentry logo 46 |
47 |
48 |

Data Carpentry develops and teaches 49 | workshops on the fundamental data skills needed to conduct research. Its 50 | target audience is researchers who have little to no prior computational 51 | experience, and its lessons are domain specific, building on learners' 52 | existing knowledge to enable them to quickly apply skills learned to their 53 | own research. Data Carpentry workshops take researchers through the entire 54 | data life cycle.

55 |
56 |
57 |
58 |
59 |
60 | Library Carpentry logo 61 |
62 |
63 |

Library Carpentry develops lessons and 64 | teaches workshops for and with people working in library- and 65 | information-related roles. Its goal is to create an on-ramp to empower this 66 | community to use software and data in their own work, as well as be 67 | advocates for and train others in efficient, effective and reproducible data 68 | and software practices.

69 |
70 |
71 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------ 2 | # Values for this lesson. 3 | #------------------------------------------------------------ 4 | 5 | # Which carpentry is this ("swc", "dc", "lc", or "cp")? 6 | # swc: Software Carpentry 7 | # dc: Data Carpentry 8 | # lc: Library Carpentry 9 | # cp: Carpentries (to use for instructor training for instance) 10 | carpentry: "swc" 11 | 12 | # Overall title for pages. 13 | title: "Intermediate Modern Fortran" 14 | 15 | # Life cycle stage of the lesson 16 | # possible values: "pre-alpha", "alpha", "beta", "stable" 17 | life_cycle: "stable" 18 | 19 | #------------------------------------------------------------ 20 | # Generic settings (should not need to change). 21 | #------------------------------------------------------------ 22 | 23 | # What kind of thing is this ("workshop" or "lesson")? 24 | kind: "lesson" 25 | 26 | # Magic to make URLs resolve both locally and on GitHub. 27 | # See https://help.github.com/articles/repository-metadata-on-github-pages/. 28 | # Please don't change it: / is correct. 29 | repository: / 30 | 31 | # Email address, no mailto: 32 | email: "support@archer2.ac.uk" 33 | 34 | # Sites. 35 | amy_site: "https://amy.software-carpentry.org/workshops" 36 | carpentries_github: "https://github.com/carpentries" 37 | carpentries_pages: "https://carpentries.github.io" 38 | carpentries_site: "https://carpentries.org/" 39 | dc_site: "http://datacarpentry.org" 40 | example_repo: "https://github.com/carpentries/lesson-example" 41 | example_site: "https://carpentries.github.io/lesson-example" 42 | lc_site: "https://librarycarpentry.org/" 43 | swc_github: "https://github.com/swcarpentry" 44 | swc_pages: "https://swcarpentry.github.io" 45 | swc_site: "https://software-carpentry.org" 46 | template_repo: "https://github.com/carpentries/styles" 47 | training_site: "https://carpentries.github.io/instructor-training" 48 | workshop_repo: "https://github.com/carpentries/workshop-template" 49 | workshop_site: "https://carpentries.github.io/workshop-template" 50 | cc_by_human: "https://creativecommons.org/licenses/by/4.0/" 51 | 52 | # Surveys. 53 | swc_pre_survey: "https://www.surveymonkey.com/r/swc_pre_workshop_v1?workshop_id=" 54 | swc_post_survey: "https://www.surveymonkey.com/r/swc_post_workshop_v1?workshop_id=" 55 | training_post_survey: "https://www.surveymonkey.com/r/post-instructor-training" 56 | dc_pre_survey: "https://www.surveymonkey.com/r/dcpreworkshopassessment?workshop_id=" 57 | dc_post_survey: "https://www.surveymonkey.com/r/dcpostworkshopassessment?workshop_id=" 58 | lc_pre_survey: "https://www.surveymonkey.com/r/lcpreworkshopsurvey?workshop_id=" 59 | lc_post_survey: "https://www.surveymonkey.com/r/lcpostworkshopsurvey?workshop_id=" 60 | instructor_pre_survey: "https://www.surveymonkey.com/r/instructor_training_pre_survey?workshop_id=" 61 | instructor_post_survey: "https://www.surveymonkey.com/r/instructor_training_post_survey?workshop_id=" 62 | 63 | 64 | # Start time in minutes (0 to be clock-independent, 540 to show a start at 09:00 am). 65 | start_time: 600 66 | 67 | # Specify that things in the episodes collection should be output. 68 | collections: 69 | episodes: 70 | output: true 71 | permalink: /:path/index.html 72 | extras: 73 | output: true 74 | permalink: /:path/index.html 75 | 76 | # Set the default layout for things in the episodes collection. 77 | defaults: 78 | - values: 79 | root: . 80 | layout: page 81 | - scope: 82 | path: "" 83 | type: episodes 84 | values: 85 | root: .. 86 | layout: episode 87 | - scope: 88 | path: "" 89 | type: extras 90 | values: 91 | root: .. 92 | layout: page 93 | 94 | # Files and directories that are not to be copied. 95 | exclude: 96 | - Makefile 97 | - bin/ 98 | - .Rproj.user/ 99 | 100 | # Turn on built-in syntax highlighting. 101 | highlighter: rouge 102 | -------------------------------------------------------------------------------- /bin/boilerplate/_config.yml: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------ 2 | # Values for this lesson. 3 | #------------------------------------------------------------ 4 | 5 | # Which carpentry is this ("swc", "dc", "lc", or "cp")? 6 | # swc: Software Carpentry 7 | # dc: Data Carpentry 8 | # lc: Library Carpentry 9 | # cp: Carpentries (to use for instructor traning for instance) 10 | carpentry: "swc" 11 | 12 | # Overall title for pages. 13 | title: "Lesson Title" 14 | 15 | # Life cycle stage of the lesson 16 | # possible values: "pre-alpha", "alpha", "beta", "stable" 17 | life_cycle: "pre-alpha" 18 | 19 | #------------------------------------------------------------ 20 | # Generic settings (should not need to change). 21 | #------------------------------------------------------------ 22 | 23 | # What kind of thing is this ("workshop" or "lesson")? 24 | kind: "lesson" 25 | 26 | # Magic to make URLs resolve both locally and on GitHub. 27 | # See https://help.github.com/articles/repository-metadata-on-github-pages/. 28 | # Please don't change it: / is correct. 29 | repository: / 30 | 31 | # Email address, no mailto: 32 | email: "team@carpentries.org" 33 | 34 | # Sites. 35 | amy_site: "https://amy.software-carpentry.org/workshops" 36 | carpentries_github: "https://github.com/carpentries" 37 | carpentries_pages: "https://carpentries.github.io" 38 | carpentries_site: "https://carpentries.org/" 39 | dc_site: "http://datacarpentry.org" 40 | example_repo: "https://github.com/carpentries/lesson-example" 41 | example_site: "https://carpentries.github.io/lesson-example" 42 | lc_site: "https://librarycarpentry.org/" 43 | swc_github: "https://github.com/swcarpentry" 44 | swc_pages: "https://swcarpentry.github.io" 45 | swc_site: "https://software-carpentry.org" 46 | template_repo: "https://github.com/carpentries/styles" 47 | training_site: "https://carpentries.github.io/instructor-training" 48 | workshop_repo: "https://github.com/carpentries/workshop-template" 49 | workshop_site: "https://carpentries.github.io/workshop-template" 50 | cc_by_human: "https://creativecommons.org/licenses/by/4.0/" 51 | 52 | # Surveys. 53 | swc_pre_survey: "https://www.surveymonkey.com/r/swc_pre_workshop_v1?workshop_id=" 54 | swc_post_survey: "https://www.surveymonkey.com/r/swc_post_workshop_v1?workshop_id=" 55 | training_post_survey: "https://www.surveymonkey.com/r/post-instructor-training" 56 | dc_pre_survey: "https://www.surveymonkey.com/r/dcpreworkshopassessment?workshop_id=" 57 | dc_post_survey: "https://www.surveymonkey.com/r/dcpostworkshopassessment?workshop_id=" 58 | lc_pre_survey: "https://www.surveymonkey.com/r/lcpreworkshopsurvey?workshop_id=" 59 | lc_post_survey: "https://www.surveymonkey.com/r/lcpostworkshopsurvey?workshop_id=" 60 | instructor_pre_survey: "https://www.surveymonkey.com/r/instructor_training_pre_survey?workshop_id=" 61 | instructor_post_survey: "https://www.surveymonkey.com/r/instructor_training_post_survey?workshop_id=" 62 | 63 | 64 | # Start time in minutes (0 to be clock-independent, 540 to show a start at 09:00 am). 65 | start_time: 0 66 | 67 | # Specify that things in the episodes collection should be output. 68 | collections: 69 | episodes: 70 | output: true 71 | permalink: /:path/index.html 72 | extras: 73 | output: true 74 | permalink: /:path/index.html 75 | 76 | # Set the default layout for things in the episodes collection. 77 | defaults: 78 | - values: 79 | root: . 80 | layout: page 81 | - scope: 82 | path: "" 83 | type: episodes 84 | values: 85 | root: .. 86 | layout: episode 87 | - scope: 88 | path: "" 89 | type: extras 90 | values: 91 | root: .. 92 | layout: page 93 | 94 | # Files and directories that are not to be copied. 95 | exclude: 96 | - Makefile 97 | - bin/ 98 | - .Rproj.user/ 99 | 100 | # Turn on built-in syntax highlighting. 101 | highlighter: rouge 102 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | ## ======================================== 2 | ## Commands for both workshop and lesson websites. 3 | 4 | # Settings 5 | MAKEFILES=Makefile $(wildcard *.mk) 6 | JEKYLL=jekyll 7 | JEKYLL_VERSION=3.7.3 8 | PARSER=bin/markdown_ast.rb 9 | DST=_site 10 | 11 | # Controls 12 | .PHONY : commands clean files 13 | .NOTPARALLEL: 14 | all : commands 15 | 16 | ## commands : show all commands. 17 | commands : 18 | @grep -h -E '^##' ${MAKEFILES} | sed -e 's/## //g' 19 | 20 | ## docker-serve : use docker to build the site 21 | docker-serve : 22 | docker run --rm -it -v ${PWD}:/srv/jekyll -p 127.0.0.1:4000:4000 jekyll/jekyll:${JEKYLL_VERSION} make serve 23 | 24 | ## serve : run a local server. 25 | serve : lesson-md 26 | ${JEKYLL} serve 27 | 28 | ## site : build files but do not run a server. 29 | site : lesson-md 30 | ${JEKYLL} build 31 | 32 | # repo-check : check repository settings. 33 | repo-check : 34 | @bin/repo_check.py -s . 35 | 36 | ## clean : clean up junk files. 37 | clean : 38 | @rm -rf ${DST} 39 | @rm -rf .sass-cache 40 | @rm -rf bin/__pycache__ 41 | @find . -name .DS_Store -exec rm {} \; 42 | @find . -name '*~' -exec rm {} \; 43 | @find . -name '*.pyc' -exec rm {} \; 44 | 45 | ## clean-rmd : clean intermediate R files (that need to be committed to the repo). 46 | clean-rmd : 47 | @rm -rf ${RMD_DST} 48 | @rm -rf fig/rmd-* 49 | 50 | ## ---------------------------------------- 51 | ## Commands specific to workshop websites. 52 | 53 | .PHONY : workshop-check 54 | 55 | ## workshop-check : check workshop homepage. 56 | workshop-check : 57 | @bin/workshop_check.py . 58 | 59 | ## ---------------------------------------- 60 | ## Commands specific to lesson websites. 61 | 62 | .PHONY : lesson-check lesson-md lesson-files lesson-fixme 63 | 64 | # RMarkdown files 65 | RMD_SRC = $(wildcard _episodes_rmd/??-*.Rmd) 66 | RMD_DST = $(patsubst _episodes_rmd/%.Rmd,_episodes/%.md,$(RMD_SRC)) 67 | 68 | # Lesson source files in the order they appear in the navigation menu. 69 | MARKDOWN_SRC = \ 70 | index.md \ 71 | CODE_OF_CONDUCT.md \ 72 | setup.md \ 73 | $(sort $(wildcard _episodes/*.md)) \ 74 | reference.md \ 75 | $(sort $(wildcard _extras/*.md)) \ 76 | LICENSE.md 77 | 78 | # Generated lesson files in the order they appear in the navigation menu. 79 | HTML_DST = \ 80 | ${DST}/index.html \ 81 | ${DST}/conduct/index.html \ 82 | ${DST}/setup/index.html \ 83 | $(patsubst _episodes/%.md,${DST}/%/index.html,$(sort $(wildcard _episodes/*.md))) \ 84 | ${DST}/reference/index.html \ 85 | $(patsubst _extras/%.md,${DST}/%/index.html,$(sort $(wildcard _extras/*.md))) \ 86 | ${DST}/license/index.html 87 | 88 | ## lesson-md : convert Rmarkdown files to markdown 89 | lesson-md : ${RMD_DST} 90 | 91 | _episodes/%.md: _episodes_rmd/%.Rmd 92 | @bin/knit_lessons.sh $< $@ 93 | 94 | ## lesson-check : validate lesson Markdown. 95 | lesson-check : lesson-fixme 96 | @bin/lesson_check.py -s . -p ${PARSER} -r _includes/links.md 97 | 98 | ## lesson-check-all : validate lesson Markdown, checking line lengths and trailing whitespace. 99 | lesson-check-all : 100 | @bin/lesson_check.py -s . -p ${PARSER} -r _includes/links.md -l -w --permissive 101 | 102 | ## unittest : run unit tests on checking tools. 103 | unittest : 104 | @bin/test_lesson_check.py 105 | 106 | ## lesson-files : show expected names of generated files for debugging. 107 | lesson-files : 108 | @echo 'RMD_SRC:' ${RMD_SRC} 109 | @echo 'RMD_DST:' ${RMD_DST} 110 | @echo 'MARKDOWN_SRC:' ${MARKDOWN_SRC} 111 | @echo 'HTML_DST:' ${HTML_DST} 112 | 113 | ## lesson-fixme : show FIXME markers embedded in source files. 114 | lesson-fixme : 115 | @fgrep -i -n FIXME ${MARKDOWN_SRC} || true 116 | 117 | #------------------------------------------------------------------------------- 118 | # Include extra commands if available. 119 | #------------------------------------------------------------------------------- 120 | 121 | -include commands.mk 122 | -------------------------------------------------------------------------------- /_episodes/12-type-parameters.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Type parameters" 3 | teaching: 15 4 | exercises: 15 5 | questions: 6 | - "How to implement user-defined types with `kind`s, like intrinsic types?" 7 | objectives: 8 | - "Understand the use of type parameters in user-defined types." 9 | keypoints: 10 | - "The `kind` of a user-defined type must be known at compile time (as for intrinsic types)" 11 | --- 12 | 13 | ## Type parameters for intrinsic types 14 | 15 | We have seen type parameters (kind type parameters) for intrinsic types: 16 | ``` 17 | use iso_fortran_env 18 | ... 19 | integer (int32) :: i32 20 | ``` 21 | This provides a way to control, parametrically, the actual data type 22 | associated with the variable. Such parameters must be known at compile 23 | time. 24 | 25 | There are all so-called deferred parameters, such as the length of a 26 | deferred length string 27 | ``` 28 | character (len = :), allocatable :: string 29 | ``` 30 | The colon indicates the length is deferred. 31 | 32 | 33 | ## Parameterised derived types 34 | 35 | These features may be combined in a parameterised type definition, e.g.: 36 | ``` 37 | type, public :: my_array_t(kr, nlen) 38 | integer, kind :: kr ! kind parameter 39 | integer, len :: nlen ! len parameter 40 | real (kr) :: data(nlen) 41 | end type my_array_t 42 | ``` 43 | The type parameters must be integers and take one of two roles: a `kind` 44 | parameter, which is used in the place of kind type parameters, and a 45 | `len` parameter, which can be used in array bound declaration or a length 46 | specificaition. A `kind` parameter must be a compile-time constant, but a 47 | length parameter may be deferred until run time. 48 | 49 | The extra components act as normal components in that they may have a 50 | default value specified in the declaration, and may be accessed at run 51 | time via the component selector `%` in the usual way. 52 | 53 | For example declaration of a variable of such a type might look like: 54 | ``` 55 | ! ... establish len_input ... 56 | 57 | type (my_array_t(real32, len_input)) :: a 58 | ``` 59 | 60 | Such a parameterised type may have a dummy argument associated with an 61 | actual argument via a dummy argument declaration, e.g., 62 | ``` 63 | type (my_array_t(real32, nlen = *)), intent(in) :: a 64 | ``` 65 | cf. 66 | ``` 67 | character (len = *), intent(in) :: str 68 | ``` 69 | A pointer declaration of this type would use the deferred notation 70 | with the colon: 71 | ``` 72 | type (my_array_t(real32, nlen = :)), pointer p => null() 73 | ``` 74 | Here, an (optional) keyword has been used in the parameter list. 75 | 76 | > ## Example 77 | > 78 | > The example code `example1` illustrates how a parameterised type can be defined and used 79 | > ``` 80 | > program exmaple1 81 | > 82 | > use iso_fortran_env 83 | > implicit none 84 | > 85 | > type :: my_array_t(kr, nlen) 86 | > integer, kind :: kr 87 | > integer, len :: nlen 88 | > real (kr) :: data(nlen) 89 | > end type my_array_t 90 | > 91 | > integer :: kr 92 | > integer :: nlen 93 | > type (my_array_t(kr = real64, nlen = 1000)) :: a 94 | > 95 | > print *, "kind a", a%kr 96 | > print *, "nlen a", a%nlen 97 | > 98 | > write (*, "(a)", advance = "no") "nlen: " 99 | > read (*, *) nlen 100 | > 101 | > call defer_me(nlen) 102 | > 103 | > contains 104 | > 105 | > subroutine defer_me(nlen) 106 | > 107 | > integer, intent(in) :: nlen 108 | > type (my_array_t(kr = real32, nlen=nlen)) :: b 109 | > 110 | > print *, "Length ", b%nlen 111 | > print *, "Shape ", shape(b%data) 112 | > 113 | > end subroutine defer_me 114 | > 115 | > end program exmaple1 116 | > ``` 117 | > The `kind` of the data held by `my_array_t%data` must be known at compile time, but the `len` of 118 | > the array can be set dynamically as shown by `defer_me()`. 119 | > You can convince yourself of this by compiling and running `example1.f90` which will allow you to 120 | > pass the array length at runtime. 121 | {: .challenge} 122 | 123 | {% include links.md %} 124 | -------------------------------------------------------------------------------- /_includes/links.md: -------------------------------------------------------------------------------- 1 | {% include base_path.html %} 2 | [archer2-connecting]: https://docs.archer2.ac.uk/user-guide/connecting/ 3 | [archer2-data]: https://docs.archer2.ac.uk/user-guide/data/ 4 | [archer2-docs]: https://docs.archer2.ac.uk/ 5 | [archer2-password]: https://www.archer2.ac.uk/about/policies/passwords_usernames.html 6 | [archer2-quickstart]: https://docs.archer2.ac.uk/quick-start/quickstart-users/ 7 | [archer2-tcoc]: https://www.archer2.ac.uk/about/policies/code-of-conduct.html 8 | [archer2-training]: https://www.archer2.ac.uk/training/ 9 | [archer2-training-materials]: https://www.archer2.ac.uk/training/materials/ 10 | [archer2-website]: https://www.archer2.ac.uk/ 11 | [c-site]: https://carpentries.org/ 12 | [cc-by-human]: https://creativecommons.org/licenses/by/4.0/ 13 | [cc-by-legal]: https://creativecommons.org/licenses/by/4.0/legalcode 14 | [ci]: http://communityin.org/ 15 | [coc-reporting]: https://docs.carpentries.org/topic_folders/policies/code-of-conduct.html#incident-reporting-guidelines 16 | [coc]: https://docs.carpentries.org/topic_folders/policies/code-of-conduct.html 17 | [concept-maps]: https://carpentries.github.io/instructor-training/05-memory/ 18 | [contrib-covenant]: https://contributor-covenant.org/ 19 | [contributing]: {{ repo_url }}/blob/{{ source_branch }}/CONTRIBUTING.md 20 | [cran-checkpoint]: https://cran.r-project.org/package=checkpoint 21 | [cran-knitr]: https://cran.r-project.org/package=knitr 22 | [cran-stringr]: https://cran.r-project.org/package=stringr 23 | [dc-issues]: https://github.com/issues?q=user%3Adatacarpentry 24 | [dc-lessons]: http://www.datacarpentry.org/lessons/ 25 | [dc-site]: http://datacarpentry.org/ 26 | [discuss-list]: http://lists.software-carpentry.org/listinfo/discuss 27 | [email]: mailto:team@carpentries.org 28 | [github-flow]: https://guides.github.com/introduction/flow/ 29 | [github-importer]: https://import.github.com/ 30 | [github-join]: https://github.com/join 31 | [github]: https://github.com 32 | [how-contribute]: https://egghead.io/series/how-to-contribute-to-an-open-source-project-on-github 33 | [importer]: https://github.com/new/import 34 | [issues]: https://guides.github.com/features/issues/ 35 | [jekyll-collection]: https://jekyllrb.com/docs/collections/ 36 | [jekyll-install]: https://jekyllrb.com/docs/installation/ 37 | [jekyll-windows]: http://jekyll-windows.juthilo.com/ 38 | [jekyll]: https://jekyllrb.com/ 39 | [jupyter]: https://jupyter.org/ 40 | [kramdown]: https://kramdown.gettalong.org/ 41 | [lammps-docs]: https://lammps.sandia.gov/doc/Manual.html 42 | [lammps-download]: https://lammps.sandia.gov/download.html 43 | [lc-issues]: https://github.com/issues?q=user%3Alibrarycarpentry 44 | [lc-lessons]: https://librarycarpentry.org/lessons/ 45 | [lc-site]: https://librarycarpentry.org/ 46 | [lesson-aio]: {{ relative_root_path }}{% link aio.md %} 47 | [lesson-coc]: {{ relative_root_path }}{% link CODE_OF_CONDUCT.md %} 48 | [lesson-example]: https://carpentries.github.io/lesson-example/ 49 | [lesson-license]: {{ relative_root_path }}{% link LICENSE.md %} 50 | [lesson-mainpage]: {{ relative_root_path }}{% link index.md %} 51 | [lesson-reference]: {{ relative_root_path }}{% link reference.md %} 52 | [lesson-setup]: {{ relative_page_root }}{% link setup.md %} 53 | [mit-license]: https://opensource.org/licenses/mit-license.html 54 | [morea]: https://morea-framework.github.io/ 55 | [numfocus]: https://numfocus.org/ 56 | [osi]: https://opensource.org 57 | [pandoc]: https://pandoc.org/ 58 | [paper-now]: https://github.com/PeerJ/paper-now 59 | [python-gapminder]: https://swcarpentry.github.io/python-novice-gapminder/ 60 | [pyyaml]: https://pypi.python.org/pypi/PyYAML 61 | [r-markdown]: https://rmarkdown.rstudio.com/ 62 | [rstudio]: https://www.rstudio.com/ 63 | [ruby-install-guide]: https://www.ruby-lang.org/en/downloads/ 64 | [ruby-installer]: https://rubyinstaller.org/ 65 | [rubygems]: https://rubygems.org/pages/download/ 66 | [safe-machine-mfa]: https://epcced.github.io/safe-docs/safe-for-users/#how-to-turn-on-mfa-on-your-machine-account 67 | [styles]: https://github.com/carpentries/styles/ 68 | [swc-issues]: https://github.com/issues?q=user%3Aswcarpentry 69 | [swc-lessons]: https://software-carpentry.org/lessons/ 70 | [swc-releases]: https://github.com/swcarpentry/swc-releases 71 | [swc-site]: https://software-carpentry.org/ 72 | [training]: https://carpentries.github.io/instructor-training/ 73 | [workshop-repo]: {{ site.workshop_repo }} 74 | [yaml]: http://yaml.org/ 75 | -------------------------------------------------------------------------------- /assets/css/syntax.css: -------------------------------------------------------------------------------- 1 | .highlight .hll { background-color: #ffffcc } 2 | .highlight { background: #f8f8f8; } 3 | .highlight .c { color: #408080; font-style: italic } /* Comment */ 4 | .highlight .err { border: 1px solid #FF0000 } /* Error */ 5 | .highlight .k { color: #008000; font-weight: bold } /* Keyword */ 6 | .highlight .o { color: #666666 } /* Operator */ 7 | .highlight .ch { color: #408080; font-style: italic } /* Comment.Hashbang */ 8 | .highlight .cm { color: #408080; font-style: italic } /* Comment.Multiline */ 9 | .highlight .cp { color: #BC7A00 } /* Comment.Preproc */ 10 | .highlight .cpf { color: #408080; font-style: italic } /* Comment.PreprocFile */ 11 | .highlight .c1 { color: #408080; font-style: italic } /* Comment.Single */ 12 | .highlight .cs { color: #408080; font-style: italic } /* Comment.Special */ 13 | .highlight .gd { color: #A00000 } /* Generic.Deleted */ 14 | .highlight .ge { font-style: italic } /* Generic.Emph */ 15 | .highlight .gr { color: #FF0000 } /* Generic.Error */ 16 | .highlight .gh { color: #000080; font-weight: bold } /* Generic.Heading */ 17 | .highlight .gi { color: #00A000 } /* Generic.Inserted */ 18 | .highlight .go { color: #888888 } /* Generic.Output */ 19 | .highlight .gp { color: #000080; font-weight: bold } /* Generic.Prompt */ 20 | .highlight .gs { font-weight: bold } /* Generic.Strong */ 21 | .highlight .gu { color: #800080; font-weight: bold } /* Generic.Subheading */ 22 | .highlight .gt { color: #0044DD } /* Generic.Traceback */ 23 | .highlight .kc { color: #008000; font-weight: bold } /* Keyword.Constant */ 24 | .highlight .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */ 25 | .highlight .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */ 26 | .highlight .kp { color: #008000 } /* Keyword.Pseudo */ 27 | .highlight .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */ 28 | .highlight .kt { color: #B00040 } /* Keyword.Type */ 29 | .highlight .m { color: #666666 } /* Literal.Number */ 30 | .highlight .s { color: #BA2121 } /* Literal.String */ 31 | .highlight .na { color: #7D9029 } /* Name.Attribute */ 32 | .highlight .nb { color: #008000 } /* Name.Builtin */ 33 | .highlight .nc { color: #0000FF; font-weight: bold } /* Name.Class */ 34 | .highlight .no { color: #880000 } /* Name.Constant */ 35 | .highlight .nd { color: #AA22FF } /* Name.Decorator */ 36 | .highlight .ni { color: #999999; font-weight: bold } /* Name.Entity */ 37 | .highlight .ne { color: #D2413A; font-weight: bold } /* Name.Exception */ 38 | .highlight .nf { color: #0000FF } /* Name.Function */ 39 | .highlight .nl { color: #A0A000 } /* Name.Label */ 40 | .highlight .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */ 41 | .highlight .nt { color: #008000; font-weight: bold } /* Name.Tag */ 42 | .highlight .nv { color: #19177C } /* Name.Variable */ 43 | .highlight .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */ 44 | .highlight .w { color: #bbbbbb } /* Text.Whitespace */ 45 | .highlight .mb { color: #666666 } /* Literal.Number.Bin */ 46 | .highlight .mf { color: #666666 } /* Literal.Number.Float */ 47 | .highlight .mh { color: #666666 } /* Literal.Number.Hex */ 48 | .highlight .mi { color: #666666 } /* Literal.Number.Integer */ 49 | .highlight .mo { color: #666666 } /* Literal.Number.Oct */ 50 | .highlight .sa { color: #BA2121 } /* Literal.String.Affix */ 51 | .highlight .sb { color: #BA2121 } /* Literal.String.Backtick */ 52 | .highlight .sc { color: #BA2121 } /* Literal.String.Char */ 53 | .highlight .dl { color: #BA2121 } /* Literal.String.Delimiter */ 54 | .highlight .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */ 55 | .highlight .s2 { color: #BA2121 } /* Literal.String.Double */ 56 | .highlight .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */ 57 | .highlight .sh { color: #BA2121 } /* Literal.String.Heredoc */ 58 | .highlight .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */ 59 | .highlight .sx { color: #008000 } /* Literal.String.Other */ 60 | .highlight .sr { color: #BB6688 } /* Literal.String.Regex */ 61 | .highlight .s1 { color: #BA2121 } /* Literal.String.Single */ 62 | .highlight .ss { color: #19177C } /* Literal.String.Symbol */ 63 | .highlight .bp { color: #008000 } /* Name.Builtin.Pseudo */ 64 | .highlight .fm { color: #0000FF } /* Name.Function.Magic */ 65 | .highlight .vc { color: #19177C } /* Name.Variable.Class */ 66 | .highlight .vg { color: #19177C } /* Name.Variable.Global */ 67 | .highlight .vi { color: #19177C } /* Name.Variable.Instance */ 68 | .highlight .vm { color: #19177C } /* Name.Variable.Magic */ 69 | .highlight .il { color: #666666 } /* Literal.Number.Integer.Long */ 70 | -------------------------------------------------------------------------------- /_episodes/13-intrinsic-modules.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Intrinsic modules" 3 | teaching: 15 4 | exercises: 5 5 | questions: 6 | - "What intrinsic modules does Fortran provide?" 7 | - "How can intrinsic modules aid writing portable code?" 8 | objectives: 9 | - "Be aware of the intrinsic modules in Fortran and their uses" 10 | keypoints: 11 | - "The `iso_fortran_env` intrinsic module provides constants and functions that enable code portability" 12 | - "The IEEE intrinsic modules allow programs to check the conformance with IEEE features" 13 | --- 14 | 15 | ## Intrisic and non-intrinsic modules 16 | 17 | Five intrinsic modules are provided by the implementation: we 18 | have seen `iso_fortran_env`. 19 | 20 | Three are related to IEEE arithmetic: `ieee_arithmetic`, `ieee_exceptions` 21 | and `ieee_features`. 22 | The last is `iso_c_binding` which concerns C/Fortran interoperability. 23 | 24 | A use statement may include, optionally, an `intrinsic` or `non_intrinsic` 25 | attribute, e.g., 26 | ``` 27 | use, intrinsic :: iso_fortran_env 28 | ``` 29 | This true intrinsic `iso_fortran_env` will then be used in preference to 30 | any other module with the same name. 31 | 32 | Likewise a non-intrinsic module can be used: 33 | ``` 34 | use, non_intrinsic :: iso_fortran_env 35 | ``` 36 | This would generate an error if a user-provided `iso_fortran_env` were 37 | unavailable to the compiler. 38 | 39 | Best practice is to always use an `only` clause with intrinsic modules, 40 | which enumerates the names required in the current scope. This is a 41 | general rule which limits "namespace pollution", and can be applied to 42 | your own modules too. 43 | 44 | 45 | ## Intrinsic module `iso_fortran_env` 46 | 47 | This module provides a number of symbolic constants and functions to 48 | provide information about the local Fortran implementation. 49 | 50 | These include: 51 | 1. `error_unit`, `input_unit` and `output_unit`: the unit numbers 52 | associated with standard error, standard input, and standard output. 53 | 2. `iostat_end` and `iostat_eor`: error codes for end-fo-file and 54 | end-of-record. 55 | 3. `character_storage_size`, `file_storage_size`, and `numeric_storage_size` 56 | related to i/o 57 | 58 | 59 | F2008 included kind type parameters for frequently used intrinsic data 60 | types: 61 | 1. `int8`, `int16`, `int32`, `int64`: integer kind type parameter for 62 | intrinsic integers (in bits); 63 | 2. `real32`, `real64`, `real128`: integer kind type parameters for 64 | intrinsic real data types. 65 | 66 | Lists of the kind types available for each intrinsic data type are also 67 | available: `integer_kinds`, `logical_kinds`, `real_kinds`, `character_kinds`. 68 | 69 | 70 | ### Functions 71 | 72 | Information on the compiler and the options at compile time can be accessed 73 | via the functions: `compiler_version()` and `compiler_options()`. Both 74 | return a string fixed at compile time. 75 | 76 | E.g., 77 | ``` 78 | character (len = *), parameter :: compiler = compiler_version() 79 | ``` 80 | 81 | ### Example (3 minutes) 82 | 83 | > ## `iso_fortran_env` values 84 | > 85 | > An example program is provided which prints out the values of the various 86 | > symbols available from `iso_fortran_env`. 87 | > ``` 88 | > $ ftn print_iso_fortran_env.f90 89 | > ``` 90 | > To see the actual values in the kind arrays (`integer_kinds` and so on) 91 | > some extra statements would be required. 92 | {: .challenge} 93 | 94 | 95 | ## IEEE arithmetic support 96 | 97 | Fortran provides support for programmers to inquire about support for various 98 | aspects of the IEEE standard for floating point arithmetic. This information 99 | is separated into three modules. 100 | 101 | 1. `ieee_exceptions` provides handling for IEEE exception types enumerated 102 | by the values: `ieee_overflow`, `ieee_divide_by_zero`, `ieee_invalid`, 103 | `ieee_underflow` and `ieee_inexact`. 104 | 2. `ieee_arithmetic` contains functionality for identifying different classes 105 | of floating point values (e.g., `ieee_negative_inf`), rounding modes, and 106 | so on. The `ieee_arithmetic` module include `ieee_exceptions`. 107 | 3. `ieee_features` does not provide names a such by may affect compilation if 108 | present. E.g., if 109 | ``` 110 | use, intrinsic :: ieee_features, only : ieee_subnormal 111 | ``` 112 | is present, then the program unit must provide support for subnormal floating 113 | point numbers (aka denormalised numbers, with a leading zero in the mantissa). 114 | 115 | A full description of the IEEE features will not be attempted here. 116 | 117 | 118 | {% include links.md %} 119 | -------------------------------------------------------------------------------- /exercises/11-unlimited-polymorphic-entities/key_value_module.f90: -------------------------------------------------------------------------------- 1 | module key_value_module 2 | 3 | ! Two types are defined: 4 | 5 | ! key_value_t to hold key value pairs, where the key is a string, 6 | ! and the value is an unlimited polymporphic type 7 | ! 8 | ! The following interface is wanted: 9 | ! 10 | ! A generic function to return a new key_value_t for 11 | ! kv = key_value_t(key, int32) key-value pair for int32 value 12 | ! kv = key_value_t(key, real32) ditto for real32 value 13 | ! kv = key_value_t(key, string) ditto for string value 14 | ! 15 | ! subroutine key_value_release(kv) to release/destroy resources 16 | ! subroutine key_value_print(kv) utility to print key/value pair 17 | 18 | ! key_value_list_t an exapndable list of key_value_t pairs 19 | 20 | use iso_fortran_env 21 | 22 | implicit none 23 | public 24 | 25 | type, public :: key_value_t 26 | character (len = :), allocatable :: key ! The key ... 27 | class (*), pointer :: val => null() ! ... value 28 | end type key_value_t 29 | 30 | type, public :: key_value_list_t 31 | integer :: npair = 0 ! Current number of pairs 32 | type (key_value_t), allocatable :: kv(:) ! Expandable list 33 | end type key_value_list_t 34 | 35 | ! We will make the specific versions private; one must use the generic 36 | ! name. 37 | private :: key_value_create_i32 38 | private :: key_value_create_r32 39 | private :: key_value_create_str 40 | 41 | contains 42 | 43 | !--------------------------------------------------------------------------- 44 | !--------------------------------------------------------------------------- 45 | 46 | function key_value_create_str(key, str) result(kv) 47 | 48 | ! Return aggregated key / value pair - note with trim(str) 49 | 50 | character (len = *), intent(in) :: key 51 | character (len = *), intent(in) :: str 52 | type (key_value_t) :: kv 53 | 54 | kv%key = trim(key) 55 | allocate(kv%val, source = trim(str)) 56 | 57 | end function key_value_create_str 58 | 59 | !--------------------------------------------------------------------------- 60 | !--------------------------------------------------------------------------- 61 | 62 | !---------------------------------------------------------------------------- 63 | !---------------------------------------------------------------------------- 64 | 65 | function key_value_list_empty_t() result(kvlist) 66 | 67 | ! Return a newly created empty list; allocate size zero pairs. 68 | 69 | type (key_value_list_t) :: kvlist 70 | 71 | kvlist%npair = 0 72 | allocate(kvlist%kv(0)) 73 | 74 | end function key_value_list_empty_t 75 | 76 | !--------------------------------------------------------------------------- 77 | !--------------------------------------------------------------------------- 78 | 79 | subroutine key_value_list_release(kvlist) 80 | 81 | ! Release list storage (assume allocated). 82 | 83 | type (key_value_list_t), intent(inout) :: kvlist 84 | 85 | integer :: ikv 86 | 87 | do ikv = 1, kvlist%npair 88 | call key_value_release(kvlist%kv(ikv)) 89 | end do 90 | 91 | deallocate(kvlist%kv) 92 | kvlist%npair = 0 93 | 94 | end subroutine key_value_list_release 95 | 96 | !--------------------------------------------------------------------------- 97 | !--------------------------------------------------------------------------- 98 | 99 | subroutine key_value_list_add_kv(kvlist, kv) 100 | 101 | ! Add attribute to list 102 | 103 | type (key_value_list_t), intent(inout) :: kvlist 104 | type (key_value_t), intent(in) :: kv 105 | 106 | integer :: nnew 107 | 108 | nnew = kvlist%npair + 1 109 | if (nnew > size(kvlist%kv)) call key_value_list_reallocate(kvlist) 110 | 111 | kvlist%npair = nnew 112 | kvlist%kv(nnew)%key = kv%key 113 | allocate(kvlist%kv(nnew)%val, source = kv%val) 114 | 115 | end subroutine key_value_list_add_kv 116 | 117 | !--------------------------------------------------------------------------- 118 | !--------------------------------------------------------------------------- 119 | 120 | subroutine key_value_list_print(kvlist) 121 | 122 | ! List items 123 | 124 | type (key_value_list_t), intent(in) :: kvlist 125 | 126 | integer :: ib 127 | 128 | print *, "List has (size, current pairs): ", size(kvlist%kv), kvlist%npair 129 | do ib = 1, kvlist%npair 130 | call key_value_print(kvlist%kv(ib)) 131 | end do 132 | 133 | end subroutine key_value_list_print 134 | 135 | !--------------------------------------------------------------------------- 136 | !--------------------------------------------------------------------------- 137 | 138 | subroutine key_value_list_reallocate(kvlist) 139 | 140 | ! Expand list storage (by a factor of 2) 141 | 142 | type (key_value_list_t), intent(inout) :: kvlist 143 | 144 | ! .. implementation required 145 | 146 | end subroutine key_value_list_reallocate 147 | 148 | end module key_value_module 149 | -------------------------------------------------------------------------------- /assets/img/swc-icon-blue.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ## Context 2 | 3 | This contribution guide is derived directly that of [The Carpentries' ][c-site]. 4 | 5 | ## Contributing 6 | 7 | This is an open source project, 8 | and we welcome contributions of all kinds: 9 | new lessons, 10 | fixes to existing material, 11 | bug reports, 12 | and reviews of proposed changes. 13 | 14 | ## Contributor Agreement 15 | 16 | By contributing, 17 | you agree that we may redistribute your work under [our license](LICENSE.md). 18 | In exchange, 19 | we will address your issues and/or assess your change proposal as promptly as we can. 20 | Everyone involved should 21 | agree to abide by our [code of conduct](CODE_OF_CONDUCT.md). 22 | 23 | ## How to Contribute 24 | 25 | The easiest way to get started is to file an issue 26 | to tell us about a spelling mistake, 27 | some awkward wording, 28 | or a factual error. 29 | This is a good way to introduce yourself 30 | and to meet some of our community members. 31 | 32 | 1. If you do not have a [GitHub][github] account, 33 | you can [send us comments by email][email]. 34 | However, 35 | we will be able to respond more quickly if you use one of the other methods described below. 36 | 37 | 2. If you have a [GitHub][github] account, 38 | or are willing to [create one][github-join], 39 | but do not know how to use Git, 40 | you can report problems or suggest improvements by [creating an issue][issues]. 41 | This allows us to assign the item to someone 42 | and to respond to it in a threaded discussion. 43 | 44 | 3. If you are comfortable with Git, 45 | and would like to add or change material, 46 | you can submit a pull request (PR). 47 | Instructions for doing this are [included below](#using-github). 48 | 49 | ## Where to Contribute 50 | 51 | 1. If you wish to change this lesson, 52 | please work in , 53 | which can be viewed at . 54 | 55 | 2. If you wish to change the example lesson, 56 | please work in , 57 | which documents the format of our lessons 58 | and can be viewed [here][lesson-example]. 59 | 60 | 3. If you wish to change the template used for workshop websites, 61 | please work in . 62 | The home page of that repository explains how to set up workshop websites, 63 | while the extra pages in 64 | provide more background on our design choices. 65 | 66 | 4. If you wish to change CSS style files, tools, 67 | or HTML boilerplate for lessons or workshops stored in `_includes` or `_layouts`, 68 | please work in [styles][styles]. 69 | 70 | ## What to Contribute 71 | 72 | There are many ways to contribute, 73 | from writing new exercises and improving existing ones 74 | to updating or filling in the documentation 75 | and submitting [bug reports][issues] 76 | about things that don't work, aren't clear, or are missing. 77 | 78 | Comments on issues and reviews of pull requests are just as welcome: 79 | we are smarter together than we are on our own. 80 | Reviews from novices and newcomers are particularly valuable: 81 | it's easy for people who have been using these lessons for a while 82 | to forget how impenetrable some of this material can be, 83 | so fresh eyes are always welcome. 84 | 85 | ## What *Not* to Contribute 86 | 87 | Our lessons already contain more material than we can cover in a typical workshop, 88 | so we are usually *not* looking for more concepts or tools to add to them. 89 | As a rule, 90 | if you want to introduce a new idea, 91 | you must (a) estimate how long it will take to teach 92 | and (b) explain what you would take out to make room for it. 93 | The first encourages contributors to be honest about requirements; 94 | the second, to think hard about priorities. 95 | 96 | ## Using GitHub 97 | 98 | If you choose to contribute via GitHub, you may want to look at 99 | [How to Contribute to an Open Source Project on GitHub][how-contribute]. 100 | To manage changes, we follow [GitHub flow][github-flow]. 101 | Each lesson has two maintainers who review issues and pull requests or encourage others to do so. 102 | The maintainers are community volunteers and have final say over what gets merged into the lesson. 103 | To use the web interface for contributing to a lesson: 104 | 105 | 1. Fork the originating repository to your GitHub profile. 106 | 2. Within your version of the forked repository, move to the `gh-pages` branch and 107 | create a new branch for each significant change being made. 108 | 3. Navigate to the file(s) you wish to change within the new branches and make revisions as required. 109 | 4. Commit all changed files within the appropriate branches. 110 | 5. Create individual pull requests from each of your changed branches 111 | to the `gh-pages` branch within the originating repository. 112 | 6. If you receive feedback, make changes using your issue-specific branches of the forked 113 | repository and the pull requests will update automatically. 114 | 7. Repeat as needed until all feedback has been addressed. 115 | 116 | When starting work, please make sure your clone of the originating `gh-pages` branch is up-to-date 117 | before creating your own revision-specific branch(es) from there. 118 | Additionally, please only work from your newly-created branch(es) and *not* 119 | your clone of the originating `gh-pages` branch. 120 | Lastly, published copies of all the lessons are available in the `gh-pages` branch of the originating 121 | repository for reference while revising. 122 | 123 | {% include links.md %} 124 | -------------------------------------------------------------------------------- /exercises/09-abstract-types/solutions/file_module.f90: -------------------------------------------------------------------------------- 1 | module file_module 2 | 3 | implicit none 4 | 5 | type, abstract, public :: file_writer_t 6 | contains 7 | procedure (if_open), pass, deferred :: open 8 | procedure (if_write), pass, deferred :: write 9 | procedure (if_close), pass, deferred :: close 10 | end type file_writer_t 11 | 12 | abstract interface 13 | function if_open(self, filename) result(ierr) 14 | import file_writer_t 15 | class (file_writer_t), intent(inout) :: self 16 | character (len = *), intent(in) :: filename 17 | integer :: ierr 18 | end function if_open 19 | 20 | function if_write(self, data) result(ierr) 21 | import file_writer_t 22 | class (file_writer_t), intent(inout) :: self 23 | integer, intent(in) :: data(:) 24 | integer :: ierr 25 | end function if_write 26 | 27 | function if_close(self) result(ierr) 28 | import file_writer_t 29 | class (file_writer_t), intent(inout) :: self 30 | integer :: ierr 31 | end function if_close 32 | end interface 33 | 34 | !---------------------------------------------------------------------------- 35 | 36 | type, extends(file_writer_t), public :: file_formatted_writer_t 37 | private 38 | integer :: myunit 39 | contains 40 | procedure, pass :: open => open_formatted 41 | procedure, pass :: write => write_formatted 42 | procedure, pass :: close => close_formatted 43 | end type file_formatted_writer_t 44 | 45 | !----------------------------------------------------------------------------- 46 | 47 | type, extends(file_writer_t), public :: file_unformatted_writer_t 48 | private 49 | integer :: myunit 50 | contains 51 | procedure, pass :: open => open_unformatted 52 | procedure, pass :: write => write_unformatted 53 | procedure, pass :: close => close_unformatted 54 | end type file_unformatted_writer_t 55 | 56 | 57 | contains 58 | 59 | !---------------------------------------------------------------------------- 60 | 61 | function open_formatted(self, filename) result(ierr) 62 | 63 | class (file_formatted_writer_t), intent(inout) :: self 64 | character (len = *), intent(in) :: filename 65 | integer :: ierr 66 | 67 | open (newunit = self%myunit, file = filename, form = 'formatted', & 68 | status = "replace", action = 'write', iostat = ierr) 69 | 70 | end function open_formatted 71 | 72 | function write_formatted(self, data) result(ierr) 73 | 74 | class (file_formatted_writer_t), intent(inout) :: self 75 | integer, intent(in) :: data(:) 76 | integer :: ierr 77 | 78 | write (unit = self%myunit, fmt = *, iostat = ierr) data(:) 79 | 80 | end function write_formatted 81 | 82 | function close_formatted(self) result(ierr) 83 | 84 | class (file_formatted_writer_t), intent(inout) :: self 85 | integer :: ierr 86 | 87 | close (unit = self%myunit, status = 'keep', iostat = ierr) 88 | 89 | end function close_formatted 90 | 91 | !---------------------------------------------------------------------------- 92 | 93 | function open_unformatted(self, filename) result(ierr) 94 | 95 | class (file_unformatted_writer_t), intent(inout) :: self 96 | character (len = *), intent(in) :: filename 97 | integer :: ierr 98 | 99 | open (newunit = self%myunit, file = filename, form = 'unformatted', & 100 | status = "replace", action = 'write', iostat = ierr) 101 | 102 | end function open_unformatted 103 | 104 | function write_unformatted(self, data) result(ierr) 105 | 106 | class (file_unformatted_writer_t), intent(inout) :: self 107 | integer, intent(in) :: data(:) 108 | integer :: ierr 109 | 110 | write (unit = self%myunit, iostat = ierr) data(:) 111 | 112 | end function write_unformatted 113 | 114 | function close_unformatted(self) result(ierr) 115 | 116 | class (file_unformatted_writer_t), intent(inout) :: self 117 | integer :: ierr 118 | 119 | close (unit = self%myunit, status = 'keep', iostat = ierr) 120 | 121 | end function close_unformatted 122 | 123 | !---------------------------------------------------------------------------- 124 | 125 | function create_file_formatted_writer_t() result(fp) 126 | 127 | class (file_formatted_writer_t), pointer :: fp 128 | allocate(fp) 129 | 130 | end function create_file_formatted_writer_t 131 | 132 | function create_file_unformatted_writer_t() result(fp) 133 | 134 | class (file_unformatted_writer_t), pointer :: fp 135 | allocate(fp) 136 | 137 | end function create_file_unformatted_writer_t 138 | 139 | function file_writer_from_string(str) result(fp) 140 | 141 | character (len = *), intent(in) :: str 142 | class (file_writer_t), pointer :: fp 143 | 144 | ! We haven't reached typed allocation yet, hence the extra 145 | ! routines to return a pointer of the right type. 146 | fp => null() 147 | select case (str) 148 | case ("formatted") 149 | fp => create_file_formatted_writer_t() 150 | case ("unformatted") 151 | fp => create_file_unformatted_writer_t() 152 | case default 153 | print *, "Not recognised ", str 154 | end select 155 | 156 | end function file_writer_from_string 157 | 158 | end module file_module 159 | --------------------------------------------------------------------------------