ETS  \$Id: Doxyfile 2162 2020-02-26 14:16:09Z g2dpc $
 All Classes Files Functions Variables Pages
ets_wrapper_chease.f90
Go to the documentation of this file.
1 ! + + + + + + + + + + + + + + + + + + + + + + + + + + + +
7 ! + + + + + + + + + + + + + + + + + + + + + + + + + + + +
9 
10  use euitm_schemas
11  implicit none
12 
13 contains
14 
15  subroutine chease_wrapper(euitm_equilibrium_in, euitm_equilibrium_out)
16 
17  use xml_file_reader
18  use write_structures
19  use itm_types
20  implicit none
21 
22  type (type_equilibrium), pointer :: euitm_equilibrium_in(:)
23  type (type_equilibrium), pointer :: euitm_equilibrium_out(:)
24  type (type_param), save :: code_parameters
25  REAL (R8) :: maxabs
26  logical, save :: first = .true.
27  integer, save :: ncall = 0
28  character*32 :: filename = 'EQ_######'
29 
30  interface
31  subroutine chease (euitm_equilibrium_in, euitm_equilibrium_out, code_parameters)
32  use euitm_schemas
33  IMPLICIT NONE
34  type (type_equilibrium), pointer :: euitm_equilibrium_in(:)
35  type (type_equilibrium), pointer :: euitm_equilibrium_out(:)
36  type (type_param) :: code_parameters
37  end SUBROUTINE chease
38  end interface
39 
40  if(first) then
41  call fill_param(code_parameters, 'XML/chease.xml', '', 'XML/chease.xsd')
42  first=.false.
43  endif
44 
45  if(associated(euitm_equilibrium_in(1)%profiles_1d%jparallel)) then
46  maxabs = maxval(abs(euitm_equilibrium_in(1)%profiles_1d%jphi))
47  write(*,*) 'max( | jphi | ) = ', maxabs
48  if(maxabs .EQ. 0.0_r8) then
49  write(*,*) 'chease_wrapper copied jparallel to jphi [ERROR]'
50  if(.not.associated(euitm_equilibrium_in(1)%profiles_1d%jphi)) &
51  allocate(euitm_equilibrium_in(1)%profiles_1d%jphi(size(euitm_equilibrium_in(1)%profiles_1d%jparallel)))
52  euitm_equilibrium_in(1)%profiles_1d%jphi = euitm_equilibrium_in(1)%profiles_1d%jparallel ! -? ToDo
53  endif
54  endif
55  if(associated(euitm_equilibrium_in(1)%profiles_1d%psi)) then
56  write(*,*) 'chease_wrapper set psi_bound and psi_ax [ERROR]'
57  write(*,*) euitm_equilibrium_in(1)%global_param%psi_ax, euitm_equilibrium_in(1)%profiles_1d%psi(1)
58  write(*,*) euitm_equilibrium_in(1)%global_param%psi_bound, euitm_equilibrium_in(1)%profiles_1d%psi(size(euitm_equilibrium_in(1)%profiles_1d%psi))
59  euitm_equilibrium_in(1)%global_param%psi_ax = euitm_equilibrium_in(1)%profiles_1d%psi(1)
60  euitm_equilibrium_in(1)%global_param%psi_bound = &
61  euitm_equilibrium_in(1)%profiles_1d%psi(size(euitm_equilibrium_in(1)%profiles_1d%psi))
62  endif
63 
64 ! the following is experimental
65  call f_par_axis(size(euitm_equilibrium_in(1)%profiles_1d%rho_tor), &
66  euitm_equilibrium_in(1)%profiles_1d%rho_tor,euitm_equilibrium_in(1)%profiles_1d%pressure)
67 ! end of the experiment
68 
69 
70  write(filename(4:9),'(I6.6)') ncall
71  write(*,*) 'Writing EQUILIBRIUM ', trim(filename)//'.IN'
72  call open_write_file(1, trim(filename)//'.IN')
73  call write_cpo(euitm_equilibrium_in(1), 'equilibrium')
74  call close_write_file
75  write(*,*) 'associated(euitm_equilibrium_out) ', associated(euitm_equilibrium_out)
76  CALL chease(euitm_equilibrium_in, euitm_equilibrium_out, code_parameters)
77  write(*,*) 'Writing EQUILIBRIUM ', trim(filename)//'.OUT'
78  call open_write_file(1, trim(filename)//'.OUT')
79  call write_cpo(euitm_equilibrium_out(1), 'equilibrium')
80  call close_write_file
81  if(.not.associated(euitm_equilibrium_out(1)%profiles_1d%jparallel)) then
82  write(*,*) 'chease_wrapper copied jphi to jparallel [ERROR]'
83  allocate(euitm_equilibrium_out(1)%profiles_1d%jparallel(size(euitm_equilibrium_out(1)%profiles_1d%jphi)))
84  euitm_equilibrium_out(1)%profiles_1d%jparallel = euitm_equilibrium_out(1)%profiles_1d%jphi
85  else
86  maxabs = maxval(abs(euitm_equilibrium_out(1)%profiles_1d%jparallel))
87  write(*,*) 'max( | jparallel | ) = ', maxabs
88  if(maxabs .EQ. 0.0_r8) then
89  write(*,*) 'chease_wrapper copied jphi to jparallel [ERROR]'
90  euitm_equilibrium_out(1)%profiles_1d%jparallel = euitm_equilibrium_out(1)%profiles_1d%jphi
91  endif
92  endif
93 
94  ncall=ncall+1
95 
96  return
97 
98  end subroutine chease_wrapper
99 
100 end module ets_wrapper_chease
wrapper for CHEASE
subroutine chease_wrapper(euitm_equilibrium_in, euitm_equilibrium_out)
subroutine f_par_axis(n, r, f)
This subroutine finds f(r_1=0) from f(r_2), f(r_3) d/dr f(r_1)=0.