-
Notifications
You must be signed in to change notification settings - Fork 3
/
HMC_Module_Data_Output_Point.f90
528 lines (451 loc) · 32.6 KB
/
HMC_Module_Data_Output_Point.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
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
!------------------------------------------------------------------------------------------
! File: HMC_Module_Data_Output_Point.f90
! Author(s): Fabio Delogu, Francesco Silvestro, Simone Gabellani
!
! Created on May 7, 2015, 4:37 PM
!------------------------------------------------------------------------------------------
!------------------------------------------------------------------------------------------
! Module Header
module HMC_Module_Data_Output_Point
!------------------------------------------------------------------------------------------
! External module(s) for all subroutine in this module
#ifdef LIB_NC
use netcdf
#endif
use HMC_Module_Namelist, only: oHMC_Namelist
use HMC_Module_Vars_Loader, only: oHMC_Vars
use HMC_Module_Tools_Debug
#ifdef LIB_NC
use HMC_Module_Tools_IO, only: HMC_Tools_IO_Put1d_ASCII, &
HMC_Tools_IO_Put2d_ASCII, &
HMC_Tools_IO_Put1d_NC, &
HMC_Tools_IO_Put2d_NC, &
check
#else
use HMC_Module_Tools_IO, only: HMC_Tools_IO_Put1d_ASCII, &
HMC_Tools_IO_Put2d_ASCII
#endif
use HMC_Module_Tools_Generic, only: HMC_Tools_Generic_ReplaceText, &
HMC_Tools_Generic_SetUnit, &
HMC_Tools_Generic_CreateFolder, &
HMC_Tools_Generic_ZipFile, &
HMC_Tools_Generic_RemoveFile, &
mean2Dvar, max2Dvar, min2Dvar
! Implicit none for all subroutines in this module
implicit none
!------------------------------------------------------------------------------------------
contains
!------------------------------------------------------------------------------------------
! Subroutine to manage output point data
subroutine HMC_Data_Output_Point_Cpl( iID, sTime, &
iRowsStart, iRowsEnd, iColsStart, iColsEnd, &
iTime, iETime, &
iNSection, iNData, &
iNLake, iNDam, iNPlant, iNJoint, iNCatch, iNRelease)
!------------------------------------------------------------------------------------------
!------------------------------------------------------------------------------------------
! Variable(s)
integer(kind = 4), parameter :: iNVar = 20, iNAnalysis = 3
integer(kind = 4) :: iID
integer(kind = 4) :: iRows, iCols
integer(kind = 4) :: iRowsStart, iRowsEnd, iColsStart, iColsEnd
integer(kind = 4) :: iTime, iETime
integer(kind = 4) :: iNSection, iNData
integer(kind = 4) :: iNLake, iNDam, iNPlant, iNJoint, iNCatch, iNRelease
integer(kind = 4) :: iFlagTypeData_Output
integer(kind = 4) :: iScaleFactor
character(len = 19) :: sTime
character(len = 700) :: sPathData_Output
character(len = 700) :: sCommandCreateFolder
real(kind = 4), dimension(iNSection) :: a1dVarQoutSection
real(kind = 4), dimension(iNDam) :: a1dVarVDam, a1dVarHDam
real(kind = 4), dimension(iNVar, iNAnalysis) :: a2dVarAnalysisValue
!------------------------------------------------------------------------------------------
!------------------------------------------------------------------------------------------
! Initialize variable(s)
a1dVarVDam = -9999.0; a1dVarHDam= -9999.0; a1dVarQoutSection = -9999.0
a2dVarAnalysisValue = -9999.0;
!------------------------------------------------------------------------------------------
!------------------------------------------------------------------------------------------
! Defining iRows and iCols (output data)
iRows = iRowsEnd - iRowsStart + 1
iCols = iColsEnd - iColsStart + 1
!------------------------------------------------------------------------------------------
!------------------------------------------------------------------------------------------
! Get global information
sPathData_Output = oHMC_Namelist(iID)%sPathData_Output_Point
iFlagTypeData_Output = oHMC_Namelist(iID)%iFlagTypeData_Output_Point
sCommandCreateFolder = oHMC_Namelist(iID)%sCommandCreateFolder
! Info start
call mprintf(.true., iINFO_Extra, ' Data :: Output point ... ' )
!------------------------------------------------------------------------------------------
!------------------------------------------------------------------------------------------
! Replace general path with specific time feature(s)
call HMC_Tools_Generic_ReplaceText(sPathData_Output, '$yyyy', sTime(1:4))
call HMC_Tools_Generic_ReplaceText(sPathData_Output, '$mm', sTime(6:7))
call HMC_Tools_Generic_ReplaceText(sPathData_Output, '$dd', sTime(9:10))
call HMC_Tools_Generic_ReplaceText(sPathData_Output, '$HH', sTime(12:13))
call HMC_Tools_Generic_ReplaceText(sPathData_Output, '$MM', sTime(15:16))
!------------------------------------------------------------------------------------------
!------------------------------------------------------------------------------------------
! Create output folder
call HMC_Tools_Generic_CreateFolder(sCommandCreateFolder, sPathData_Output, .true.)
!------------------------------------------------------------------------------------------
!------------------------------------------------------------------------------------------
! Get variable(s) from global workspace
if (iDEBUG.gt.0) then
! MEAN VARIABLE(S) VALUE(S)
! Get Forcing variable(s)
a2dVarAnalysisValue(1, 1) = mean2Dvar(oHMC_Vars(iID)%a2dRain, oHMC_Vars(iID)%a2iMask)
a2dVarAnalysisValue(2, 1) = mean2Dvar(oHMC_Vars(iID)%a2dTa, oHMC_Vars(iID)%a2iMask)
a2dVarAnalysisValue(3, 1) = mean2Dvar(oHMC_Vars(iID)%a2dK, oHMC_Vars(iID)%a2iMask)
a2dVarAnalysisValue(4, 1) = mean2Dvar(oHMC_Vars(iID)%a2dW, oHMC_Vars(iID)%a2iMask)
a2dVarAnalysisValue(5, 1) = mean2Dvar(oHMC_Vars(iID)%a2dRHum, oHMC_Vars(iID)%a2iMask)
a2dVarAnalysisValue(6, 1) = mean2Dvar(oHMC_Vars(iID)%a2dPres, oHMC_Vars(iID)%a2iMask)
a2dVarAnalysisValue(7, 1) = mean2Dvar(oHMC_Vars(iID)%a2dLAI, oHMC_Vars(iID)%a2iMask)
a2dVarAnalysisValue(8, 1) = mean2Dvar(oHMC_Vars(iID)%a2dAlbedo, oHMC_Vars(iID)%a2iMask)
! Get Outcome variable(s)
a2dVarAnalysisValue(9, 1) = mean2Dvar(oHMC_Vars(iID)%a2dLST, oHMC_Vars(iID)%a2iMask)
a2dVarAnalysisValue(10, 1) = mean2Dvar(oHMC_Vars(iID)%a2dH, oHMC_Vars(iID)%a2iMask)
a2dVarAnalysisValue(11, 1) = mean2Dvar(oHMC_Vars(iID)%a2dLE, oHMC_Vars(iID)%a2iMask)
a2dVarAnalysisValue(12, 1) = mean2Dvar(oHMC_Vars(iID)%a2dET, oHMC_Vars(iID)%a2iMask)
a2dVarAnalysisValue(13, 1) = mean2Dvar(oHMC_Vars(iID)%a2dIntensity, oHMC_Vars(iID)%a2iMask)
a2dVarAnalysisValue(14, 1) = mean2Dvar(oHMC_Vars(iID)%a2dVTot, oHMC_Vars(iID)%a2iMask)
a2dVarAnalysisValue(15, 1) = mean2Dvar(oHMC_Vars(iID)%a2dVRet, oHMC_Vars(iID)%a2iMask)
a2dVarAnalysisValue(16, 1) = mean2Dvar(oHMC_Vars(iID)%a2dVSub, oHMC_Vars(iID)%a2iMask)
a2dVarAnalysisValue(17, 1) = mean2Dvar(oHMC_Vars(iID)%a2dVLoss, oHMC_Vars(iID)%a2iMask)
a2dVarAnalysisValue(18, 1) = mean2Dvar(oHMC_Vars(iID)%a2dVExf, oHMC_Vars(iID)%a2iMask)
a2dVarAnalysisValue(19, 1) = mean2Dvar(oHMC_Vars(iID)%a2dFlowDeep, oHMC_Vars(iID)%a2iMask)
a2dVarAnalysisValue(20, 1) = mean2Dvar(oHMC_Vars(iID)%a2dWTable, oHMC_Vars(iID)%a2iMask)
! MAXIMUM VARIABLE(S) VALUE(S)
! Get Forcing variable(s)
a2dVarAnalysisValue(1, 2) = max2Dvar(oHMC_Vars(iID)%a2dRain, oHMC_Vars(iID)%a2iMask)
a2dVarAnalysisValue(2, 2) = max2Dvar(oHMC_Vars(iID)%a2dTa, oHMC_Vars(iID)%a2iMask)
a2dVarAnalysisValue(3, 2) = max2Dvar(oHMC_Vars(iID)%a2dK, oHMC_Vars(iID)%a2iMask)
a2dVarAnalysisValue(4, 2) = max2Dvar(oHMC_Vars(iID)%a2dW, oHMC_Vars(iID)%a2iMask)
a2dVarAnalysisValue(5, 2) = max2Dvar(oHMC_Vars(iID)%a2dRHum, oHMC_Vars(iID)%a2iMask)
a2dVarAnalysisValue(6, 2) = max2Dvar(oHMC_Vars(iID)%a2dPres, oHMC_Vars(iID)%a2iMask)
a2dVarAnalysisValue(7, 2) = max2Dvar(oHMC_Vars(iID)%a2dLAI, oHMC_Vars(iID)%a2iMask)
a2dVarAnalysisValue(8, 2) = max2Dvar(oHMC_Vars(iID)%a2dAlbedo, oHMC_Vars(iID)%a2iMask)
! Get Outcome variable(s)
a2dVarAnalysisValue(9, 2) = max2Dvar(oHMC_Vars(iID)%a2dLST, oHMC_Vars(iID)%a2iMask)
a2dVarAnalysisValue(10, 2) = max2Dvar(oHMC_Vars(iID)%a2dH, oHMC_Vars(iID)%a2iMask)
a2dVarAnalysisValue(11, 2) = max2Dvar(oHMC_Vars(iID)%a2dLE, oHMC_Vars(iID)%a2iMask)
a2dVarAnalysisValue(12, 2) = max2Dvar(oHMC_Vars(iID)%a2dET, oHMC_Vars(iID)%a2iMask)
a2dVarAnalysisValue(13, 2) = max2Dvar(oHMC_Vars(iID)%a2dIntensity, oHMC_Vars(iID)%a2iMask)
a2dVarAnalysisValue(14, 2) = max2Dvar(oHMC_Vars(iID)%a2dVTot, oHMC_Vars(iID)%a2iMask)
a2dVarAnalysisValue(15, 2) = max2Dvar(oHMC_Vars(iID)%a2dVRet, oHMC_Vars(iID)%a2iMask)
a2dVarAnalysisValue(16, 2) = max2Dvar(oHMC_Vars(iID)%a2dVSub, oHMC_Vars(iID)%a2iMask)
a2dVarAnalysisValue(17, 2) = max2Dvar(oHMC_Vars(iID)%a2dVLoss, oHMC_Vars(iID)%a2iMask)
a2dVarAnalysisValue(18, 2) = max2Dvar(oHMC_Vars(iID)%a2dVExf, oHMC_Vars(iID)%a2iMask)
a2dVarAnalysisValue(19, 2) = max2Dvar(oHMC_Vars(iID)%a2dFlowDeep, oHMC_Vars(iID)%a2iMask)
a2dVarAnalysisValue(20, 2) = max2Dvar(oHMC_Vars(iID)%a2dWTable, oHMC_Vars(iID)%a2iMask)
! MINIMUM VARIABLE(S) VALUE(S)
! Get Forcing variable(s)
a2dVarAnalysisValue(1, 3) = min2Dvar(oHMC_Vars(iID)%a2dRain, oHMC_Vars(iID)%a2iMask)
a2dVarAnalysisValue(2, 3) = min2Dvar(oHMC_Vars(iID)%a2dTa, oHMC_Vars(iID)%a2iMask)
a2dVarAnalysisValue(3, 3) = min2Dvar(oHMC_Vars(iID)%a2dK, oHMC_Vars(iID)%a2iMask)
a2dVarAnalysisValue(4, 3) = min2Dvar(oHMC_Vars(iID)%a2dW, oHMC_Vars(iID)%a2iMask)
a2dVarAnalysisValue(5, 3) = min2Dvar(oHMC_Vars(iID)%a2dRHum, oHMC_Vars(iID)%a2iMask)
a2dVarAnalysisValue(6, 3) = min2Dvar(oHMC_Vars(iID)%a2dPres, oHMC_Vars(iID)%a2iMask)
a2dVarAnalysisValue(7, 3) = min2Dvar(oHMC_Vars(iID)%a2dLAI, oHMC_Vars(iID)%a2iMask)
a2dVarAnalysisValue(8, 3) = min2Dvar(oHMC_Vars(iID)%a2dAlbedo, oHMC_Vars(iID)%a2iMask)
! Get Outcome variable(s)
a2dVarAnalysisValue(9, 3) = min2Dvar(oHMC_Vars(iID)%a2dLST, oHMC_Vars(iID)%a2iMask)
a2dVarAnalysisValue(10, 3) = min2Dvar(oHMC_Vars(iID)%a2dH, oHMC_Vars(iID)%a2iMask)
a2dVarAnalysisValue(11, 3) = min2Dvar(oHMC_Vars(iID)%a2dLE, oHMC_Vars(iID)%a2iMask)
a2dVarAnalysisValue(12, 3) = min2Dvar(oHMC_Vars(iID)%a2dET, oHMC_Vars(iID)%a2iMask)
a2dVarAnalysisValue(13, 3) = min2Dvar(oHMC_Vars(iID)%a2dIntensity, oHMC_Vars(iID)%a2iMask)
a2dVarAnalysisValue(14, 3) = min2Dvar(oHMC_Vars(iID)%a2dVTot, oHMC_Vars(iID)%a2iMask)
a2dVarAnalysisValue(15, 3) = min2Dvar(oHMC_Vars(iID)%a2dVRet, oHMC_Vars(iID)%a2iMask)
a2dVarAnalysisValue(16, 3) = min2Dvar(oHMC_Vars(iID)%a2dVSub, oHMC_Vars(iID)%a2iMask)
a2dVarAnalysisValue(17, 3) = min2Dvar(oHMC_Vars(iID)%a2dVLoss, oHMC_Vars(iID)%a2iMask)
a2dVarAnalysisValue(18, 3) = min2Dvar(oHMC_Vars(iID)%a2dVExf, oHMC_Vars(iID)%a2iMask)
a2dVarAnalysisValue(19, 3) = min2Dvar(oHMC_Vars(iID)%a2dFlowDeep, oHMC_Vars(iID)%a2iMask)
a2dVarAnalysisValue(20, 3) = min2Dvar(oHMC_Vars(iID)%a2dWTable, oHMC_Vars(iID)%a2iMask)
endif
! Get discharge in outlet section(s)
a1dVarQoutSection = oHMC_Vars(iID)%a1dQoutSection
! Get volume, level amd discharge in dam section(s)
a1dVarVDam = oHMC_Vars(iID)%a1dVDam
a1dVarHDam = oHMC_Vars(iID)%a1dHDam
!------------------------------------------------------------------------------------------
!------------------------------------------------------------------------------------------
! Subroutine for writing sequential netCDF output data
if (iFlagTypeData_Output == 2) then
!------------------------------------------------------------------------------------------
! Call subroutine to write point data
#ifdef LIB_NC
call HMC_Data_Output_Point_NC(iID, &
sPathData_Output, &
iNSection, iNData, iNVar, iNAnalysis, &
iNLake, iNDam, iNPlant, iNJoint, iNCatch, iNRelease, &
sTime, &
a1dVarQoutSection, a1dVarVDam, a1dVarHDam, &
a2dVarAnalysisValue)
#else
! Redefinition of output data flag (if netCDF library is not linked)
iFlagTypeData_Output = 1
call mprintf(.true., iWARN, ' ATTENTION: '// &
'output point data type selected was netCDF but library is not linked! '// &
'Will be used data in ASCII format!')
#endif
!------------------------------------------------------------------------------------------
endif
!------------------------------------------------------------------------------------------
!------------------------------------------------------------------------------------------
! Subroutine for writing sequential binary output data
if (iFlagTypeData_Output == 1) then
!------------------------------------------------------------------------------------------
! Call subroutine to write point data
call HMC_Data_Output_Point_ASCII(iID, &
sPathData_Output, &
iNSection, iNData, iNVar, iNAnalysis, &
iNLake, iNDam, iNPlant, iNJoint, iNCatch, iNRelease, &
sTime, &
a1dVarQoutSection, a1dVarVDam, a1dVarHDam, &
a2dVarAnalysisValue)
!------------------------------------------------------------------------------------------
endif
!------------------------------------------------------------------------------------------
!------------------------------------------------------------------------------------------
! Info end
call mprintf(.true., iINFO_Extra, ' Data :: Output point ... OK ' )
!------------------------------------------------------------------------------------------
end subroutine HMC_Data_Output_Point_Cpl
!------------------------------------------------------------------------------------------
!------------------------------------------------------------------------------------------
! Subroutine to write netCDF point data output
#ifdef LIB_NC
subroutine HMC_Data_Output_Point_NC(iID, &
sPathData_Output, &
iNSection, iDataN, iNVar, iNAnalysis, &
iNLake, iNDam, iNPlant, iNJoint, iNCatch, iNRelease, &
sTime, &
a1dVarQoutSection, a1dVarVDam, a1dVarHDam, &
a2dVarAnalysisValue)
!------------------------------------------------------------------------------------------
! Variable(s)
integer(kind = 4) :: iID
character(len = 256), intent(in) :: sPathData_Output
character(len = 700) :: sFileNameData_Output
character(len = 256) :: sVarName, sVarNameLong
character(len = 256) :: sVarGridMap, sVarDescription, sVarCoords
integer(kind = 4), intent(in) :: iNSection, iDataN, iNVar, iNAnalysis
integer(kind = 4), intent(in) :: iNLake, iNDam, iNPlant, iNJoint, iNCatch, iNRelease
character(len = 19) :: sTime, sTimeSave
real(kind = 4) :: dVarMissingValue
character(len = 700) :: sCommandZipFile
real(kind = 4), dimension(iNVar, iNAnalysis), intent(in) :: a2dVarAnalysisValue
real(kind = 4), dimension(iNSection), intent(in) :: a1dVarQoutSection
real(kind = 4), dimension(iNDam), intent(in) :: a1dVarVDam, a1dVarHDam
character(len = 256) :: sVarUnits
integer(kind = 4) :: iErr
integer(kind = 4) :: iFileID
integer(kind = 4) :: iID_Dim_Section, iID_Dim_Var, iID_Dim_Time, iID_Dim_Dam, iID_Dim_Analysis
!------------------------------------------------------------------------------------------
!------------------------------------------------------------------------------------------
! Get from global workspace
sCommandZipFile = oHMC_Namelist(iID)%sCommandZipFile
! Info start
call mprintf(.true., iINFO_Extra, ' Data :: Output point :: NetCDF ... ' )
!------------------------------------------------------------------------------------------
!------------------------------------------------------------------------------------------
! Filename output
sFileNameData_Output = trim(sPathData_Output)//"hmc.output-point."// &
sTime(1:4)//sTime(6:7)//sTime(9:10)// &
sTime(12:13)//sTime(15:16)// &
".nc"
! Info netCDF filename
call mprintf(.true., iINFO_Verbose, ' Save filename (result point): '//trim(sFileNameData_Output)//' ... ')
!------------------------------------------------------------------------------------------
!------------------------------------------------------------------------------------------
! Create netcdf file
call check( nf90_create(trim(sFileNameData_Output), 0, iFileID) )
! Dimension(s)
call check( nf90_def_dim(iFileID, "time", NF90_UNLIMITED, iID_Dim_Time) )
call check( nf90_def_dim(iFileID, "section", iNSection, iID_Dim_Section) )
call check( nf90_def_dim(iFileID, "n_variable", iNVar, iID_Dim_Var) )
call check( nf90_def_dim(iFileID, "n_analysis", iNAnalysis, iID_Dim_Analysis) )
!------------------------------------------------------------------------------------------
!------------------------------------------------------------------------------------------
! Global attribute(s)
sTimeSave(1:len_trim(sTime)) = sTime
call check( nf90_put_att(iFileID, NF90_GLOBAL, "time_coverage_end", sTimeSave) )
!------------------------------------------------------------------------------------------
!------------------------------------------------------------------------------------------
! Definition mode OFF - Data mode ON
call check( nf90_enddef(iFileID))
!------------------------------------------------------------------------------------------
!------------------------------------------------------------------------------------------
! Writing dynamic point variable(s) in netCDF output file
! POINT SECTIONS DISCHARGE
if (iNSection .gt. 0) then
sVarName = 'Discharge'; sVarNameLong = 'section_discharge'; sVarDescription = 'outlet section discharge';
sVarUnits = 'm^3/s'; sVarCoords = 'x y'; sVarGridMap = 'epsg:4326'; dVarMissingValue = -9E15;
call HMC_Tools_IO_Put1d_NC(iFileID, iID_Dim_Section, &
sVarName, sVarNameLong, sVarDescription, &
sVarUnits, sVarCoords, sVarGridMap, dVarMissingValue, &
iNSection, a1dVarQoutSection)
endif
! POINT DAMS VOLUME
if (iNDam .gt. 0) then
sVarName = 'VDam'; sVarNameLong = 'dam_volume'; sVarDescription = 'dam volume';
sVarUnits = 'm^3'; sVarCoords = 'x y'; sVarGridMap = 'epsg:4326'; dVarMissingValue = -9E15;
call HMC_Tools_IO_Put1d_NC(iFileID, iID_Dim_Dam, &
sVarName, sVarNameLong, sVarDescription, &
sVarUnits, sVarCoords, sVarGridMap, dVarMissingValue, &
iNDam, a1dVarVDam)
endif
! POINT DAMS LEVEL
if (iNDam .gt. 0) then
sVarName = 'LDam'; sVarNameLong = 'dam_level'; sVarDescription = 'dam level';
sVarUnits = 'm'; sVarCoords = 'x y'; sVarGridMap = 'epsg:4326'; dVarMissingValue = -9E15;
call HMC_Tools_IO_Put1d_NC(iFileID, iID_Dim_Dam, &
sVarName, sVarNameLong, sVarDescription, &
sVarUnits, sVarCoords, sVarGridMap, dVarMissingValue, &
iNDam, a1dVarHDam)
endif
! POINT ANALYSIS VARIABLE(S)
if (iDEBUG.gt.0) then
sVarName = 'AnalysisVar'; sVarNameLong = 'analysis_variable'; sVarDescription = 'analysis variable(s) at each timestep';
sVarUnits = ''; sVarCoords = 'x y'; sVarGridMap = 'epsg:4326'; dVarMissingValue = -9E15;
call HMC_Tools_IO_Put2d_NC(iFileID, iID_Dim_Var, iID_Dim_Analysis, &
sVarName, sVarNameLong, sVarDescription, &
sVarUnits, sVarCoords, sVarGridMap, dVarMissingValue, &
iNVar, iNAnalysis, a2dVarAnalysisValue)
endif
!------------------------------------------------------------------------------------------
!------------------------------------------------------------------------------------------
! Close
call check( nf90_close(iFileID) )
! Info netCDF filename
call mprintf(.true., iINFO_Verbose, ' Save filename (result point): '//trim(sFileNameData_Output)//' ... OK ')
!------------------------------------------------------------------------------------------
!------------------------------------------------------------------------------------------
! Zip file
!call HMC_Tools_Generic_ZipFile(sCommandZipFile, &
! sFileNameData_Output//'.gz', sFileNameData_Output, .false.)
! Remove un-zipped file
!call HMC_Tools_Generic_RemoveFile(oHMC_Namelist(iID)%sCommandRemoveFile, sFileNameData_Output, .false.)
!------------------------------------------------------------------------------------------
!------------------------------------------------------------------------------------------
! Info end
call mprintf(.true., iINFO_Extra, ' Data :: Output point :: NetCDF ... OK ' )
!------------------------------------------------------------------------------------------
end subroutine HMC_Data_Output_Point_NC
#endif
!------------------------------------------------------------------------------------------
!------------------------------------------------------------------------------------------
! Subroutine to write point ASCII data output
subroutine HMC_Data_Output_Point_ASCII(iID, &
sPathData_Output, &
iNSection, iNData, iNVar, iNAnalysis, &
iNLake, iNDam, iNPlant, iNJoint, iNCatch, iNRelease, &
sTime, &
a1dVarQoutSection, a1dVarVDam, a1dVarHDam, &
a2dVarAnalysisValue)
!------------------------------------------------------------------------------------------
! Variable(s)
integer(kind = 4) :: iID
character(len = 700), intent(in) :: sPathData_Output
character(len = 700) :: sFileNameData_Output
character(len = 256) :: sVarName
integer(kind = 4) :: iNSection, iNData, iNVar, iNAnalysis
integer(kind = 4) :: iNLake, iNDam, iNPlant, iNJoint, iNCatch, iNRelease
integer(kind = 4) :: iRet
logical :: bFileExist
character(len = 19), intent(in) :: sTime
real(kind = 4), dimension(iNVar, iNAnalysis), intent(in) :: a2dVarAnalysisValue
real(kind = 4), dimension(iNSection), intent(in) :: a1dVarQoutSection
real(kind = 4), dimension(iNDam), intent(in) :: a1dVarVDam, a1dVarHDam
character(len = 256) :: sVarUnits
integer(kind = 4) :: iErr
character(len = 20), parameter :: sFMTDischarge = "(F14.2)"
character(len = 40), parameter :: sFMTVarAnalysis = "(F20.5, F20.5, F20.5)"
character(len = 20), parameter :: sFMTVarVDam = "(F20.5)"
character(len = 20), parameter :: sFMTVarHDam = "(F20.5)"
!------------------------------------------------------------------------------------------
!------------------------------------------------------------------------------------------
! Writing dynamic point variable(s) in ASCII output file
call mprintf(.true., iINFO_Extra, ' Data :: Output point :: ASCII ... ' )
! Info filename(s) at each time step
call mprintf(.true., iINFO_Verbose, ' Save (result point) at time: '//trim(sTime)//' ... ')
!------------------------------------------------------------------------------------------
!------------------------------------------------------------------------------------------
! POINT SECTION(S) DISCHARGE
if (iNSection .gt. 0) then
sFileNameData_Output = trim(sPathData_Output)//"hmc.discharge."// &
sTime(1:4)//sTime(6:7)//sTime(9:10)//sTime(12:13)//sTime(15:16)// &
".txt"
! Check and remove old file
inquire (file = trim(sFileNameData_Output), exist = bFileExist, iostat = iRet)
if ( bFileExist ) then
call HMC_Tools_Generic_RemoveFile(oHMC_Namelist(iID)%sCommandRemoveFile, sFileNameData_Output, .false.)
endif
! Save file
call mprintf(.true., iINFO_Extra, ' Save filename: '//trim(sFileNameData_Output) )
call HMC_Tools_IO_Put1d_ASCII(sFileNameData_Output, a1dVarQoutSection, iNSection, .true., iErr, sFMTDischarge)
endif
!------------------------------------------------------------------------------------------
!------------------------------------------------------------------------------------------
! POINT DAM(S) VOLUME
if (iNDam .gt. 0) then
sFileNameData_Output = trim(sPathData_Output)//"hmc.vdam."// &
sTime(1:4)//sTime(6:7)//sTime(9:10)//sTime(12:13)//sTime(15:16)// &
".txt"
! Check and remove old file
inquire (file = trim(sFileNameData_Output), exist = bFileExist, iostat = iRet)
if ( bFileExist ) then
call HMC_Tools_Generic_RemoveFile(oHMC_Namelist(iID)%sCommandRemoveFile, sFileNameData_Output, .false.)
endif
! Save file
call mprintf(.true., iINFO_Extra, ' Save filename: '//trim(sFileNameData_Output) )
call HMC_Tools_IO_Put1d_ASCII(sFileNameData_Output, a1dVarVDam, iNDam, .true., iErr, sFMTVarVDam)
endif
!------------------------------------------------------------------------------------------
!------------------------------------------------------------------------------------------
! POINT DAM(S) LEVEL
if (iNDam .gt. 0) then
sFileNameData_Output = trim(sPathData_Output)//"hmc.ldam."// &
sTime(1:4)//sTime(6:7)//sTime(9:10)//sTime(12:13)//sTime(15:16)// &
".txt"
! Check and remove old file
inquire (file = trim(sFileNameData_Output), exist = bFileExist, iostat = iRet)
if ( bFileExist ) then
call HMC_Tools_Generic_RemoveFile(oHMC_Namelist(iID)%sCommandRemoveFile, sFileNameData_Output, .false.)
endif
! Save file
call mprintf(.true., iINFO_Extra, ' Save filename: '//trim(sFileNameData_Output) )
call HMC_Tools_IO_Put1d_ASCII(sFileNameData_Output, a1dVarHDam, iNDam, .true., iErr, sFMTVarHDam)
endif
!------------------------------------------------------------------------------------------
!------------------------------------------------------------------------------------------
! POINT ANALYSIS VARIABLE(S)
if (iDEBUG.gt.0) then
sFileNameData_Output = trim(sPathData_Output)//"hmc.var-analysis."// &
sTime(1:4)//sTime(6:7)//sTime(9:10)//sTime(12:13)//sTime(15:16)// &
".txt"
! Check and remove old file
inquire (file = trim(sFileNameData_Output), exist = bFileExist, iostat = iRet)
if ( bFileExist ) then
call HMC_Tools_Generic_RemoveFile(oHMC_Namelist(iID)%sCommandRemoveFile, sFileNameData_Output, .false.)
endif
! Save file
call mprintf(.true., iINFO_Extra, ' Save filename: '//trim(sFileNameData_Output) )
call HMC_Tools_IO_Put2d_ASCII(sFileNameData_Output, a2dVarAnalysisValue, &
iNVar, iNAnalysis, .true., iErr, sFMTVarAnalysis)
endif
!------------------------------------------------------------------------------------------
!------------------------------------------------------------------------------------------
! Print filename(s) info
call mprintf(.true., iINFO_Verbose, ' Save (result point) at time: '//trim(sTime)//' ... OK')
!------------------------------------------------------------------------------------------
!------------------------------------------------------------------------------------------
! Info end
call mprintf(.true., iINFO_Extra, ' Data :: Output point :: ASCII ... OK' )
!------------------------------------------------------------------------------------------
end subroutine HMC_Data_Output_Point_ASCII
!------------------------------------------------------------------------------------------
end module HMC_Module_Data_Output_Point
!------------------------------------------------------------------------------------------