Table of Contents |
---|
4.2.1. Changes
CHEAT SHEET | |
ITM | IMAS |
---|---|
use euitm_schemas | use ids_schemas |
use euitm_routines | use ids_routines |
type(type_<cpo_name>) :: cpo | type (ids_<ids_name>) :: ids |
type(type_<cpo_name>), pointer :: cpoArray(:) <= ARRAY !! | type (ids_<ids_name>) :: ids <== SINGLE OBJ !!! |
eval-pkg-config | pkg-config |
eval-pkg-config --cflags --libs ual-ifort | pkg-config --cflags --libs imas-ifort |
eval-pkg-config --cflags --libs ual-gfortran | pkg-config --cflags --libs imas-gfortran |
type(type_param) :: XML_params | type(ids_parameters_input ) :: XML_params |
type type_param ... :: default_param ... :: schema | type ids_parameters_input ... :: parameters_value ... :: parameters_default |
...
... :: schema endtype | |
use euitm_xml_parser | use imas_xml_parser |
call euitm_xml_parse(code_params, nparm, param_list) | call imas_xml_parse(code_params, nparm, param_list) |
eval-pkg-config | pkg-config |
eval-pkg-config --cflags ual-ifort | pkg-config --cflags imas-ifort |
eval-pkg-config --cflags ual-gfortran | pkg-config --cflags imas-gfortran |
4.2.2 Examples
Examples of interface between wrapper and user code | |||||
---|---|---|---|---|---|
ITM
| IMAS
|
4.2.2 XML Parsing
Code Block |
---|
use imas_xml_parser
type(ids_Parameters_Input),intent(in) :: code_parameters
integer, intent(out) :: return_status
type(tree) :: parameter_list
type(element), pointer :: temp_pointer
integer(itm_i4) :: i, nparm, n_values,j
character(len = 132) :: cname
!... initialisations
nparm = 0
n_values = 0
return_status = 0 ! no error
j = 0
!-- parse xml-string code_parameters%parameters using W3C XML schema in
! code_parameters%schema
call imas_xml_parse(code_parameters, nparm, parameter_list)
!-- assign variables
temp_pointer => parameter_list%first
outer: do
cname = char2str(temp_pointer%cname) ! necessary for AIX
select case (cname)
!-- parameters overall
case ("parameters")
temp_pointer => temp_pointer%child
cycle
!-- parameter classes
!-- individual parameters
case ("tokamak")
if (allocated(temp_pointer%cvalue)) &
call char2num(temp_pointer%cvalue, tokamak)
case default
write(0, *) 'ERROR: invalid parameter', cname
return_status = 1
exit
end select
do
if (associated(temp_pointer%sibling)) then
temp_pointer => temp_pointer%sibling
exit
end if
if (associated(temp_pointer%parent, parameter_list%first )) &
exit outer
if (associated(temp_pointer%parent)) then
temp_pointer => temp_pointer%parent
else
write(0, *) 'ERROR: broken list.'
return
end if
end do
end do outer |
4.2.3 Delivery of the user code
The user code should be delivered as a static library.
Please find examples of the simple "Makefile" below:
Code Block | ||||
---|---|---|---|---|
| ||||
F90 = ifort
COPTS = -g -O0 -assume no2underscore -fPIC -shared-intel
INCLUDES = $(shell pkg-config --cflags imas-ifort)
all: equilibrium2distsource.o libequilibrium2distsource
libequilibrium2distsource: equilibrium2distsource |
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 IDS(es) from UAL and passes data to user code
- Passes input code parameters (XML/XSD files) to user code
- Calls user subroutine/function
- Saves output IDS(es)
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 $@ $^libequilibrium2distsource.a equilibrium2distsource.o simplecppactorequilibrium2distsource.o: simplecppactorequilibrium2distsource.cppf90 $(CXXF90) $(CXXFLAGS) $(CXXINCLUDESCOPTS) -c -o $@ $^ ${INCLUDES} clean: rm -f *.ao *.oa |
Tip |
---|
Recomendations
|