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