FV3 Bundle
iAtm_Define.f90
Go to the documentation of this file.
1 !
2 ! iAtm_Define
3 !
4 ! Module for defining the Atmosphere module internal data object
5 !
6 !
7 ! CREATION HISTORY:
8 ! Written by: Paul van Delst, 07-Apr-2009
9 ! paul.vandelst@noaa.gov
10 !
11 
13 
14  ! -----------------
15  ! Environment setup
16  ! -----------------
17  ! Module use
18  USE type_kinds , ONLY: fp
20  USE crtm_parameters, ONLY: zero, set
21  ! Disable implicit typing
22  IMPLICIT NONE
23 
24 
25  ! ------------
26  ! Visibilities
27  ! ------------
28  ! Everything private by default
29  PRIVATE
30  ! Structures
31  PUBLIC :: iatm_type
32  ! Procedures
33  PUBLIC :: iatm_associated
34  PUBLIC :: iatm_create
35  PUBLIC :: iatm_destroy
36 
37 
38  ! -----------------
39  ! Module parameters
40  ! -----------------
41  ! Version Id for the module
42  CHARACTER(*), PARAMETER :: module_version_id = &
43  '$Id: iAtm_Define.f90 60152 2015-08-13 19:19:13Z paul.vandelst@noaa.gov $'
44  ! Message string length
45  INTEGER, PARAMETER :: ml = 256
46 
47 
48  ! --------------------
49  ! Structure definition
50  ! --------------------
51  !:tdoc+:
52  TYPE :: iatm_type
53  ! Allocation indicator
54  LOGICAL :: is_allocated = .false.
55  ! Dimensions
56  INTEGER :: n_layers = 0 ! K dimension
57  INTEGER :: n_absorbers = 0 ! J dimension
58  ! Level arrays
59  REAL(fp), ALLOCATABLE :: pl(:) ! 0:K
60  REAL(fp), ALLOCATABLE :: tl(:) ! 0:K
61  REAL(fp), ALLOCATABLE :: al(:,:) ! 0:K x J
62  ! Layer arrays
63  REAL(fp), ALLOCATABLE :: p(:) ! K
64  REAL(fp), ALLOCATABLE :: t(:) ! K
65  REAL(fp), ALLOCATABLE :: a(:,:) ! K x J
66  ! Save variables
67  REAL(fp) :: pln_save = zero
68  REAL(fp) :: tln_save = zero
69  REAL(fp), ALLOCATABLE :: aln_save(:) ! J
70  REAL(fp) :: plint_save = zero
71  REAL(fp) :: tlint_save = zero
72  REAL(fp), ALLOCATABLE :: alint_save(:) ! J
73  REAL(fp), ALLOCATABLE :: a_save(:,:) ! K x J
74  ! Interpolating polynomials
75  REAL(fp) :: ilpoly = zero ! Interpolating polynomial for extra levels to user Pl(0)
76  REAL(fp) :: elpoly = zero ! Extrapolating polynomial for user "layer 0" values
77  END TYPE iatm_type
78  !:tdoc-:
79 
80 
81 CONTAINS
82 
83 
84 !##################################################################################
85 !##################################################################################
86 !##
87 !## ## PUBLIC MODULE ROUTINES ##
88 !##
89 !##################################################################################
90 !##################################################################################
91 
92 !--------------------------------------------------------------------------------
93 !:sdoc+:
94 !
95 ! NAME:
96 ! iAtm_Associated
97 !
98 ! PURPOSE:
99 ! Elemental function to test the status of the allocatable components
100 ! of an iAtm object.
101 !
102 ! CALLING SEQUENCE:
103 ! Status = iAtm_Associated( iAtm )
104 !
105 ! OBJECTS:
106 ! iAtm: Internal iAtm object which is to have its member's
107 ! status tested.
108 ! UNITS: N/A
109 ! TYPE: iAtm_type
110 ! DIMENSION: Scalar or any rank
111 ! ATTRIBUTES: INTENT(IN)
112 !
113 ! FUNCTION RESULT:
114 ! Status: The return value is a logical value indicating the
115 ! status of the iAtm members.
116 ! .TRUE. - if ANY of the allocatable or
117 ! pointer members are in use.
118 ! .FALSE. - if ALL of the allocatable or
119 ! pointer members are not in use.
120 ! UNITS: N/A
121 ! TYPE: LOGICAL
122 ! DIMENSION: Same as input
123 !
124 !:sdoc-:
125 !--------------------------------------------------------------------------------
126 
127  ELEMENTAL FUNCTION iatm_associated( self ) RESULT( Status )
128  TYPE(iatm_type), INTENT(IN) :: self
129  LOGICAL :: status
130  status = self%Is_Allocated
131  END FUNCTION iatm_associated
132 
133 
134 !--------------------------------------------------------------------------------
135 !:sdoc+:
136 !
137 ! NAME:
138 ! Destroy_iAtm
139 !
140 ! PURPOSE:
141 ! Elemental subroutine to re-initialize iAtm objects.
142 !
143 ! CALLING SEQUENCE:
144 ! CALL iAtm_Destroy( iAtm )
145 !
146 ! OBJECTS:
147 ! iAtm: Re-initialized internal iAtm object.
148 ! UNITS: N/A
149 ! TYPE: iAtm_type
150 ! DIMENSION: Scalar or any rank
151 ! ATTRIBUTES: INTENT(OUT)
152 !
153 !:sdoc-:
154 !--------------------------------------------------------------------------------
155 
156  ELEMENTAL SUBROUTINE iatm_destroy( self )
157  TYPE(iatm_type), INTENT(OUT) :: self
158  self%Is_Allocated = .false.
159  END SUBROUTINE iatm_destroy
160 
161 
162 !--------------------------------------------------------------------------------
163 !:sdoc+:
164 !
165 ! NAME:
166 ! iAtm_Create
167 !
168 ! PURPOSE:
169 ! Elemental subroutine to create an instance of the iAtm object.
170 !
171 ! CALLING SEQUENCE:
172 ! CALL iAtm_Create( iAtm , &
173 ! n_Layers , &
174 ! n_Absorbers, &
175 ! iAtm )
176 !
177 ! OBJECTS:
178 ! iAtm: Internal iAtm structure.
179 ! UNITS: N/A
180 ! TYPE: iAtm_type
181 ! DIMENSION: Scalar or any rank
182 ! ATTRIBUTES: INTENT(OUT)
183 !
184 ! INPUTS:
185 ! n_Layers: Number of layers dimension.
186 ! Must be > 0.
187 ! UNITS: N/A
188 ! TYPE: INTEGER
189 ! DIMENSION: Scalar or same as iAtm object
190 ! ATTRIBUTES: INTENT(IN)
191 !
192 ! n_Absorbers: Number of absorbers dimension.
193 ! Must be > 0.
194 ! UNITS: N/A
195 ! TYPE: INTEGER
196 ! DIMENSION: Scalar or same as iAtm object
197 ! ATTRIBUTES: INTENT(IN)
198 !
199 !:sdoc-:
200 !--------------------------------------------------------------------------------
201 
202  ELEMENTAL SUBROUTINE iatm_create( &
203  self , & ! Output
204  n_Layers , & ! Input
205  n_Absorbers ) ! Input
206  ! Arguments
207  TYPE(iatm_type), INTENT(OUT) :: self
208  INTEGER , INTENT(IN) :: n_layers
209  INTEGER , INTENT(IN) :: n_absorbers
210  ! Local variables
211  INTEGER :: alloc_stat
212 
213  ! Check input
214  IF ( n_layers < 1 .OR. n_absorbers < 1 ) RETURN
215 
216  ! Perform the allocation
217  ALLOCATE( self%pl(0:n_layers), self%tl(0:n_layers), self%al(0:n_layers, 1:n_absorbers), &
218  self%p(1:n_layers) , self%t(1:n_layers) , self%a(1:n_layers, 1:n_absorbers) , &
219  self%aln_save(1:n_absorbers), &
220  self%alint_save(1:n_absorbers), &
221  self%a_save(1:n_layers,1:n_absorbers), &
222  stat = alloc_stat )
223  IF ( alloc_stat /= 0 ) RETURN
224 
225  ! Initialise
226  ! ...Dimensions
227  self%n_Layers = n_layers
228  self%n_Absorbers = n_absorbers
229  ! ...Arrays
230  self%pl = zero
231  self%tl = zero
232  self%al = zero
233  self%p = zero
234  self%t = zero
235  self%a = zero
236  self%aln_save = zero
237  self%alint_save = zero
238  self%a_save = zero
239 
240  ! Set allocation indicator
241  self%Is_Allocated = .true.
242  END SUBROUTINE iatm_create
243 
244 END MODULE iatm_define
245 
integer, parameter, public failure
integer, parameter, public set
real(fp), parameter, public zero
elemental logical function, public iatm_associated(self)
integer, parameter, public fp
Definition: Type_Kinds.f90:124
elemental subroutine, public iatm_create(self, n_Layers, n_Absorbers)
recursive subroutine, public display_message(Routine_Name, Message, Error_State, Message_Log)
character(*), parameter module_version_id
Definition: iAtm_Define.f90:42
elemental subroutine, public iatm_destroy(self)
integer, parameter ml
Definition: iAtm_Define.f90:45
integer, parameter, public success