跳轉到內容

Fortran/Fortran 文件

來自華夏公益教科書,自由的教科書

FORD - FORtran 文件工具

[編輯 | 編輯原始碼]

FORD 是一個用於文件化 Fortran 原始碼的優秀程式。

有關安裝和使用 FORD 的說明,請參見 github 頁面:github.com

使用 Doxygen 文件化 Fortran

[編輯 | 編輯原始碼]

可以使用 Doxygen 直接從原始碼建立文件。

命令列程式 doxygen 使用配置檔案建立文件。GUI 程式 doxygen-wizard 幫助建立這些檔案。

原始碼需要使用特殊的 註釋語法 進行文件化: !> !!

始終應在配置檔案中設定 OPTIMIZE_FOR_FORTRAN = YES

Doxygen 命令通常以空註釋行或新的 doxygen 命令結束。

注意,Doxygen 對 Fortran 的支援相當差。即使是 type 內的 public/private 語句等簡單結構也不受支援(參見 github.com)。

您也可以在文件中包含 LaTeX 程式碼。Doxygen 網站 提供了詳細的資訊。

子程式

[編輯 | 編輯原始碼]
!> @brief inserts a value into an ordered array
!!
!! An array "list" consisting of n ascending ordered values. The method insert a
!! "new_entry" into the array.
!! hint: use cshift and eo-shift
!!
!! @param[in,out]   list    a real array, size: max_size
!! @param[in]       n       current values in the array
!! @param[in]       max_size    size if the array
!! @param[in]       new_entry   the value to insert
subroutine insert(list, n, max_size, new_entry)
    implicit none
    real, dimension (:), intent (inout) :: list
    integer, intent (in) :: n, max_size
    real, intent (in) :: new_entry

    ! code ........
end subroutine insert
!> @brief calcs the angle between two given vectors
!!
!! using the standard formula:
!!  \f$\cos \theta = \frac{ \vec v \cdot \vec w}{\abs{v}\abs{w}}\f$.
!!
!! @param[in]   \f$v,w\f$   real vectors
!! @return  a real value describing the angle. 0 if \f$\abs v\f$ or \f$\abs w\f$ below a
!!          threshold.
pure function calc_angle(v, w) result (theta)
  implicit none
  real, dimension (:), intent (in) :: v, w
  real :: theta

  ! code .......
end function calc_angle

故障排除

[編輯 | 編輯原始碼]

空文件

[編輯 | 編輯原始碼]

如果文件只是一張空頁面,您可以嘗試設定 EXTRACT_ALL = YES

華夏公益教科書