Subversion-Projekte lars-tiefland.ci

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
776 lars 1
<!doctype html>
2
<title>CodeMirror: Fortran mode</title>
3
<meta charset="utf-8" />
4
<link rel=stylesheet href="../../doc/docs.css">
5
<link rel="stylesheet" href="../../lib/codemirror.css">
6
<script src="../../lib/codemirror.js"></script>
7
<script src="fortran.js"></script>
8
<style type="text/css">
9
    .CodeMirror {
10
        border-top: 1px solid black;
11
        border-bottom: 1px solid black;
12
    }
13
</style>
14
<div id=nav>
15
    <a href="http://codemirror.net">
16
        <h1>CodeMirror</h1>
17
        <img id=logo src="../../doc/logo.png">
18
    </a>
19
    <ul>
20
        <li>
21
            <a href="../../index.html">Home</a>
22
            <li>
23
                <a href="../../doc/manual.html">Manual</a>
24
                <li>
25
                    <a href="https://github.com/codemirror/codemirror">Code</a>
26
    </ul>
27
    <ul>
28
        <li>
29
            <a href="../index.html">Language modes</a>
30
            <li>
31
                <a class=active href="#">Fortran</a>
32
    </ul>
33
</div>
34
<article>
35
    <h2>Fortran mode</h2>
36
    <div>
37
        <textarea id="code" name="code"> ! Example Fortran code program average ! Read in some numbers and take the average ! As written, if there are no data points, an average of zero is returned ! While this may not be desired behavior, it keeps this example simple implicit none real,
38
            dimension(:), allocatable :: points integer :: number_of_points real :: average_points=0., positive_average=0., negative_average=0. write (*,*) "Input number of points to average:" read (*,*) number_of_points allocate (points(number_of_points))
39
            write (*,*) "Enter the points to average:" read (*,*) points ! Take the average by summing points and dividing by number_of_points if (number_of_points > 0) average_points = sum(points) / number_of_points ! Now form average over positive and
40
            negative points only if (count(points > 0.) > 0) then positive_average = sum(points, points > 0.) / count(points > 0.) end if if (count(points
41
            < 0.)> 0) then negative_average = sum(points, points
42
                < 0.) / count(points < 0.) end if deallocate (points) ! Print result to terminal write (*, '(a,g12.4)') 'Average = ', average_points write (*, '(a,g12.4)') 'Average of positive points = ', positive_average
43
                    write (*, '(a,g12.4)') 'Average of negative points = ', negative_average end program average </textarea>
44
    </div>
45
    <script>
46
        var editor = CodeMirror.fromTextArea(document.getElementById("code"),
47
        {
48
            lineNumbers: true,
49
            mode: "text/x-fortran"
50
        });
51
    </script>
52
    <p>
53
        <strong>MIME types defined:</strong> <code>text/x-Fortran</code>.</p>
54
</article>