Presentation is loading. Please wait.

Presentation is loading. Please wait.

Babel F2003 Struct Support Update and FACETS integration Funded by DOE (TASCS) Grant No DE-FC02-07ER25805, DOE Grant No DE-FG02-04ER84099 and Tech-X Stefan.

Similar presentations


Presentation on theme: "Babel F2003 Struct Support Update and FACETS integration Funded by DOE (TASCS) Grant No DE-FC02-07ER25805, DOE Grant No DE-FG02-04ER84099 and Tech-X Stefan."— Presentation transcript:

1 Babel F2003 Struct Support Update and FACETS integration Funded by DOE (TASCS) Grant No DE-FC02-07ER25805, DOE Grant No DE-FG02-04ER84099 and Tech-X Stefan Muszala John Cary, Tom Epperly, Ammar Hakim, Scott Kruger, Gary Kumfert, Alexander Pletzer, Rooparani Pundaleeka, Srinath Vadlamani, Nanbor Wang January 17, 2008

2 Distcomp: One of the goals of the Distcomp work is to implement Fortran 2003 bindings in Babel for struct support. This work is aligned with the work of the Common Component Architecture (TASCS). What are the Tech-X scopes of the Distcomp and TASCS projects? TASCS: Part of the TASCS work is a collaboration with the FACETS* project in which we are integrating a C++ framework with Fortran modules (eventually Python, C). We are using the newly developed Fortran 2003 bindings in Babel to achieve our goal. * FACETS-( Framework Application for Core-Edge Transport Simulations ) is a SCIDAC project led by Tech-X which aims to integrate core, edge and wall fusion simulations.

3 FACETS+Babel integration only requires components at end of call chain

4 What work has been Completed? Distcomp: F2003 Implementation of Primitive Types in Babel. F2003 Implementation of Array Types in Babel. F2003 Implementation of R-array Types in Babel. TASCS work related to Fusion Projects: Have SIDL versions of FACETS Fortran Derived Types. Runs in a test FACETS Framework using R- arrays. Have SIDL prototype of FACETS interface which passes Babel struct from C++ to Fortran transport module Added timing infrastructure to test codes in order to compare with original (non-Babel) test code.

5 What still needs to be completed? Distcomp : Regression tests for F2003 structs. Includes all Fortran->”other language” combinations. Add examples - have some of these in Tech-X repo. Enumeration Types Documentation. Check pointer _init - (OK?) for non-static rarrays. Check pointer _destroy - (OK?) for non-static rarrays. Make sure copy works - (OK?) For non-static rarrays. _serialize/_deserialize for RMI calls. Provide access to every struct member. TASCS work related to Fusion Projects: Complete transport module interfaces. Continue working on SIDL interfaces for other modules.

6 package addRand version 1.0{ struct fStruct{ double bX; int bY; }; … } module addRand_fStruc use,intrinsic :: iso_c_binding type,bind(c) :: addRand_fStruct_t real(c_double) :: bX integer(c_int32_t) :: bY end type addRand_fStruct_t end module addRand_fStruct How we use BindC to provide Babel Primitive type capability in Babel Structs.

7 How we use BindC to provide Babel Array type capability in Babel Structs. package addRand version 1.0{ struct fStruct{ double bX; int iY; array testArr; }; class modStruct{ void doWork(in int n, inout fStruct structTest); } addRand::fStruct fTest; … for (size_t i = 0 ; i < N ; i++) { sidl_double__array_set1(fTest.testArr,i,double(i)); } … addRand::modStruct bS = addRand::modStruct:: _create(); bS.doWork(10,fTest); … type(addRand_fStruct_t) :: structTest ! inout … do i=0,structTest%iY call get(structTest%testArr, i, temp) call set(structTest%testArr,i,temp*5.0) enddo module addRand_fStruct use,intrinsic :: iso_c_binding use sidl_double_array type,bind(c) :: addRand_fStruct_t real(c_double) :: bX integer(c_int32_t) :: iY type(sidl_double_1d) :: testArr end type addRand_fStruct_t end module addRand_fStruct

8 We have used BIND© to provide two types of rarray support for C/F90 and C++/F90 struct bindings. SIDL struct flags{ … rarray glfIflagin(5); … } C++/C … double glfIflagin[5]; … FORTRAN … real(c_double)::glfIflagin(5) … Static R-Array

9 We have used BIND© to provide two types of rarray support for C/F90 and C++/F90 struct bindings. SIDL struct structTest{ … int iY; rarray structRaw(iY); // Probably don’t want: rarray structRaw(*); … } C++/C double *structRaw; real(c_double),dimension(:),pointer :: structTest_structRAW_fptr call C_F_POINTER(CPTR=structTest%structRAW, & FPTR=structTest_structRAW_fptr, & SHAPE=(/DIM/)) … do i=1,structTest%iY structTest_structRAW_fptr(i)=structTest_structRAW_fptr(i)+5.0 enddo module addRand_fStruct use,intrinsic :: iso_c_binding use sidl_double_array type,bind(c) :: addRand_fStruct_t real(c_double) :: bX integer(c_int32_t) :: iY type(c_ptr) :: structRAW real(c_double)::fixBound(10) end type addRand_fStruct_t end module addRand_fStruct Dynamic R-Array

10 real(c_double),dimension(:),pointer :: structTest_structRAW_fptr call C_F_POINTER(CPTR=structTest%structRAW, & FPTR=structTest_structRAW_fptr, & SHAPE=(/DIM/)) do i=1,structTest%iY structTest_structRAW_fptr(i)=structTest_structRAW_fptr(i)+5.0 enddo call procedureDoSomething(structTest_structRAW_fptr) ! NOT call procedureDoSomething(structTest) What is the best way to pass the converted F pointer to deeply nested procedure calls?

11 struct Flags { … double glfCbetae; /*FD set cbetae=1 for fully electromagnetic */ double glfCnu; /*FD factor for the collisionality */ rarray glfIflagin(5); /*FD Transport flags internal to the GLF module */ rarray glfXparam(30); /*FD Normalizers and calibration coefficients */ /* internal to the module */ int mmmNroot; /*FD number of moments */ int mmmNpoints; /*FD should be always 1 */ … }; REAL(kind=r8) :: glfCbetae !*FD set cbetae=1 for fully electromagnetic REAL(kind=r8) :: glfCnu !*FD factor for the collisionality INTEGER, DIMENSION(5) :: glfIflagin !*FD Transport flags internal to the GLF module REAL(kind=r8), DIMENSION(30) :: glfXparam !*FD Normalizers and calibration c !* coefficients internal to the module INTEGER :: mmmNroot !*FD number of moments INTEGER :: mmmNpoints !*FD should be always 1 How do we convert the transport module Flags type to SIDL?

12 How do we provide the transport modules interface using Babel? fmcfmWrap::fmcfm FM = fmcfmWrap::fmcfm::_create(); retVal=t_start("TmInitFlags"); FM.siInitFlags(flags,funit_input); retVal=t_stop("TmInitFlags"); recursive subroutine fmcfmWrap_fmcfm_siInitFlags_mi(self, mflags, funit, & exception) … call sidlInitFlags(mflags,funit) … 19 SUBROUTINE sidlInitFlags(mFlags,funit) 20 USE input_namelist_mod 21 IMPLICIT NONE 22 23 TYPE(fmcfmWrap_Flags_t),INTENT(OUT) :: mflags 24 INTEGER, INTENT(IN) :: funit 25 26 IF(funit > 0) THEN 27 REWIND(funit) 28 READ(funit,GLF_FLAGS) 29 REWIND(funit) 30 READ(funit,MMM_FLAGS) 31 ENDIF 32 33 CALL setFlags(mFlags) 34 35 END SUBROUTINE sidlInitFlags

13 Questions/Comments


Download ppt "Babel F2003 Struct Support Update and FACETS integration Funded by DOE (TASCS) Grant No DE-FC02-07ER25805, DOE Grant No DE-FG02-04ER84099 and Tech-X Stefan."

Similar presentations


Ads by Google