-
Notifications
You must be signed in to change notification settings - Fork 0
/
OwnDataTypes_mod.f90
334 lines (303 loc) · 16.1 KB
/
OwnDataTypes_mod.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
! <OwnDataTypes_mod.f90 - A component of the EMEP MSC-W Chemical transport Model>
!*****************************************************************************!
!* You should have received a copy of the GNU General Public License
!* along with this program. If not, see <http://www.gnu.org/licenses/>.
!*****************************************************************************!
module OwnDataTypes_mod
use NumberConstants, only : UNDEF_I, UNDEF_R
use TimeDate_mod, only : date
implicit none
private
public :: print_Deriv_type
public :: print_Asc2D
integer, public, parameter :: &
TXTLEN_DERIV = 34, &
TXTLEN_SHORT = 28, &
TXTLEN_IND = 6, &
TXTLEN_NAME = 64, & !for performance, should be a multiple of 8
TXTLEN_FILE = 200 ! large enough for paths from namelists
! Contains some user-defined data-types, and routine associated
! with these. Collecting them here will
! avoid some dependencies, and shorten some My type modules.
!
! depmap used in DryDep_mod and My_WetDep_mod
! Deriv used in My_Derived and Derived_mod
! VBST from SOA_mod
!MOVED!/-- we define a type to map indices of species to be deposited
!MOVED to the lesser number of species where Vg is calculated
!MOVED
!MOVED type, public :: dep_t
!MOVED character(len=TXTLEN_SHORT) :: name ! Species name
!MOVED character(len=TXTLEN_SHORT) :: surrogate ! Surrogate species in calculated dep arrays
!MOVED integer :: iadv ! Index of species in IXADV_ or IX_ arrays
!MOVED integer :: idef ! Index of species in DryDep_Defs or WetDep_Defs. Set in run
!MOVED real :: setRate ! if CDDEP_SET, give vg in m/s
!MOVED endtype dep_t
!==================
!/ generic groups for integers
type, public :: typ_i2
integer :: int1
integer :: int2
end type typ_i2
type, public :: typ_i3
integer :: int1
integer :: int2
integer :: int3
end type typ_i3
!/ generic group for two (short) strings
type, public :: typ_ss
character(len=TXTLEN_SHORT) :: txt1='-' ! e.g. POD1_IAM_DF
character(len=TXTLEN_SHORT) :: txt2='-' ! e.g. POD1_IAM_DF
end type typ_ss
!/ generic group for name and pointer to arrays
type, public :: typ_sp
character(len=TXTLEN_SHORT) :: name ! e.g. POD1_IAM_DF
integer, dimension(:), pointer :: specs
end type typ_sp
!/ HI: generic group for name and two pointers to one integer and one
!/ real array
type, public :: typ_factors
character(len=TXTLEN_SHORT) :: name ! e.g. POD1_IAM_DF
integer, dimension(:), pointer :: species ! like ptr in typ_sp
real, dimension(:), pointer :: factors
end type typ_factors
!/ HI: generic group for name and two pointers to one integer and one
!/ character array
type, public :: typ_maps
character(len=TXTLEN_SHORT) :: name ! e.g. POD1_IAM_DF
integer, dimension(:), pointer :: species ! like ptr in typ_sp
character(len=TXTLEN_SHORT), dimension(:), pointer :: maps ! other
! species' or variables' names to map this one to
endtype typ_maps
!/ generic group one (short) string & one integer
type, public :: typ_si
character(len=TXTLEN_SHORT) :: name = '-'
integer :: ind = UNDEF_I
endtype typ_si
!/ generic group for one (short) string & one shorter string
type, public :: typ_s1ind
character(len=TXTLEN_SHORT) :: name
character(len=TXTLEN_IND) :: ind ! e.g. YMDHI
end type typ_s1ind
!/ generic group one (short) string & one real
type, public :: typ_sr
character(len=TXTLEN_SHORT) :: name
real :: rval
end type typ_sr
!/ generic group for three (short) strings
type, public :: typ_s3
character(len=TXTLEN_SHORT) :: txt1,txt2,txt3
end type typ_s3
!/ generic group for four (short) strings
type, public :: typ_s4
character(len=TXTLEN_SHORT) :: txt1,txt2,txt3,txt4 ! e.g. POD1_IAM_DF
end type typ_s4
!/ generic group for five (short) strings & one integer
type, public :: typ_s5i
character(len=TXTLEN_SHORT) :: txt1,txt2,txt3,txt4, &
txt5 ! e.g. SO2,ugS,2d,AIR_CONC,SPEC
integer :: ind ! e.g. IOU_DAY
end type typ_s5i
!/ generic group for five (short) strings & one shorter string
type, public :: typ_s5ind
character(len=TXTLEN_SHORT) :: txt1,txt2,txt3,txt4, &
txt5 ! e.g. SO2,ugS,2d,AIR_CONC,SPEC,
character(len=TXTLEN_IND) :: ind ! e.g. YMDHI
end type typ_s5ind
!==================
!+ Derived output type
type, public:: Deriv
character(len=TXTLEN_DERIV) :: name = '-' ! e.g. DDEP_SO2_m2Conif
character(len=TXTLEN_SHORT) :: class = '-' ! Type of data, e.g. ADV or Mosaic
character(len=TXTLEN_SHORT) :: subclass = '-' ! e.g. "VG", "Rns"
character(len=TXTLEN_SHORT) :: txt = '-' ! text where needed, e.g. "Conif"
character(len=TXTLEN_SHORT) :: unit = '-' ! writen in netCDF output
integer :: index =UNDEF_I ! index in concentation array, or other
integer :: f2d =UNDEF_I ! index in f_2d arrays
logical :: dt_scale =.false. ! used only if we need a factor on dt_advec,
real :: scale =UNDEF_R ! e.g. use 100.0 to get cm/s
logical :: avg =.true. ! True => average data (divide by nav at end),
! else accumulate over run period
character(len=TXTLEN_IND) :: iotype = '-' ! sets output timing
end type
! Sentinel values (moved to NumberConstants)
! real, private, parameter :: UNDEF_R = -huge(0.0)
! integer, private, parameter :: UNDEF_I = -huge(0)
!==================
!+ Hourly ASCII/NetCDF output type
type, public:: Asc2D
character(len=TXTLEN_DERIV):: name = "-" ! Name (no spaces!)
character(len=TXTLEN_SHORT):: type = "-" ! "ADVppbv" or "ADVugm3" or "SHLmcm3"
! character(len=9) :: ofmt ! Output format (e.g. es12.4)
integer :: spec = UNDEF_I ! Species number in xn_adv or xn_shl array
! or other arrays
integer :: nk = UNDEF_I ! number of vertical levels
character(len=TXTLEN_SHORT) :: unit ! Unit used
real :: unitconv = UNDEF_R ! conv. factor
real :: max = UNDEF_R ! Max allowed value for output
end type
!==================
!+ Defines SOA, NONVOL and VBS params
type, public :: VBST
integer :: index ! just for clarity
real :: CiStar ! ug/m3
!real :: Tref ! Assumed 300
real :: DeltaH ! kJ/mole
end type VBST
!==================
!==================
! uEMEP parameters
integer, public, parameter :: Npoll_uemep_max=7 !max number of uEMEP pollutant
integer, public, parameter :: Nsector_uemep_max=10 !max number of sectors for each uEMEP pollutant
type, public :: poll_type
character(len=4):: emis='none' ! one of EMIS_File: "sox ", "nox ", "co ", "voc ", "nh3 ", "pm25", "pmco"
integer, dimension(Nsector_uemep_max) ::sector=-1 ! sectors to be included for this pollutant. Zero is sum of all sectors
integer :: EMIS_File_ix = 0 !index in EMIS_File (set by model)
integer :: Nsectors = 0 !set by model
integer :: sec_poll_ishift = 0 !The start of index for isec_poll loops
integer :: Nix=0 ! Number of components to take (set by model)
integer, dimension(15) :: ix ! Index of components to take (set by model)
real, dimension(15) :: mw=0.0 ! (set by model)
end type poll_type
!array of struct or struct of arrays? For searches it is best with struct of arrays
type, public :: Emis_id_type
character(len=TXTLEN_NAME) :: varname = 'NOTSET' !name of variable in netcdf file
character(len=TXTLEN_NAME) :: species = 'NOTSET' !which species to put emissions into
character(len=TXTLEN_NAME) :: units = 'NOTSET'!units AFTER netcdf values are multiplied by factor
character(len=TXTLEN_NAME) :: country_ISO = 'NOTSET' !country name, for example FR for France, as defined in Country_mod
character(len=TXTLEN_NAME) :: periodicity = 'NOTSET' !how often fresh values must be read from the netcdf file
integer :: SNAPsector = -1 !sector defined as SNAP
integer :: GNFRsector = -1 !sector defined as GNFR, not defined yet
integer :: sector = -1 !sector as defined in current model, according to USE_SECTORS_NAME
integer :: species_ix = -1 ! internal index for species
integer :: injection_k = -1 !which model k level to put emissions into. Only for individual species
real :: factor = -1.0 ! scaling factor. multiply values by this number
logical :: include_in_local_fractions = .true. !if this is to be accounted in the local fractions (uEMEP)
logical :: apply_femis = .true. !whether the general femis.dat should be applied to this source
character(len=TXTLEN_NAME) :: mask_ID = 'NOTSET' ! set to ID of mask, if to be applied
character(len=TXTLEN_NAME) :: mask_ID_reverse = 'NOTSET' ! set to ID of mask, if to be applied as reversed
integer :: mask_ix = -1 ! mask index, >0 if set. Internal index, do not set
integer :: mask_reverse_ix = -1 ! mask index, >0 if set. Internal index, do not set
integer :: country_ix = 67 !Internal country index. Does not have any meaning outside of code
integer :: height = 0 !could define own release height. not implemented
logical :: is3D = .false.
integer :: istart = -999
integer :: jstart = -999
integer :: kstart = -1
integer :: kend = -1
logical :: reversek = .true.
integer :: ix_in = -1!index of the corresponding source in the config defintions (internal use only)
end type Emis_id_type
integer, parameter, public :: NSOURCESMAX = 50
type, public :: Emis_sourceFile_id_type
character(len=TXTLEN_FILE) :: filename = 'NOTSET'!netcdf filename with path
character(len=TXTLEN_NAME) :: projection = 'NOTSET' !projection or 'native' if same projection and size as meteo grid
character(len=TXTLEN_NAME) :: periodicity = 'NOTSET' !how often fresh values must be read from the netcdf file
real :: grid_resolution = 0.0 !resolution of the emission file
real :: factor = -1.0 !scaling factor. multiply values for all sources by this number. Comes on top of source factors.
type(Emis_id_type) :: source(NSOURCESMAX) ! one source defined for each netcdf field to include
!default values for sources:
character(len=TXTLEN_NAME) :: species = 'NOTSET' !default emep species
character(len=TXTLEN_NAME) :: units = 'NOTSET'! default units
character(len=TXTLEN_NAME) :: country_ISO = 'NOTSET' ! default country name
integer :: sector = -1 !default sector
logical :: apply_femis = .true. !whether the general femis.dat should be applied to sources from this file
logical :: include_in_local_fractions = .true. !if this is to be accounted in the local fractions (uEMEP)
character(len=TXTLEN_NAME) :: mask_ID = 'NOTSET' ! set to ID of mask, if to be applied. Will then be default for all sources in file
character(len=TXTLEN_NAME) :: mask_ID_reverse = 'NOTSET' ! set to ID of mask, if to be applied as reversed. Will then be default for all sources in file
end type Emis_sourceFile_id_type
type, public :: Emis_mask_type
character(len=TXTLEN_FILE) :: filename = 'NOTSET'! netcdf filename with path
character(len=TXTLEN_NAME) :: cdfname = 'NOTSET' ! name of the mask in the netcdf file
character(len=TXTLEN_NAME) :: ID = 'NOTSET' ! name that the user set to identify this mask
real :: threshold = 1.E-20 !min value below which is considered as zero (not masked)
end type Emis_mask_type
type, public :: EmisFile_id_type
character(len=TXTLEN_FILE) :: filename = 'NOTSET'!netcdf filename with path
character(len=TXTLEN_NAME) :: projection = 'NOTSET' !projection or 'native' if same projection and size as meteo grid
character(len=TXTLEN_NAME) :: periodicity = 'NOTSET' !how often fresh values must be read from the netcdf file
real :: grid_resolution = 0.0!resolution of the emission file
real :: factor = -1.0 !scaling factor. multiply values for all sources by this number. Comes on top of source factors.
type(date) :: end_of_validity_date = date(0,0,0,0,0)!internal date to know when to fetch new data
integer :: Nsources = 0 !number of valid sources (i.e variables in the netcdf file)
integer :: source_start = 0
integer :: source_end = 0
character(len=TXTLEN_NAME) :: species = 'NOTSET' !default emep species
character(len=TXTLEN_NAME) :: units = 'NOTSET'! default units
character(len=TXTLEN_NAME) :: country_ISO = 'NOTSET' ! default country name
integer :: sector = -1 !default sector .NB: not read from attributes
character(len=TXTLEN_NAME) :: mask_ID = 'NOTSET' ! set to ID of mask, if to be applied. Will then be default for all sources in file .NB: not read from attributes
character(len=TXTLEN_NAME) :: mask_ID_reverse = 'NOTSET' ! set to ID of mask, if to be applied as reversed. Will then be default for all sources in file .NB: not read from attributes
end type EmisFile_id_type
!/ Emissions file treatment. Dims more than used.
type, public :: emis_in
character(len=150) :: name = "NOTSET" ! e.g. POD1_IAM_DF
integer :: Nincl=0, Nexcl=0
character(len=10), dimension(90) :: incl = "-"
character(len=10), dimension(90) :: excl = "-"
character(len=40), dimension(20) :: pollName = "NOTSET"
character(len=40), dimension(20) :: pollemepName = "NOTSET"
character(len=40) :: periodicity = "NOTSET" !How often new data should be read in
character(len=40) :: format = "NOTSET" !set to fraction, if fractions
character(len=40) :: type = "sectors" !steers special treatments
logical :: use_lonlat_femis = .true. !allows to switch off lonlat femis reductions
!for specific emission files
!Country+sector specific reductions can be dealt
!with with incl/excl, so those are not affected
logical :: set_mask = .false. !if T, set mask for each (i,j) where non zero emission is found
logical :: use_mask = .false. !if T, do not include emission where mask is set
character(len=40) :: sector = "NOTSET" !put emissions into a specific sector (not yet implemented)
real :: scale = 1.0 ! multiply by scale (not yet implemented)
end type emis_in
type, public :: uEMEP_type
integer :: Npoll=0 ! Number of pollutants to treat in total
integer :: Nsec_poll=1 ! Number of sector and pollutants to treat in total
integer :: dist=0 ! max distance of neighbor to include. (will include a square with edge size=2*dist+1)
integer :: Nvert=20 ! number of k levels to include
integer :: DOMAIN(4) = -999
type(poll_type) :: poll(Npoll_uemep_max) !pollutants to include
logical :: YEAR =.true.! Output frequency
logical :: MONTH =.false.
logical :: DAY =.false.
logical :: HOUR =.false.
logical :: HOUR_INST =.false.
logical :: COMPUTE_LOCAL_TRANSPORT=.false.
end type uEMEP_type
contains
!=========================================================================
subroutine print_Asc2D(w)
type(Asc2D), intent(in) :: w ! wanted
write(*,*) "Prints Asc2D type ========================="
write(*,"(a,a)") "Name :", trim(w%name)
write(*,"(a,a)") "type :", trim(w%type)
write(*,"(a,i4)") "spec :", w%spec
write(*,"(a,a)") "unit :", trim(w%unit)
write(*,"(a,i4)") "nk :", w%nk
write(*,"(a,es10.3)") "unitconv:",w%unitconv
write(*,"(a,es10.3)") "max :", w%max
end subroutine print_Asc2D
!=========================================================================
subroutine print_Deriv_type(w)
type(Deriv), intent(in) :: w ! wanted
write(*,*) "Prints Deriv type ========================="
write(*,"(a,a)") "Name :", trim(w%name)
write(*,"(a,a)") "class :", trim(w%class)
write(*,"(a,a)") "subclass:",trim(w%subclass)
write(*,"(a,a)") "txt :", trim(w%txt)
write(*,"(a,a)") "units :", trim(w%unit)
if(w%index==UNDEF_I)then
write(*,"(a)") "index : UNDEF"
else
write(*,"(a,i5)") "index :", w%index
end if
if(w%f2d==UNDEF_I)then
write(*,"(a)") "f2d : UNDEF"
else
write(*,"(a,i3)") "f2d :", w%f2d
end if
write(*,"(a,es10.3)") "scale :", w%scale
write(*,*) "dt_scale:", w%dt_scale
write(*,*) "avg :", w%avg
end subroutine print_Deriv_type
!=========================================================================
endmodule OwnDataTypes_mod