Line data Source code
1 : !-------------------------------------------------------------------------------
2 : ! $Id$
3 : !===============================================================================
4 : module stat_file_module
5 :
6 :
7 : ! Description:
8 : ! Contains two derived types for describing the contents and location of
9 : ! either NetCDF or GrADS files.
10 : !-------------------------------------------------------------------------------
11 : use clubb_precision, only: &
12 : stat_rknd, & ! Variable
13 : time_precision, &
14 : core_rknd
15 :
16 : implicit none
17 :
18 : public :: grid_avg_variable, samples_of_variable, stat_file
19 :
20 : ! These are used in a 2D or 3D host model to output multiple columns
21 : ! Set clubb_i and clubb_j according to the column within the host model;
22 : ! The indices must not exceed nlon (for i) or nlat (for j).
23 : integer, save, public :: clubb_i = 1, clubb_j = 1
24 : !$omp threadprivate(clubb_i, clubb_j)
25 :
26 : private ! Default scope
27 :
28 : ! Structures to hold the description of a variable
29 :
30 : type grid_avg_variable
31 : ! Pointer to the array
32 : real(kind=stat_rknd), dimension(:,:,:), pointer :: ptr
33 :
34 : character(len = 30) :: name ! Variable name
35 : character(len = 100) :: description ! Variable description
36 : character(len = 25) :: units ! Variable units
37 :
38 : integer :: indx ! NetCDF module Id for var / GrADS index
39 :
40 : logical :: l_silhs ! If true, we sample this variable once for each SILHS
41 : ! sample point per timestep, rather than just once per
42 : ! timestep.
43 : end type grid_avg_variable
44 :
45 : type samples_of_variable
46 : ! Pointer to the array
47 : real(kind=stat_rknd), dimension(:,:,:,:), pointer :: ptr
48 :
49 : character(len = 30) :: name ! Variable name
50 : character(len = 100) :: description ! Variable description
51 : character(len = 25) :: units ! Variable units
52 :
53 : integer :: indx ! NetCDF module Id for var / GrADS index
54 :
55 : logical :: l_silhs ! If true, we sample this variable once for each SILHS
56 : ! sample point per timestep, rather than just once per
57 : ! timestep.
58 : end type samples_of_variable
59 :
60 : ! Structure to hold the description of a NetCDF output file
61 : ! This makes the new code as compatible as possible with the
62 : ! GrADS output code
63 :
64 : type stat_file
65 :
66 : ! File information
67 :
68 : character(len = 200) :: &
69 : fname, & ! File name without suffix
70 : fdir ! Path where fname resides
71 :
72 : integer :: iounit ! This number is used internally by the
73 : ! NetCDF module to track the data set, or by
74 : ! GrADS to track the actual file unit.
75 : integer :: &
76 : nrecord, & ! Number of records written
77 : ntimes ! Number of times written
78 :
79 : logical :: &
80 : l_defined, & ! Whether nf90_enddef() has been called
81 : l_byte_swapped ! Is this a file in the opposite byte ordering?
82 :
83 : ! NetCDF datafile dimensions indices (Samp*Id for SILHS samples)
84 : integer :: &
85 : SampDimId, LatDimId, LongDimId, AltDimId, TimeDimId, &
86 : SampVarId, LatVarId, LongVarId, AltVarId, TimeVarId
87 :
88 : ! Grid information
89 :
90 : integer :: ia, iz ! Vertical extent
91 :
92 : integer :: nlat, nlon ! The number of points in the X and Y
93 :
94 : ! Number of SILHS samples (i.e. subcolumns). Initialized to zero
95 : ! to be safe, but will be updated if appropriate
96 : integer :: nsamp = 0
97 :
98 : real( kind = core_rknd ), dimension(:), allocatable :: &
99 : z ! Height of vertical levels [m]
100 :
101 : ! Time information
102 :
103 : integer :: day, month, year ! Date of starting time
104 :
105 : real( kind = core_rknd ), dimension(:), allocatable :: &
106 : lat_vals, & ! Latitude [Degrees N]
107 : lon_vals, & ! Longitude [Degrees E]
108 : samp_idx ! SILHS subcolumn index
109 :
110 : real( kind = core_rknd ) :: &
111 : dtwrite ! Interval between output [Seconds]
112 :
113 : real( kind = time_precision ) :: &
114 : time ! Start time [Seconds]
115 :
116 : ! Statistical Variables
117 :
118 : integer :: nvar ! Number of variables for this file
119 :
120 : type (grid_avg_variable), dimension(:), allocatable :: &
121 : grid_avg_var ! List and variable description
122 :
123 : type (samples_of_variable), dimension(:), allocatable :: &
124 : samples_of_var
125 :
126 : end type stat_file
127 :
128 0 : end module stat_file_module
|