Fortran: help with arguments to a pre-built software

In summary: in lwsp, the number of elements in the output array. ipiv - input parameter - an integer. iexph - output parameter - an integer. ns - number of scaling-squaring used. iflag - output flag.
  • #1
brydustin
205
0
There are two functions that I need help with:

http://www.maths.uq.edu.au/expokit/fortran/dgpadm.f
http://www.maths.uq.edu.au/expokit/fortran/dgchbv.f

The problem I'm having is that the arguments on the line DGPADM(...) don't match identically with the explanation. For example, H, ldh and m vs. m and H(ldh,m) not sure why there is a parenthesis. If someone could give me a simple example of acceptable parameters that I could try out,that would be greatly appreciated.

I understand what to put for ideg, m, t, but not so sure about wsp, ipiv , H or the others. For example, H is a matrix, so I guess it needs a matrix as an argument... regardless could someone help me out here?! Thanks!

In the first case:
subroutine DGPADM( ideg,m,t,H,ldh,wsp,lwsp,ipiv,iexph,ns,iflag )

* ideg : (input) the degre of the diagonal Pade to be used.
* a value of 6 is generally satisfactory.
*
* m : (input) order of H.
*
* H(ldh,m) : (input) argument matrix.
*
* t : (input) time-scale (can be < 0).
*
* wsp(lwsp) : (workspace/output) lwsp .ge. 4*m*m+ideg+1.
*
* ipiv(m) : (workspace)
*
*>>>> iexph : (output) number such that wsp(iexph) points to exp(tH)
* i.e., exp(tH) is located at wsp(iexph ... iexph+m*m-1)
* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
* NOTE: if the routine was called with wsp(iptr),
* then exp(tH) will start at wsp(iptr+iexph-1).
*
* ns : (output) number of scaling-squaring used.
*
* iflag : (output) exit flag.
* 0 - no problem
* <0 - problem


Second case:
subroutine DGCHBV( m, t, H,ldh, y, wsp, iwsp, iflag )

* m : (input) order of the matrix H
*
* t : (input) time-scaling factor (can be < 0).
*
* H(ldh,m): (input) argument matrix.
*
* y(m) : (input/output) on input the operand vector,
* on output the resulting vector exp(t*H)*y.
*
* iwsp(m) : (workspace)
*
* wsp : (workspace). Observe that a double precision vector of
* length 2*m*(m+2) can be used as well when calling this
* routine (thus avoiding an idle complex array elsewhere)
 
Technology news on Phys.org
  • #3
brydustin said:
There are two functions that I need help with:

http://www.maths.uq.edu.au/expokit/fortran/dgpadm.f
http://www.maths.uq.edu.au/expokit/fortran/dgchbv.f

The problem I'm having is that the arguments on the line DGPADM(...) don't match identically with the explanation. For example, H, ldh and m vs. m and H(ldh,m) not sure why there is a parenthesis. If someone could give me a simple example of acceptable parameters that I could try out,that would be greatly appreciated.

I understand what to put for ideg, m, t, but not so sure about wsp, ipiv , H or the others. For example, H is a matrix, so I guess it needs a matrix as an argument... regardless could someone help me out here?! Thanks!
I'll take a stab at the first one.

H - the name of a two-dimensional matrix - the matrix contains double precision numbers.
ldh - # of rows in matrix H - an integer.
m - # of cols in matrix H - an integer.
t - timescale. This is the constant t in etH -- double precision.
wsp - workspace - an output array with lwsp elements, each of type double precision.
lwsp - # of elements of the wsp array - an integer. It needs to be > 4m2 + ideg + 1.
ipiv - an output array with m integer elements.
iexph - an index into the wsp array - an integer.
The computed elements of etH are located in the wsp array. They start at wsp(iexph) and end at wsp(iexph + m2 - 1). This section of the array contains all of the elements of etH.
ns - no clue - integer.
iflag - a flag that indicates whether the calculation was successful or not. Negative value indicates some kind of error.

I would start with a very simple matrix, like
$$H = \begin{bmatrix} 0 & 1 \\ 0 & 0 \end{bmatrix}$$
and a value of 1.0 for t.

You should end up with
$$e^{tH} = \begin{bmatrix} 1 & 1 \\ 0 & 1 \end{bmatrix}$$

The variables that are identified as being output don't need to be initialized before calling this routine. The other variables need to be initialized before the call.

brydustin said:
In the first case:
subroutine DGPADM( ideg,m,t,H,ldh,wsp,lwsp,ipiv,iexph,ns,iflag )

* ideg : (input) the degre of the diagonal Pade to be used.
* a value of 6 is generally satisfactory.
*
* m : (input) order of H.
*
* H(ldh,m) : (input) argument matrix.
*
* t : (input) time-scale (can be < 0).
*
* wsp(lwsp) : (workspace/output) lwsp .ge. 4*m*m+ideg+1.
*
* ipiv(m) : (workspace)
*
*>>>> iexph : (output) number such that wsp(iexph) points to exp(tH)
* i.e., exp(tH) is located at wsp(iexph ... iexph+m*m-1)
* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
* NOTE: if the routine was called with wsp(iptr),
* then exp(tH) will start at wsp(iptr+iexph-1).
*
* ns : (output) number of scaling-squaring used.
*
* iflag : (output) exit flag.
* 0 - no problem
* <0 - problem


Second case:
subroutine DGCHBV( m, t, H,ldh, y, wsp, iwsp, iflag )

* m : (input) order of the matrix H
*
* t : (input) time-scaling factor (can be < 0).
*
* H(ldh,m): (input) argument matrix.
*
* y(m) : (input/output) on input the operand vector,
* on output the resulting vector exp(t*H)*y.
*
* iwsp(m) : (workspace)
*
* wsp : (workspace). Observe that a double precision vector of
* length 2*m*(m+2) can be used as well when calling this
* routine (thus avoiding an idle complex array elsewhere)
 

Related to Fortran: help with arguments to a pre-built software

1. What is Fortran?

Fortran is a programming language commonly used in scientific and engineering applications. It stands for "Formula Translation" and is known for its efficient handling of mathematical and scientific computations.

2. How can I pass arguments to a pre-built software written in Fortran?

To pass arguments to a pre-built software written in Fortran, you can use the "call" statement followed by the name of the subroutine or function and the arguments you want to pass. For example: "call subroutine_name(argument1, argument2)".

3. What are the rules for passing arguments in Fortran?

In Fortran, arguments are passed by reference by default, meaning that the subroutine or function can modify the values of the arguments. To pass arguments by value, you can use the "value" attribute before the argument in the subroutine or function declaration. Additionally, Fortran follows a strict type-checking system, so the data types of the arguments must match the data types expected by the subroutine or function.

4. How can I handle optional arguments in Fortran?

To handle optional arguments in Fortran, you can use the "optional" attribute before the argument in the subroutine or function declaration. This allows the argument to be omitted when the subroutine or function is called. In the subroutine or function body, you can use the "present" intrinsic function to check if the optional argument was provided or not.

5. Are there any special considerations when passing arrays as arguments in Fortran?

Yes, when passing arrays as arguments in Fortran, you need to specify the size of the array in the subroutine or function declaration. Additionally, arrays are passed by reference by default, so any modifications made to the array in the subroutine or function will be reflected in the original array in the main program.

Similar threads

  • Programming and Computer Science
Replies
18
Views
6K
  • Programming and Computer Science
Replies
6
Views
3K
  • Programming and Computer Science
Replies
1
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
0
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
5K
Back
Top