<script setup lang="ts">

</script>

<template>
  <div>
    <h1 class="text-3xl">Setting Up The Environment</h1>
    <hr>
    <br>

    <p>If you're familiar with C, then you would feel right at home with Fortran's build environment. There isn't really
      an "official" compiler for the language, only a standard, that has to be implemented by the compilers. But there
      are a lot of great compilers, that might as well be "official."</p>
    <br>

    <p>The top listed compiler on Fortran's website, is the GNU Fortran compiler (gfortran). It's the one I will be using
      throughout the examples on the site. Unless stated otherwise. There are also some other notable compilers, that
      has some rather interesting qualities to them.</p>
    <br>

    <p>Compilers:</p>
    <ul>
      <li><a class="underline" href="https://lfortran.org/">lfortran</a> (This one can be used as an interactive
        compiler, and also supports parsing all of the 2018 standard syntax. It can also compile Fortran to WebAssemply).</li>
      <li><a class="underline" href="https://developer.nvidia.com/hpc-sdk">NVIDIA HPC SDK</a> (This one comes with a whole lot of GPU
        accelerated libraries).</li>
    </ul>
    <br>

    <p>But , we will use gfortran. I will mainly be focusing on installing and developing on Linux.</p>
    <br>

    <p>First, we install the compiler.</p>
    <br>

    <p>For Fedora.</p>
    <code>$ sudo dnf install gcc-gfortran</code>
    <br>
    <br>

    <p>For ubuntu.</p>
    <code>$ sudo apt install gfortran</code>
    <br>
    <br>

    <p>And that's it. Pretty easy.</p>
    <br>

    <h1 class="text-3xl">Project Structure</h1>
    <hr>
    <br>

    <p>When creating a Fortran project, or any project in general, you want a structure. There is a lot of different
      layouts for the structure, but equal amongst them, is the <code>src</code> folder. That's where we keep all of out
      source code. Like <code>*.f90, *.f95</code> files.</p>
    <br>

    <p>But other than that, most projects include a <code>Makefile</code> file, a <code>library</code>, <code>test</code>
      and <code>bin</code> folder. Your layout doesn't need to look like this specifically, nor does it have to contain
      the same folders. Each project is different, and so are the requirements. But this layout is simple, and great
      for medium to large projects.</p>
    <br>

    <p>But if we're doing micro-projects, as in like, a hello world application, a test application, or a small tool,
      this layout is rather redundant, and on the examples on the website here, we will only use it on bigger projects,
      and we will let you know, when or how we set up the project.</p>
    <br>

    <div class="font-mono">
      <pre><code class="text-sm">
project/
├── src/          # Source files (.f90, .f95, etc.)
│   ├── modules/  # Module definitions
│   └── main.f90  # Main program file
├── include/      # Include files (e.g., interface definitions)
├── lib/          # Library object files and archives
├── bin/          # Executable binaries
├── tests/        # Test cases
└── Makefile      # Build script
      </code></pre>
    </div>
    <br>

    <p>Notes:</p>
    <ul>
      <li>&gt; <code>src</code> (This is where we keep all of out source code).</li>
      <li>&gt; <code>modules</code> (This is where we keep our classes. Or in Fortran-speak, modules).</li>
      <li>&gt; <code>include</code> (This is where we keep our interfaces, that out modules will inherit from, if we're using Fortran 90 or above).</li>
      <li>&gt; <code>bin</code> (This is where the compiled program should end up in).</li>
    </ul>
    <br>

    <p>Makefiles are very useful, and becomes increasingly useful, the bigger the project is.</p>
  </div>
</template>