-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ed3422f
commit 7918b34
Showing
8 changed files
with
1,034 additions
and
204 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
cmake_minimum_required(VERSION "3.14") | ||
|
||
project(FORWARDDIF LANGUAGES Fortran) | ||
set(CMAKE_Fortran_MODULE_DIRECTORY "${CMAKE_BINARY_DIR}/modules") | ||
|
||
add_subdirectory(src) | ||
add_subdirectory(test) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module forwarddif | ||
use forwarddif_const | ||
use forwarddif_dual | ||
use forwarddif_derivative | ||
implicit none | ||
public | ||
end module |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module forwarddif_const | ||
use iso_fortran_env, only: wp => real32 | ||
end module |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
module forwarddif_derivative | ||
use forwarddif_const, only: wp | ||
use forwarddif_dual, only: dual | ||
implicit none | ||
private | ||
|
||
public :: derivative, derivative_sig | ||
|
||
abstract interface | ||
function derivative_sig(x) result(res) | ||
import :: dual | ||
type(dual), intent(in) :: x | ||
type(dual) :: res | ||
end function | ||
end interface | ||
|
||
contains | ||
|
||
subroutine derivative(fcn, x, fcn_x, dfcn_x) | ||
procedure(derivative_sig) :: fcn | ||
real(wp), intent(in) :: x | ||
real(wp), intent(out) :: fcn_x | ||
real(wp), intent(out) :: dfcn_x | ||
type(dual) :: f | ||
f = fcn(dual(x, [1.0_wp])) | ||
fcn_x = f%val | ||
dfcn_x = f%der(1) | ||
end subroutine | ||
|
||
end module |
Oops, something went wrong.