tstLibrary.f90

./Core/dc/f/tests/tstLibrary.f90

1 program tstlibrary
2 
3 #include "ScaleSTL/FortranTestMacros.h"
4 
8 
9 implicit none
10 
11 type(origen_library) :: lib
12 type(origen_libraryheader) :: definition
13 type(origen_decaydata) :: decay_data
14 type(origen_transitionstructure) :: tstruct
15 type(origen_transitioncoeff) :: tcoeff
16 type(origen_nuclideset) :: nucset
17 
18 type(origen_fakefactory) :: ff
19 type(scalestl_vec_flt) :: fvec
20 type(scalestl_vec_int) :: ivec
21 real(C_FLOAT),allocatable :: farr(:)
22 integer(C_INT),allocatable :: iarr(:)
23 
24 integer,parameter :: l=c_size_t
25 logical :: loaded
26 
27 call lib % initialize()
28 loaded = ff % Library_random1(lib,333)
29 if( .not. loaded )stop 1
30 
31 !
32 ! Get different parts of the library.
33 !
34 call lib % getptr_definition(definition)
35 assert_c_assoc(definition)
36 
37 !test the header
38 call nucset % initialize()
39 call definition % get_nuclide_set(nucset)
40 expect_eq(742,nucset % num_in_sublib(origen_sublib_1lt))
41 expect_eq(556,nucset % num_in_sublib(origen_sublib_2ac))
42 expect_eq(928,nucset % num_in_sublib(origen_sublib_3fp))
43 
44 !test decay data
45 call lib % getptr_decay_data(decay_data)
46 assert_c_assoc(decay_data)
47 expect_near( 1.50642300e-3 , decay_data%decay_constants(1) , 1e-5)
48 
49 !test transition structure
50 call lib % getptr_transition_structure(tstruct)
51 assert_c_assoc(tstruct)
52 call tstruct % getptr_num_parents_vec(ivec)
53 assert_c_assoc(ivec)
54 expect_eq(6,ivec%at(1_l))
55 expect_eq(2226_l,ivec%size())
56 !try with native arrays
57 call tstruct % get_num_parents(iarr)
58 expect_eq(6,iarr(1))
59 expect_eq(2226,size(iarr,1))
60 
61 !test transition coeff
62 call lib % getptr_transition_coeff_at(tcoeff,1_l)
63 assert_c_assoc(tcoeff)
64 call tcoeff % getptr_matrix_vec(fvec)
65 assert_c_assoc(fvec)
66 expect_near(8.69777426e-03,fvec%at(1_l),1e-5)
67 !try with native arrays
68 call tcoeff % get_matrix(farr)
69 expect_near(8.69777426e-03,farr(1),1e-5)
70 
71 call lib % destroy()
72 
73 end program