...
1. What code wrapper actually does?
The code wrapper intermediates between Kepler actor and user code:
- Passes variables of language built-in types (int, char, etc) from actor to the code
- Reads CPO(s) from UAL and passes data to user code
- Passes input code parameters (XML/XSD files) to user code
- Calls user subroutine/function
- Saves output CPO(s)
2. Development of Fortran codes
2.1 Subroutine syntax
subroutine name ( <in/out arguments list> [,code_parameters] )
- name - subroutine name
- in/out arguments list - mandatory - a list of input and output subroutine arguments including:
- Fortran intrisic data types, eg:
- integer :: input
- character(50) :: charstring
- integer,dimension(4) :: tabint
- CPOs, eg:
- type (type_equilibrium),pointer :: equilibriumin(:)
- type (type_distsource),pointer :: distsourceout(:)
- Fortran intrisic data types, eg:
- code_parameters - optional - user defined input parameters
Argument of type: type_param
Code Block type type_param ! character(len=132), dimension(:), pointer ::parameters character(len=132), dimension(:), pointer ::default_param character(len=132), dimension(:), pointer ::schema endtype
- Derived type type_param describes:
- parameters - Actual value of the code parameters (instance of coparam/parameters in XML format).
- default_param - Default value of the code parameters (instance of coparam/parameters in XML format).
- schema - Code parameters schema.
- An example: (type_param) :: codeparam
Warning |
---|
|
2.2 Examples
Code Block | ||
---|---|---|
| ||
subroutine nocpo(input, output) integer, intent(in):: input integer, intent(out):: output |
Code Block | ||
---|---|---|
| ||
subroutine equil2dist(equilibriumin, distsourceout) use euITM_schemas implicit none type (type_equilibrium), pointer :: equilibriumin(:) type (type_distsource), pointer :: distsourceout(:) |
Code Block | ||
---|---|---|
| ||
subroutine teststring(coreprof,equi,tabint,tabchar,codeparam) use euITM_schemas implicit none !input type(type_coreprof),pointer,dimension(:) :: coreprof integer, dimension(4), intent(in) :: tabint !output type(type_equilibrium),pointer,dimension(:) :: equi character(50), intent(out) :: tabchar !code parameters type(type_param), intent(in) :: codeparam |
3 Development of C++ codes
3.1 Function syntax
void name ( <in/out arguments list> [,code_parameters] )
- name - function name
- in/out arguments list - mandatory - a list of input and output function arguments including:
- CPP intrisic data types, eg:
- int &x
- double &y
- CPOs, eg:
- ItmNs::Itm::antennas & ant
- ItmNs::Itm::equilibriumArray & eq
- CPP intrisic data types, eg:
- code_parameters - optional - user defined input parameters
- Argument of type: ItmNs::codeparam_t &
typedef struct { char **parameters; char **default_param; char **schema; } codeparam_t;
- A structure codeparam_t describes:
- parameters - Actual value of the code parameters (instance of coparam/parameters in XML format).
- default_param - Default value of the code parameters (instance of coparam/parameters in XML format).
- schema - Code parameters schema.
- An example: ItmNs::codeparam_t & codeparam
- Argument of type: ItmNs::codeparam_t &
Warning |
---|
Required header Do not forget to add #include "UALClasses.h" while playing with CPOs! |
3.2 Examples
Code Block | ||||
---|---|---|---|---|
| ||||
void simplecppactornocpo(double &x, double &y) |
Code Block | ||||
---|---|---|---|---|
| ||||
void simplecppactor(ItmNs::Itm::equilibriumArray &eq, double &x, double &y)
|
Code Block |
---|
void mycppfunctionbis_init();
void mycppfunction(ItmNs::Itm::summary& sum, ItmNs::Itm::equilibriumArray& eq, int& x, ItmNs::Itm::coreimpur& cor, double& y, ItmNs::codeparam_t& codeparam) |
Info |
---|
Initialization If user function needs any pre-initialization, an additional function <name>_init could be defined. |
4. Delivery of the user code
The user code should be delivered as a static library.
Please find examples of the simple "makefiles" below:
Code Block | ||||
---|---|---|---|---|
| ||||
F90 = $(ITM_INTEL_FC) COPTS = -g -O0 -assume no2underscore -fPIC -shared-intel INCLUDES = $(shell eval-pkg-config --cflags ual-$(ITM_INTEL_OBJECTCODE)) all: equilibrium2distsource.o libequilibrium2distsource libequilibrium2distsource: equilibrium2distsource.o ar -rvs libequilibrium2distsource.a equilibrium2distsource.o equilibrium2distsource.o: equilibrium2distsource.f90 $(F90) $(COPTS) -c -o $@ $^ ${INCLUDES} clean: rm -f *.o *.a |
Code Block | ||
---|---|---|
| ||
CXX=g++ CXXFLAGS= -g -fPIC CXXINCLUDES= ${shell eval-pkg-config --cflags ual-cpp-gnu} all: libsimplecppactor.a libsimplecppactor.a: simplecppactor.o ar -rvs $@ $^ simplecppactor.o: simplecppactor.cpp $(CXX) $(CXXFLAGS) $(CXXINCLUDES) -c -o $@ $^ clean: rm *.a *.o |
Tip |
---|
Recomendations
|