Constructor for a finite_diff_method.
Note
factors are input as integers for convenience, but are converted to reals for the actual computations. (note: this means we can't currently define methods that have non-integer factors).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | id |
unique ID for the method |
||
character(len=*), | intent(in) | :: | name |
the name of the method |
||
integer, | intent(in) | :: | class |
2=backward diffs, 3=central diffs, etc... |
||
integer, | intent(in), | dimension(:) | :: | dx_factors |
multiplicative factors for dx perturbation |
|
integer, | intent(in), | dimension(:) | :: | df_factors |
multiplicative factors for accumulating function evaluations |
|
integer, | intent(in) | :: | df_den_factor |
denominator factor for finite difference equation (times dx) |
function initialize_finite_difference_method(id,name,class,dx_factors,& df_factors,df_den_factor) result(me) implicit none type(finite_diff_method) :: me integer,intent(in) :: id !! unique ID for the method character(len=*),intent(in) :: name !! the name of the method integer,intent(in) :: class !! 2=backward diffs, 3=central diffs, etc... integer,dimension(:),intent(in) :: dx_factors !! multiplicative factors for dx perturbation integer,dimension(:),intent(in) :: df_factors !! multiplicative factors for accumulating function evaluations integer,intent(in) :: df_den_factor !! denominator factor for finite difference equation (times dx) if (size(dx_factors)/=size(df_factors)) then error stop 'Error in initialize_finite_difference_method: '//& 'dx_factors and df_factors arrays must be the same size.' else me%id = id me%name = trim(name) me%class = class ! the following is not strictly necessary if the ! compiler fully supports auto-LHS allocation: allocate(me%dx_factors(size(dx_factors))) allocate(me%df_factors(size(df_factors))) me%dx_factors = real(dx_factors,wp) me%df_factors = real(df_factors,wp) me%df_den_factor = real(df_den_factor,wp) end if end function initialize_finite_difference_method