Ignore:
Timestamp:
Nov 22, 2018 4:01:22 PM (4 years ago)
Author:
eckhard
Message:

inifor: Updated documentation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • palm/trunk/UTIL/inifor/src/inifor_grid.f90

    r3537 r3557  
    2626! -----------------
    2727! $Id$
     28! Updated documentation
     29!
     30!
     31! 3537 2018-11-20 10:53:14Z eckhard
    2832! Read COSMO domain extents and soil depths from input files
    2933! Report averaging mode and debugging mode in log
     
    6973! Authors:
    7074! --------
    71 ! @author Eckhard Kadasch
     75!> @author Eckhard Kadasch (Deutscher Wetterdienst, Offenbach)
    7276!
    7377!------------------------------------------------------------------------------!
     
    193197    INTEGER ::  step_hour !< number of hours between forcing time steps
    194198
    195     LOGICAL ::  init_variables_required
    196     LOGICAL ::  boundary_variables_required
    197     LOGICAL ::  ls_forcing_variables_required
    198     LOGICAL ::  profile_grids_required
    199     LOGICAL ::  surface_forcing_required
     199    LOGICAL ::  init_variables_required       !< flag controlling whether init variables are to be processed
     200    LOGICAL ::  boundary_variables_required   !< flag controlling whether boundary grids are to be allocated and boundary variables are to be computed
     201    LOGICAL ::  ls_forcing_variables_required !< flag controlling whether large-scale forcing variables are to be computed
     202    LOGICAL ::  surface_forcing_required      !< flag controlling whether surface forcing variables are to be computed
    200203
    201204    TYPE(nc_var), ALLOCATABLE, TARGET ::  input_var_table(:)  !< table of input variables
    202205    TYPE(nc_var), ALLOCATABLE, TARGET ::  output_var_table(:) !< table of input variables
    203     TYPE(nc_var)                      ::  cosmo_var           !< COSMO-DE dummy variable, used for reading HHL, rlon, rlat
     206    TYPE(nc_var)                      ::  cosmo_var           !< COSMO dummy variable, used for reading HHL, rlon, rlat
    204207
    205208    TYPE(grid_definition), TARGET ::  palm_grid                       !< PALM-4U grid in the target system (COSMO-DE rotated-pole)
    206209    TYPE(grid_definition), TARGET ::  palm_intermediate               !< PALM-4U grid with coarse vertical grid wiht levels interpolated from COSMO-DE grid
    207210    TYPE(grid_definition), TARGET ::  cosmo_grid                      !< target system (COSMO-DE rotated-pole)
    208     TYPE(grid_definition), TARGET ::  scalars_east_grid               !<
    209     TYPE(grid_definition), TARGET ::  scalars_west_grid               !<
    210     TYPE(grid_definition), TARGET ::  scalars_north_grid              !<
    211     TYPE(grid_definition), TARGET ::  scalars_south_grid              !<
    212     TYPE(grid_definition), TARGET ::  scalars_top_grid                !<
    213     TYPE(grid_definition), TARGET ::  scalars_east_intermediate       !<
    214     TYPE(grid_definition), TARGET ::  scalars_west_intermediate       !<
    215     TYPE(grid_definition), TARGET ::  scalars_north_intermediate      !<
    216     TYPE(grid_definition), TARGET ::  scalars_south_intermediate      !<
    217     TYPE(grid_definition), TARGET ::  scalars_top_intermediate        !<
    218     TYPE(grid_definition), TARGET ::  u_initial_grid                  !<
    219     TYPE(grid_definition), TARGET ::  u_east_grid                     !<
    220     TYPE(grid_definition), TARGET ::  u_west_grid                     !<
    221     TYPE(grid_definition), TARGET ::  u_north_grid                    !<
    222     TYPE(grid_definition), TARGET ::  u_south_grid                    !<
    223     TYPE(grid_definition), TARGET ::  u_top_grid                      !<
    224     TYPE(grid_definition), TARGET ::  u_initial_intermediate          !<
    225     TYPE(grid_definition), TARGET ::  u_east_intermediate             !<
    226     TYPE(grid_definition), TARGET ::  u_west_intermediate             !<
    227     TYPE(grid_definition), TARGET ::  u_north_intermediate            !<
    228     TYPE(grid_definition), TARGET ::  u_south_intermediate            !<
    229     TYPE(grid_definition), TARGET ::  u_top_intermediate              !<
    230     TYPE(grid_definition), TARGET ::  v_initial_grid                  !<
    231     TYPE(grid_definition), TARGET ::  v_east_grid                     !<
    232     TYPE(grid_definition), TARGET ::  v_west_grid                     !<
    233     TYPE(grid_definition), TARGET ::  v_north_grid                    !<
    234     TYPE(grid_definition), TARGET ::  v_south_grid                    !<
    235     TYPE(grid_definition), TARGET ::  v_top_grid                      !<
    236     TYPE(grid_definition), TARGET ::  v_initial_intermediate          !<
    237     TYPE(grid_definition), TARGET ::  v_east_intermediate             !<
    238     TYPE(grid_definition), TARGET ::  v_west_intermediate             !<
    239     TYPE(grid_definition), TARGET ::  v_north_intermediate            !<
    240     TYPE(grid_definition), TARGET ::  v_south_intermediate            !<
    241     TYPE(grid_definition), TARGET ::  v_top_intermediate              !<
    242     TYPE(grid_definition), TARGET ::  w_initial_grid                  !<
    243     TYPE(grid_definition), TARGET ::  w_east_grid                     !<
    244     TYPE(grid_definition), TARGET ::  w_west_grid                     !<
    245     TYPE(grid_definition), TARGET ::  w_north_grid                    !<
    246     TYPE(grid_definition), TARGET ::  w_south_grid                    !<
    247     TYPE(grid_definition), TARGET ::  w_top_grid                      !<
    248     TYPE(grid_definition), TARGET ::  w_initial_intermediate          !<
    249     TYPE(grid_definition), TARGET ::  w_east_intermediate             !<
    250     TYPE(grid_definition), TARGET ::  w_west_intermediate             !<
    251     TYPE(grid_definition), TARGET ::  w_north_intermediate            !<
    252     TYPE(grid_definition), TARGET ::  w_south_intermediate            !<
    253     TYPE(grid_definition), TARGET ::  w_top_intermediate              !<
    254 
    255     TYPE(grid_definition), TARGET ::  north_averaged_scalar_profile
    256     TYPE(grid_definition), TARGET ::  south_averaged_scalar_profile
    257     TYPE(grid_definition), TARGET ::  west_averaged_scalar_profile
    258     TYPE(grid_definition), TARGET ::  east_averaged_scalar_profile
    259     TYPE(grid_definition), TARGET ::  averaged_scalar_profile
    260     TYPE(grid_definition), TARGET ::  averaged_w_profile
     211    TYPE(grid_definition), TARGET ::  scalars_east_grid               !< grid for eastern scalar boundary condition
     212    TYPE(grid_definition), TARGET ::  scalars_west_grid               !< grid for western scalar boundary condition
     213    TYPE(grid_definition), TARGET ::  scalars_north_grid              !< grid for northern scalar boundary condition
     214    TYPE(grid_definition), TARGET ::  scalars_south_grid              !< grid for southern scalar boundary condition
     215    TYPE(grid_definition), TARGET ::  scalars_top_grid                !< grid for top scalar boundary condition
     216    TYPE(grid_definition), TARGET ::  scalars_east_intermediate       !< intermediate grid for eastern scalar boundary condition
     217    TYPE(grid_definition), TARGET ::  scalars_west_intermediate       !< intermediate grid for western scalar boundary condition
     218    TYPE(grid_definition), TARGET ::  scalars_north_intermediate      !< intermediate grid for northern scalar boundary condition
     219    TYPE(grid_definition), TARGET ::  scalars_south_intermediate      !< intermediate grid for southern scalar boundary condition
     220    TYPE(grid_definition), TARGET ::  scalars_top_intermediate        !< intermediate grid for top scalar boundary condition
     221    TYPE(grid_definition), TARGET ::  u_initial_grid                  !< grid for u initial condition
     222    TYPE(grid_definition), TARGET ::  u_east_grid                     !< grid for eastern u boundary condition
     223    TYPE(grid_definition), TARGET ::  u_west_grid                     !< grid for western u boundary condition
     224    TYPE(grid_definition), TARGET ::  u_north_grid                    !< grid for northern u boundary condition
     225    TYPE(grid_definition), TARGET ::  u_south_grid                    !< grid for southern u boundary condition
     226    TYPE(grid_definition), TARGET ::  u_top_grid                      !< grid for top u boundary condition
     227    TYPE(grid_definition), TARGET ::  u_initial_intermediate          !< intermediate grid for u initial condition
     228    TYPE(grid_definition), TARGET ::  u_east_intermediate             !< intermediate grid for eastern u boundary condition
     229    TYPE(grid_definition), TARGET ::  u_west_intermediate             !< intermediate grid for western u boundary condition
     230    TYPE(grid_definition), TARGET ::  u_north_intermediate            !< intermediate grid for northern u boundary condition
     231    TYPE(grid_definition), TARGET ::  u_south_intermediate            !< intermediate grid for southern u boundary condition
     232    TYPE(grid_definition), TARGET ::  u_top_intermediate              !< intermediate grid for top u boundary condition
     233    TYPE(grid_definition), TARGET ::  v_initial_grid                  !< grid for v initial condition
     234    TYPE(grid_definition), TARGET ::  v_east_grid                     !< grid for eastern v boundary condition
     235    TYPE(grid_definition), TARGET ::  v_west_grid                     !< grid for western v boundary condition
     236    TYPE(grid_definition), TARGET ::  v_north_grid                    !< grid for northern v boundary condition
     237    TYPE(grid_definition), TARGET ::  v_south_grid                    !< grid for southern v boundary condition
     238    TYPE(grid_definition), TARGET ::  v_top_grid                      !< grid for top v boundary condition
     239    TYPE(grid_definition), TARGET ::  v_initial_intermediate          !< intermediate grid for v initial condition
     240    TYPE(grid_definition), TARGET ::  v_east_intermediate             !< intermediate grid for eastern v boundary condition
     241    TYPE(grid_definition), TARGET ::  v_west_intermediate             !< intermediate grid for western v boundary condition
     242    TYPE(grid_definition), TARGET ::  v_north_intermediate            !< intermediate grid for northern v boundary condition
     243    TYPE(grid_definition), TARGET ::  v_south_intermediate            !< intermediate grid for southern v boundary condition
     244    TYPE(grid_definition), TARGET ::  v_top_intermediate              !< intermediate grid for top v boundary condition
     245    TYPE(grid_definition), TARGET ::  w_initial_grid                  !< grid for w initial condition
     246    TYPE(grid_definition), TARGET ::  w_east_grid                     !< grid for eastern w boundary condition
     247    TYPE(grid_definition), TARGET ::  w_west_grid                     !< grid for western w boundary condition
     248    TYPE(grid_definition), TARGET ::  w_north_grid                    !< grid for northern w boundary condition
     249    TYPE(grid_definition), TARGET ::  w_south_grid                    !< grid for southern w boundary condition
     250    TYPE(grid_definition), TARGET ::  w_top_grid                      !< grid for top w boundary condition
     251    TYPE(grid_definition), TARGET ::  w_initial_intermediate          !< intermediate grid for w initial condition
     252    TYPE(grid_definition), TARGET ::  w_east_intermediate             !< intermediate grid for eastern w boundary condition
     253    TYPE(grid_definition), TARGET ::  w_west_intermediate             !< intermediate grid for western w boundary condition
     254    TYPE(grid_definition), TARGET ::  w_north_intermediate            !< intermediate grid for northern w boundary condition
     255    TYPE(grid_definition), TARGET ::  w_south_intermediate            !< intermediate grid for southern w boundary condition
     256    TYPE(grid_definition), TARGET ::  w_top_intermediate              !< intermediate grid for top w boundary condition
     257    TYPE(grid_definition), TARGET ::  north_averaged_scalar_profile   !< grid of the northern scalar averaging region
     258    TYPE(grid_definition), TARGET ::  south_averaged_scalar_profile   !< grid of the southern scalar averaging region
     259    TYPE(grid_definition), TARGET ::  west_averaged_scalar_profile    !< grid of the western scalar averaging region
     260    TYPE(grid_definition), TARGET ::  east_averaged_scalar_profile    !< grid of the eastern scalar averaging region
     261    TYPE(grid_definition), TARGET ::  averaged_scalar_profile         !< grid of the central scalar averaging region
     262    TYPE(grid_definition), TARGET ::  averaged_w_profile              !< grid of the central w-velocity averaging region
    261263
    262264    TYPE(io_group), ALLOCATABLE, TARGET ::  io_group_list(:)  !< List of I/O groups, which group together output variables that share the same input variable
    263265 
    264266    NAMELIST /inipar/ nx, ny, nz, dx, dy, dz, longitude, latitude,             &
    265                       dz_max, dz_stretch_factor, dz_stretch_level,             & !< old grid stretching parameters
    266                       dz_stretch_level_start, dz_stretch_level_end               !< new grid stretching parameters
     267                      dz_max, dz_stretch_factor, dz_stretch_level,             &
     268                      dz_stretch_level_start, dz_stretch_level_end
    267269    NAMELIST /d3par/  end_time
    268270   
    269     CHARACTER(LEN=LNAME) ::  nc_source_text     = ''  !< Text describing the source of the output data, e.g. 'COSMO-DE analysis from ...'
    270     CHARACTER(LEN=PATH), ALLOCATABLE, DIMENSION(:) ::  flow_files
    271     CHARACTER(LEN=PATH), ALLOCATABLE, DIMENSION(:) ::  soil_moisture_files
    272     CHARACTER(LEN=PATH), ALLOCATABLE, DIMENSION(:) ::  soil_files
    273     CHARACTER(LEN=PATH), ALLOCATABLE, DIMENSION(:) ::  radiation_files
    274     CHARACTER(LEN=SNAME) ::  input_prefix         !< Prefix of input files, e.g. 'laf' for COSMO-DE analyses
    275     CHARACTER(LEN=SNAME) ::  flow_prefix          !< Prefix of flow input files, e.g. 'laf' for COSMO-DE analyses
    276     CHARACTER(LEN=SNAME) ::  soil_prefix          !< Prefix of soil input files, e.g. 'laf' for COSMO-DE analyses
    277     CHARACTER(LEN=SNAME) ::  radiation_prefix     !< Prefix of radiation input files, e.g. 'laf' for COSMO-DE analyses
    278     CHARACTER(LEN=SNAME) ::  soilmoisture_prefix  !< Prefix of input files for soil moisture spin-up, e.g. 'laf' for COSMO-DE analyses
    279     CHARACTER(LEN=SNAME) ::  flow_suffix          !< Suffix of flow input files, e.g. 'flow'
    280     CHARACTER(LEN=SNAME) ::  soil_suffix          !< Suffix of soil input files, e.g. 'soil'
    281     CHARACTER(LEN=SNAME) ::  radiation_suffix     !< Suffix of radiation input files, e.g. 'radiation'
    282     CHARACTER(LEN=SNAME) ::  soilmoisture_suffix  !< Suffix of input files for soil moisture spin-up, e.g. 'soilmoisture'
     271    CHARACTER(LEN=LNAME) ::  nc_source_text = ''  !< Text describing the source of the output data, e.g. 'COSMO-DE analysis from ...'
     272
     273    CHARACTER(LEN=PATH), ALLOCATABLE, DIMENSION(:) ::  flow_files          !< list of atmospheric input files (<prefix>YYYYMMDDHH-flow.nc)
     274    CHARACTER(LEN=PATH), ALLOCATABLE, DIMENSION(:) ::  soil_moisture_files !< list of precipitation input files (<prefix>YYYYMMDDHH-soilmoisture.nc)
     275    CHARACTER(LEN=PATH), ALLOCATABLE, DIMENSION(:) ::  soil_files          !< list of soil input files (temperature, moisture, <prefix>YYYYMMDDHH-soil.nc)
     276    CHARACTER(LEN=PATH), ALLOCATABLE, DIMENSION(:) ::  radiation_files     !< list of radiation input files (<prefix>YYYYMMDDHH-rad.nc)
     277
     278    CHARACTER(LEN=SNAME) ::  input_prefix         !< prefix of input files, e.g. 'laf' for COSMO-DE analyses
     279    CHARACTER(LEN=SNAME) ::  flow_prefix          !< prefix of flow input files, e.g. 'laf' for COSMO-DE analyses
     280    CHARACTER(LEN=SNAME) ::  soil_prefix          !< prefix of soil input files, e.g. 'laf' for COSMO-DE analyses
     281    CHARACTER(LEN=SNAME) ::  radiation_prefix     !< prefix of radiation input files, e.g. 'laf' for COSMO-DE analyses
     282    CHARACTER(LEN=SNAME) ::  soilmoisture_prefix  !< prefix of input files for soil moisture spin-up, e.g. 'laf' for COSMO-DE analyses
     283    CHARACTER(LEN=SNAME) ::  flow_suffix          !< suffix of flow input files, e.g. 'flow'
     284    CHARACTER(LEN=SNAME) ::  soil_suffix          !< suffix of soil input files, e.g. 'soil'
     285    CHARACTER(LEN=SNAME) ::  radiation_suffix     !< suffix of radiation input files, e.g. 'radiation'
     286    CHARACTER(LEN=SNAME) ::  soilmoisture_suffix  !< suffix of input files for soil moisture spin-up, e.g. 'soilmoisture'
    283287                         
    284     TYPE(nc_file) ::  output_file
    285 
    286     TYPE(inifor_config) ::  cfg !< Container of INIFOR configuration
     288    TYPE(nc_file) ::  output_file !< metadata of the dynamic driver
     289
     290    TYPE(inifor_config) ::  cfg !< container of the INIFOR command-line configuration
    287291
    288292 CONTAINS
    289293   
     294!------------------------------------------------------------------------------!
     295! Description:
     296! ------------
     297!> This routine initializes INIFOR. This includes parsing command-line options,
     298!> setting the names of the input and output files, reading INIFOR's namelist
     299!> file as well as reading in and setting grid parameters for defining
     300!> interplation grids later in setup_grids().
     301!------------------------------------------------------------------------------!
    290302    SUBROUTINE setup_parameters()
    291        INTEGER ::  k
     303       INTEGER ::  k !< loop index
    292304
    293305!
     
    300312       start_hour_soilmoisture = - (4 * 7 * 24) - 2
    301313
    302        ! COSMO-DE default rotated pole
     314!
     315!--    COSMO-DE and -D2 rotated pole position
    303316       phi_n     =   40.0_dp * TO_RADIANS
    304317       phi_equat =   50.0_dp * TO_RADIANS
    305318       lambda_n  = -170.0_dp * TO_RADIANS
    306319
    307        ! Defaultmain centre (_c) of the PALM-4U grid in the geographical system (_g)
     320!
     321!--    Defaultmain centre (_c) of the PALM-4U grid in the geographical system (_g)
    308322       origin_lat = 52.325079_dp * TO_RADIANS ! south-west of Berlin, origin used for the Dec 2017 showcase simulation
    309323       origin_lon = 13.082744_dp * TO_RADIANS
    310324       cfg % z0 = 35.0_dp
    311325
    312        ! Default atmospheric parameters
     326!
     327!--    Default atmospheric parameters
    313328       cfg % ug = 0.0_dp
    314329       cfg % vg = 0.0_dp
    315330       cfg % p0 = P_SL
    316331
    317        ! Parameters for file names
     332!
     333!--    Parameters for file names
    318334       start_hour_flow = 0
    319335       start_hour_soil = 0
     
    323339       step_hour = FORCING_STEP
    324340
    325        input_prefix = 'laf'  ! 'laf' for COSMO-DE analyses
     341       input_prefix = 'laf'
    326342       cfg % flow_prefix = input_prefix
    327343       cfg % input_prefix = input_prefix
     
    342358!------------------------------------------------------------------------------
    343359
    344        ! Set default paths and modes
     360!
     361!--    Set default paths and modes
    345362       cfg % input_path         = './'
    346363       cfg % hhl_file           = ''
     
    353370       cfg % averaging_mode = 'level'
    354371
    355        ! Overwrite defaults with user configuration
     372!
     373!--    Overwrite defaults with user configuration
    356374       CALL parse_command_line_arguments( cfg )
    357375
     
    380398       END IF
    381399
    382 
    383        ! Set default file paths, if not specified by user.
     400!
     401!--    Set default file paths, if not specified by user.
    384402       CALL normalize_path(cfg % input_path)
    385403       IF (TRIM(cfg % hhl_file) == '')  cfg % hhl_file = TRIM(cfg % input_path) // 'hhl.nc'
     
    399417
    400418 CALL run_control('time', 'init')
    401        ! Read in namelist parameters
     419 !
     420 !--   Read in namelist parameters
    402421       OPEN(10, FILE=cfg % namelist_file)
    403422       READ(10, NML=inipar) ! nx, ny, nz, dx, dy, dz
     
    408427       end_hour = CEILING( end_time / 3600.0 * step_hour )
    409428
    410        ! Generate input file lists
     429!
     430!--    Generate input file lists
    411431       CALL get_input_file_list(                                               &
    412432          cfg % start_date, start_hour_flow, end_hour, step_hour,              &
     
    437457
    438458 CALL run_control('time', 'init')
    439        ! Read COSMO-DE soil type map
     459!
     460!--    Read COSMO soil type map
    440461       cosmo_var % name = 'SOILTYP'
    441462       CALL get_netcdf_variable(cfg % soiltyp_file, cosmo_var, soiltyp)
     
    465486       CALL report('setup_parameters', message)
    466487
    467 
    468        ! Read in COSMO-DE heights of half layers (vertical cell faces)
     488!
     489!--    Read in COSMO heights of half layers (vertical cell faces)
    469490       cosmo_var % name = 'HHL'
    470491       CALL get_netcdf_variable(cfg % hhl_file, cosmo_var, hhl)
     
    486507 CALL run_control('time', 'comp')
    487508
    488        ! Appoximate COSMO-DE heights of full layers (cell centres)
     509!
     510!--    Appoximate COSMO-DE heights of full layers (cell centres)
    489511       ALLOCATE( hfl(nlon, nlat, nlev-1) )
    490512       ALLOCATE( d_depth(ndepths), d_depth_rho_inv(ndepths) )
     
    494516       d_depth_rho_inv = 1.0_dp / ( d_depth * RHO_L )
    495517
    496        ! Appoximate COSMO-DE heights of full layers (cell centres)
     518!
     519!--    Appoximate COSMO-DE heights of full layers (cell centres)
    497520       DO k = 1, nlev-1
    498521          hfl(:,:,k) = 0.5_dp * ( hhl(:,:,k) +                                 &
     
    506529! Section 4.2: PALM-4U parameters
    507530!------------------------------------------------------------------------------
    508        ! PALM-4U domain extents
     531!
     532!--    PALM-4U domain extents
    509533       lx = (nx+1) * dx
    510534       ly = (ny+1) * dy
    511535       
    512        ! PALM-4U point of Earth tangency
     536!
     537!--    PALM-4U point of Earth tangency
    513538       x0 = 0.0_dp
    514539       y0 = 0.0_dp
    515540
    516        ! time vector
     541!
     542!--    time vector
    517543       nt = CEILING(end_time / (step_hour * 3600.0_dp)) + 1
    518544       ALLOCATE( time(nt) )
     
    521547 CALL run_control('time', 'init')
    522548
    523 ! Convert the PALM-4U origin coordinates to COSMO's rotated-pole grid
     549!
     550!--    Convert the PALM-4U origin coordinates to COSMO's rotated-pole grid
    524551       phi_c    = TO_RADIANS *                                                 &
    525552                  phi2phirot( origin_lat * TO_DEGREES, origin_lon * TO_DEGREES,&
     
    530557                              0.0_dp )
    531558
    532 ! Set gamma according to whether PALM domain is in the northern or southern
    533 ! hemisphere of the COSMO-DE rotated-pole system. Gamma assumes either the
    534 ! value 0 or PI and is needed to work around around a bug in the rotated-pole
    535 ! coordinate transformations.
     559!
     560!--    Set gamma according to whether PALM domain is in the northern or southern
     561!--    hemisphere of the COSMO rotated-pole system. Gamma assumes either the
     562!--    value 0 or PI and is needed to work around around a bug in the
     563!--    rotated-pole coordinate transformations.
    536564       gam = gamma_from_hemisphere(origin_lat, phi_equat)
    537565
    538 ! Compute the north pole of the rotated-pole grid centred at the PALM-4U domain
    539 ! centre. The resulting (phi_cn, lambda_cn) are coordinates in COSMO-DE's
    540 ! rotated-pole grid.
     566!
     567!--    Compute the north pole of the rotated-pole grid centred at the PALM-4U
     568!--    domain centre. The resulting (phi_cn, lambda_cn) are coordinates in
     569!--    COSMO-DE's rotated-pole grid.
    541570       phi_cn    = phic_to_phin(phi_c)
    542571       lambda_cn = lamc_to_lamn(phi_c, lambda_c)
     
    573602!------------------------------------------------------------------------------
    574603
    575     ! Compute coordiantes of the PALM centre in the source (COSMO) system
     604!
     605!-- Compute coordiantes of the PALM centre in the source (COSMO) system
    576606    phi_centre = phirot2phi(                                                   &
    577607       phirot = project(0.5_dp*ly, y0, EARTH_RADIUS) * TO_DEGREES,             &
     
    595625    CALL report( 'setup_parameters', message )
    596626
    597 
    598     ! Compute boundaries of the central averaging box
     627!
     628!-- Compute boundaries of the central averaging box
    599629    averaging_angle = cfg % averaging_angle * TO_RADIANS
    600630    lam_east = lam_centre + 0.5_dp * averaging_angle
     
    605635    averaging_width_ns = averaging_angle * EARTH_RADIUS
    606636
    607     ! Coriolis parameter
     637!
     638!-- Coriolis parameter
    608639    f3 = 2.0_dp * OMEGA * SIN(                                                 &
    609640       TO_RADIANS*phirot2phi( phi_centre * TO_DEGREES, lam_centre * TO_DEGREES,&
     
    618649! Description:
    619650! ------------
    620 !> Initializes the COSMO-DE, PALM-4U, PALM-4U boundary grids.
     651!> Defines the COSMO, PALM-4U, PALM-4U boundary grids, in partucular their
     652!> coordinates and interpolation weights
    621653!------------------------------------------------------------------------------!
    622     SUBROUTINE setup_grids() ! setup_grids(inifor_settings(with nx, ny, nz,...))
     654    SUBROUTINE setup_grids()
    623655       CHARACTER ::  interp_mode
    624656
     
    626658! Section 0: Define base PALM-4U grid coordinate vectors
    627659!------------------------------------------------------------------------------
    628        ! palm x y z, we allocate the column to nz+1 in order to include the top
    629        ! scalar boundary. The interpolation grids will be associated with
    630        ! a shorter column that omits the top element.
    631        
     660!
     661!--    palm x y z, we allocate the column to nz+1 in order to include the top
     662!--    scalar boundary. The interpolation grids will be associated with
     663!--    a shorter column that omits the top element.
    632664       ALLOCATE( x(0:nx), y(0:ny), z(1:nz), z_column(1:nz+1) )
    633665       CALL linspace(0.5_dp * dx, lx - 0.5_dp * dx, x)
     
    642674       z_top = z_column(nz+1)
    643675
    644        ! palm xu yv zw, compared to the scalar grid, velocity coordinates
    645        ! contain one element less.
     676!
     677!--    palm xu yv zw, compared to the scalar grid, velocity coordinates
     678!--    contain one element less.
    646679       ALLOCATE( xu(1:nx),  yv(1:ny), zw(1:nz-1), zw_column(1:nz))
    647680       CALL linspace(dx, lx - dx, xu)
     
    661694               nx=nx, ny=ny, nz=nz, z=z, zw=zw, ic_mode=cfg % ic_mode)
    662695
    663        ! Subtracting 1 because arrays will be allocated with nlon + 1 elements.
     696!
     697!--    Subtracting 1 because arrays will be allocated with nlon + 1 elements.
    664698       CALL init_grid_definition('cosmo-de', grid=cosmo_grid,                  &
    665699               xmin=lonmin, xmax=lonmax,                                       &
     
    668702               nx=nlon-1, ny=nlat-1, nz=nlev-1)
    669703
    670 ! Define intermediate grid. This is the same as palm_grid except with a much
    671 ! coarser vertical grid. The vertical levels are interpolated in each PALM-4U
    672 ! column from COSMO-DE's secondary levels. The main levels are then computed as
    673 ! the averages of the bounding secondary levels.
     704!
     705!--    Define intermediate grid. This is the same as palm_grid except with a
     706!--    much coarser vertical grid. The vertical levels are interpolated in each
     707!--    PALM column from COSMO's secondary levels. The main levels are then
     708!--    computed as the averages of the bounding secondary levels.
    674709       CALL init_grid_definition('palm intermediate', grid=palm_intermediate,  &
    675710               xmin=0.0_dp, xmax=lx,                                           &
     
    10071042               latmin = phi_south, latmax = phi_north,                         &
    10081043               kind='scalar')
    1009 
    1010        profile_grids_required = ( TRIM(cfg % ic_mode) == 'profile' .OR.        &
    1011                                   TRIM(cfg % bc_mode) == 'ideal' )
    1012 
    1013        !IF (profile_grids_required)  THEN
    1014        !   ! Here, I use the 'boundary' kind, so the vertical coordinate uses the
    1015        !   ! PALM z coordinate.
    1016        !   CALL init_grid_definition('boundary', grid=scalar_profile_grid,      &
    1017        !           xmin = 0.5_dp * lx, xmax = 0.5_dp * lx,                      &
    1018        !           ymin = 0.5_dp * ly, ymax = 0.5_dp * ly,                      &
    1019        !           x0=x0, y0=y0, z0 = z0,                                       &
    1020        !           nx = 0, ny = 0, nz = nz, z=z)
    1021 
    1022        !   CALL init_grid_definition('boundary', grid=w_profile_grid,           &
    1023        !           xmin = 0.5_dp * lx, xmax = 0.5_dp * lx,                      &
    1024        !           ymin = 0.5_dp * ly, ymax = 0.5_dp * ly,                      &
    1025        !           x0=x0, y0=y0, z0 = z0,                                       &
    1026        !           nx = 0, ny = 0, nz = nz - 1, z=zw)
    1027 
    1028        !   CALL init_grid_definition('boundary', grid=scalar_profile_intermediate,&
    1029        !           xmin = 0.5_dp * lx, xmax = 0.5_dp * lx,                      &
    1030        !           ymin = 0.5_dp * ly, ymax = 0.5_dp * ly,                      &
    1031        !           x0=x0, y0=y0, z0 = z0,                                       &
    1032        !           nx = 0, ny = 0, nz = nlev - 2, z=z)
    1033 
    1034        !   CALL init_grid_definition('boundary', grid=w_profile_intermediate,   &
    1035        !           xmin = 0.5_dp * lx, xmax = 0.5_dp * lx,                      &
    1036        !           ymin = 0.5_dp * ly, ymax = 0.5_dp * ly,                      &
    1037        !           x0=x0, y0=y0, z0 = z0,                                       &
    1038        !           nx = 0, ny = 0, nz = nlev - 2, z=zw)
    1039        !END IF
    10401044
    10411045!                                                                             
     
    10911095
    10921096
     1097!------------------------------------------------------------------------------!
     1098! Description:
     1099! ------------
     1100!> Driver for computing neighbour indices and weights for horizontal and
     1101!> vertical interpolation.
     1102!------------------------------------------------------------------------------!
    10931103    SUBROUTINE setup_interpolation(cosmo_grid, grid, intermediate_grid, kind, ic_mode)
    10941104
     
    11061116! Section 1: Horizontal interpolation                                       
    11071117!------------------------------------------------------------------------------
    1108        ! Select horizontal coordinates according to kind of points (s/w, u, v)
     1118!
     1119!--    Select horizontal coordinates according to kind of points (s/w, u, v)
    11091120       SELECT CASE(kind)
    11101121
    1111        CASE('s') ! scalars
     1122!
     1123!--    scalars
     1124       CASE('s')
    11121125
    11131126          cosmo_lat => cosmo_grid % lat
    11141127          cosmo_lon => cosmo_grid % lon
    11151128          cosmo_h   => cosmo_grid % hfl
    1116 
    1117        CASE('w') ! vertical velocity
     1129!
     1130!--    vertical velocity
     1131       CASE('w')
    11181132
    11191133          cosmo_lat => cosmo_grid % lat
    11201134          cosmo_lon => cosmo_grid % lon
    11211135          cosmo_h   => cosmo_grid % hhl
    1122 
    1123        CASE('u') ! x velocity
     1136!
     1137!--    x velocity
     1138       CASE('u')
    11241139
    11251140          cosmo_lat => cosmo_grid % lat
     
    11271142          cosmo_h   => cosmo_grid % hfl
    11281143
    1129        CASE('v') ! y velocity
     1144!
     1145!--    y velocity
     1146       CASE('v')
    11301147
    11311148          cosmo_lat => cosmo_grid % latv
     
    11531170!------------------------------------------------------------------------------
    11541171
    1155        ! If profile initialization is chosen, we--somewhat counterintuitively--
    1156        ! don't need to compute vertical interpolation weights. At least, we
    1157        ! don't need them on the intermediate grid, which fills the entire PALM
    1158        ! domain volume. Instead we need vertical weights for the intermediate
    1159        ! profile grids, which get computed in setup_averaging().
    1160        setup_volumetric = .TRUE.
     1172!
     1173!--    If profile initialization is chosen, we--somewhat counterintuitively--
     1174!--    don't need to compute vertical interpolation weights. At least, we
     1175!--    don't need them on the intermediate grid, which fills the entire PALM
     1176!--    domain volume. Instead we need vertical weights for the intermediate
     1177!--    profile grids, which get computed in setup_averaging().
     1178!--    setup_volumetric = .TRUE.
    11611179       IF (PRESENT(ic_mode))  THEN
    11621180          IF (TRIM(ic_mode) == 'profile')  setup_volumetric = .FALSE.
     
    11691187          intermediate_grid % h(:,:,:) = - EARTH_RADIUS
    11701188
    1171           ! For w points, use hhl, for scalars use hfl
    1172           ! compute the full heights for the intermediate grids
     1189!
     1190!--       For w points, use hhl, for scalars use hfl
     1191!--       compute the full heights for the intermediate grids
    11731192          CALL interpolate_2d(cosmo_h, intermediate_grid % h, intermediate_grid)
    11741193          CALL find_vertical_neighbours_and_weights_interp(grid, intermediate_grid)
     
    12461265           grid % z => z
    12471266
    1248            ! Allocate neighbour indices and weights
     1267!
     1268!--        Allocate neighbour indices and weights
    12491269           IF (TRIM(ic_mode) .NE. 'profile')  THEN
    12501270              ALLOCATE( grid % kk(0:nx, 0:ny, 1:nz, 2) )
     
    12741294           )
    12751295
    1276            ! Allocate neighbour indices and weights
     1296!
     1297!--        Allocate neighbour indices and weights
    12771298           ALLOCATE( grid % ii(0:nx, 0:ny, 4),                                 &
    12781299                     grid % jj(0:nx, 0:ny, 4) )
     
    12831304           grid % w_horiz(:,:,:)   = 0.0_dp
    12841305       
    1285         ! This mode initializes a Cartesian PALM-4U grid and adds the
    1286         ! corresponding latitudes and longitudes of the rotated pole grid.
     1306!
     1307!--     This mode initializes a Cartesian PALM-4U grid and adds the
     1308!--     corresponding latitudes and longitudes of the rotated pole grid.
    12871309        CASE('palm')
    12881310
     
    13011323           grid % name(3) = 'z'
    13021324
    1303            !TODO: Remove use of global dx, dy, dz variables. Consider
    1304            !TODO:   associating global x,y, and z arrays.
     1325!
     1326!--        TODO: Remove use of global dx, dy, dz variables. Consider
     1327!--        TODO: associating global x,y, and z arrays.
    13051328           ALLOCATE( grid % x(0:nx),   grid % y(0:ny) )
    13061329           ALLOCATE( grid % xu(1:nx),  grid % yv(1:ny) )
     
    13141337           grid % depths => depths
    13151338
    1316            ! Allocate neighbour indices and weights
     1339!
     1340!--        Allocate neighbour indices and weights
    13171341           IF (TRIM(ic_mode) .NE. 'profile')  THEN
    13181342              ALLOCATE( grid % kk(0:nx, 0:ny, 1:nz, 2) )
     
    13291353           grid % name(3) = 'interpolated hhl or hfl'
    13301354
    1331            !TODO: Remove use of global dx, dy, dz variables. Consider
    1332            !TODO:   associating global x,y, and z arrays.
     1355!
     1356!--        TODO: Remove use of global dx, dy, dz variables. Consider
     1357!--        TODO: associating global x,y, and z arrays.
    13331358           ALLOCATE( grid % x(0:nx),   grid % y(0:ny) )
    13341359           ALLOCATE( grid % xu(1:nx),  grid % yv(1:ny) )
     
    13401365           grid % depths => depths
    13411366
    1342            ! Allocate rotated-pole coordinates, clon is for (c)osmo-de (lon)gitude
     1367!
     1368!--        Allocate rotated-pole coordinates, clon is for (c)osmo-de (lon)gitude
    13431369           ALLOCATE( grid % clon(0:nx, 0:ny),   grid % clat(0:nx, 0:ny)  )
    13441370           ALLOCATE( grid % clonu(1:nx, 0:ny),  grid % clatu(1:nx, 0:ny) )
    13451371           ALLOCATE( grid % clonv(0:nx, 1:ny),  grid % clatv(0:nx, 1:ny) )
    13461372
    1347            ! Compute rotated-pole coordinates of...
    1348            ! ... PALM-4U centres
     1373!
     1374!--        Compute rotated-pole coordinates of...
     1375!--        ... PALM-4U centres
    13491376           CALL rotate_to_cosmo(                                               &
    13501377              phir = project( grid % y, y0, EARTH_RADIUS ) , & ! = plate-carree latitude
     
    13561383           )
    13571384
    1358            ! ... PALM-4U u winds
     1385!
     1386!--        ... PALM-4U u winds
    13591387           CALL rotate_to_cosmo(                                               &
    13601388              phir = project( grid % y,  y0, EARTH_RADIUS ), & ! = plate-carree latitude
     
    13661394           )
    13671395
    1368            ! ... PALM-4U v winds
     1396!
     1397!--        ... PALM-4U v winds
    13691398           CALL rotate_to_cosmo(                                               &
    13701399              phir = project( grid % yv, y0, EARTH_RADIUS ), & ! = plate-carree latitude
     
    13761405           )
    13771406
    1378            ! Allocate neighbour indices and weights
     1407!
     1408!--        Allocate neighbour indices and weights
    13791409           ALLOCATE( grid % ii(0:nx, 0:ny, 4),                                 &
    13801410                     grid % jj(0:nx, 0:ny, 4) )
     
    13981428           grid % latv(:) = grid % lat + 0.5_dp * (grid % ly / grid % ny)
    13991429
    1400            ! Point to heights of half levels (hhl) and compute heights of full
    1401            ! levels (hfl) as arithmetic averages
     1430!
     1431!--        Point to heights of half levels (hhl) and compute heights of full
     1432!--        levels (hfl) as arithmetic averages
    14021433           grid % hhl => hhl
    14031434           grid % hfl => hfl
     
    14721503       avg_grid % kind = TRIM(kind)
    14731504
    1474        ! Find and store COSMO columns that fall into the coordinate range
    1475        ! given by avg_grid % clon, % clat
     1505!
     1506!--    Find and store COSMO columns that fall into the coordinate range
     1507!--    given by avg_grid % clon, % clat
    14761508       CALL get_cosmo_averaging_region(avg_grid, cosmo_grid)
    14771509
    14781510       ALLOCATE (avg_grid % kkk(avg_grid % n_columns, avg_grid % nz, 2) )
    14791511       ALLOCATE (avg_grid % w(avg_grid % n_columns, avg_grid % nz, 2) )
    1480        ! Compute average COSMO levels in the averaging region
     1512!
     1513!--    Compute average COSMO levels in the averaging region
    14811514       SELECT CASE(avg_grid % kind)
    14821515
     
    14941527       END SELECT
    14951528
    1496        ! For level-besed averaging, compute average heights
     1529!
     1530!--    For level-besed averaging, compute average heights
    14971531       level_based_averaging = .TRUE.
    14981532       IF (level_based_averaging)  THEN
     
    15031537       END IF
    15041538
    1505        ! Copy averaged grid to all COSMO columns, leads to computing the same
    1506        ! vertical interpolation weights for all columns and to COSMO grid level
    1507        ! based averaging onto the averaged COSMO heights.
     1539!
     1540!--    Copy averaged grid to all COSMO columns, leads to computing the same
     1541!--    vertical interpolation weights for all columns and to COSMO grid level
     1542!--    based averaging onto the averaged COSMO heights.
    15081543       IF ( TRIM(cfg % averaging_mode) == 'level' )  THEN
    15091544          FORALL(                                                              &
     
    15131548       END IF
    15141549
    1515        ! Compute vertical weights and neighbours
     1550!
     1551!--    Compute vertical weights and neighbours
    15161552       CALL find_vertical_neighbours_and_weights_average(avg_grid)
    15171553
     
    15501586       END SELECT
    15511587
    1552 
    1553        ! FIXME: make dlon, dlat parameters of the grid_defintion type
     1588!
     1589!--    FIXME: make dlon, dlat parameters of the grid_defintion type
    15541590       dlon = cosmo_lon(1) - cosmo_lon(0)
    15551591       dlat = cosmo_lat(1) - cosmo_lat(0)
     
    16101646       REAL(dp) ::  dz_level_end, dz_stretched
    16111647
    1612        INTEGER ::  dz_stretch_level_end_index(9)               !< vertical grid level index until which the vertical grid spacing is stretched
    1613        INTEGER ::  dz_stretch_level_start_index(9)             !< vertical grid level index above which the vertical grid spacing is stretched
     1648       INTEGER ::  dz_stretch_level_end_index(9)      !< vertical grid level index until which the vertical grid spacing is stretched
     1649       INTEGER ::  dz_stretch_level_start_index(9)    !< vertical grid level index above which the vertical grid spacing is stretched
    16141650       INTEGER ::  dz_stretch_level_index = 0
    16151651       INTEGER ::  k, n, number_dz
     1652
    16161653!
    16171654!-- Compute height of u-levels from constant grid length and dz stretch factors
     
    18261863
    18271864
     1865!------------------------------------------------------------------------------!
    18281866! Description: [PALM subroutine]
    18291867! -----------------------------------------------------------------------------!
     
    19361974             
    19371975!
    1938 !--                stretch_factor_1 is taken to guarantee that the stretching
    1939 !--                procedure ends as close as possible to dz_stretch_level_end.
    1940 !--                stretch_factor_2 would guarantee that the stretched dz(n) is
    1941 !--                equal to dz(n+1) after l_rounded grid levels.
     1976!--          stretch_factor_1 is taken to guarantee that the stretching
     1977!--          procedure ends as close as possible to dz_stretch_level_end.
     1978!--          stretch_factor_2 would guarantee that the stretched dz(n) is
     1979!--          equal to dz(n+1) after l_rounded grid levels.
    19421980             IF (delta_total_new < delta_total_old) THEN
    19431981                dz_stretch_factor_array(n) = stretch_factor_1
     
    19742012 END SUBROUTINE calculate_stretching_factor
    19752013
     2014!------------------------------------------------------------------------------!
     2015! Description:
     2016! ------------
     2017!> Computes the midpoint between two neighbouring coordinates in the given
     2018!> coordinate vector 'z' and stores it in 'zw'.
     2019!------------------------------------------------------------------------------!
    19762020    SUBROUTINE midpoints(z, zw)
    19772021
     
    19872031    END SUBROUTINE midpoints
    19882032
    1989 
     2033!------------------------------------------------------------------------------!
     2034! Description:
     2035! ------------
     2036!> Defines INFOR's IO groups.
     2037!------------------------------------------------------------------------------!
    19902038    SUBROUTINE setup_io_groups()
    19912039
     
    19942042       ngroups = 16
    19952043       ALLOCATE( io_group_list(ngroups) )
    1996        
    1997        !soil temp
     2044
     2045!
     2046!--    soil temp
    19982047       io_group_list(1) = init_io_group(                                       &
    19992048          in_files = soil_files,                                               &
     
    20032052       )
    20042053
    2005        !soil water
     2054!
     2055!--    soil water
    20062056       io_group_list(2) = init_io_group(                                       &
    20072057          in_files = soil_files,                                               &
     
    20112061       )
    20122062
    2013        !potential temperature, surface pressure, specific humidity including
    2014        !nudging and subsidence, and geostrophic winds ug, vg
     2063!
     2064!--    potential temperature, surface pressure, specific humidity including
     2065!--    nudging and subsidence, and geostrophic winds ug, vg
    20152066       io_group_list(3) = init_io_group(                                       &
    20162067          in_files = flow_files,                                               &
     
    20252076       )
    20262077
    2027        !Moved to therodynamic io_group
     2078!
     2079!--    Moved to therodynamic io_group
    20282080       !io_group_list(4) = init_io_group(                                       &
    20292081       !   in_files = flow_files,                                               &
     
    20332085       !)
    20342086
    2035        !u and v velocity, ug anv vg moved to thermodynamic io group.
     2087!
     2088!--    u and v velocity
    20362089       io_group_list(5) = init_io_group(                                       &
    20372090          in_files = flow_files,                                               &
     
    20432096       )
    20442097   
    2045        !!v velocity, deprecated!
     2098!
     2099!--    v velocity, deprecated!
    20462100       !io_group_list(6) = init_io_group(                                       &
    20472101       !   in_files = flow_files,                                               &
     
    20522106       !io_group_list(6) % to_be_processed = .FALSE.
    20532107   
    2054        !w velocity and subsidence and w nudging
     2108!
     2109!--    w velocity and subsidence and w nudging
    20552110       io_group_list(7) = init_io_group(                                       &
    20562111          in_files = flow_files,                                               &
     
    20592114          kind = 'scalar'                                                      &
    20602115       )
    2061 
    2062        !rain
     2116!
     2117!--    rain
    20632118       io_group_list(8) = init_io_group(                                       &
    20642119          in_files = soil_moisture_files,                                      &
     
    20682123       )
    20692124       io_group_list(8) % to_be_processed = .FALSE.
    2070 
    2071        !snow
     2125!
     2126!--    snow
    20722127       io_group_list(9) = init_io_group(                                       &
    20732128          in_files = soil_moisture_files,                                      &
     
    20772132       )
    20782133       io_group_list(9) % to_be_processed = .FALSE.
    2079 
    2080        !graupel
     2134!
     2135!--    graupel
    20812136       io_group_list(10) = init_io_group(                                      &
    20822137          in_files = soil_moisture_files,                                      &
     
    20862141       )
    20872142       io_group_list(10) % to_be_processed = .FALSE.
    2088 
    2089        !evapotranspiration
     2143!
     2144!--    evapotranspiration
    20902145       io_group_list(11) = init_io_group(                                      &
    20912146          in_files = soil_moisture_files,                                      &
     
    20952150       )
    20962151       io_group_list(11) % to_be_processed = .FALSE.
    2097 
    2098        !2m air temperature
     2152!
     2153!--    2m air temperature
    20992154       io_group_list(12) = init_io_group(                                      &
    21002155          in_files = soil_moisture_files,                                      &
     
    21032158          kind = 'surface'                                                     &
    21042159       )
    2105 
    2106        !incoming diffusive sw flux
     2160!
     2161!--    incoming diffusive sw flux
    21072162       io_group_list(13) = init_io_group(                                      &
    21082163          in_files = radiation_files,                                          &
     
    21122167       )
    21132168       io_group_list(13) % to_be_processed = .FALSE.
    2114 
    2115        !incoming direct sw flux
     2169!
     2170!--    incoming direct sw flux
    21162171       io_group_list(14) = init_io_group(                                      &
    21172172          in_files = radiation_files,                                          &
     
    21212176       )
    21222177       io_group_list(14) % to_be_processed = .FALSE.
    2123 
    2124        !sw radiation balance
     2178!
     2179!--    sw radiation balance
    21252180       io_group_list(15) = init_io_group(                                      &
    21262181          in_files = radiation_files,                                          &
     
    21302185       )
    21312186       io_group_list(15) % to_be_processed = .FALSE.
    2132 
    2133        !lw radiation balance
     2187!
     2188!--    lw radiation balance
    21342189       io_group_list(16) = init_io_group(                                      &
    21352190          in_files = radiation_files,                                          &
     
    21432198
    21442199
     2200!------------------------------------------------------------------------------!
     2201! Description:
     2202! ------------
     2203!> Initializes an IO group with the list of input files, the lists of
     2204!> input and output variables, and sets the number of output quantities.
     2205!>
     2206!> In this context, output quantities refers to the physical quantities required
     2207!> to interpolate netCDF output variables, not the output variables itsleft. For
     2208!> instance, the output variables ls_forcing_left/_right/_north/_south all rely
     2209!> on the output quantity Theta.
     2210!------------------------------------------------------------------------------!
    21452211    FUNCTION init_io_group(in_files, out_vars, in_var_list, kind,              &
    21462212                           n_output_quantities) RESULT(group)
     
    21572223       group % n_inputs = SIZE(in_var_list)
    21582224       group % kind = TRIM(kind)
    2159 
     2225!
     2226!--    For the 'thermodynamics' IO group, one quantity more than input variables
     2227!--    is needed to compute all output variables of the IO group. Concretely, in
     2228!--    preprocess() the density is computed from T,P or PP,QV in adddition to
     2229!--    the variables Theta, p, qv. In read_input_variables(),
     2230!--    n_output_quantities is used to allocate the correct number of input
     2231!--    buffers.
    21602232       IF ( PRESENT(n_output_quantities) )  THEN
    21612233          group % n_output_quantities = n_output_quantities
     
    22072279! Description:
    22082280! ------------
    2209 !> Initializes the the variable list.
     2281!> Initializes the variable list.
    22102282!------------------------------------------------------------------------------!
    22112283    SUBROUTINE setup_variable_tables(ic_mode)
     
    27872859          intermediate_grid = palm_intermediate                                &
    27882860       )
    2789        ! Radiation fluxes and balances
     2861
    27902862       output_var_table(38) = init_nc_var(                                     &
    27912863          name              = 'rad_swd_dif_0',                                 &
     
    31543226       output_var_table(64) % to_be_processed = .NOT. cfg % ug_is_set
    31553227
    3156        ! Attributes shared among all variables
     3228!
     3229!--    Attributes shared among all variables
    31573230       output_var_table(:) % source = nc_source_text
    31583231
     
    31643237! Description:
    31653238! ------------
    3166 !> Initializes and nc_var varible with the given parameters. The 'kind'
     3239!> Initializes an nc_var varible with the given parameters. The 'kind'
    31673240!> parameter is used to infer the correct netCDF IDs and the level of detail,
    31683241!> 'lod', as defined by the PALM-4U input data standard.
     
    31993272       SELECT CASE( TRIM(out_var_kind) )
    32003273
    3201        !TODO: Using global module variables 'init_variables_required' and
    3202        !TODO: 'boundary_variables_required'. Encapsulate in settings type
    3203        !TODO: and pass into init_nc_var.
     3274!
     3275!--    TODO: Using global module variables 'init_variables_required' and
     3276!--    TODO: 'boundary_variables_required'. Encapsulate in settings type
     3277!--    TODO: and pass into init_nc_var.
    32043278       CASE( 'init soil' )
    32053279          var % nt              = 1
     
    35913665       
    35923666       CASE( 'velocities' )
    3593           ! Allocate a compute buffer with the same number of arrays as the input
     3667!
     3668!--       Allocate a compute buffer with the same number of arrays as the input
    35943669          ALLOCATE( preprocess_buffer( SIZE(input_buffer) ) )
    35953670
    3596           ! Allocate u and v arrays with scalar dimensions
     3671!
     3672!--       Allocate u and v arrays with scalar dimensions
    35973673          nx = SIZE(input_buffer(1) % array, 1)
    35983674          ny = SIZE(input_buffer(1) % array, 2)
     
    36033679 CALL run_control('time', 'alloc')
    36043680
    3605           ! interpolate U and V to centres
     3681!
     3682!--       interpolate U and V to centres
    36063683          CALL centre_velocities( u_face = input_buffer(1) % array,            &
    36073684                                  v_face = input_buffer(2) % array,            &
     
    36133690
    36143691          CASE('rotated-pole')
    3615              ! rotate U and V to PALM-4U orientation and overwrite U and V with
    3616              ! rotated velocities
     3692!
     3693!--          rotate U and V to PALM-4U orientation and overwrite U and V with
     3694!--          rotated velocities
    36173695             DO k = 1, nz
    36183696             DO j = 1, ny
     
    36373715          END SELECT
    36383716
    3639           ! set values
    36403717          input_buffer(1) % array(1,:,:) = 0.0_dp
    36413718          input_buffer(2) % array(1,:,:) = 0.0_dp
     
    36583735          nz = SIZE(input_buffer(1) % array, 3)
    36593736
    3660           ! Compute absolute pressure if presure perturbation has been read in.
     3737!
     3738!--       Compute absolute pressure if presure perturbation has been read in.
    36613739          IF ( TRIM(group % in_var_list(2) % name) == 'PP' )  THEN
    36623740             message = "Absolute pressure, P, not available, " //              &
     
    36733751                                     RD, G, basic_state_pressure)
    36743752
     3753!
     3754!--             Overwrite pressure perturbation with absolute pressure. HECTO
     3755!--             converts pressure perturbation from hPa to Pa.
    36753756                input_buffer (2) % array(i,j,:) =                              &
    36763757                   HECTO * input_buffer (2) % array(i,j,:) +                   &
     
    36873768
    36883769          END IF
    3689           ! pressure
     3770!
     3771!--       mark pressure as preprocessed
    36903772          input_buffer(2) % is_preprocessed = .TRUE.
    36913773
    3692           ! Copy temperature to last input buffer array
     3774!
     3775!--       Copy temperature to the last input buffer array
    36933776          ALLOCATE(                                                            &
    36943777              input_buffer( group % n_output_quantities ) % array (nx, ny, nz) &
     
    36973780              input_buffer(1) % array(:,:,:)
    36983781
    3699           ! Convert absolute to potential temperature
     3782!
     3783!--       Convert absolute in place to potential temperature
    37003784          CALL potential_temperature(                                          &
    37013785             t = input_buffer(1) % array(:,:,:),                               &
     
    37063790          )
    37073791
    3708           ! potential temperature
     3792!
     3793!--       mark potential temperature as preprocessed
    37093794          input_buffer(1) % is_preprocessed = .TRUE.
    37103795
    3711           ! Convert temperature copy to density
     3796!
     3797!--       Convert temperature copy to density
    37123798          CALL moist_density(                                                  &
    37133799             t_rho = input_buffer(group % n_output_quantities) % array(:,:,:), &
     
    37183804          )
    37193805
    3720           ! qv
     3806!
     3807!--       mark qv as preprocessed
    37213808          input_buffer(3) % is_preprocessed = .TRUE.
    37223809
    3723           ! density
     3810!
     3811!--       mark density as preprocessed
    37243812          input_buffer(group % n_output_quantities) % is_preprocessed = .TRUE.
    37253813
     
    37803868          SELECT CASE(dt)
    37813869
     3870!
     3871!--       input has been accumulated over one hour. Leave as is
     3872!--       input_buffer(1) % array(:,:,:) carrries one-hour integral
    37823873          CASE(1)
    3783              !input has been accumulated over one hour. Leave as is
    3784              !input_buffer(1) % array(:,:,:) carrries one-hour integral
    3785 
     3874
     3875!
     3876!--       input has been accumulated over two hours. Subtract previous step
     3877!--       input_buffer(1) % array(:,:,:) carrries one-hour integral
     3878!--       input_buffer(2) % array(:,:,:) carrries two-hour integral
    37863879          CASE(2)
    3787              !input has been accumulated over two hours. Subtract previous step
    3788              !input_buffer(1) % array(:,:,:) carrries one-hour integral
    3789              !input_buffer(2) % array(:,:,:) carrries two-hour integral
    37903880             CALL deaverage(                                                   &
    37913881                      avg_1 = input_buffer(1) % array(:,:,:), t1 = 1.0_dp,     &
    37923882                      avg_2 = input_buffer(2) % array(:,:,:), t2 = 1.0_dp,     &
    37933883                      avg_3 = input_buffer(1) % array(:,:,:), t3 = 1.0_dp )
    3794              !input_buffer(1) % array(:,:,:) carrries one-hour integral of second hour
    3795 
     3884!
     3885!--          input_buffer(1) % array(:,:,:) carrries one-hour integral of second hour
     3886
     3887!
     3888!--       input has been accumulated over three hours. Subtract previous step
     3889!--       input_buffer(1) % array(:,:,:) carrries three-hour integral
     3890!--       input_buffer(2) % array(:,:,:) still carrries two-hour integral
    37963891          CASE(3)
    3797              !input has been accumulated over three hours. Subtract previous step
    3798              !input_buffer(1) % array(:,:,:) carrries three-hour integral
    3799              !input_buffer(2) % array(:,:,:) still carrries two-hour integral
    38003892             CALL deaverage(                                                   &
    38013893                     avg_1 = input_buffer(2) % array(:,:,:), t1 = 1.0_dp,      &
    38023894                     avg_2 = input_buffer(1) % array(:,:,:), t2 = 1.0_dp,      &
    38033895                     avg_3 = input_buffer(1) % array(:,:,:), t3 = 1.0_dp )
    3804              !input_buffer(1) % array(:,:,:) carrries one-hour integral of third hourA
     3896!
     3897!--          input_buffer(1) % array(:,:,:) carrries one-hour integral of third hourA
    38053898
    38063899          CASE DEFAULT
     
    38183911
    38193912          hour = iter - 1
    3820           dt = MODULO(hour, 3) + 1 ! averaging period
     3913!
     3914!--       averaging period
     3915          dt = MODULO(hour, 3) + 1
    38213916          SELECT CASE(dt)
    3822 
     3917!
     3918!--       input has been accumulated over one hour. Leave as is
     3919!--       input_buffer(1) % array(:,:,:) carrries one-hour integral
    38233920          CASE(1)
    3824              !input has been accumulated over one hour. Leave as is
    3825              !input_buffer(1) % array(:,:,:) carrries one-hour integral
    3826 
     3921
     3922!
     3923!--       input has been accumulated over two hours. Subtract previous step
     3924!--       input_buffer(1) % array(:,:,:) carrries one-hour integral
     3925!--       input_buffer(2) % array(:,:,:) carrries two-hour integral
    38273926          CASE(2)
    3828              !input has been accumulated over two hours. Subtract previous step
    3829              !input_buffer(1) % array(:,:,:) carrries one-hour integral
    3830              !input_buffer(2) % array(:,:,:) carrries two-hour integral
    38313927             CALL deaverage( input_buffer(1) % array(:,:,:), 1.0_dp,           &
    38323928                             input_buffer(2) % array(:,:,:), 2.0_dp,           &
    38333929                             input_buffer(1) % array(:,:,:), 1.0_dp)
    3834              !input_buffer(1) % array(:,:,:) carrries one-hour integral of second hour
    3835 
     3930!
     3931!--          input_buffer(1) % array(:,:,:) carrries one-hour integral of second hour
     3932
     3933!
     3934!--       input has been accumulated over three hours. Subtract previous step
     3935!--       input_buffer(1) % array(:,:,:) carrries three-hour integral
     3936!--       input_buffer(2) % array(:,:,:) still carrries two-hour integral
    38363937          CASE(3)
    3837              !input has been accumulated over three hours. Subtract previous step
    3838              !input_buffer(1) % array(:,:,:) carrries three-hour integral
    3839              !input_buffer(2) % array(:,:,:) still carrries two-hour integral
    38403938             CALL deaverage( input_buffer(2) % array(:,:,:), 2.0_dp,           &
    38413939                             input_buffer(1) % array(:,:,:), 3.0_dp,           &
    38423940                             input_buffer(1) % array(:,:,:), 1.0_dp)
    3843              !input_buffer(1) % array(:,:,:) carrries one-hour integral of third hourA
     3941!
     3942!--          input_buffer(1) % array(:,:,:) carrries one-hour integral of third hourA
    38443943
    38453944          CASE DEFAULT
     
    38603959
    38613960
     3961!------------------------------------------------------------------------------!
    38623962! Description:
    38633963! ------------
     
    39284028                END DO
    39294029
    3930                 ! Overwrite if at least one non-water neighbour cell is available
     4030!
     4031!--             Overwrite if at least one non-water neighbour cell is available
    39314032                IF (n_cells > 0)  THEN
    39324033                   array(i,j,:) = column(:) / n_cells
Note: See TracChangeset for help on using the changeset viewer.