feat: add missing KF6 framework recipes

This commit is contained in:
2026-05-07 07:53:26 +01:00
parent d8d498f831
commit a69f479b52
2374 changed files with 2610246 additions and 0 deletions
@@ -0,0 +1,184 @@
<!DOCTYPE html>
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>highlight.f90</title>
<meta name="generator" content="KF5::SyntaxHighlighting - Definition (Fortran (Free Format)) - Theme (Breeze Dark)"/>
</head><body style="background-color:#232629;color:#cfcfc2"><pre>
<span style="color:#7a7c7d">! This file is an example to test the syntax highlighting file fortran-free.xml</span>
<span style="color:#7a7c7d">! (for fortran, free format)</span>
<span style="color:#7a7c7d">!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!</span>
<span style="color:#7a7c7d">! THIS IS AN EXAMPLE OF A MODULE !</span>
<span style="color:#7a7c7d">!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!</span>
<span style="font-weight:bold">module</span> module_example
<span style="color:#7a7c7d">! use 'implicit none' when you want all variables to be declared</span>
<span style="font-weight:bold">implicit</span> <span style="font-weight:bold">none</span>
<span style="color:#7a7c7d">!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!</span>
<span style="color:#7a7c7d">! PUBLICS AND PRIVATES</span>
<span style="color:#7a7c7d">! In fortran 90 you can define your own operator</span>
<span style="color:#2980b9">public</span> <span style="color:#2980b9">::</span> <span style="font-weight:bold">operator</span>(<span style="color:#3f8058;font-weight:bold">.norm.</span>)
<span style="color:#2980b9">public</span> <span style="color:#2980b9">::</span> <span style="font-weight:bold">operator</span>(<span style="font-weight:bold">+</span>) <span style="color:#7a7c7d">! &lt;-- you can also overload the usual operators</span>
<span style="color:#2980b9">public</span> <span style="color:#2980b9">::</span> factorial
<span style="color:#2980b9">public</span> <span style="color:#2980b9">::</span> example_fn
<span style="color:#2980b9">private</span> <span style="color:#2980b9">::</span> point3d_add
<span style="color:#2980b9">private</span> <span style="color:#2980b9">::</span> point3d_norm
<span style="color:#7a7c7d">!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!</span>
<span style="color:#7a7c7d">! USER-DEFINED TYPES...</span>
<span style="color:#7a7c7d">! This is a definition to use in declarations of real variables,</span>
<span style="color:#7a7c7d">! parameters, etc.</span>
<span style="color:#2980b9">integer</span>, <span style="color:#2980b9">parameter</span>, <span style="color:#2980b9">public</span> <span style="color:#2980b9">::</span> kr <span style="font-weight:bold">=</span> <span style="color:#8e44ad;font-weight:bold">selected_real_kind</span>(<span style="color:#f67400">10</span>)
<span style="color:#7a7c7d">! This is a user-defined type</span>
<span style="color:#2980b9">type</span>, <span style="color:#2980b9">public</span> <span style="color:#2980b9">::</span> point3d
<span style="color:#2980b9">real(kind=kr)</span> <span style="color:#2980b9">::</span> x, y, z
<span style="color:#2980b9">end type</span> point3d
<span style="color:#7a7c7d">! This type is useless: it is only an example of type definition!</span>
<span style="color:#2980b9">type</span>, <span style="color:#2980b9">public</span> <span style="color:#2980b9">::</span> example_type
<span style="color:#2980b9">complex(kind=kr)</span> <span style="color:#2980b9">::</span> c <span style="color:#7a7c7d">! &lt;-- a complex number (two reals of kind kr)!</span>
<span style="color:#2980b9">real</span>, <span style="color:#2980b9">dimension(-10:10)</span> <span style="color:#2980b9">::</span> <span style="font-weight:bold">&amp;</span> <span style="color:#7a7c7d">! &lt;-- this line does not end here!</span>
r1, r2 <span style="color:#7a7c7d">! &lt;-- this is the final part of the previous line</span>
<span style="color:#2980b9">real</span>, <span style="color:#2980b9">pointer</span>, <span style="color:#2980b9">dimension(:)</span> <span style="color:#2980b9">::</span> pointer_to_array_of_real
<span style="color:#2980b9">real</span>, <span style="color:#2980b9">dimension(:)</span>, <span style="color:#2980b9">pointer</span> <span style="color:#2980b9">::</span> array_of_pointer_to_real
<span style="color:#2980b9">end type</span> example_type
<span style="color:#7a7c7d">!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!</span>
<span style="color:#7a7c7d">! INTERFACES...</span>
<span style="color:#7a7c7d">! Interface for the norm of a 3-D vector</span>
<span style="font-weight:bold">interface</span> <span style="font-weight:bold">operator</span>(<span style="color:#3f8058;font-weight:bold">.norm.</span>)
<span style="font-weight:bold">module procedure</span> point3d_norm
<span style="font-weight:bold">end interface</span>
<span style="color:#7a7c7d">! Interface for the operator '+'</span>
<span style="font-weight:bold">interface</span> <span style="font-weight:bold">operator</span>(<span style="font-weight:bold">+</span>)
<span style="font-weight:bold">module procedure</span> point3d_add
<span style="font-weight:bold">end interface</span>
<span style="color:#7a7c7d">!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!</span>
<span style="color:#7a7c7d">! SOME DECLARATIONS...</span>
<span style="color:#7a7c7d">! A real number can be declared with the following line:</span>
<span style="color:#2980b9">real(kind=kr)</span> <span style="color:#2980b9">::</span> real_var1
<span style="color:#7a7c7d">! But if you are not interested on the precision of floating point numbers,</span>
<span style="color:#7a7c7d">! you can use simply:</span>
<span style="color:#2980b9">real</span> <span style="color:#2980b9">::</span> real_var2
<span style="color:#7a7c7d">! An array can be declared in two ways:</span>
<span style="color:#2980b9">real(kind=kr)</span>, <span style="color:#2980b9">dimension(1:10, -4:5)</span>, <span style="color:#2980b9">private</span> <span style="color:#2980b9">::</span> a, b, c
<span style="color:#2980b9">real(kind=kr)</span>, <span style="color:#2980b9">private</span> <span style="color:#2980b9">::</span> d(<span style="color:#f67400">1</span>:<span style="color:#f67400">10</span>, <span style="font-weight:bold">-</span><span style="color:#f67400">4</span>:<span style="color:#f67400">5</span>)
<span style="color:#7a7c7d">! This is a string with fixed lenght</span>
<span style="color:#2980b9">character(len=10)</span> <span style="color:#2980b9">::</span> str_var
<span style="color:#7a7c7d">! This is an allocatable array, which can be a target of a pointer</span>
<span style="color:#2980b9">type(example_type)</span>, <span style="color:#2980b9">private</span>, <span style="color:#2980b9">dimension(:)</span>, <span style="color:#2980b9">allocatable</span>, <span style="color:#2980b9">target</span> <span style="color:#2980b9">::</span> <span style="font-weight:bold">&amp;</span>
many_examples
<span style="color:#7a7c7d">! Fortran 90 hasn't got its own preprocessor, it uses the C preprocessor!</span>
<span style="color:#27ae60">#ifdef XXX</span>
<span style="color:#27ae60">#endif</span>
<span style="font-weight:bold">contains</span>
<span style="color:#7a7c7d">! The sum of two points</span>
<span style="font-weight:bold">pure</span> <span style="font-weight:bold">function</span> point3d_add(a, b) <span style="font-weight:bold">result</span>(rs)
<span style="color:#2980b9">type(point3d)</span> <span style="color:#2980b9">::</span> rs
<span style="color:#2980b9">type(point3d)</span>, <span style="color:#2980b9">intent(in)</span> <span style="color:#2980b9">::</span> a, b
rs<span style="color:#3f8058;font-weight:bold">%</span>x <span style="font-weight:bold">=</span> a<span style="color:#3f8058;font-weight:bold">%</span>x <span style="font-weight:bold">+</span> b<span style="color:#3f8058;font-weight:bold">%</span>x
rs<span style="color:#3f8058;font-weight:bold">%</span>y <span style="font-weight:bold">=</span> a<span style="color:#3f8058;font-weight:bold">%</span>y <span style="font-weight:bold">+</span> b<span style="color:#3f8058;font-weight:bold">%</span>y
rs<span style="color:#3f8058;font-weight:bold">%</span>z <span style="font-weight:bold">=</span> a<span style="color:#3f8058;font-weight:bold">%</span>z <span style="font-weight:bold">+</span> b<span style="color:#3f8058;font-weight:bold">%</span>z
<span style="font-weight:bold">end function</span> point3d_add
<span style="color:#7a7c7d">! The norm of a point</span>
<span style="font-weight:bold">pure</span> <span style="font-weight:bold">function</span> point3d_norm(a) <span style="font-weight:bold">result</span>(rs)
<span style="color:#2980b9">real(kind=kr)</span> <span style="color:#2980b9">::</span> rs
<span style="color:#2980b9">type(point3d)</span>, <span style="color:#2980b9">intent(in)</span> <span style="color:#2980b9">::</span> a
rs <span style="font-weight:bold">=</span> <span style="color:#7f8c8d;font-weight:bold">sqrt</span>(a<span style="color:#3f8058;font-weight:bold">%</span>x <span style="font-weight:bold">*</span> a<span style="color:#3f8058;font-weight:bold">%</span>x <span style="font-weight:bold">+</span> a<span style="color:#3f8058;font-weight:bold">%</span>y <span style="font-weight:bold">*</span> a<span style="color:#3f8058;font-weight:bold">%</span>y <span style="font-weight:bold">+</span> a<span style="color:#3f8058;font-weight:bold">%</span>z <span style="font-weight:bold">*</span> a<span style="color:#3f8058;font-weight:bold">%</span>z)
<span style="font-weight:bold">end function</span> point3d_norm
<span style="color:#7a7c7d">! A simple recursive function</span>
<span style="font-weight:bold">recursive</span> <span style="font-weight:bold">function</span> factorial(i) <span style="font-weight:bold">result</span> (rs)
<span style="color:#2980b9">integer</span> <span style="color:#2980b9">::</span> rs
<span style="color:#2980b9">integer</span>, <span style="color:#2980b9">intent(in)</span> <span style="color:#2980b9">::</span> i
<span style="font-weight:bold">if</span> ( i <span style="color:#3f8058;font-weight:bold">&lt;=</span> <span style="color:#f67400">1</span> ) <span style="font-weight:bold">then</span>
rs <span style="font-weight:bold">=</span> <span style="color:#f67400">1</span>
<span style="font-weight:bold">else</span>
rs <span style="font-weight:bold">=</span> i <span style="font-weight:bold">*</span> factorial(i <span style="font-weight:bold">-</span> <span style="color:#f67400">1</span>)
<span style="font-weight:bold">end if</span>
<span style="font-weight:bold">end function</span> factorial
<span style="color:#7a7c7d">! This is a useless function</span>
<span style="font-weight:bold">subroutine</span> example_fn(int_arg, real_arg, str_arg)
<span style="color:#2980b9">integer</span>, <span style="color:#2980b9">intent(in)</span> <span style="color:#2980b9">::</span> int_arg
<span style="color:#2980b9">real(kind=kr)</span>, <span style="color:#2980b9">intent(out)</span> <span style="color:#2980b9">::</span> real_arg
<span style="color:#2980b9">character(len=*)</span>, <span style="color:#2980b9">intent(in)</span> <span style="color:#2980b9">::</span> str_arg
<span style="color:#2980b9">type(example_type)</span>, <span style="color:#2980b9">pointer</span> <span style="color:#2980b9">::</span> p
<span style="color:#2980b9">integer</span> <span style="color:#2980b9">::</span> n, i, j
<span style="color:#2980b9">logical</span> <span style="color:#2980b9">::</span> flag
flag <span style="font-weight:bold">=</span> <span style="color:#27aeae;font-weight:bold">.true.</span> <span style="color:#7a7c7d">! .true. is not an operator!</span>
<span style="font-weight:bold">if</span> ( flag <span style="color:#3f8058;font-weight:bold">.and.</span> flag ) <span style="font-weight:bold">then</span> <span style="color:#7a7c7d">! .and. is a pre-defined operator</span>
<span style="color:#8e44ad">print</span> <span style="font-weight:bold">*</span>, <span style="color:#f44f4f">"blabla"</span>
<span style="font-weight:bold">end if</span>
<span style="color:#7a7c7d">! Examples of inquiry functions: allocated, lbound, ubound.</span>
<span style="font-weight:bold">if</span> ( <span style="color:#3f8058;font-weight:bold">.not.</span> <span style="color:#8e44ad;font-weight:bold;font-style:italic">allocated</span>(many_examples) ) <span style="font-weight:bold">then</span>
<span style="font-weight:bold">allocate</span>( many_examples(<span style="color:#f67400">10</span>) )
<span style="font-weight:bold">end if</span>
<span style="color:#8e44ad">print</span> <span style="font-weight:bold">*</span>, <span style="color:#f44f4f">"Lower bound = "</span>, <span style="color:#8e44ad;font-weight:bold;font-style:italic">lbound</span>(many_examples, <span style="color:#f67400">1</span>)
<span style="color:#8e44ad">print</span> <span style="font-weight:bold">*</span>, <span style="color:#f44f4f">"Upper bound = "</span>, <span style="color:#8e44ad;font-weight:bold;font-style:italic">ubound</span>(many_examples, <span style="color:#f67400">1</span>)
p <span style="font-weight:bold">=</span><span style="color:#3f8058;font-weight:bold">></span> many_examples(<span style="color:#f67400">5</span>) <span style="color:#7a7c7d">! &lt;-- p is a pointer</span>
<span style="color:#7a7c7d">! A strange way to calculate i*i: add the first i odd numbers</span>
i <span style="font-weight:bold">=</span> <span style="color:#f67400">6</span>
j <span style="font-weight:bold">=</span> <span style="color:#f67400">0</span>
<span style="font-weight:bold">do</span> n <span style="font-weight:bold">=</span> <span style="color:#f67400">1</span>, i
j <span style="font-weight:bold">=</span> j <span style="font-weight:bold">+</span> (<span style="color:#f67400">2</span><span style="font-weight:bold">*</span>n <span style="font-weight:bold">-</span> <span style="color:#f67400">1</span>)
<span style="font-weight:bold">end do</span>
<span style="color:#8e44ad">print</span> <span style="font-weight:bold">*</span>, <span style="color:#f44f4f">"i*i = "</span>, i<span style="font-weight:bold">*</span>i, j
real_arg <span style="font-weight:bold">=</span> <span style="color:#2980b9">real(j)</span> <span style="color:#7a7c7d">! &lt;-- here the highlighting is not very good:</span>
<span style="color:#7a7c7d">! it is unable to distinguish between this and a definition like:</span>
<span style="color:#7a7c7d">! real(kind=kr) :: a</span>
<span style="font-weight:bold">deallocate</span>( many_examples )
<span style="font-weight:bold">end subroutine</span> example_fn
<span style="font-weight:bold">end module</span> module_example
<span style="color:#7a7c7d">!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!</span>
<span style="color:#7a7c7d">! THIS IS THE MAIN PROGRAM !</span>
<span style="color:#7a7c7d">!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!</span>
<span style="font-weight:bold">program</span> example
<span style="font-weight:bold">use</span> module_example
<span style="color:#7a7c7d">! this is another example of use of the 'implicit' keyword</span>
<span style="font-weight:bold">implicit</span> <span style="color:#2980b9">double precision</span> (a<span style="font-weight:bold">-</span>h,o<span style="font-weight:bold">-</span>z)
<span style="color:#2980b9">real(kind=kr)</span> <span style="color:#2980b9">::</span> var_out
<span style="color:#2980b9">type(point3d)</span> <span style="color:#2980b9">::</span> <span style="font-weight:bold">&amp;</span>
a <span style="font-weight:bold">=</span> point3d(<span style="color:#f67400">0.0_kr</span>, <span style="color:#f67400">1.0_kr</span>, <span style="color:#f67400">2.0_kr</span>), <span style="font-weight:bold">&amp;</span>
b <span style="font-weight:bold">=</span> point3d(<span style="color:#f67400">4.0_kr</span>, <span style="color:#f67400">5.0_kr</span>, <span style="color:#f67400">6.0_kr</span>)
<span style="color:#8e44ad">print</span> <span style="font-weight:bold">*</span>, <span style="color:#f44f4f">"a + b = "</span>, <span style="color:#3f8058;font-weight:bold">.norm.</span> (a <span style="font-weight:bold">+</span> b)
<span style="color:#8e44ad">print</span> <span style="font-weight:bold">*</span>, <span style="color:#f44f4f">"factorial of 5 = "</span>, factorial(<span style="color:#f67400">5</span>)
<span style="font-weight:bold">call</span> example_fn(<span style="color:#f67400">1</span>, var_out, <span style="color:#f44f4f">"hello!"</span>)
<span style="font-weight:bold">end program</span> example
</pre></body></html>