551days since
Proposal Due Date

Recent site activity

Data Management

As a computational environment aimed at group projects, data and software management must ultimately be an integral part of the Field Marshal environment. Past experience with such systems has shown that they are too often a “straitjacket” for users, driving great creativity in getting around imposed limitations (creativity better spent on R&D). The FM Phase I team acknowledges the need for data management but feels that it is best evolved into a system with extensive user testing and comment. For this reason Phase I did not explore details of this issue; however, the approach we developed is compatible with evolution and integration of data management components in Phase II.

Legacy Data Integration

Any project that plans to build thea next generation framework for scientific calculations cannot ignore the legacy software, or it will likely be ignored by those who developed and use legacy software. A new framework must make it easy to blend the capabilities of  legacy software with the capabilitiies of the new framework.

The Python language has long history of providing seemless integration of the Python language with legacy software written in the C language. Many Python programmers are very adept at writing Python style software in the C language by making use of the C API for the Python language. This wrapper capability has been automated to some extent by wrapper libraries such as SWIG. More domain specific libraries such as SIP also exist. Over the last decade the scientific community has developed a new generation of standard libraries in the C++ language. These new libraries have resulted in tools that go beyond the level of integration that SWIG and SIP have made possible. For instance, the Weave project has achieve very high levels of performance. The Weave project built on the research of the Pyro?? project and the Pyrex. These tools looked for ways to integrate the type declaritive nature of C with the dynamic type checking features of Python. The next generation of capabilities, as is being explored by PyPy are likely to reduce the effort required to declare type safety, when that is advantageous, with the flexibility of a dynamically typed language such as Python.

At a different layer in the problem of enterprise integration is the problem of capitalizing on the legacy investment in programs written in mature languages, such as Fortran. The scientific community has over 40 years invested in vetted software written in Fortran. This legacy investment should not be tossed aside if it can be harvested and integrated into the Field Marshal project. This is not a big issue with Python. The C API to the Python interpreter makes it relatively easy to link at run-time to any computer langauge. In order to link to languages written in Fortran the trick is in setting up a tool chain that captures the algoritm and meets the data I/O requirements for the application. Over the past couple decades there have been a number of attempts to reduce the burden on mingling legacy Fortran code with Python code. During the Phase I evaluation the Field Marshal project evaluated several options for linking legacy Fortran software with the Field Marshal framework. While we concluded that one approach is prefered, there is nothing in the Python API that prevents alternative approaches to systems integration from including legacy Fortran software into the Field Marshal framework.

Testing PyFort

The following code is available in the PyGridGen.f file. It defines function/subrs descriptors.

! $Id$
!
! Module descriptor file for Field Marshall Fortran-Python
! interconnect demonostration
!
! Author: Nick Seidenman <nick@seidenman.net>
!
! $Log$
!

!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
! ArcCircle.f

subroutine arc_circle (p1, p2, p3, pc, rc, angle,
quadrant, opt, valid)
!
! Subroutine to generate and set parameters for a circular arc
! from user supplied geometry input.
!
! P1 - (z,x) or (z,r) of the initial point
! P2 - (z,x) or (z,r) of the final point
! P3 - (z,x) or (z,r) of any intermediate point
! P ! - (z,x) or (z,r) of the circle center point
! R ! - radius of the circle
! ANGLE - angle in degrees (+/-) that the arc
! sweeps out relative to the initial point
!
! The user *MUST* supply P1, its values are assumed to be
! correct.
!
! The user *MUST* supply at least one of the components of P2,
! ie either the z or x/r value (or both).
!
! The user has the following valid choices:
!
! OPT = -1 - Invalid (set in InitArc), unchanged by user
! OPT = 0 - P1, P2 and P ! provided
! OPT = 1 - P1, P ! and P2-(z, ---) value provided
! OPT = 2 - P1, P ! and P2-(---, x/r) value provided
!
!
! QUADRANT = 1 if arc is in the first quadrant,
! add z to Pc-z and add x/r to Pc-x/r
! when computing FZ(X/Rg) and F_X_R(Zg)
!
! 2 if arc is in the second quadrant,
! sub z to Pc-z and add x/r to Pc-x/r
! when computing FZ(X/Rg) and F_X_R(Zg)
!
! 3 if arc is in the third quadrant,
! sub z to Pc-z and sub x/r to Pc-x/r
! when computing FZ(X/Rg) and F_X_R(Zg)
!
! 4 if arc is in the fourth quadrant,
! add z to Pc-z and sub x/r to Pc-x/r
! when computing FZ(X/Rg) and F_X_R(Zg)

real*8,intent(in):: p1(2)
real*8,intent(inout):: p2(2), p3(2), pc(2)
real*8 angle
real*8,intent(out):: rc
integer,intent(in):: quadrant
integer,intent(in):: opt
integer,intent(out):: valid
end subroutine arc_circle

!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
! ArcLength.f

subroutine arc_length (n, s, x, y)
! Subroutine to compute the arc length of boundary elements
! for use as an ordering parameter. Arc length squared is
! used for some cases to avoid the unnecessary computational
! expense of computing the square root.
integer n
real*8,intent(out):: s(n)
real*8,intent(in):: x(n)
real*8,intent(in):: y(n)
end subroutine arc_length

!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
! FuncFX.f

function fz (ixr)
! Z VALUES AT INTEGER VALUES OF XR
integer,intent(in):: ixr
real*8 fz
end function fz

!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
! FuncFXR.f

function f_x_r (iz)
! XR VALUES AT INTEGER VALUES OF Z
integer,intent(in):: iz
real*8 f_x_r
end function fz

!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
! FuncFY.f

function fy (ix)
! Y VALUES AT INTEGER VALUES OF X
integer,intent(in):: ix
real*8 fy
end function fz

!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
! GenMesh.f

subroutine gen_mesh_pts (num, mesh_tol, mesh)
! Subroutine to create an ordered list of boundary points from
! elemental geometric input. The points have associated
! off-sets (i.e. deltas) from the mesh boundary nodes to the
! actual boundary. The off-sets can be set for either
! 5-pt or 9-pt stencils.
integer,intent(out):: num
real*8,intent(in):: mesh_tol
character*(*) mesh
end subroutine gen_mesh_pts

!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
! InitArc ! ir.f

subroutine init_arc_circle (p1, p2, p3, pc, rc, angle,
quadrant, opt, valid)

! Subroutine to initialize geometric parameters for a general
! (ie not vertical or horizontal) line.

! P1 - (x,y) or (z,r) of the initial point
! P2 - (x,y) or (z,r) of the final point
! ANGLE - angle in degrees (+/-) that the line
! makes with the positive x/z-axis
! S - slope of the line
! B - y/r intercept

! OPT = I_NULL - Indicator for invalid input or
! value unchanged by user
! OPT = 0 - P2-(x/z, y/r) values provided
! OPT = 1 - P2-(x/z, ---) value provided
! OPT = 2 - P2-(---, y/r) value provided

real*8,intent(in):: p1(2)
real*8,intent(inout):: p2(2), p3(2), pc(2)
real*8 angle
real*8,intent(out):: rc
integer,intent(in):: quadrant
integer,intent(in):: opt
integer,intent(out):: valid
end subroutine init_arc_circle

!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
! InitLine.f

subroutine init_line (p1, p2, opt, angle, s, b)
! Subroutine to initialize geometric parameters for a general
! (ie not vertical or horizontal) line.

! P1 - (x,y) or (z,r) of the initial point
! P2 - (x,y) or (z,r) of the final point
! ANGLE - angle in degrees (+/-) that the line
! makes with the positive x/z-axis
! S - slope of the line
! B - y/r intercept

! OPT = I_NULL - Indicator for invalid input or
! value unchanged by user
! OPT = 0 - P2-(x/z, y/r) values provided
! OPT = 1 - P2-(x/z, ---) value provided
! OPT = 2 - P2-(---, y/r) value provided
real*8,intent(out):: p1(2), p2(2)
integer,intent(out):: opt
real*8,intent(out):: angle
real*8,intent(out):: s
real*8,intent(out):: b
end subroutine init_line

!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
! Line.f

subroutine line (p1, p2, opt, angle, s, b)
! Subroutine to generate and set parameters for a general
! (ie not vertical or horizontal) line from user supplied
! geometry input.

! P1 - (z,x) or (z,r) of the initial point
! P2 - (z,x) or (z,r) of the final point
! ANGLE - angle in degrees (+/-) that the line
! makes with the positive z-axis
! S - slope of the line
! B - x/r intercept

! The user *MUST* supply P1, its values are assumed to be correct.

! The user *MUST* supply at least one of the components of P2,
! ie either the z or x/r value (or both).

! Which the user has chosen to do is indicated by *NON-ZERO*
! values for one of ANGLE, S, or B, and an option value:

! OPT = -1 - Invalid, option not set by user
! OPT = 0 - P2-(z, x/r) values provided
! OPT = 1 - P2-(z, ---) value provided
! OPT = 2 - P2-(---, x/r) value provided
real*8,intent(in):: p1(2)
real*8,intent(inout):: p2(2)
integer,intent(in):: opt
real*8,intent(inout):: angle
real*8,intent(inout):: s
real*8,intent(inout):: b
end subroutine line

!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
! MuInt8.f
function my_int8 (x)
! FUN ! TION MY_INT8: Truncation of X to integer values.
! Note that negative values are truncated
! to the lower negative value. For example:

! MY_INT8( -2.5 ) = -3
! MY_INT8( -0.5 ) = -1
! MY_INT8( -4.0 ) = -4
real*8 x
integer my_int8
end function my_int8

!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
! PlotMeshBound.f

subroutine plot_mesh_boundary (num)
integer,intent(in):: num
end subroutine plot_mesh_boundary

!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
! TransArc ! ir.f
subroutine trnsfr_arc_cir (p1, p2, inside, tag,
pc, rc, quadrant, atype, label)
! SUBROUTINE TRNSFR_AR ! _ ! IR
!
! Subroutine to generate and set parameters for a circular arc
! from user supplied geometry input.
!
! P1 - (x,y) or (z,r) of the initial point
! P2 - (x,y) or (z,r) of the final point
! P ! - (x,y) or (z,r) of the circle center point
! R ! - radius of the circle
!
! The inside/outside indicator is *ALWAYS* stored in I4_PARAMS(1).
! When looking from point_1 along the curve to point_2, the
! following holds:
!
! INSIDE = -1 if 'inside' is to the right
! 1 if 'inside' is to the left
!
! QUADRANT = 1 if arc is in the first quadrant,
! add x/z to Pc-x/z and add y/r to Pc-y/r
! when computing FX(Yg) and FY(Xg)
!
! 2 if arc is in the second quadrant,
! sub x/z to Pc-x/z and add y/r to Pc-y/r
! when computing FX(Yg) and FY(Xg)
!
! 3 if arc is in the third quadrant,
! sub x/z to Pc-x/z and sub y/r to Pc-y/r
! when computing FX(Yg) and FY(Xg)
!
! 4 if arc is in the fourth quadrant,
! add x/z to Pc-x/z and sub y/r to Pc-y/r
! when computing FX(Yg) and FY(Xg)

real*8,intent(in):: p1(2), p2(2),pc(2)
real*8,intent(in):: rc
integer,intent(in):: inside, tag
integer,intent(in):: quadrant
character*(*),intent(in):: atype, label

end subroutine trnsfr_arc_cir


!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
! TransLine.f

subroutine trnsfr_line (p1, p2, inside, tag, s, b, atype, label)
! Subroutine to generate and set parameters for a general
! (ie not vertical or horizontal) line from user supplied
! geometry input.

! P1 - (x,y) or (z,r) of the initial point
! P2 - (x,y) or (z,r) of the final point
! S - slope of the line
! B - y/r intercept

! The inside/outside indicator is *ALWAYS* stored in I4_PARAMS(1).
! When looking from point_1 along the curve to point_2, the
! following holds:

! INSIDE = -1 if 'inside' is to the right
! 1 if 'inside' is to the left
real*8,intent(in):: p1(2), p2(2)
real*8,intent(in):: s, b
integer,intent(in):: inside, tag
integer,intent(in):: quadrant
character*(*),intent(in):: atype, label
end subroutine trnsfr_line

The following code is place in a second file, PyGridGen.pfp, This is the project file for the test case.


pyf( 'PyGridGen.pyf', sources=['src/ArcCircle.f',
'src/MyInt8.f',
'src/ArcLength.f',
'src/FuncFX.f',
'src/FuncFXR.f',
'src/FuncFY.f',
'src/GenMesh.f',
'src/InitArcCir.f',
'src/InitLine.f',
'src/Line.f',
'src/PlotMeshBound.f',
'src/TransArcCir.f',
'src/TransLine.f'])