UNIHIVE

Study Hub UNIPORT ENG 213.1

ENG 213.1 · Computer Programming for Engineers

Computer languages, compilers and the Fortran story

Machine, assembly and high-level languages, compilers and interpreters, and how a Fortran program is built and run.

Our notes

2 min read

Levels of language

LevelDescriptionExample
Machine languagebinary instructions the CPU runs directly10110000 01100001
Assembly languageshort mnemonics for machine instructionsMOV AL, 61h
High-level languagesclose to human and mathematical notation; machine independentFortran, C, Python, MATLAB, Java

High-level languages are easier to write, read and move between computers; they must be translated.

Translators

  • Compiler: translates the whole program into machine code once, then the program runs fast (Fortran, C).
  • Interpreter: translates and runs one statement at a time (classic BASIC, Python): easy to test, usually slower.
  • Assembler: translates assembly language.

Building a Fortran program

  1. Edit: type the source code into a file, for example area.f90.
  2. Compile: the compiler checks the syntax and makes an object file. Syntax errors are reported here.
  3. Link: joins the object file with library routines (sqrt, sin, input/output) into an executable.
  4. Run: the executable reads input and gives output. Run-time and logic errors appear here.

With gfortran the compile and link steps are one command:
gfortran area.f90 -o area
then run ./area (or area.exe on Windows).

Fortran versions

  • FORTRAN 66 and 77: fixed format (statements in columns 7-72, comments with C in column 1, often in capitals).
  • Fortran 90/95: free format, modules, array operations, IMPLICIT NONE, DO WHILE, SELECT CASE.
  • Fortran 2003, 2008, 2018 and later: object-oriented features, parallel programming (coarrays).

These notes use free-form Fortran 90 and later, saved in files ending .f90.

Other languages engineers meet

  • C and C++: systems programs, microcontrollers, fast simulation.
  • Python: data analysis, scripting, with NumPy and SciPy.
  • MATLAB / Octave: matrices, control, signal processing.
  • PLC languages (ladder logic) for industrial control.

Exams usually ask

  • Distinguish machine, assembly and high-level languages.
  • Compare a compiler with an interpreter.
  • Describe the steps from writing to running a program.

Common mistake

Saying a program that compiles is correct. Compiling only shows the syntax is right; the logic can still be wrong.

Written by the UniHive team in our own words. Spotted a mistake? Tell us on WhatsApp.

Read

Watch

We link to free material and never copy it. Every link was opened by our team before it went up; video data is a rough guide at 360p.

All ENG 213.1 topics

Report

Sign in to report this. It is free.

Is this your work (a lecturer, author or publisher)? Ask us to take it down.