Find us on…

GitHub

ForCompile

GitHub Version Documentation License Build

ForCompile

ForCompile: A Fortran library to access the Compiler Explorer API.

How to use

Prerequisites:

On Ubuntu, you need to install the curl development headers. Use the following command:

sudo apt install -y libcurl4-openssl-dev

Clone the repository:

You can clone the ForCompile repository from GitHub using the following command:

git clone https://github.com/gha3mi/forcompile.git
cd forcompile

list of languages

program test_1

   use forcompile, only: compiler_explorer
   implicit none
   type(compiler_explorer) :: ce

   call ce%list_compilers()

end program test_1

list of compilers

program test_2

   use forcompile, only: compiler_explorer
   implicit none
   type(compiler_explorer) :: ce

   call ce%list_languages()

end program test_2

list of compilers with matching language

program test_3

   use forcompile, only: compiler_explorer
   implicit none
   type(compiler_explorer) :: ce

   call ce%list_compilers(language_id='fortran')

end program test_3

list of libraries

program test_4

   use forcompile, only: compiler_explorer
   implicit none
   type(compiler_explorer) :: ce

   call ce%list_libraries()

end program test_4

list of libraries with matching language

program test_5

   use forcompile, only: compiler_explorer
   implicit none
   type(compiler_explorer) :: ce

   call ce%list_libraries(language_id='fortran')

end program test_5

list of code formatters

program test_6

   use forcompile, only: compiler_explorer
   implicit none
   type(compiler_explorer) :: ce

   call ce%list_formatters()

end program test_6

perform a compilation

program test_7

   use forcompile, only: compiler_explorer
   implicit none
   type(compiler_explorer) :: ce

   call ce%set_source("&
      program hello;&
      write(*,*) 'Hello World';&
      end program hello&
      ")

   call ce%set_compiler_id('gfortran132')

   call ce%options%set_userArguments('-O3')
   call ce%options%set_compilerOptions(skipAsm=.false., executorRequest=.false.)
   call ce%options%set_filters(&
      binary=.false.,&
      binaryObject=.false.,&
      commentOnly=.true.,&
      demangle=.true.,&
      directives=.true.,&
      execute=.true.,&
      intel=.true.,&
      labels=.true.,&
      libraryCode=.false.,&
      trim=.false.,&
      debugCalls=.false.)

   call ce%set_lang('fortran')
   call ce%set_allowStoreCodeDebug(.true.)

   call ce%compile()

   call ce%finalize()

end program test_7

fpm dependency

If you want to use ForCompile as a dependency in your own fpm project, you can easily include it by adding the following line to your fpm.toml file:

[dependencies]
forcompile = {git="https://github.com/gha3mi/forcompile.git"}

API documentation

The most up-to-date API documentation for the master branch is available here. To generate the API documentation for ForCompile using ford run the following command:

ford ford.yml

Contributing

Contributions to ForCompile are welcome! If you find any issues or would like to suggest improvements, please open an issue.

Developer Info

Seyed Ali Ghasemi