ETS  \$Id: Doxyfile 2162 2020-02-26 14:16:09Z g2dpc $
 All Classes Files Functions Variables Pages
wrapper_helena.f90
Go to the documentation of this file.
2 !----------------------------------------------------------------------------
3 ! This wrapper calls the HELENA fixed boundary equilibrium code as a
4 ! subroutine.
5 !----------------------------------------------------------------------------
6 
7  use itm_types
8  use mod_parameter
9  use mod_corners
10  use mod_dat
11  use mod_dete
12  use mod_gauss
13  use mod_map
14  use mod_mesh
15  use mod_meshacc
16  use mod_output
17  use mod_profiles
18  use mod_helena_io
19  use deallocate_structures
20  use copy_structures
21  use is_set_structures
22  use size_of_structures
23  use write_structures
24  use read_structures
25  use euitm_schemas
26  use euitm_xml_parser
27  use xml_file_reader
28 
29 
31 
32  implicit none
33 
34 !-- interface definitions for actors
35 
36  interface
37  subroutine helena(equilibrium_in, equilibrium_out, path, code_parameters)
38  use euitm_schemas
39  use euitm_xml_parser
40  type (type_equilibrium), pointer :: equilibrium_in(:)
41  type (type_equilibrium), pointer :: equilibrium_out(:)
42  character(len = 132), optional :: path
43  type (type_param) :: code_parameters
44  end subroutine helena
45 
46  subroutine progen(equilibrium_in, equilibrium_out, active, path, &
47  path_tag, code_parameters)
48  use euitm_schemas
49  use euitm_xml_parser
50  use itm_types
51  type (type_equilibrium), pointer :: equilibrium_in(:)
52  type (type_equilibrium), pointer :: equilibrium_out(:)
53  integer(itm_i4), intent(in) :: active
54  character(len = 132), optional :: path
55  character(len = 132), optional :: path_tag
56  type (type_param) :: code_parameters
57  end subroutine progen
58  end interface
59 
60 !-- variable definitions
61 
62  type (type_equilibrium), pointer :: equilibrium_in(:)
63  type (type_equilibrium), pointer :: equilibrium_out(:)
64  integer(itm_i4) :: active = 1 ! progen always active in wrapper
65  character(len = 132) :: filename_progen_xml
66  character(len = 132) :: filename_helena_xml
67  character(len = 132) :: path, path_tag
68  type (type_param) :: code_parameters
69 
70  integer(itm_i4) :: i
71  integer(itm_i8) :: total_size = 0
72  logical, parameter :: human_readable = .true.
73 
74  integer(itm_i4) :: iargc
75 
76 !-- define default behaviour without input arguments
77  path = './' ! run locally
78  filename_progen_xml = 'progen.xml'
79  filename_helena_xml = 'helena.xml'
80 
81  path_tag = ''
82  if (iargc() >= 2) then
83  call getarg(1, filename_progen_xml)
84  call getarg(2, filename_helena_xml)
85  if (iargc() >= 3) then
86  call getarg(3, path)
87  end if
88  if (index(filename_helena_xml, 'helena') /= -1) then
89  path_tag = filename_helena_xml(index(filename_helena_xml, 'helena') &
90  + 6 : index(filename_helena_xml, '.xml') - 1)
91  end if
92  end if
93 
94 !-- allocate empty input CPO
95  allocate(equilibrium_in(1))
96 
97 !-- read PROGEN schema and input
98  call fill_param(code_parameters, trim(adjustl(path)) &
99  // trim(adjustl(filename_progen_xml)), '', trim(adjustl(path)) &
100  // 'progen.xsd')
101 !-- profiles and shape generation: PROGEN
102  call progen(equilibrium_in = equilibrium_in, &
103  equilibrium_out = equilibrium_out, active = active, path = path, &
104  path_tag = path_tag, code_parameters = code_parameters)
105 
106 !-- output of PROGEN equilibrium CPO
107  call set_write_verbosity(0) ! no verbose output
108  call open_write_file(12, trim(adjustl(path)) // 'progen_equilibrium.cpo')
109  call write_cpo(equilibrium_out, 'equilibrium')
110  call close_write_file
111 
112 !-- destroy equilibrium_in
113  call set_deallocate_verbosity(1) ! verbose output
114  call deallocate_cpo(equilibrium_in)
115 
116 !-- test which fields have been set
117  call is_set_cpo(equilibrium_out(1), 'equilibrium_out')
118 
119 !-- allocate equilibrium_in
120  allocate(equilibrium_in(size(equilibrium_out)))
121 
122 !-- copy equilibrium_out to equilibrium_in
123  call set_copy_verbosity(1) ! verbose output
124  do i = 1, size(equilibrium_out)
125  call copy_cpo(equilibrium_out(i), equilibrium_in(i))
126  end do
127 
128 !-- destroy equilibrium_out
129  call deallocate_cpo(equilibrium_out)
130 
131 !-- read HELENA schema and input
132  call fill_param(code_parameters, trim(adjustl(path)) &
133  // trim(adjustl(filename_helena_xml)), '', trim(adjustl(path)) &
134  // 'helena.xsd')
135 
136 !-- set path to output path
137  if (path_tag /= '') then
138  path = trim(adjustl(path)) // 'helena' // trim(adjustl(path_tag)) // '/'
139  write(iu6, *) 'HELENA output redirected to ', trim(adjustl(path))
140  end if
141 
142 !-- solve equilibrium: HELENA
143  call helena(equilibrium_in = equilibrium_in, &
144  equilibrium_out = equilibrium_out, path = path, &
145  code_parameters = code_parameters)
146 
147 !-- test which fields have been set
148  call is_set_cpo(equilibrium_out(1), 'equilibrium_out')
149 
150 !-- display size of output CPO
151  call set_size_of_verbosity(0)
152  call set_size_of_maxlevel(1)
153 ! call size_of_cpo(equilibrium_out(1), total_size, &
154 ! human_readable, 'equilibrium_out')
155 
156 !-- output of HELENA equilibrium for ILSA
157  call write_equilibrium(path, equilibrium_out(1))
158 
159 !-- output of HELENA equilibrium CPO
160  call set_write_verbosity(0) ! no verbose output
161  call open_write_file(12, trim(adjustl(path)) // 'equilibrium.cpo')
162  call write_cpo(equilibrium_out(1), 'equilibrium')
163  call close_write_file
164 
165 !-- deallocate equilibrium CPOs
166  call set_deallocate_verbosity(0) ! non-verbose output
167  call deallocate_cpo(equilibrium_in)
168  call deallocate_cpo(equilibrium_out)
169 
170  allocate(equilibrium_out(1))
171 
172 !-- read equilibrium CPO from output file (to check file)
173  call set_read_verbosity(0) ! no verbose output
174  call open_read_file(12, trim(adjustl(path)) // 'equilibrium.cpo')
175  call read_cpo(equilibrium_out(1), 'equilibrium')
176  call close_read_file
177 
178 !-- final deallocate
179  call deallocate_cpo(equilibrium_out)
180 
181  stop 'finished wrapper'
182 
183 end program wrapper_helena
subroutine helena(equilibrium_in, equilibrium_out, in_path, code_parameters)
Definition: helena.f90:1
subroutine write_equilibrium(path, equilibrium_out)
program wrapper_helena
subroutine, public equilibrium_destructor(equilibrium)