V3FIT
thscte_T.f
1 
2 !*******************************************************************************
3 ! File thscte_T.f
4 ! Contains module thscte_T
5 ! Defines derived-types: thscte_desc
6 ! A type of Diagnostic - Thomspon Scattering Te diagnostic
7 !
8 !*******************************************************************************
9 ! MODULE sxr_T
10 ! (SXR 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 SXR_T
19 !
20 ! SECTION XVI. COMMENTS FOR DIFFERENT REVISIONS
21 !*******************************************************************************
22  MODULE thscte_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
36 
37 !-------------------------------------------------------------------------------
38 ! Use Statements for other structures, V3 Utilities
39 !-------------------------------------------------------------------------------
40 ! USE v3_utilities
41 
42 !-------------------------------------------------------------------------------
43 ! Implicit None comes after USE statements, before other declarations
44 !-------------------------------------------------------------------------------
45  IMPLICIT NONE
46 
47 !-------------------------------------------------------------------------------
48 ! Make type declarations and constants Private, so there are no conflicts.
49 !-------------------------------------------------------------------------------
50  PRIVATE rprec, pi, zero
51 
52 !-------------------------------------------------------------------------------
53 ! Lengths of Character Variables
54 !-------------------------------------------------------------------------------
55 
56 !------------------------------------------------------------------------------
57  INTEGER,PARAMETER :: chord_name_len=30
58 !------------------------------------------------------------------------------
59 
60 !*******************************************************************************
61 ! SECTION II. DERIVED-TYPE DECLARATIONS
62 ! thscte Description:
63 ! thscte_desc
64 ! Type of diagnostic specified by % d_type = 'thscte'.
65 !
66 !*******************************************************************************
67 !-------------------------------------------------------------------------------
68 !-------------------------------------------------------------------------------
69 ! Declare type thscte_desc
70 ! chord_name - character, chord name
71 ! xcart(3) - Cartesian position vector - where Te is measured
72 ! thsc_type - 't' - Temperature
73 ! - 'd' - Density
74 ! - 'p' - Pressure
75 !-------------------------------------------------------------------------------
77  CHARACTER(LEN=chord_name_len) :: chord_name
78  REAL(rprec), DIMENSION(3) :: xcart
79  CHARACTER(LEN=1) :: thsc_type
80  END TYPE thscte_desc
81 
82 !*******************************************************************************
83 ! SECTION III. INTERFACE BLOCKS
84 !*******************************************************************************
85 
86  CONTAINS
87 !*******************************************************************************
88 ! SECTION IV. CONSTRUCTION SUBROUTINES
89 !*******************************************************************************
90 !-------------------------------------------------------------------------------
91 ! Construct a thscte_desc
92 !
93 ! For d_type = 'thscte' (Thomson Scattering Te)
94 !-------------------------------------------------------------------------------
95  SUBROUTINE thscte_desc_construct(this, chord_name, xcart, &
96  & chord_type)
97 
98  IMPLICIT NONE
99 
100 !-------------------------------------------------------------------------------
101 ! Argument Declarations
102 !-------------------------------------------------------------------------------
103  TYPE (thscte_desc), INTENT(inout) :: this
104  CHARACTER(LEN=chord_name_len),INTENT(in) :: chord_name
105  REAL(rprec), DIMENSION(3), INTENT(in) :: xcart
106  CHARACTER(LEN=1),INTENT(in) :: chord_type
107 
108 !-------------------------------------------------------------------------------
109 ! Start of executable code
110 !-------------------------------------------------------------------------------
111 
112 ! Assignments
113  this % chord_name = chord_name
114  this % xcart = xcart
115  this % thsc_type = chord_type
116 
117  END SUBROUTINE thscte_desc_construct
118 
119 !*******************************************************************************
120 ! SECTION V. DESTRUCTION SUBROUTINES
121 !*******************************************************************************
122 !-------------------------------------------------------------------------------
123 ! Destroy an thscte_desc
124 !
125 ! ARGUMENT
126 ! this - an thscte_desc
127 !-------------------------------------------------------------------------------
128  SUBROUTINE thscte_desc_destroy(this)
129 
130  TYPE (thscte_desc),INTENT(inout) :: this
131 
132  this % chord_name = ''
133  this % xcart = zero
134 
135 
136  END SUBROUTINE thscte_desc_destroy
137 
138 
139 !*******************************************************************************
140 ! SECTION VI. ASSIGNMENT SUBROUTINES
141 !
142 ! These are not needed because the intrinsic assignments work
143 !*******************************************************************************
144 
145 !*******************************************************************************
146 ! SECTION VII. OUTPUT SUBROUTINES
147 !*******************************************************************************
148 !-------------------------------------------------------------------------------
149 ! Write out the contents of a thscte_desc
150 ! if iou and filaname are present - write to file
151 ! if iou and filename are not present - write to stdout (screen)
152 !
153 ! THIS NEEDS MODIFYING TO BE ABLE TO APPEND RECORDS AND NOT OVERWRITE FILES
154 !-------------------------------------------------------------------------------
155 
156  SUBROUTINE thscte_desc_write(this,iounit,filename)
157  IMPLICIT NONE
158 !-------------------------------------------------------------------------------
159 ! Arguments
160 ! this - sxr_chord
161 ! iou - output io unit number
162 ! filename - output file name
163 !-------------------------------------------------------------------------------
164 
165  TYPE (thscte_desc),INTENT(in) :: this
166  INTEGER, OPTIONAL,INTENT(in) :: iounit
167  CHARACTER*300,OPTIONAL,INTENT(in) :: filename
168 !-------------------------------------------------------------------------------
169 ! Local Variables
170 ! iou - iounit to use
171 ! istat - status of file opening
172 !-------------------------------------------------------------------------------
173 
174  INTEGER :: iou = 6
175  INTEGER :: istat = 0 !status of safe_open call
176 
177  IF (PRESENT(iounit).AND.PRESENT(filename)) THEN
178  iou=iounit
179  CALL safe_open(iou,istat,filename,'replace','formatted')
180  WRITE(iou,*) 'chord name - ', this % chord_name
181  WRITE(iou,*) 'position -', this % xcart
182  ELSE
183  WRITE(*,*)'chord name - ',this % chord_name
184  WRITE(*,*)'position -',this % xcart
185  END IF
186 
187  END SUBROUTINE thscte_desc_write
188 !*******************************************************************************
189 ! SECTION XVI. COMMENTS FOR DIFFERENT REVISIONS
190 !*******************************************************************************
191 !
192 ! TO DO 2011-10-23
193 ! 1) Change name of chord_name component to something more appropriate
194 !
195 ! 2011-10-23 JDH
196 ! First version of module, based on sxrch_T
197 !
198 !
199  END MODULE thscte_t
thscte_t::thscte_desc
Definition: thscte_T.f:76