1 | !> @file src/types.f90 |
---|
2 | !------------------------------------------------------------------------------! |
---|
3 | ! This file is part of the PALM model system. |
---|
4 | ! |
---|
5 | ! PALM is free software: you can redistribute it and/or modify it under the |
---|
6 | ! terms of the GNU General Public License as published by the Free Software |
---|
7 | ! Foundation, either version 3 of the License, or (at your option) any later |
---|
8 | ! version. |
---|
9 | ! |
---|
10 | ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY |
---|
11 | ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
---|
12 | ! A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
---|
13 | ! |
---|
14 | ! You should have received a copy of the GNU General Public License along with |
---|
15 | ! PALM. If not, see <http://www.gnu.org/licenses/>. |
---|
16 | ! |
---|
17 | ! Copyright 2017-2018 Leibniz Universitaet Hannover |
---|
18 | ! Copyright 2017-2018 Deutscher Wetterdienst Offenbach |
---|
19 | !------------------------------------------------------------------------------! |
---|
20 | ! |
---|
21 | ! Current revisions: |
---|
22 | ! ----------------- |
---|
23 | ! |
---|
24 | ! |
---|
25 | ! Former revisions: |
---|
26 | ! ----------------- |
---|
27 | ! $Id: types.f90 3183 2018-07-27 14:25:55Z suehring $ |
---|
28 | ! Introduced new PALM grid stretching: |
---|
29 | ! - Converted vertical grid_definition coordinte variables to pointers |
---|
30 | ! Improved command line interface: |
---|
31 | ! - Moved INIFOR configuration into a new derived data type |
---|
32 | ! Removed unnecessary variables |
---|
33 | ! |
---|
34 | ! |
---|
35 | ! 3182 2018-07-27 13:36:03Z suehring |
---|
36 | ! Initial revision |
---|
37 | ! |
---|
38 | ! |
---|
39 | ! |
---|
40 | ! Authors: |
---|
41 | ! -------- |
---|
42 | ! @author Eckhard Kadasch |
---|
43 | ! |
---|
44 | ! Description: |
---|
45 | ! ------------ |
---|
46 | !> The types module provides derived data types used in INIFOR. |
---|
47 | !------------------------------------------------------------------------------! |
---|
48 | MODULE types |
---|
49 | |
---|
50 | USE defs, & |
---|
51 | ONLY: dp, DATE, PATH, SNAME, LNAME |
---|
52 | USE netcdf, & |
---|
53 | ONLY: NF90_MAX_VAR_DIMS, NF90_MAX_NAME |
---|
54 | |
---|
55 | IMPLICIT NONE |
---|
56 | |
---|
57 | TYPE inifor_config |
---|
58 | CHARACTER(LEN=DATE) :: start_date !< String of the FORMAT YYYYMMDDHH indicating the start of the intended PALM-4U simulation |
---|
59 | |
---|
60 | CHARACTER(LEN=PATH) :: input_path !< Path to the input data file directory |
---|
61 | CHARACTER(LEN=PATH) :: hhl_file !< Path to the file containing the COSMO-DE HHL variable (height of half layers, i.e. vertical cell faces) |
---|
62 | CHARACTER(LEN=PATH) :: namelist_file !< Path to the PALM-4U namelist file |
---|
63 | CHARACTER(LEN=PATH) :: output_file !< Path to the INIFOR output file (i.e. PALM-4U dynamic driver') |
---|
64 | CHARACTER(LEN=PATH) :: soiltyp_file !< Path to the file containing the COSMO-DE SOILTYP variable (map of COSMO-DE soil types) |
---|
65 | CHARACTER(LEN=PATH) :: static_driver_file !< Path to the file containing the COSMO-DE SOILTYP variable (map of COSMO-DE soil types) |
---|
66 | |
---|
67 | CHARACTER(LEN=SNAME) :: flow_prefix !< Prefix of flow input files, e.g. 'laf' for COSMO-DE analyses |
---|
68 | CHARACTER(LEN=SNAME) :: soil_prefix !< Prefix of soil input files, e.g. 'laf' for COSMO-DE analyses |
---|
69 | CHARACTER(LEN=SNAME) :: radiation_prefix !< Prefix of radiation input files, e.g 'laf' for COSMO-DE analyses |
---|
70 | CHARACTER(LEN=SNAME) :: soilmoisture_prefix !< Prefix of input files for soil moisture spin-up, e.g 'laf' for COSMO-DE analyses |
---|
71 | |
---|
72 | CHARACTER(LEN=SNAME) :: bc_mode |
---|
73 | CHARACTER(LEN=SNAME) :: ic_mode |
---|
74 | CHARACTER(LEN=SNAME) :: rotation_method |
---|
75 | |
---|
76 | REAL(dp) :: p0 |
---|
77 | REAL(dp) :: ug |
---|
78 | REAL(dp) :: vg |
---|
79 | REAL(dp) :: z0 !< Elevation of the PALM-4U domain above sea level [m] |
---|
80 | END TYPE inifor_config |
---|
81 | |
---|
82 | TYPE grid_definition |
---|
83 | CHARACTER(LEN=SNAME) :: name(3) !< names of the grid dimensions, e.g. (/'x', 'y', 'z'/) or (/'latitude', 'longitude', 'height'/) |
---|
84 | INTEGER :: nx !< number of gridpoints in the first dimension |
---|
85 | INTEGER :: ny !< number of gridpoints in the second dimension |
---|
86 | INTEGER :: nz !< number of gridpoints in the third dimension |
---|
87 | INTEGER, ALLOCATABLE :: ii(:,:,:) !< Given a point (i,j,k) in the PALM-4U grid, ii(i,j,l) gives the x index of the l'th horizontl neighbour on the COSMO-DE grid. |
---|
88 | INTEGER, ALLOCATABLE :: jj(:,:,:) !< Given a point (i,j,k) in the PALM-4U grid, jj(i,j,l) gives the y index of the l'th horizontl neighbour on the COSMO-DE grid. |
---|
89 | INTEGER, ALLOCATABLE :: kk(:,:,:,:) !< Given a point (i,j,k) in the PALM-4U grid, kk(i,j,k,l) gives the z index of the l'th vertical neighbour in the intermediate grid. |
---|
90 | REAL(dp) :: lx !< domain length in the first dimension [m] |
---|
91 | REAL(dp) :: ly !< domain length in the second dimension [m] |
---|
92 | REAL(dp) :: x0 !< x coordinate of PALM-4U domain projection centre, i.e. location of zero distortion |
---|
93 | REAL(dp) :: y0 !< y coordinate of PALM-4U domain projection centre, i.e. location of zwro distortion |
---|
94 | REAL(dp) :: z0 !< displacement of the coordinate origin above sea level [m] |
---|
95 | REAL(dp), ALLOCATABLE :: x(:) !< coordinates of cell centers in x direction [m] |
---|
96 | REAL(dp), ALLOCATABLE :: y(:) !< coordinates of cell centers in y direction [m] |
---|
97 | REAL(dp), POINTER :: z(:) !< coordinates of cell centers in z direction [m] |
---|
98 | REAL(dp), ALLOCATABLE :: h(:,:,:) !< heights grid point for intermediate grids [m] |
---|
99 | REAL(dp), POINTER :: hhl(:,:,:) !< heights of half layers (cell faces) above sea level in COSMO-DE, read in from |
---|
100 | REAL(dp), POINTER :: hfl(:,:,:) !< heights of full layers (cell centres) above sea level in COSMO-DE, computed as arithmetic average of hhl |
---|
101 | REAL(dp), POINTER :: depths(:) !< depths of output soil layers, equal the depths of the source model (e.g. COSMO-DE) |
---|
102 | REAL(dp), ALLOCATABLE :: xu(:) !< coordinates of cell faces in x direction [m] |
---|
103 | REAL(dp), ALLOCATABLE :: yv(:) !< coordinates of cell faces in y direction [m] |
---|
104 | REAL(dp), POINTER :: zw(:) !< coordinates of cell faces in z direction [m] |
---|
105 | REAL(dp), ALLOCATABLE :: lat(:) !< rotated-pole latitudes of scalars (cell centers) of the COSMO-DE grid [rad] |
---|
106 | REAL(dp), ALLOCATABLE :: lon(:) !< rotated-pole longitudes of scalars (cell centres) of the COSMO-DE grid [rad] |
---|
107 | REAL(dp), ALLOCATABLE :: latv(:) !< rotated-pole latitudes of v winds (face centres in latitudal/y direction) [rad] |
---|
108 | REAL(dp), ALLOCATABLE :: lonu(:) !< rotated-pole latitudes of u winds (face centres in longitudal/x direction) [rad] |
---|
109 | REAL(dp), ALLOCATABLE :: clat(:,:) !< latitudes of PALM-4U cell centres in COSMO-DE's rotated-pole grid [rad] |
---|
110 | REAL(dp), ALLOCATABLE :: clon(:,:) !< longitudes of PALM-4U scalars (cell centres) in COSMO-DE's rotated-pole grid [rad] |
---|
111 | REAL(dp), ALLOCATABLE :: clatu(:,:) !< latitudes of PALM-4U u winds (cell faces in u direction) in COSMO-DE's rotated-pole grid [rad] |
---|
112 | REAL(dp), ALLOCATABLE :: clonu(:,:) !< longitudes of PALM-4U u winds (cell faces in u direction) in COSMO-DE's rotated-pole grid [rad] |
---|
113 | REAL(dp), ALLOCATABLE :: clatv(:,:) !< latitudes of PALM-4U v winds (cell faces in v direction) in COSMO-DE's rotated-pole grid [rad] |
---|
114 | REAL(dp), ALLOCATABLE :: clonv(:,:) !< longitudes of PALM-4U v winds (cell faces in v direction) in COSMO-DE's rotated-pole grid [rad] |
---|
115 | REAL(dp), ALLOCATABLE :: w_horiz(:,:,:) !< weights for bilinear horizontal interpolation |
---|
116 | REAL(dp), ALLOCATABLE :: w_verti(:,:,:,:) !< weights for linear vertical interpolation |
---|
117 | END TYPE grid_definition |
---|
118 | |
---|
119 | |
---|
120 | TYPE nc_file |
---|
121 | CHARACTER(LEN=PATH) :: name !< file name |
---|
122 | INTEGER :: dimid_time !< NetCDF IDs of the time dimension |
---|
123 | INTEGER :: dimids_scl(3) !< NetCDF IDs of the grid dimensions for scalar points x, y, z |
---|
124 | INTEGER :: dimids_vel(3) !< NetCDF IDs of the grid dimensions for velocity points xu, yu, zu |
---|
125 | INTEGER :: dimids_soil(3)!< NetCDF IDs of the grid dimensions for soil points x, y, depth |
---|
126 | INTEGER :: dimvarid_time !< NetCDF IDs of the time variable |
---|
127 | INTEGER :: dimvarids_scl(3) !< NetCDF IDs of the grid coordinates of scalars x, y, z |
---|
128 | INTEGER :: dimvarids_vel(3) !< NetCDF IDs of the grid coordinates of velocities xu, yu, zu. Note that velocities are located at mix of both coordinates, e.g. u(xu, y, z). |
---|
129 | INTEGER :: dimvarids_soil(3)!< NetCDF IDs of the grid coordinates for soil points x, y, depth |
---|
130 | REAL(dp), POINTER :: time(:) ! vector of output time steps |
---|
131 | END TYPE nc_file |
---|
132 | |
---|
133 | |
---|
134 | TYPE nc_var |
---|
135 | INTEGER :: varid !< NetCDF ID of the variable |
---|
136 | INTEGER :: input_id !< ID of the correpsonding input variables, only valid for output variables |
---|
137 | INTEGER :: ndim !< number of NetCDF dimensions |
---|
138 | INTEGER :: nt !< number of output time steps |
---|
139 | INTEGER :: lod !< NetCDF attribute indicating the PALM-4U level of detail |
---|
140 | INTEGER, DIMENSION(NF90_MAX_VAR_DIMS) :: dimids !< NetCDF IDs of the dimensions |
---|
141 | INTEGER, DIMENSION(NF90_MAX_VAR_DIMS) :: dimvarids !< IDs of NetCDF dimension variables |
---|
142 | INTEGER, DIMENSION(NF90_MAX_VAR_DIMS) :: dimlen !< length of NetCDF dimensions |
---|
143 | CHARACTER(LEN=NF90_MAX_NAME), DIMENSION(NF90_MAX_VAR_DIMS) :: dimname !< names of NetCDF dimensions |
---|
144 | CHARACTER(LEN=SNAME) :: name !< NetCDF short name of the variable |
---|
145 | CHARACTER(LEN=LNAME) :: standard_name !< NetCDF standard name of the variable |
---|
146 | CHARACTER(LEN=LNAME) :: long_name !< NetCDF long name of the variable |
---|
147 | CHARACTER(LEN=LNAME) :: source !< NetCDF attribute indicating the data source for the output |
---|
148 | CHARACTER(LEN=SNAME) :: units !< NetCDF units of the variable |
---|
149 | CHARACTER(LEN=SNAME) :: kind !< Kind of grid |
---|
150 | CHARACTER(LEN=SNAME) :: task !< Processing task that generates this variable, e.g. 'interpolate_2d' or 'average profile' |
---|
151 | LOGICAL :: to_be_processed = .FALSE. !< INIFOR flag indicating whether variable shall be processed |
---|
152 | LOGICAL :: is_read = .FALSE. !< INIFOR flag indicating whether variable has been read |
---|
153 | LOGICAL :: is_upside_down = .FALSE. !< INIFOR flag indicating whether variable shall be processed |
---|
154 | TYPE(grid_definition), POINTER :: grid !< Pointer to the corresponding output grid |
---|
155 | TYPE(grid_definition), POINTER :: intermediate_grid !< Pointer to the corresponding intermediate grid |
---|
156 | END TYPE nc_var |
---|
157 | |
---|
158 | |
---|
159 | TYPE io_group !< Input/Output group, groups together output variabels that share their input variables. For instance, all boundary surfaces and initialization fields of the potential temperature are base on T and p. |
---|
160 | INTEGER :: nt !< maximum number of output time steps across all output variables |
---|
161 | INTEGER :: nv !< number of output variables |
---|
162 | CHARACTER(LEN=SNAME) :: kind !< kind of I/O group |
---|
163 | CHARACTER(LEN=PATH), ALLOCATABLE :: in_files(:) !< list of nt input files |
---|
164 | TYPE(nc_var), ALLOCATABLE :: out_vars(:) !< list of output variables |
---|
165 | TYPE(nc_var), ALLOCATABLE :: in_var_list(:) !< list of input variables |
---|
166 | LOGICAL :: to_be_processed = .FALSE. !< Inifor flag indicating whether I/O group shall be processed |
---|
167 | LOGICAL :: is_accumulated = .FALSE. !< Flag indicating whether this I/O group contains accumulated variables |
---|
168 | LOGICAL :: is_preprocessed = .FALSE. !< Inifor flag indicating whether the I/O group has been preprocessed |
---|
169 | END TYPE io_group |
---|
170 | |
---|
171 | |
---|
172 | TYPE container |
---|
173 | REAL(dp), ALLOCATABLE :: array(:,:,:) |
---|
174 | LOGICAL :: is_preprocessed = .FALSE. |
---|
175 | END TYPE container |
---|
176 | |
---|
177 | END MODULE types |
---|
178 | |
---|