V3FIT
ipch_T.f
1 
2 !*******************************************************************************
3 ! File ipch_T.f
4 ! Contains module ipch_T
5 ! Defines derived-types: ipch_desc
6 ! A type of Diagnostic - Interferometry-Polarimetry chordal diagnostic
7 !
8 !*******************************************************************************
9 ! MODULE ip_T
10 ! (ip Type Definition, for the V3FIT code)
11 ! SECTION I. VARIABLE DECLARATIONS
12 ! SECTION II. DERIVED-TYPE DECLARATIONS
13 ! SECTION III. INTERFACE BLOCKS
14 ! SECTION IV. CONSTRUCTION SUBROUTINES
15 ! SECTION V. DESTRUCTION SUBROUTINES
16 ! SECTION VI. ASSIGNMENT SUBROUTINES
17 ! SECTION VII. OUTPUT SUBROUTINES
18 ! SECTION VIII. PRIVATE ROUTINES USED IN ip_T
19 !
20 ! SECTION XVI. COMMENTS FOR DIFFERENT REVISIONS
21 !*******************************************************************************
22  MODULE ipch_t
23 
24 !*******************************************************************************
25 ! SECTION I. VARIABLE DECLARATIONS
26 !*******************************************************************************
27 
28 !-------------------------------------------------------------------------------
29 ! Type declarations - lengths of reals, integers, and complexes.
30 ! Frequently used mathematical constants, lots of extra precision.
31 !-------------------------------------------------------------------------------
32 
33  USE stel_kinds , only : rprec
34  USE stel_constants, only : pi, zero
35  USE safe_open_mod !from LIBSTELL/MODULES
37 
38 !-------------------------------------------------------------------------------
39 ! Use Statements for other structures, V3 Utilities
40 !-------------------------------------------------------------------------------
41 ! USE v3_utilities
42 
43 !-------------------------------------------------------------------------------
44 ! Implicit None comes after USE statements, before other declarations
45 !-------------------------------------------------------------------------------
46  IMPLICIT NONE
47 
48 !-------------------------------------------------------------------------------
49 ! Make type declarations and constants Private, so there are no conflicts.
50 !-------------------------------------------------------------------------------
51  PRIVATE rprec, pi, zero
52 
53 !-------------------------------------------------------------------------------
54 ! Lengths of Character Variables
55 !-------------------------------------------------------------------------------
56 
57 !------------------------------------------------------------------------------
58  INTEGER,PARAMETER :: chord_name_len=30
59 !------------------------------------------------------------------------------
60 
61 !*******************************************************************************
62 ! SECTION II. DERIVED-TYPE DECLARATIONS
63 ! ipCH Description:
64 ! ipch_desc
65 ! Type of diagnostic specified by % d_type = 'ipch'.
66 !
67 !*******************************************************************************
68 !-------------------------------------------------------------------------------
69 !-------------------------------------------------------------------------------
70 ! Declare type ipch_desc
71 ! chord_name - character, chord name
72 ! xcart_i(3) - Cartesian position vector, start of chord (meters)
73 ! xcart_f(3) - Cartesian position vector, end of chord (meters)
74 ! ip_type - 'i' - interferometry
75 ! - 'p' - polarimetry
76 ! wavelength _ wavelength of the beam
77 !-------------------------------------------------------------------------------
78  TYPE ipch_desc
79  CHARACTER(LEN=chord_name_len) :: chord_name
80  CHARACTER(LEN=1) :: ip_type
81  REAL(rprec) :: wavelength
82  LOGICAL :: inDegrees
83  TYPE(vertex), POINTER :: chordPath => null()
84  END TYPE ipch_desc
85 
86 !*******************************************************************************
87 ! SECTION III. INTERFACE BLOCKS
88 !*******************************************************************************
89 
90  CONTAINS
91 !*******************************************************************************
92 ! SECTION IV. CONSTRUCTION SUBROUTINES
93 !*******************************************************************************
94 !-------------------------------------------------------------------------------
95 ! Construct a ipch_desc
96 !
97 ! For d_type = 'ipch' (interferometry-polarimetry chord)
98 !-------------------------------------------------------------------------------
99  SUBROUTINE ipch_desc_construct(this, chord_name, &
100  & xcart_i, xcart_f, &
101  & ip_type, wavelength, &
102  & inDegrees)
103 
104  IMPLICIT NONE
105 
106 !-------------------------------------------------------------------------------
107 ! Argument Declarations
108 !-------------------------------------------------------------------------------
109  TYPE (ipch_desc), INTENT(inout) :: this
110  CHARACTER(LEN=chord_name_len),INTENT(in) :: chord_name
111  REAL(rprec), DIMENSION(3), INTENT(in) :: xcart_i
112  REAL(rprec), DIMENSION(3), INTENT(in) :: xcart_f
113  CHARACTER(LEN=1), INTENT(in) :: ip_type
114  REAL(rprec), INTENT(in) :: wavelength
115  LOGICAL, INTENT(in) :: inDegrees
116 
117 !-------------------------------------------------------------------------------
118 ! Start of executable code
119 !-------------------------------------------------------------------------------
120 
121 ! Assignments
122  this % chord_name = chord_name
123  this % ip_type = ip_type
124  this % wavelength = wavelength
125  this % inDegrees = indegrees
126 
127 ! Must NULL out the vertices array or else it will point to the last
128 ! integration_path created in memory
129 
130  CALL path_append_vertex(this%chordPath, xcart_i)
131  CALL path_append_vertex(this%chordPath, xcart_f)
132 
133  END SUBROUTINE ipch_desc_construct
134 
135 !*******************************************************************************
136 ! SECTION V. DESTRUCTION SUBROUTINES
137 !*******************************************************************************
138 !-------------------------------------------------------------------------------
139 ! Destroy an ipch_desc
140 !
141 ! ARGUMENT
142 ! this - an ipch_desc
143 !-------------------------------------------------------------------------------
144  SUBROUTINE ipch_desc_destroy(this)
145 
146  TYPE (ipch_desc),INTENT(inout) :: this
147 
148  this % chord_name = ''
149  this % ip_type = ' '
150  this % wavelength = zero
151 
152  CALL path_destruct(this%chordPath)
153 
154  END SUBROUTINE ipch_desc_destroy
155 
156 
157 !*******************************************************************************
158 ! SECTION VI. ASSIGNMENT SUBROUTINES
159 !
160 ! These are not needed because the intrinsic assignments work
161 !*******************************************************************************
162 
163 !*******************************************************************************
164 ! SECTION VII. OUTPUT SUBROUTINES
165 !*******************************************************************************
166 !-------------------------------------------------------------------------------
167 ! Write out the contents of a ipch_desc
168 ! if iou and filaname are present - write to file
169 ! if iou and filename are not present - write to stdout (screen)
170 !
171 ! THIS NEEDS MODIFYING TO BE ABLE TO APPEND RECORDS AND NOT OVERWRITE FILES
172 !-------------------------------------------------------------------------------
173 
174  SUBROUTINE ipch_desc_write(this,iounit,filename)
175  IMPLICIT NONE
176 !-------------------------------------------------------------------------------
177 ! Arguments
178 ! this - ip_chord
179 ! iou - output io unit number
180 ! filename - output file name
181 !-------------------------------------------------------------------------------
182 
183  TYPE (ipch_desc),INTENT(in) :: this
184  INTEGER, OPTIONAL,INTENT(in) :: iounit
185  CHARACTER*300,OPTIONAL,INTENT(in) :: filename
186 !-------------------------------------------------------------------------------
187 ! Local Variables
188 ! iou - iounit to use
189 ! istat - status of file opening
190 !-------------------------------------------------------------------------------
191  REAL(rprec), DIMENSION(3) :: xcart_i
192  REAL(rprec), DIMENSION(3) :: xcart_f
193 
194  INTEGER :: iou = 6
195  INTEGER :: istat = 0 !status of safe_open call
196 
197  xcart_i = this%chordPath%position
198  xcart_f = this%chordPath%next%position
199 
200  IF (PRESENT(iounit).AND.PRESENT(filename)) THEN
201  iou=iounit
202  CALL safe_open(iou,istat,filename,'replace','formatted')
203  WRITE(iou,*) 'chord name - ', this % chord_name
204  WRITE(iou,*) 'start position -', xcart_i
205  WRITE(iou,*) 'end position -', xcart_f
206  WRITE(iou,*) 'ip_type -', this % ip_type
207  WRITE(iou,*) 'wavelength -', this % wavelength
208  ELSE
209  WRITE(*,*) 'chord name - ',this % chord_name
210  WRITE(*,*) 'start position -', xcart_i
211  WRITE(*,*) 'end position -', xcart_f
212  WRITE(*,*) 'ip_type -', this % ip_type
213  WRITE(*,*) 'wavelength -', this % wavelength
214  END IF
215 
216  END SUBROUTINE ipch_desc_write
217 !*******************************************************************************
218 ! SECTION XVI. COMMENTS FOR DIFFERENT REVISIONS
219 !*******************************************************************************
220 !
221 ! GJH 2009-08-18. First version of sxr_T. Copied and edited from mddc_T
222 !
223 ! GJH 2010-01-22 Added measurement units to sxr_chords
224 !
225 ! JDH 2011-08-01
226 ! Refactor sxrc -> sxrch
227 !
228 ! JDH 2011-08-29 - Added these changes from GJH:
229 ! GJH 2010-09-08
230 ! Changed Ro,Zo,Phio to Ri,Zi,Phii
231 ! removed camera_type
232 ! removed position units
233 ! added chord_num
234 ! in sxrch_desc
235 !
236 ! JDH 2011-09-06
237 ! Modified R2x in sxrch_desc_construct
238 !
239 ! 2011-09-08 JDH
240 ! Significant modification and code elimination. Just ID, start and end
241 ! positions, and calibration constant. Creation from camera description
242 ! must now be done elsewhere.
243 
244 ! 2011-10-17 JDH
245 ! Further simplification. Now just start and end position (cartesian) a
246 ! and chord name (longer - 30 characters)
247 
248 ! 2012-03-15 JDH
249 ! First version for ipch. Copied and edited from sxrch, added ip_type
250 
251  END MODULE ipch_t
ipch_t::ipch_desc
Definition: ipch_T.f:78
integration_path
Module is part of the LIBSTELL. This modules contains code to define and integrate along an arbitray ...
Definition: integration_path.f:12
integration_path::path_append_vertex
recursive subroutine path_append_vertex(this, position)
Append a vertex to a path.
Definition: integration_path.f:253
integration_path::path_destruct
Destruct interface using either path_destruct_int or path_destruct_vertex.
Definition: integration_path.f:84