Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Print Compiler Version

---
jupytext:
  formats: md:myst
  text_representation:
    extension: .md
    format_name: myst
kernelspec:
  display_name: Python 3
  language: python
  name: python3
---

Print Compiler Version

Adapted from: “Modern Fortran: Building Efficient Parallel Applications” by Milan Curcic (Manning)

program print_compiler_info

    use iso_fortran_env
    implicit none
    print *, 'Compiler version: ', compiler_version()
    print *, 'Compiler options: ', compiler_options()
    
end program print_compiler_info

The above program is compiled and run using Fortran Package Manager (fpm):

import os
root_dir = os.getcwd()
code_dir = root_dir + "/" + "Fortran_Code/Print_Compiler_Version"
os.chdir(code_dir)
build_status = os.system("fpm build 2>/dev/null")
exec_status = os.system("fpm run 2>/dev/null")
 Compiler version: GCC version 12.2.0
 Compiler options: -I build/gfortran_87E2AE0597D39913 -mtune=generic -march=x86-64 -g -Wall -Wextra -Werror=implicit-interface -fPIC -fmax-errors=1 -fbounds-check -fcheck=array-temps -fbacktrace -fcoarray=single -fimplicit-none -ffree-form -J build/gfortran_87E2AE0597D39913 -fpre-include=/usr/include/finclude/x86_64-linux-gnu/math-vector-fortran.h