1. Home
  2. /
  3. Fortran
  4. /
  5. Even Numbers Filter

Even Numbers Filter - Fortran Typing CST Test

Loading…

Even Numbers Filter — Fortran Code

Prints even numbers from an array.

program EvenFilter
	integer, dimension(5) :: nums = (/1,2,3,4,5/)
	integer :: i
	do i = 1, 5
		if (mod(nums(i),2) == 0) then
		print *, 'Even:', nums(i)
		end if
	end do
end program EvenFilter

Fortran Language Guide

Fortran (Formula Translation) is a high-level, compiled programming language designed for numeric computation, scientific computing, and engineering applications. Known for its efficiency in numerical calculations, Fortran has been a standard in scientific computing for over 60 years.

Primary Use Cases

  • ▸Scientific simulations
  • ▸Numerical and matrix computations
  • ▸High-performance computing
  • ▸Weather & climate modeling
  • ▸Finite element analysis
  • ▸Computational physics & chemistry

Notable Features

  • ▸Efficient numerical computation
  • ▸Array-oriented syntax
  • ▸Strong support for parallelism (OpenMP, MPI)
  • ▸Modern Fortran supports OOP
  • ▸Backward compatible across decades of standards

Origin & Creator

Fortran was developed in the 1950s by IBM engineers led by John Backus to simplify programming of numeric computations on early computers.

Industrial Note

Fortran is heavily used in computational fluid dynamics, weather modeling, numerical simulations, high-performance computing (HPC), aerospace, and energy industry applications.

Quick Explain

  • ▸Fortran excels at high-performance numerical computation and array processing.
  • ▸It supports modular programming, procedures, and modern object-oriented features in newer standards.
  • ▸Commonly used in scientific simulations, weather modeling, computational physics, and engineering calculations.

Core Features

  • ▸Modules and subroutines
  • ▸Array operations and intrinsic functions
  • ▸Derived data types
  • ▸Control structures (loops, conditionals)
  • ▸I/O facilities for formatted/unformatted data

Learning Path

  • ▸Learn Fortran syntax and variables
  • ▸Master arrays and intrinsic functions
  • ▸Understand modules and subroutines
  • ▸Learn file I/O and formatted output
  • ▸Practice numerical problem solving

Practical Examples

  • ▸Matrix multiplication
  • ▸Numerical integration
  • ▸Weather simulation module
  • ▸Finite element analysis
  • ▸Vectorized linear algebra

Comparisons

  • ▸Faster than interpreted languages for numeric computation
  • ▸Better array handling than C in some cases
  • ▸Less general-purpose than Python or Java
  • ▸Strong legacy presence in HPC vs newer languages
  • ▸Syntax can be verbose compared to modern languages

Strengths

  • ▸High computational performance
  • ▸Mature ecosystem in scientific computing
  • ▸Efficient memory and vectorized operations
  • ▸Widely supported in HPC systems
  • ▸Legacy codebases in critical scientific domains

Limitations

  • ▸Primarily numerical, not general-purpose
  • ▸Older syntax can be verbose
  • ▸Limited libraries for modern tasks outside science
  • ▸Cross-platform GUIs are weak
  • ▸Complex parallel programming setup

When NOT to Use

  • ▸Web development
  • ▸Mobile applications
  • ▸Modern GUI applications
  • ▸Non-numeric business apps
  • ▸Rapid prototyping outside science

Cheat Sheet

  • ▸program name ... end program name
  • ▸subroutine subname(args) ... end subroutine
  • ▸do i=1,n ... end do
  • ▸if (condition) then ... end if
  • ▸print *, 'Hello World'

FAQ

  • ▸Is Fortran still relevant?
  • ▸Yes - especially in scientific computing and HPC.
  • ▸Can Fortran do object-oriented programming?
  • ▸Yes - modern standards (Fortran 90/2003/2008) support OOP.
  • ▸Is Fortran fast?
  • ▸Yes - excellent for numerical and array operations.
  • ▸Can I integrate Fortran with Python?
  • ▸Yes - using f2py or C bindings.

30-Day Skill Plan

  • ▸Week 1: Variables, loops, conditionals
  • ▸Week 2: Subroutines, modules, functions
  • ▸Week 3: Arrays, intrinsic functions, I/O
  • ▸Week 4: Parallel programming (OpenMP/MPI)

Final Summary

  • ▸Fortran is a high-performance language for scientific computing and numerical simulations.
  • ▸It excels in array-based computation, HPC, and legacy scientific codebases.
  • ▸Modern standards support modular and object-oriented programming.
  • ▸Still widely used in engineering, physics, climate modeling, and computational chemistry.

Project Structure

  • ▸source.f90 files
  • ▸modules/
  • ▸libraries/
  • ▸tests/
  • ▸executables/

Monetization

  • ▸HPC software development
  • ▸Scientific consulting
  • ▸Engineering simulations
  • ▸Aerospace & defense simulations
  • ▸Energy modeling services

Productivity Tips

  • ▸Use compiler optimizations
  • ▸Vectorize arrays
  • ▸Parallelize loops
  • ▸Reuse modules
  • ▸Automate build & testing

Basic Concepts

  • ▸Variables, constants, and types
  • ▸Control structures (if, do, select case)
  • ▸Subroutines and functions
  • ▸Modules and derived types
  • ▸Arrays and intrinsic operations

Official Docs

  • ▸ISO Fortran Standards
  • ▸Fortran-lang.org
  • ▸Intel Fortran Documentation

More Fortran Typing Exercises

Fortran Counter and Theme ToggleFortran Simple AdditionFortran FactorialFortran Fibonacci SequenceFortran Max of Two NumbersFortran Array SumFortran Conditional Counter IncrementFortran Resettable CounterFortran Theme Toggle Only

Practice Other Languages

CReactPythonC++RustTypeScriptKotlinPHPJavaC#RubyMqlCqlN1qlCypher