source: palm/trunk/UTIL/inifor/src/inifor_types.f90 @ 3681

Last change on this file since 3681 was 3680, checked in by knoop, 5 years ago

Added cpp-option netcdf to inifor

  • Property svn:keywords set to Id
File size: 17.8 KB
RevLine 
[3447]1!> @file src/inifor_types.f90
[2696]2!------------------------------------------------------------------------------!
[2718]3! This file is part of the PALM model system.
[2696]4!
[2718]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
[2696]8! version.
9!
[2718]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.
[2696]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!
[2718]17! Copyright 2017-2018 Leibniz Universitaet Hannover
18! Copyright 2017-2018 Deutscher Wetterdienst Offenbach
[2696]19!------------------------------------------------------------------------------!
20!
21! Current revisions:
22! -----------------
[3183]23!
24!
25! Former revisions:
26! -----------------
27! $Id: inifor_types.f90 3680 2019-01-18 14:54:12Z hellstea $
[3618]28! Prefixed all INIFOR modules with inifor_
29!
30!
31! 3557 2018-11-22 16:01:22Z eckhard
[3557]32! Updated documentation
33!
34!
35! 3447 2018-10-29 15:52:54Z eckhard
[3447]36! Renamed source files for compatibilty with PALM build system
37!
38!
39! 3395 2018-10-22 17:32:49Z eckhard
[3395]40! Added *_is_set LOGICALs to inifor_config type to indicate option invocation
41!     from the command-line
42! Added 1D index vertical weights lists to support addressing averaging regions
43!     by list of columns instead of index bounds
44!
45!
46! 3183 2018-07-27 14:25:55Z suehring
[3182]47! Introduced new PALM grid stretching:
48! - Converted vertical grid_definition coordinte variables to pointers
49! Improved command line interface:
50! - Moved INIFOR configuration into a new derived data type
51! Removed unnecessary variables
[2696]52!
53!
[3183]54! 3182 2018-07-27 13:36:03Z suehring
[2696]55! Initial revision
56!
57!
58!
59! Authors:
60! --------
[3557]61!> @author Eckhard Kadasch (Deutscher Wetterdienst, Offenbach)
[2696]62!
63! Description:
64! ------------
65!> The types module provides derived data types used in INIFOR.
66!------------------------------------------------------------------------------!
[3680]67#if defined ( __netcdf )
[3618]68 MODULE inifor_types
[2696]69 
[3618]70 USE inifor_defs,                                                              &
[3182]71    ONLY:  dp, DATE, PATH, SNAME, LNAME
[2696]72 USE netcdf,                                                                   &
73    ONLY:  NF90_MAX_VAR_DIMS, NF90_MAX_NAME
74
75 IMPLICIT NONE
76
[3557]77!------------------------------------------------------------------------------!
78! Description:
79! ------------
80!> Contaner for the INIFOR command-line configuration
81!------------------------------------------------------------------------------!
[3182]82 TYPE inifor_config
83    CHARACTER(LEN=DATE)  ::  start_date           !< String of the FORMAT YYYYMMDDHH indicating the start of the intended PALM-4U simulation
84
85    CHARACTER(LEN=PATH)  ::  input_path           !< Path to the input data file directory
86    CHARACTER(LEN=PATH)  ::  hhl_file             !< Path to the file containing the COSMO-DE HHL variable (height of half layers, i.e. vertical cell faces)
87    CHARACTER(LEN=PATH)  ::  namelist_file        !< Path to the PALM-4U namelist file
88    CHARACTER(LEN=PATH)  ::  output_file          !< Path to the INIFOR output file (i.e. PALM-4U dynamic driver')
89    CHARACTER(LEN=PATH)  ::  soiltyp_file         !< Path to the file containing the COSMO-DE SOILTYP variable (map of COSMO-DE soil types)
90    CHARACTER(LEN=PATH)  ::  static_driver_file   !< Path to the file containing the COSMO-DE SOILTYP variable (map of COSMO-DE soil types)
91
92    CHARACTER(LEN=SNAME) ::  flow_prefix          !< Prefix of flow input files, e.g. 'laf' for COSMO-DE analyses
[3395]93    CHARACTER(LEN=SNAME) ::  input_prefix         !< Prefix of all input files, e.g. 'laf' for COSMO-DE analyses
94    CHARACTER(LEN=SNAME) ::  radiation_prefix     !< Prefix of radiation input files, e.g 'laf' for COSMO-DE analyses
[3182]95    CHARACTER(LEN=SNAME) ::  soil_prefix          !< Prefix of soil input files, e.g. 'laf' for COSMO-DE analyses
96    CHARACTER(LEN=SNAME) ::  soilmoisture_prefix  !< Prefix of input files for soil moisture spin-up, e.g 'laf' for COSMO-DE analyses
97
[3557]98    CHARACTER(LEN=SNAME) ::  averaging_mode       !< destinguishes between level-based and heigh-based averaging
99    CHARACTER(LEN=SNAME) ::  bc_mode              !< destinguishes realistic and idealistic forcing
100    CHARACTER(LEN=SNAME) ::  ic_mode              !< destinguishes volume and profile initialization
101    CHARACTER(LEN=SNAME) ::  rotation_method      !< selects method for velocity rotation
[3182]102
[3557]103    REAL(dp)             ::  p0                   !< manually specified surface pressure [Pa]
104    REAL(dp)             ::  ug                   !< manually spefied geostrophic wind component in x direction [m/s]
105    REAL(dp)             ::  vg                   !< manually spefied geostrophic wind component in y direction [m/s]
106    REAL(dp)             ::  z0                   !< elevation of the PALM-4U domain above sea level [m]
[3395]107    REAL(dp)             ::  averaging_angle      !< latitudal and longitudal width of averaging regions [deg]
108   
[3557]109    LOGICAL              ::  debug                       !< indicates whether --debug option was given
110    LOGICAL              ::  p0_is_set                   !< indicates whether p0 was set manually
111    LOGICAL              ::  ug_is_set                   !< indicates whether ug was set manually
112    LOGICAL              ::  vg_is_set                   !< indicates whether vg was set manually
113    LOGICAL              ::  flow_prefix_is_set          !<  indicates whether the flow prefix was set manually
114    LOGICAL              ::  input_prefix_is_set         !<  indicates whether the input prefix was set manually
115    LOGICAL              ::  radiation_prefix_is_set     !<  indicates whether the radiation prefix was set manually
116    LOGICAL              ::  soil_prefix_is_set          !<  indicates whether the soil prefix was set manually
117    LOGICAL              ::  soilmoisture_prefix_is_set  !<  indicates whether the soilmoisture prefix was set manually
[3182]118 END TYPE inifor_config
119
[3557]120
121!------------------------------------------------------------------------------!
122! Description:
123! ------------
124!> Container for grid data, in partucular coordinates, interpolation neighbours
125!> and weights
126!------------------------------------------------------------------------------!
[2696]127 TYPE grid_definition
128    CHARACTER(LEN=SNAME)  ::  name(3)       !< names of the grid dimensions, e.g. (/'x', 'y', 'z'/) or (/'latitude', 'longitude', 'height'/)
[3395]129    CHARACTER(LEN=SNAME)  ::  kind          !< names of the grid dimensions, e.g. (/'x', 'y', 'z'/) or (/'latitude', 'longitude', 'height'/)
130    INTEGER               ::  k_min         !< Index of lowest PALM grid level that is not cut by local COSMO orography; vertically separates interpolation and extrapolation region.
[2696]131    INTEGER               ::  nx            !< number of gridpoints in the first dimension
132    INTEGER               ::  ny            !< number of gridpoints in the second dimension
[3395]133    INTEGER               ::  nz            !< number of gridpoints in the third dimension, used for PALM points
134    INTEGER               ::  nlev          !< number of COSMO grid levels
135    INTEGER               ::  n_columns     !< number of averaging columns of the source grid
[2696]136    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.
137    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.
138    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.
[3395]139    INTEGER, ALLOCATABLE  ::  iii(:)        !< profile averaging neighbour indices
140    INTEGER, ALLOCATABLE  ::  jjj(:)        !< profile averaging neighbour indices
141    INTEGER, ALLOCATABLE  ::  kkk(:,:,:)    !< indices of vertical interpolation neightbours, kkk(<source column>, <PALM k level>, <neighbour index>)
[2696]142    REAL(dp)              ::  lx            !< domain length in the first dimension [m]
143    REAL(dp)              ::  ly            !< domain length in the second dimension [m]
144    REAL(dp)              ::  x0            !< x coordinate of PALM-4U domain projection centre, i.e. location of zero distortion
145    REAL(dp)              ::  y0            !< y coordinate of PALM-4U domain projection centre, i.e. location of zwro distortion
146    REAL(dp)              ::  z0            !< displacement of the coordinate origin above sea level [m]
147    REAL(dp), ALLOCATABLE ::  x(:)          !< coordinates of cell centers in x direction [m]
148    REAL(dp), ALLOCATABLE ::  y(:)          !< coordinates of cell centers in y direction [m]
[3182]149    REAL(dp), POINTER     ::  z(:)          !< coordinates of cell centers in z direction [m]
[2696]150    REAL(dp), ALLOCATABLE ::  h(:,:,:)      !< heights grid point for intermediate grids [m]
[3395]151    REAL(dp), POINTER     ::  cosmo_h(:,:,:)!< pointer to appropriate COSMO level heights (scalar/w) [m]
[2696]152    REAL(dp), POINTER     ::  hhl(:,:,:)    !< heights of half layers (cell faces) above sea level in COSMO-DE, read in from
153    REAL(dp), POINTER     ::  hfl(:,:,:)    !< heights of full layers (cell centres) above sea level in COSMO-DE, computed as arithmetic average of hhl
154    REAL(dp), POINTER     ::  depths(:)     !< depths of output soil layers, equal the depths of the source model (e.g. COSMO-DE)
155    REAL(dp), ALLOCATABLE ::  xu(:)         !< coordinates of cell faces in x direction [m]
156    REAL(dp), ALLOCATABLE ::  yv(:)         !< coordinates of cell faces in y direction [m]
[3182]157    REAL(dp), POINTER     ::  zw(:)         !< coordinates of cell faces in z direction [m]
[2696]158    REAL(dp), ALLOCATABLE ::  lat(:)        !< rotated-pole latitudes of scalars (cell centers) of the COSMO-DE grid [rad]
159    REAL(dp), ALLOCATABLE ::  lon(:)        !< rotated-pole longitudes of scalars (cell centres) of the COSMO-DE grid [rad]
160    REAL(dp), ALLOCATABLE ::  latv(:)       !< rotated-pole latitudes of v winds (face centres in latitudal/y direction) [rad]
161    REAL(dp), ALLOCATABLE ::  lonu(:)       !< rotated-pole latitudes of u winds (face centres in longitudal/x direction) [rad]
162    REAL(dp), ALLOCATABLE ::  clat(:,:)     !< latitudes of PALM-4U cell centres in COSMO-DE's rotated-pole grid [rad]
163    REAL(dp), ALLOCATABLE ::  clon(:,:)     !< longitudes of PALM-4U scalars (cell centres) in COSMO-DE's rotated-pole grid [rad]
164    REAL(dp), ALLOCATABLE ::  clatu(:,:)    !< latitudes of PALM-4U u winds (cell faces in u direction) in COSMO-DE's rotated-pole grid [rad]
165    REAL(dp), ALLOCATABLE ::  clonu(:,:)    !< longitudes of PALM-4U u winds (cell faces in u direction) in COSMO-DE's rotated-pole grid [rad]
166    REAL(dp), ALLOCATABLE ::  clatv(:,:)    !< latitudes of PALM-4U v winds (cell faces in v direction) in COSMO-DE's rotated-pole grid [rad]
167    REAL(dp), ALLOCATABLE ::  clonv(:,:)    !< longitudes of PALM-4U v winds (cell faces in v direction) in COSMO-DE's rotated-pole grid [rad]
168    REAL(dp), ALLOCATABLE ::  w_horiz(:,:,:)   !< weights for bilinear horizontal interpolation
169    REAL(dp), ALLOCATABLE ::  w_verti(:,:,:,:) !< weights for linear vertical interpolation
[3395]170    REAL(dp), ALLOCATABLE ::  w(:,:,:)      !< vertical interpolation weights, w(<source_column>, <PALM k level>, <neighbour index>) [-]
[3182]171 END TYPE grid_definition
[2696]172
173
[3557]174!------------------------------------------------------------------------------!
175! Description:
176! ------------
177!> Container for name and dimensions of the netCDF output file
178!------------------------------------------------------------------------------!
[2696]179 TYPE nc_file
[3557]180    CHARACTER(LEN=PATH)   ::  name              !< file name
181    INTEGER               ::  dimid_time        !< NetCDF IDs of the time dimension
182    INTEGER               ::  dimids_scl(3)     !< NetCDF IDs of the grid dimensions for scalar points x, y, z
183    INTEGER               ::  dimids_vel(3)     !< NetCDF IDs of the grid dimensions for velocity points xu, yu, zu
184    INTEGER               ::  dimids_soil(3)    !< NetCDF IDs of the grid dimensions for soil points x, y, depth
185    INTEGER               ::  dimvarid_time     !< NetCDF IDs of the time variable
186    INTEGER               ::  dimvarids_scl(3)  !< NetCDF IDs of the grid coordinates of scalars x, y, z
187    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).
188    INTEGER               ::  dimvarids_soil(3) !< NetCDF IDs of the grid coordinates for soil points x, y, depth
189    REAL(dp), POINTER     ::  time(:)           !< vector of output time steps
[3182]190 END TYPE nc_file
[2696]191
192
[3557]193!------------------------------------------------------------------------------!
194! Description:
195! ------------
196!> Metadata container for netCDF variables
197!------------------------------------------------------------------------------!
[2696]198 TYPE nc_var
199    INTEGER                               ::  varid     !< NetCDF ID of the variable
200    INTEGER                               ::  input_id  !< ID of the correpsonding input variables, only valid for output variables
201    INTEGER                               ::  ndim      !< number of NetCDF dimensions
202    INTEGER                               ::  nt        !< number of output time steps
203    INTEGER                               ::  lod       !< NetCDF attribute indicating the PALM-4U level of detail
204    INTEGER, DIMENSION(NF90_MAX_VAR_DIMS) ::  dimids    !< NetCDF IDs of the dimensions
205    INTEGER, DIMENSION(NF90_MAX_VAR_DIMS) ::  dimvarids !< IDs of NetCDF dimension variables
206    INTEGER, DIMENSION(NF90_MAX_VAR_DIMS) ::  dimlen    !< length of NetCDF dimensions
207    CHARACTER(LEN=NF90_MAX_NAME), DIMENSION(NF90_MAX_VAR_DIMS) ::  dimname !< names of NetCDF dimensions
208    CHARACTER(LEN=SNAME)                  ::  name                      !< NetCDF short name of the variable
209    CHARACTER(LEN=LNAME)                  ::  standard_name             !< NetCDF standard name of the variable
210    CHARACTER(LEN=LNAME)                  ::  long_name                 !< NetCDF long name of the variable
211    CHARACTER(LEN=LNAME)                  ::  source                    !< NetCDF attribute indicating the data source for the output
212    CHARACTER(LEN=SNAME)                  ::  units                     !< NetCDF units of the variable
213    CHARACTER(LEN=SNAME)                  ::  kind                      !< Kind of grid
214    CHARACTER(LEN=SNAME)                  ::  task                      !< Processing task that generates this variable, e.g. 'interpolate_2d' or 'average profile'
[3182]215    LOGICAL                               ::  to_be_processed = .FALSE. !< INIFOR flag indicating whether variable shall be processed
[3395]216    LOGICAL                               ::  is_internal = .FALSE.     !< INIFOR flag indicating whether variable shall be written to netCDF file (.FALSE.) or kept for later (.TRUE.)
[3182]217    LOGICAL                               ::  is_read = .FALSE.         !< INIFOR flag indicating whether variable has been read
[3395]218    LOGICAL                               ::  is_upside_down  = .FALSE. !< INIFOR flag indicating whether vertical dimension is reversed (typically the case with COSMO-DE atmospheric fields)
[2696]219    TYPE(grid_definition), POINTER        ::  grid                      !< Pointer to the corresponding output grid
220    TYPE(grid_definition), POINTER        ::  intermediate_grid         !< Pointer to the corresponding intermediate grid
[3395]221    TYPE(grid_definition), POINTER        ::  averaging_grid         !< Pointer to the corresponding intermediate grid
[2696]222 END TYPE nc_var
223
224
[3557]225!------------------------------------------------------------------------------!
226! Description:
227! ------------
228!> Input/Output group, groups together nc_var-type output variabels that share
229!> input variables as well as lists of the netCDF files they are stored in.
230!> For instance, all boundary surfaces and initialization fields of the
231!> potential temperature are base on the input netCDF variables T and P.
232!------------------------------------------------------------------------------!
233 TYPE io_group
[2696]234    INTEGER                          ::  nt             !< maximum number of output time steps across all output variables
[3395]235    INTEGER                          ::  nv             !< number of netCDF output variables
236    INTEGER                          ::  n_inputs       !< number of input variables
237    INTEGER                          ::  n_output_quantities !< number of physical quantities required for computing netCDF output variables
[2696]238    CHARACTER(LEN=SNAME)             ::  kind           !< kind of I/O group
239    CHARACTER(LEN=PATH), ALLOCATABLE ::  in_files(:)    !< list of nt input files
240    TYPE(nc_var), ALLOCATABLE        ::  out_vars(:)    !< list of output variables
241    TYPE(nc_var), ALLOCATABLE        ::  in_var_list(:) !< list of input variables
242    LOGICAL                          ::  to_be_processed = .FALSE. !< Inifor flag indicating whether I/O group shall be processed
243    LOGICAL                          ::  is_accumulated = .FALSE.  !< Flag indicating whether this I/O group contains accumulated variables
244    LOGICAL                          ::  is_preprocessed = .FALSE. !< Inifor flag indicating whether the I/O group has been preprocessed
245 END TYPE io_group 
246
247
[3557]248!------------------------------------------------------------------------------!
249! Description:
250! ------------
251!> Container for input data arrays. read_input_variables() allocates a
252!> one-dimensional array of containers, to accomodate all inputs of the given
253!> IO group in one variable.
254!------------------------------------------------------------------------------!
[2696]255 TYPE container
[3557]256   REAL(dp), ALLOCATABLE ::  array(:,:,:)               !< generic data array
257   LOGICAL               ::  is_preprocessed = .FALSE.  !< flag indicating whether input array has been preprocessed
[2696]258 END TYPE container
259
[3618]260 END MODULE inifor_types
[3680]261#endif
[2696]262
Note: See TracBrowser for help on using the repository browser.