Skip to content

chemfiles/chemfiles.f03

Repository files navigation

Fortran binding for the chemfiles library

Build Status Code coverage Documentation

This repository contains the fortran 2003 binding to the chemfiles library. The documentation contains the installation instructions.

Usage example

Here is a simple example of how the usage feels in Fortran:

program example
    use chemfiles
    use iso_fortran_env, only: int64, real64

    implicit none
    type(chfl_trajectory) :: trajectory
    type(chfl_frame) :: frame
    integer(int64) :: natoms
    real(real64), dimension(:, :), pointer :: positions
    integer :: status

    call trajectory%open("filename.xyz", "r", status=status)
    if (status /= 0) stop "Error while opening file"
    call frame%init()

    call trajectory%read(frame, status=status)
    if (status /= 0) stop "Error while reading file"

    call frame%atoms_count(natoms)
    write(*, *) "There are ", natoms, "atoms in the frame"

    call frame%positions(positions, natoms)
    ! Do awesome things with the positions here !

    call frame%free()
    call trajectory%close()
end program

You can find more examples in the examples directory.

Bug reports, feature requests

Please report any bug you find and any feature you may want as a github issue.