100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace
Programming

Fortran Interview Questions

Commonly asked Fortran interview questions covering language fundamentals, array semantics, and HPC concepts.

PracticeIntermediate8 min readJul 10, 2026
Analogies

What Interviewers Actually Probe For

Fortran interviews for HPC, computational science, or legacy-modernization roles rarely test syntax trivia; they probe whether you understand array storage order, aliasing rules, and precision handling well enough to avoid the bugs that plague large numerical codebases. Expect questions that ask you to reason about why a particular loop nesting is slow (row-major intuition applied incorrectly to Fortran's column-major storage), or why a seemingly correct subroutine call produces wrong numbers (an aliasing violation). Being able to explain *why* an idiom exists, not just recite it, is what separates a strong answer from a memorized one.

🏏

Cricket analogy: A good interview answer is like a commentator explaining why a captain set a particular field for a leg-spinner, not just naming the field — understanding the reasoning behind Fortran's column-major storage matters more than reciting the rule.

Array Storage and Loop Order

A near-universal interview question: 'Why does looping with the leftmost index innermost matter in Fortran?' The answer: Fortran stores multidimensional arrays in column-major order, meaning consecutive elements of the first (leftmost) index are contiguous in memory. A loop nest with the leftmost index as the innermost loop accesses memory sequentially, maximizing cache-line reuse; swapping the loop order to match C-style row-major intuition causes a cache miss on nearly every access for large arrays, often producing an order-of-magnitude slowdown with no change to the actual arithmetic performed.

🏏

Cricket analogy: Accessing a column-major array in the wrong order is like a fielder chasing the ball around the boundary the long way instead of taking the direct line — the destination (result) is the same, but every extra step (cache miss) costs time.

fortran
! Fast: leftmost index varies fastest (column-major friendly)
do j = 1, n
  do i = 1, n
    a(i, j) = a(i, j) * 2.0_rk
  end do
end do

! Slow: leftmost index varies slowest -- strided memory access
do i = 1, n
  do j = 1, n
    a(i, j) = a(i, j) * 2.0_rk
  end do
end do

A strong candidate will also mention that do concurrent and compiler auto-vectorization can sometimes hide a bad loop order's cost on small arrays, but the effect reappears sharply once array size exceeds cache capacity — always benchmark on realistic problem sizes, not toy examples.

Common 'Explain the Bug' Questions

Interviewers often show a snippet where a subroutine is called with the same actual array passed as two different dummy arguments, and ask what could go wrong. The correct answer identifies that Fortran's aliasing rules assume dummy arguments don't overlap unless declared target, so a compiler is free to reorder reads and writes in ways that are only correct without overlap — meaning the code may work fine at low optimization levels (-O0) and silently break at -O2/-O3, which is exactly the kind of 'works on my machine, fails in production' bug interviewers want to see you reason through methodically rather than guess at.

🏏

Cricket analogy: This bug is like a review system that works fine on a slow, casual local pitch but fails under DRS scrutiny at international level — code that's 'correct' at -O0 can break under the more aggressive optimization (scrutiny) of -O3.

If you're asked to debug a Fortran program that behaves differently at different optimization levels, aliasing violations and uninitialized variables are the two most common root causes — mention both explicitly, since interviewers are often testing whether you know optimization-level-dependent behavior is a signal, not noise, in Fortran specifically.

  • Interviewers test reasoning about column-major storage, aliasing, and precision — not syntax memorization.
  • Explain why leftmost-index-innermost loops are fast: column-major storage makes that access pattern sequential in memory.
  • Be ready to spot aliasing bugs from overlapping array arguments passed without target.
  • Know that aliasing and uninitialized-variable bugs commonly appear or disappear across optimization levels (-O0 vs -O3).
  • Be able to explain why implicit none and explicit interfaces prevent whole classes of runtime bugs.
  • Understand the difference between allocatable arrays and pointers well enough to justify choosing one over the other.
  • Practice explaining trade-offs (direct vs iterative solvers, kind parameters, module design) out loud, not just reciting definitions.

Practice what you learned

Was this page helpful?

Topics covered

#Programming#FortranStudyNotes#FortranInterviewQuestions#Fortran#Interview#Questions#Interviewers#StudyNotes#SkillVeris#ExamPrep