Changeset 4523 for palm/trunk


Ignore:
Timestamp:
May 7, 2020 3:58:16 PM (4 years ago)
Author:
eckhard
Message:

fixed constant-density pressure extrapolation, respect integer working precision

Location:
palm/trunk/UTIL/inifor/src
Files:
8 edited

Legend:

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

    r4481 r4523  
    2626! -----------------
    2727! $Id$
     28! respect integer working precision (iwp) specified in inifor_defs.f90
     29!
     30!
     31! 4481 2020-03-31 18:55:54Z maronga
    2832! Alert user to warnings if any
    2933!
     
    128132        ONLY:  average_pressure_perturbation,                                  &
    129133               average_profile,                                                &
    130                extrapolate_density,                                            &
    131                extrapolate_pressure,                                           &
    132134               geostrophic_winds,                                              &
    133135               get_surface_pressure,                                           &
     
    141143    IMPLICIT NONE
    142144   
    143     INTEGER ::  igroup !< loop index for IO groups
    144     INTEGER ::  ivar   !< loop index for output variables
    145     INTEGER ::  iter   !< loop index for time steps
     145    INTEGER(iwp) ::  igroup !< loop index for IO groups
     146    INTEGER(iwp) ::  ivar   !< loop index for output variables
     147    INTEGER(iwp) ::  iter   !< loop index for time steps
    146148
    147149    REAL(wp), ALLOCATABLE, DIMENSION(:,:,:)     ::  output_arr !< array buffer for interpolated quantities
  • palm/trunk/UTIL/inifor/src/inifor_control.f90

    r4481 r4523  
    2626! -----------------
    2727! $Id$
     28! respect integer working precision (iwp) specified in inifor_defs.f90
     29!
     30!
     31! 4481 2020-03-31 18:55:54Z maronga
    2832! Change output format in routine report to allow for better message formatting
    2933!
     
    8387
    8488    USE inifor_defs,                                                           &
    85         ONLY:  COPYRIGHT, LNAME, LOG_FILE_NAME, VERSION, wp
     89        ONLY:  COPYRIGHT, LNAME, LOG_FILE_NAME, VERSION, iwp, wp
    8690    USE inifor_util,                                                           &
    8791        ONLY:  real_to_str, real_to_str_f
     
    9195    CHARACTER (LEN=5000) ::  message = '' !< log message buffer
    9296    CHARACTER (LEN=5000) ::  tip     = '' !< optional log message buffer for tips on how to rectify encountered errors
    93     INTEGER, SAVE        ::  u            !< Fortran file unit for the log file
    94     INTEGER, SAVE        ::  n_wrngs = 0  !< Fortran file unit for the log file
     97    INTEGER(iwp), SAVE        ::  u            !< Fortran file unit for the log file
     98    INTEGER(iwp), SAVE        ::  n_wrngs = 0  !< Fortran file unit for the log file
    9599
    96100 CONTAINS
  • palm/trunk/UTIL/inifor/src/inifor_defs.f90

    r4499 r4523  
    141141!
    142142!-- COSMO parameters
    143  INTEGER, PARAMETER  ::  WATER_ID = 9                !< Integer corresponding to the water soil type in COSMO-DE [-]
     143 INTEGER(iwp), PARAMETER  ::  WATER_ID = 9                !< Integer corresponding to the water soil type in COSMO-DE [-]
    144144 REAL(wp), PARAMETER ::  EARTH_RADIUS = 6371229.0_wp !< Earth radius used in COSMO-DE [m]
    145145 REAL(wp), PARAMETER ::  P_SL = 1e5_wp               !< Reference pressure for computation of COSMO-DE's basic state pressure [Pa]
     
    181181!
    182182!-- INIFOR parameters
    183  INTEGER, PARAMETER          ::  FILL_ITERATIONS = 5          !< Number of iterations for extrapolating soil data into COSMO-DE
     183 INTEGER(iwp), PARAMETER     ::  FILL_ITERATIONS = 5          !< Number of iterations for extrapolating soil data into COSMO-DE
    184184                                                              !< water cells [-]
    185  INTEGER, PARAMETER          ::  FORCING_STEP = 1             !< Number of hours between forcing time steps [h]
     185 INTEGER(iwp), PARAMETER     ::  FORCING_STEP = 1             !< Number of hours between forcing time steps [h]
    186186 REAL(wp), PARAMETER         ::  NUDGING_TAU = 21600.0_wp     !< Nudging relaxation time scale [s]
    187187 CHARACTER(LEN=*), PARAMETER ::  COPYRIGHT = 'Copyright 2017-2020 Leibniz Universitaet Hannover' // &
    188188    ACHAR( 10 ) // ' Copyright 2017-2020 Deutscher Wetterdienst Offenbach' !< Copyright notice
    189189 CHARACTER(LEN=*), PARAMETER ::  LOG_FILE_NAME = 'inifor.log' !< Name of INIFOR's log file
    190  CHARACTER(LEN=*), PARAMETER ::  VERSION = '1.4.12'           !< INIFOR version number
     190 CHARACTER(LEN=*), PARAMETER ::  VERSION = '1.4.13'           !< INIFOR version number
    191191 
    192192 END MODULE inifor_defs
  • palm/trunk/UTIL/inifor/src/inifor_grid.f90

    r4481 r4523  
    2626! -----------------
    2727! $Id$
     28! respect integer working precision (iwp) specified in inifor_defs.f90
     29!
     30!
     31! 4481 2020-03-31 18:55:54Z maronga
    2832! Bugfix: check if namelist file could be opened without error
    2933!
     
    155159    USE inifor_defs,                                                           &
    156160        ONLY:  DATE, EARTH_RADIUS, TO_RADIANS, TO_DEGREES, PI,                 &
    157                SNAME, LNAME, PATH, FORCING_STEP, WATER_ID, FILL_ITERATIONS,    &
     161               SNAME, LNAME, PATH, FORCING_STEP, FILL_ITERATIONS,              &
    158162               BETA, P_SL, T_SL, BETA, RD, RV, G, P_REF, RD_PALM, CP_PALM,     &
    159163               RHO_L, OMEGA, HECTO, wp, iwp,                                   &
     
    167171    USE inifor_transform,                                                      &
    168172        ONLY:  average_2d, rotate_to_cosmo, find_horizontal_neighbours,        &
    169                compute_horizontal_interp_weights,                              &
     173               compute_horizontal_interp_weights, fill_water_cells,            &
    170174               find_vertical_neighbours_and_weights_interp,                    &
    171175               find_vertical_neighbours_and_weights_average, interpolate_2d,   &
     
    257261
    258262    INTEGER(iwp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  soiltyp     !< COSMO-DE soil type map
    259     INTEGER ::  dz_stretch_level_end_index(9)               !< vertical grid level index until which the vertical grid spacing is stretched
    260     INTEGER ::  dz_stretch_level_start_index(9)             !< vertical grid level index above which the vertical grid spacing is stretched
    261     INTEGER ::  iostat !< return status of READ statement
    262     INTEGER ::  nt    !< number of output time steps
    263     INTEGER ::  nx    !< number of PALM-4U grid points in x direction
    264     INTEGER ::  ny    !< number of PALM-4U grid points in y direction
    265     INTEGER ::  nz    !< number of PALM-4U grid points in z direction
    266     INTEGER ::  nlon  !< number of longitudal points in target grid (COSMO-DE)
    267     INTEGER ::  nlat  !< number of latitudal points in target grid (COSMO-DE)
    268     INTEGER ::  nlev  !< number of levels in target grid (COSMO-DE)
    269     INTEGER ::  ndepths !< number of COSMO-DE soil layers
    270     INTEGER ::  start_hour_flow         !< start of flow forcing in number of hours relative to start_date
    271     INTEGER ::  start_hour_soil         !< start of soil forcing in number of hours relative to start_date, typically equals start_hour_flow
    272     INTEGER ::  start_hour_radiation    !< start of radiation forcing in number of hours relative to start_date, 0 to 2 hours before start_hour_flow to reconstruct hourly averages from one- to three hourly averages of the input data
    273     INTEGER ::  start_hour_soilmoisture !< start of forcing for the soil moisture spin-up in number of hours relative to start_date, typically -672 (-4 weeks)
    274     INTEGER ::  end_hour  !< simulation time in hours
    275     INTEGER ::  end_hour_soilmoisture  !< end of soil moisture spin-up in hours relative to start_hour_flow
    276     INTEGER ::  step_hour !< number of hours between forcing time steps
     263    INTEGER(iwp) ::  dz_stretch_level_end_index(9)               !< vertical grid level index until which the vertical grid spacing is stretched
     264    INTEGER(iwp) ::  dz_stretch_level_start_index(9)             !< vertical grid level index above which the vertical grid spacing is stretched
     265    INTEGER(iwp) ::  iostat !< return status of READ statement
     266    INTEGER(iwp) ::  nt    !< number of output time steps
     267    INTEGER(iwp) ::  nx    !< number of PALM-4U grid points in x direction
     268    INTEGER(iwp) ::  ny    !< number of PALM-4U grid points in y direction
     269    INTEGER(iwp) ::  nz    !< number of PALM-4U grid points in z direction
     270    INTEGER(iwp) ::  nlon  !< number of longitudal points in target grid (COSMO-DE)
     271    INTEGER(iwp) ::  nlat  !< number of latitudal points in target grid (COSMO-DE)
     272    INTEGER(iwp) ::  nlev  !< number of levels in target grid (COSMO-DE)
     273    INTEGER(iwp) ::  ndepths !< number of COSMO-DE soil layers
     274    INTEGER(iwp) ::  start_hour_flow         !< start of flow forcing in number of hours relative to start_date
     275    INTEGER(iwp) ::  start_hour_soil         !< start of soil forcing in number of hours relative to start_date, typically equals start_hour_flow
     276    INTEGER(iwp) ::  start_hour_radiation    !< start of radiation forcing in number of hours relative to start_date, 0 to 2 hours before start_hour_flow to reconstruct hourly averages from one- to three hourly averages of the input data
     277    INTEGER(iwp) ::  start_hour_soilmoisture !< start of forcing for the soil moisture spin-up in number of hours relative to start_date, typically -672 (-4 weeks)
     278    INTEGER(iwp) ::  end_hour  !< simulation time in hours
     279    INTEGER(iwp) ::  end_hour_soilmoisture  !< end of soil moisture spin-up in hours relative to start_hour_flow
     280    INTEGER(iwp) ::  step_hour !< number of hours between forcing time steps
    277281
    278282    LOGICAL ::  init_variables_required       !< flag controlling whether init variables are to be processed
     
    858862               ymin =  0.5_wp * dy, ymax = ly - 0.5_wp * dy,                   &
    859863               x0=x0, y0=y0, z0 = z0,                                          &
    860                nx = 0, ny = ny, nz = nz, z=z)
     864               nx = 0_iwp, ny = ny, nz = nz, z=z)
    861865
    862866       CALL init_grid_definition('boundary', grid=scalars_west_grid,           &
     
    864868               ymin =  0.5_wp * dy, ymax = ly - 0.5_wp * dy,                   &
    865869               x0=x0, y0=y0, z0 = z0,                                          &
    866                nx = 0, ny = ny, nz = nz, z=z)
     870               nx = 0_iwp, ny = ny, nz = nz, z=z)
    867871
    868872       CALL init_grid_definition('boundary', grid=scalars_north_grid,          &
     
    870874               ymin = ly + 0.5_wp * dy, ymax = ly + 0.5_wp * dy,               &
    871875               x0=x0, y0=y0, z0 = z0,                                          &
    872                nx = nx, ny = 0, nz = nz, z=z)
     876               nx = nx, ny = 0_iwp, nz = nz, z=z)
    873877
    874878       CALL init_grid_definition('boundary', grid=scalars_south_grid,          &
     
    876880               ymin = -0.5_wp * dy, ymax = -0.5_wp * dy,                       &
    877881               x0=x0, y0=y0, z0 = z0,                                          &
    878                nx = nx, ny = 0, nz = nz, z=z)
     882               nx = nx, ny = 0_iwp, nz = nz, z=z)
    879883
    880884       CALL init_grid_definition('boundary', grid=scalars_top_grid,            &
     
    882886               ymin =  0.5_wp * dy, ymax = ly - 0.5_wp * dy,                   &
    883887               x0=x0, y0=y0, z0 = z0,                                          &
    884                nx = nx, ny = ny, nz = 1, z=z_top)
     888               nx = nx, ny = ny, nz = 1_iwp, z=z_top)
    885889
    886890       CALL init_grid_definition('boundary', grid=u_east_grid,                 &
     
    888892               ymin = 0.5_wp * dy, ymax = ly - 0.5_wp * dy,                    &
    889893               x0=x0, y0=y0, z0 = z0,                                          &
    890                nx = 0, ny = ny, nz = nz, z=z)
     894               nx = 0_iwp, ny = ny, nz = nz, z=z)
    891895
    892896       CALL init_grid_definition('boundary', grid=u_west_grid,                 &
     
    894898               ymin = 0.5_wp * dy, ymax = ly - 0.5_wp * dy,                    &
    895899               x0=x0, y0=y0, z0 = z0,                                          &
    896                nx = 0, ny = ny, nz = nz, z=z)
     900               nx = 0_iwp, ny = ny, nz = nz, z=z)
    897901
    898902       CALL init_grid_definition('boundary', grid=u_north_grid,                &
     
    900904               ymin = ly + 0.5_wp * dy, ymax = ly + 0.5_wp * dy,               &
    901905               x0=x0, y0=y0, z0 = z0,                                          &
    902                nx = nx-1, ny = 0, nz = nz, z=z)
     906               nx = nx-1, ny = 0_iwp, nz = nz, z=z)
    903907   
    904908       CALL init_grid_definition('boundary', grid=u_south_grid,                &
     
    906910               ymin = -0.5_wp * dy, ymax = -0.5_wp * dy,                       &
    907911               x0=x0, y0=y0, z0 = z0,                                          &
    908                nx = nx-1, ny = 0, nz = nz, z=z)
     912               nx = nx-1, ny = 0_iwp, nz = nz, z=z)
    909913
    910914       CALL init_grid_definition('boundary', grid=u_top_grid,                  &
     
    912916               ymin = 0.5_wp * dy, ymax = ly - 0.5_wp * dy,                    &
    913917               x0=x0, y0=y0, z0 = z0,                                          &
    914                nx = nx-1, ny = ny, nz = 1, z=z_top)
     918               nx = nx-1, ny = ny, nz = 1_iwp, z=z_top)
    915919
    916920       CALL init_grid_definition('boundary', grid=v_east_grid,                 &
     
    918922               ymin = dy, ymax = ly - dy,                                      &
    919923               x0=x0, y0=y0, z0 = z0,                                          &
    920                nx = 0, ny = ny-1, nz = nz, z=z)
     924               nx = 0_iwp, ny = ny-1, nz = nz, z=z)
    921925
    922926       CALL init_grid_definition('boundary', grid=v_west_grid,                 &
     
    924928               ymin = dy, ymax = ly - dy,                                      &
    925929               x0=x0, y0=y0, z0 = z0,                                          &
    926                nx = 0, ny = ny-1, nz = nz, z=z)
     930               nx = 0_iwp, ny = ny-1, nz = nz, z=z)
    927931
    928932       CALL init_grid_definition('boundary', grid=v_north_grid,                &
     
    930934               ymin = ly, ymax = ly,                                           &
    931935               x0=x0, y0=y0, z0 = z0,                                          &
    932                nx = nx, ny = 0, nz = nz, z=z)
     936               nx = nx, ny = 0_iwp, nz = nz, z=z)
    933937
    934938       CALL init_grid_definition('boundary', grid=v_south_grid,                &
     
    936940               ymin = 0.0_wp, ymax = 0.0_wp,                                   &
    937941               x0=x0, y0=y0, z0 = z0,                                          &
    938                nx = nx, ny = 0, nz = nz, z=z)
     942               nx = nx, ny = 0_iwp, nz = nz, z=z)
    939943
    940944       CALL init_grid_definition('boundary', grid=v_top_grid,                  &
     
    942946               ymin = dy, ymax = ly - dy,                                      &
    943947               x0=x0, y0=y0, z0 = z0,                                          &
    944                nx = nx, ny = ny-1, nz = 1, z=(/z_top/))
     948               nx = nx, ny = ny-1, nz = 1_iwp, z=(/z_top/))
    945949
    946950       CALL init_grid_definition('boundary', grid=w_east_grid,                 &
     
    948952               ymin =  0.5_wp * dy, ymax = ly - 0.5_wp * dy,                   &
    949953               x0=x0, y0=y0, z0 = z0,                                          &
    950                nx = 0, ny = ny, nz = nz - 1, z=zw)
     954               nx = 0_iwp, ny = ny, nz = nz - 1, z=zw)
    951955
    952956       CALL init_grid_definition('boundary', grid=w_west_grid,                 &
     
    954958               ymin = 0.5_wp * dy, ymax = ly - 0.5_wp * dy,                    &
    955959               x0=x0, y0=y0, z0 = z0,                                          &
    956                nx = 0, ny = ny, nz = nz - 1, z=zw)
     960               nx = 0_iwp, ny = ny, nz = nz - 1, z=zw)
    957961
    958962       CALL init_grid_definition('boundary', grid=w_north_grid,                &
     
    960964               ymin = ly + 0.5_wp * dy, ymax = ly + 0.5_wp * dy,               &
    961965               x0=x0, y0=y0, z0 = z0,                                          &
    962                nx = nx, ny = 0, nz = nz - 1, z=zw)
     966               nx = nx, ny = 0_iwp, nz = nz - 1, z=zw)
    963967
    964968       CALL init_grid_definition('boundary', grid=w_south_grid,                &
     
    966970               ymin = -0.5_wp * dy, ymax = -0.5_wp * dy,                       &
    967971               x0=x0, y0=y0, z0 = z0,                                          &
    968                nx = nx, ny = 0, nz = nz - 1, z=zw)
     972               nx = nx, ny = 0_iwp, nz = nz - 1, z=zw)
    969973
    970974       CALL init_grid_definition('boundary', grid=w_top_grid,                  &
     
    972976               ymin = 0.5_wp * dy, ymax = ly - 0.5_wp * dy,                    &
    973977               x0=x0, y0=y0, z0 = z0,                                          &
    974                nx = nx, ny = ny, nz = 1, z=zw_top)
     978               nx = nx, ny = ny, nz = 1_iwp, z=zw_top)
    975979
    976980       CALL init_grid_definition('boundary intermediate', grid=scalars_east_intermediate,   &
     
    978982               ymin =  0.5_wp * dy, ymax = ly - 0.5_wp * dy,                   &
    979983               x0=x0, y0=y0, z0 = z0,                                          &
    980                nx = 0, ny = ny, nz = nlev - 2)
     984               nx = 0_iwp, ny = ny, nz = nlev - 2)
    981985
    982986       CALL init_grid_definition('boundary intermediate', grid=scalars_west_intermediate,   &
     
    984988               ymin =  0.5_wp * dy, ymax = ly - 0.5_wp * dy,                   &
    985989               x0=x0, y0=y0, z0 = z0,                                          &
    986                nx = 0, ny = ny, nz = nlev - 2)
     990               nx = 0_iwp, ny = ny, nz = nlev - 2)
    987991
    988992       CALL init_grid_definition('boundary intermediate', grid=scalars_north_intermediate,  &
     
    990994               ymin = ly + 0.5_wp * dy, ymax = ly + 0.5_wp * dy,               &
    991995               x0=x0, y0=y0, z0 = z0,                                          &
    992                nx = nx, ny = 0, nz = nlev - 2)
     996               nx = nx, ny = 0_iwp, nz = nlev - 2)
    993997
    994998       CALL init_grid_definition('boundary intermediate', grid=scalars_south_intermediate,  &
     
    9961000               ymin = -0.5_wp * dy, ymax = -0.5_wp * dy,                       &
    9971001               x0=x0, y0=y0, z0 = z0,                                          &
    998                nx = nx, ny = 0, nz = nlev - 2)
     1002               nx = nx, ny = 0_iwp, nz = nlev - 2)
    9991003
    10001004       CALL init_grid_definition('boundary intermediate', grid=scalars_top_intermediate,    &
     
    10081012               ymin = 0.5_wp * dy, ymax = ly - 0.5_wp * dy,                    &
    10091013               x0=x0, y0=y0, z0 = z0,                                          &
    1010                nx = 0, ny = ny, nz = nlev - 2)
     1014               nx = 0_iwp, ny = ny, nz = nlev - 2)
    10111015
    10121016       CALL init_grid_definition('boundary intermediate', grid=u_west_intermediate,         &
     
    10141018               ymin = 0.5_wp * dy, ymax = ly - 0.5_wp * dy,                    &
    10151019               x0=x0, y0=y0, z0 = z0,                                          &
    1016                nx = 0, ny = ny, nz = nlev - 2)
     1020               nx = 0_iwp, ny = ny, nz = nlev - 2)
    10171021
    10181022       CALL init_grid_definition('boundary intermediate', grid=u_north_intermediate,        &
     
    10201024               ymin = ly + 0.5_wp * dy, ymax = ly + 0.5_wp * dy,               &
    10211025               x0=x0, y0=y0, z0 = z0,                                          &
    1022                nx = nx-1, ny = 0, nz = nlev - 2)
     1026               nx = nx-1, ny = 0_iwp, nz = nlev - 2)
    10231027
    10241028       CALL init_grid_definition('boundary intermediate', grid=u_south_intermediate,        &
     
    10261030               ymin = -0.5_wp * dy, ymax = -0.5_wp * dy,                       &
    10271031               x0=x0, y0=y0, z0 = z0,                                          &
    1028                nx = nx-1, ny = 0, nz = nlev - 2)
     1032               nx = nx-1, ny = 0_iwp, nz = nlev - 2)
    10291033
    10301034       CALL init_grid_definition('boundary intermediate', grid=u_top_intermediate,          &
     
    10381042               ymin = dy, ymax = ly - dy,                                      &
    10391043               x0=x0, y0=y0, z0 = z0,                                          &
    1040                nx = 0, ny = ny-1, nz = nlev - 2)
     1044               nx = 0_iwp, ny = ny-1, nz = nlev - 2)
    10411045
    10421046       CALL init_grid_definition('boundary intermediate', grid=v_west_intermediate,         &
     
    10441048               ymin = dy, ymax = ly - dy,                                      &
    10451049               x0=x0, y0=y0, z0 = z0,                                          &
    1046                nx = 0, ny = ny-1, nz = nlev - 2)
     1050               nx = 0_iwp, ny = ny-1, nz = nlev - 2)
    10471051
    10481052       CALL init_grid_definition('boundary intermediate', grid=v_north_intermediate,        &
     
    10501054               ymin = ly, ymax = ly,                                           &
    10511055               x0=x0, y0=y0, z0 = z0,                                          &
    1052                nx = nx, ny = 0, nz = nlev - 2)
     1056               nx = nx, ny = 0_iwp, nz = nlev - 2)
    10531057
    10541058       CALL init_grid_definition('boundary intermediate', grid=v_south_intermediate,        &
     
    10561060               ymin = 0.0_wp, ymax = 0.0_wp,                                   &
    10571061               x0=x0, y0=y0, z0 = z0,                                          &
    1058                nx = nx, ny = 0, nz = nlev - 2)
     1062               nx = nx, ny = 0_iwp, nz = nlev - 2)
    10591063
    10601064       CALL init_grid_definition('boundary intermediate', grid=v_top_intermediate,          &
     
    10681072               ymin =  0.5_wp * dy, ymax = ly - 0.5_wp * dy,                   &
    10691073               x0=x0, y0=y0, z0 = z0,                                          &
    1070                nx = 0, ny = ny, nz = nlev - 1)
     1074               nx = 0_iwp, ny = ny, nz = nlev - 1)
    10711075
    10721076       CALL init_grid_definition('boundary intermediate', grid=w_west_intermediate,         &
     
    10741078               ymin =  0.5_wp * dy, ymax = ly - 0.5_wp * dy,                   &
    10751079               x0=x0, y0=y0, z0 = z0,                                          &
    1076                nx = 0, ny = ny, nz = nlev - 1)
     1080               nx = 0_iwp, ny = ny, nz = nlev - 1)
    10771081
    10781082       CALL init_grid_definition('boundary intermediate', grid=w_north_intermediate,        &
     
    10801084               ymin = ly + 0.5_wp * dy, ymax = ly + 0.5_wp * dy,               &
    10811085               x0=x0, y0=y0, z0 = z0,                                          &
    1082                nx = nx, ny = 0, nz = nlev - 1)
     1086               nx = nx, ny = 0_iwp, nz = nlev - 1)
    10831087
    10841088       CALL init_grid_definition('boundary intermediate', grid=w_south_intermediate,        &
     
    10861090               ymin = -0.5_wp * dy, ymax = -0.5_wp * dy,                       &
    10871091               x0=x0, y0=y0, z0 = z0,                                          &
    1088                nx = nx, ny = 0, nz = nlev - 1)
     1092               nx = nx, ny = 0_iwp, nz = nlev - 1)
    10891093
    10901094       CALL init_grid_definition('boundary intermediate', grid=w_top_intermediate,          &
     
    13441348    CHARACTER(LEN=*), INTENT(IN)           ::  kind
    13451349    CHARACTER(LEN=*), INTENT(IN), OPTIONAL ::  ic_mode
    1346     INTEGER, INTENT(IN)                    ::  nx, ny, nz
     1350    INTEGER(iwp), INTENT(IN)               ::  nx, ny, nz
    13471351    REAL(wp), INTENT(IN)                   ::  xmin, xmax, ymin, ymax
    13481352    REAL(wp), INTENT(IN)                   ::  x0, y0, z0
     
    16711675    REAL(wp)                                     ::  dlon, dlat
    16721676
    1673     INTEGER ::  i, j, imin, imax, jmin, jmax, l, nx, ny
     1677    INTEGER(iwp) ::  i, j, imin, imax, jmin, jmax, l, nx, ny
    16741678
    16751679
     
    17491753    REAL(wp), INTENT(IN) ::  dz_max, dz_stretch_factor, dz_stretch_level
    17501754
    1751     INTEGER ::  number_stretch_level_start        !< number of user-specified start levels for stretching
    1752     INTEGER ::  number_stretch_level_end          !< number of user-specified end levels for stretching
     1755    INTEGER(iwp) ::  number_stretch_level_start        !< number of user-specified start levels for stretching
     1756    INTEGER(iwp) ::  number_stretch_level_end          !< number of user-specified end levels for stretching
    17531757
    17541758    REAL(wp), DIMENSION(:), ALLOCATABLE ::  min_dz_stretch_level_end
    17551759    REAL(wp) ::  dz_level_end, dz_stretched
    17561760
    1757     INTEGER ::  dz_stretch_level_end_index(9)      !< vertical grid level index until which the vertical grid spacing is stretched
    1758     INTEGER ::  dz_stretch_level_start_index(9)    !< vertical grid level index above which the vertical grid spacing is stretched
    1759     INTEGER ::  dz_stretch_level_index = 0
    1760     INTEGER ::  k, n, number_dz
     1761    INTEGER(iwp) ::  dz_stretch_level_end_index(9)      !< vertical grid level index until which the vertical grid spacing is stretched
     1762    INTEGER(iwp) ::  dz_stretch_level_start_index(9)    !< vertical grid level index above which the vertical grid spacing is stretched
     1763    INTEGER(iwp) ::  dz_stretch_level_index = 0
     1764    INTEGER(iwp) ::  k, n, number_dz
    17611765
    17621766!
     
    19901994    REAL(wp), DIMENSION(:), INTENT(IN)    ::  dz_stretch_level_end, dz_stretch_level_start
    19911995 
    1992     INTEGER ::  iterations  !< number of iterations until stretch_factor_lower/upper_limit is reached 
    1993     INTEGER ::  l_rounded   !< after l_rounded grid levels dz(n) is strechted to dz(n+1) with stretch_factor_2
    1994     INTEGER ::  n           !< loop variable for stretching
     1996    INTEGER(iwp) ::  iterations  !< number of iterations until stretch_factor_lower/upper_limit is reached 
     1997    INTEGER(iwp) ::  l_rounded   !< after l_rounded grid levels dz(n) is strechted to dz(n+1) with stretch_factor_2
     1998    INTEGER(iwp) ::  n           !< loop variable for stretching
    19951999   
    1996     INTEGER, INTENT(IN) ::  number_end !< number of user-specified end levels for stretching
     2000    INTEGER(iwp), INTENT(IN) ::  number_end !< number of user-specified end levels for stretching
    19972001       
    19982002    REAL(wp) ::  delta_l               !< absolute difference between l and l_rounded
     
    21302134     REAL(wp), INTENT(OUT) ::  zw(1:)
    21312135
    2132      INTEGER ::  k
     2136     INTEGER(iwp) ::  k
    21332137
    21342138     DO  k = 1, UBOUND(zw, 1)
     
    21452149 SUBROUTINE setup_io_groups()
    21462150
    2147     INTEGER ::  ngroups
     2151    INTEGER(iwp) ::  ngroups
    21482152
    21492153    ngroups = 16
     
    21802184                       input_var_table(4) /),                               &
    21812185       kind = 'thermodynamics',                                             &
    2182        n_output_quantities = 4                                              & ! P, Theta, Rho, qv
     2186       n_output_quantities = 4_iwp                                          & ! P, Theta, Rho, qv
    21832187    )
    21842188
     
    23232327    TYPE(nc_var), INTENT(IN)        ::  out_vars(:)
    23242328    TYPE(nc_var), INTENT(IN)        ::  in_var_list(:)
    2325     INTEGER, OPTIONAL               ::  n_output_quantities
     2329    INTEGER(iwp), OPTIONAL          ::  n_output_quantities
    23262330
    23272331    TYPE(io_group)                  ::  group
     
    23912395 SUBROUTINE setup_variable_tables(ic_mode)
    23922396    CHARACTER(LEN=*), INTENT(IN) ::  ic_mode
    2393     INTEGER                      ::  n_invar = 0  !< number of variables in the input variable table
    2394     INTEGER                      ::  n_outvar = 0 !< number of variables in the output variable table
     2397    INTEGER(iwp)                 ::  n_invar = 0  !< number of variables in the input variable table
     2398    INTEGER(iwp)                 ::  n_outvar = 0 !< number of variables in the output variable table
    23952399    TYPE(nc_var), POINTER        ::  var
    23962400
     
    25102514       units             = "K",                                             &
    25112515       kind              = "init soil",                                     &
    2512        input_id          = 1,                                               &
     2516       input_id          = 1_iwp,                                           &
    25132517       output_file       = output_file,                                     &
    25142518       grid              = palm_grid,                                       &
     
    25222526       units             = "m^3/m^3",                                       &
    25232527       kind              = "init soil",                                     &
    2524        input_id          = 1,                                               &
     2528       input_id          = 1_iwp,                                           &
    25252529       output_file       = output_file,                                     &
    25262530       grid              = palm_grid,                                       &
     
    25342538       units             = "K",                                             &
    25352539       kind              = "init scalar",                                   &
    2536        input_id          = 1,                                               & ! first in (T, p) IO group
     2540       input_id          = 1_iwp,                                           & ! first in (T, p) IO group
    25372541       output_file       = output_file,                                     &
    25382542       grid              = palm_grid,                                       &
     
    25502554       units             = "K",                                             &
    25512555       kind              = "left scalar",                                   &
    2552        input_id          = 1,                                               &
     2556       input_id          = 1_iwp,                                           &
    25532557       grid              = scalars_west_grid,                               &
    25542558       intermediate_grid = scalars_west_intermediate,                       &
     
    25622566       units             = "K",                                             &
    25632567       kind              = "right scalar",                                  &
    2564        input_id          = 1,                                               &
     2568       input_id          = 1_iwp,                                           &
    25652569       grid              = scalars_east_grid,                               &
    25662570       intermediate_grid = scalars_east_intermediate,                       &
     
    25742578       units             = "K",                                             &
    25752579       kind              = "north scalar",                                  &
    2576        input_id          = 1,                                               &
     2580       input_id          = 1_iwp,                                           &
    25772581       grid              = scalars_north_grid,                              &
    25782582       intermediate_grid = scalars_north_intermediate,                      &
     
    25862590       units             = "K",                                             &
    25872591       kind              = "south scalar",                                  &
    2588        input_id          = 1,                                               &
     2592       input_id          = 1_iwp,                                           &
    25892593       grid              = scalars_south_grid,                              &
    25902594       intermediate_grid = scalars_south_intermediate,                      &
     
    25982602       units             = "K",                                             &
    25992603       kind              = "top scalar",                                    &
    2600        input_id          = 1,                                               &
     2604       input_id          = 1_iwp,                                           &
    26012605       grid              = scalars_top_grid,                                &
    26022606       intermediate_grid = scalars_top_intermediate,                        &
     
    26102614       units             = "kg/kg",                                         &
    26112615       kind              = "init scalar",                                   &
    2612        input_id          = 3,                                               &
     2616       input_id          = 3_iwp,                                           &
    26132617       output_file       = output_file,                                     &
    26142618       grid              = palm_grid,                                       &
     
    26262630       units             = "kg/kg",                                         &
    26272631       kind              = "left scalar",                                   &
    2628        input_id          = 3,                                               &
     2632       input_id          = 3_iwp,                                           &
    26292633       output_file       = output_file,                                     &
    26302634       grid              = scalars_west_grid,                               &
     
    26382642       units             = "kg/kg",                                         &
    26392643       kind              = "right scalar",                                  &
    2640        input_id          = 3,                                               &
     2644       input_id          = 3_iwp,                                           &
    26412645       output_file       = output_file,                                     &
    26422646       grid              = scalars_east_grid,                               &
     
    26502654       units             = "kg/kg",                                         &
    26512655       kind              = "north scalar",                                  &
    2652        input_id          = 3,                                               &
     2656       input_id          = 3_iwp,                                           &
    26532657       output_file       = output_file,                                     &
    26542658       grid              = scalars_north_grid,                              &
     
    26622666       units             = "kg/kg",                                         &
    26632667       kind              = "south scalar",                                  &
    2664        input_id          = 3,                                               &
     2668       input_id          = 3_iwp,                                           &
    26652669       output_file       = output_file,                                     &
    26662670       grid              = scalars_south_grid,                              &
     
    26742678       units             = "kg/kg",                                         &
    26752679       kind              = "top scalar",                                    &
    2676        input_id          = 3,                                               &
     2680       input_id          = 3_iwp,                                           &
    26772681       output_file       = output_file,                                     &
    26782682       grid              = scalars_top_grid,                                &
     
    26862690       units             = "m/s",                                           &
    26872691       kind              = "init u",                                        &
    2688        input_id          = 1,                                               & ! first in (U, V) I/O group
     2692       input_id          = 1_iwp,                                           & ! first in (U, V) I/O group
    26892693       output_file       = output_file,                                     &
    26902694       grid              = u_initial_grid,                                  &
     
    27022706       units             = "m/s",                                           &
    27032707       kind              = "left u",                                        &
    2704        input_id          = 1,                                               & ! first in (U, V) I/O group
     2708       input_id          = 1_iwp,                                           & ! first in (U, V) I/O group
    27052709       output_file       = output_file,                                     &
    27062710       grid              = u_west_grid,                                     &
     
    27142718       units             = "m/s",                                           &
    27152719       kind              = "right u",                                       &
    2716        input_id          = 1,                                               & ! first in (U, V) I/O group
     2720       input_id          = 1_iwp,                                           & ! first in (U, V) I/O group
    27172721       output_file       = output_file,                                     &
    27182722       grid              = u_east_grid,                                     &
     
    27262730       units             = "m/s",                                           &
    27272731       kind              = "north u",                                       &
    2728        input_id          = 1,                                               & ! first in (U, V) I/O group
     2732       input_id          = 1_iwp,                                           & ! first in (U, V) I/O group
    27292733       output_file       = output_file,                                     &
    27302734       grid              = u_north_grid,                                    &
     
    27382742       units             = "m/s",                                           &
    27392743       kind              = "south u",                                       &
    2740        input_id          = 1,                                               & ! first in (U, V) I/O group
     2744       input_id          = 1_iwp,                                           & ! first in (U, V) I/O group
    27412745       output_file       = output_file,                                     &
    27422746       grid              = u_south_grid,                                    &
     
    27502754       units             = "m/s",                                           &
    27512755       kind              = "top u",                                         &
    2752        input_id          = 1,                                               & ! first in (U, V) I/O group
     2756       input_id          = 1_iwp,                                           & ! first in (U, V) I/O group
    27532757       output_file       = output_file,                                     &
    27542758       grid              = u_top_grid,                                      &
     
    27622766       units             = "m/s",                                           &
    27632767       kind              = "init v",                                        &
    2764        input_id          = 2,                                               & ! second in (U, V) I/O group
     2768       input_id          = 2_iwp,                                           & ! second in (U, V) I/O group
    27652769       output_file       = output_file,                                     &
    27662770       grid              = v_initial_grid,                                  &
     
    27782782       units             = "m/s",                                           &
    27792783       kind              = "right v",                                       &
    2780        input_id          = 2,                                               & ! second in (U, V) I/O group
     2784       input_id          = 2_iwp,                                           & ! second in (U, V) I/O group
    27812785       output_file       = output_file,                                     &
    27822786       grid              = v_west_grid,                                     &
     
    27902794       units             = "m/s",                                           &
    27912795       kind              = "right v",                                       &
    2792        input_id          = 2,                                               & ! second in (U, V) I/O group
     2796       input_id          = 2_iwp,                                           & ! second in (U, V) I/O group
    27932797       output_file       = output_file,                                     &
    27942798       grid              = v_east_grid,                                     &
     
    28022806       units             = "m/s",                                           &
    28032807       kind              = "north v",                                       &
    2804        input_id          = 2,                                               & ! second in (U, V) I/O group
     2808       input_id          = 2_iwp,                                           & ! second in (U, V) I/O group
    28052809       output_file       = output_file,                                     &
    28062810       grid              = v_north_grid,                                    &
     
    28142818       units             = "m/s",                                           &
    28152819       kind              = "south v",                                       &
    2816        input_id          = 2,                                               & ! second in (U, V) I/O group
     2820       input_id          = 2_iwp,                                           & ! second in (U, V) I/O group
    28172821       output_file       = output_file,                                     &
    28182822       grid              = v_south_grid,                                    &
     
    28262830       units             = "m/s",                                           &
    28272831       kind              = "top v",                                         &
    2828        input_id          = 2,                                               & ! second in (U, V) I/O group
     2832       input_id          = 2_iwp,                                           & ! second in (U, V) I/O group
    28292833       output_file       = output_file,                                     &
    28302834       grid              = v_top_grid,                                      &
     
    28382842       units             = "m/s",                                           &
    28392843       kind              = "init w",                                        &
    2840        input_id          = 1,                                               &
     2844       input_id          = 1_iwp,                                           &
    28412845       output_file       = output_file,                                     &
    28422846       grid              = w_initial_grid,                                  &
     
    28542858       units             = "m/s",                                           &
    28552859       kind              = "left w",                                        &
    2856        input_id          = 1,                                               &
     2860       input_id          = 1_iwp,                                           &
    28572861       output_file       = output_file,                                     &
    28582862       grid              = w_west_grid,                                     &
     
    28662870       units             = "m/s",                                           &
    28672871       kind              = "right w",                                       &
    2868        input_id          = 1,                                               &
     2872       input_id          = 1_iwp,                                           &
    28692873       output_file       = output_file,                                     &
    28702874       grid              = w_east_grid,                                     &
     
    28782882       units             = "m/s",                                           &
    28792883       kind              = "north w",                                       &
    2880        input_id          = 1,                                               &
     2884       input_id          = 1_iwp,                                           &
    28812885       output_file       = output_file,                                     &
    28822886       grid              = w_north_grid,                                    &
     
    28902894       units             = "m/s",                                           &
    28912895       kind              = "south w",                                       &
    2892        input_id          = 1,                                               &
     2896       input_id          = 1_iwp,                                           &
    28932897       output_file       = output_file,                                     &
    28942898       grid              = w_south_grid,                                    &
     
    29022906       units             = "m/s",                                           &
    29032907       kind              = "top w",                                         &
    2904        input_id          = 1,                                               &
     2908       input_id          = 1_iwp,                                           &
    29052909       output_file       = output_file,                                     &
    29062910       grid              = w_top_grid,                                      &
     
    29142918       units             = "kg/m2",                                         &
    29152919       kind              = "surface forcing",                               &
    2916        input_id          = 1,                                               &
     2920       input_id          = 1_iwp,                                           &
    29172921       output_file       = output_file,                                     &
    29182922       grid              = palm_grid,                                       &
     
    29262930       units             = "kg/m2",                                         &
    29272931       kind              = "surface forcing",                               &
    2928        input_id          = 1,                                               &
     2932       input_id          = 1_iwp,                                           &
    29292933       output_file       = output_file,                                     &
    29302934       grid              = palm_grid,                                       &
     
    29382942       units             = "kg/m2",                                         &
    29392943       kind              = "surface forcing",                               &
    2940        input_id          = 1,                                               &
     2944       input_id          = 1_iwp,                                           &
    29412945       output_file       = output_file,                                     &
    29422946       grid              = palm_grid,                                       &
     
    29502954       units             = "kg/m2",                                         &
    29512955       kind              = "surface forcing",                               &
    2952        input_id          = 1,                                               &
     2956       input_id          = 1_iwp,                                           &
    29532957       output_file       = output_file,                                     &
    29542958       grid              = palm_grid,                                       &
     
    29622966       units             = "kg/m2",                                         &
    29632967       kind              = "surface forcing",                               &
    2964        input_id          = 1,                                               &
     2968       input_id          = 1_iwp,                                           &
    29652969       output_file       = output_file,                                     &
    29662970       grid              = palm_grid,                                       &
     
    29742978       units             = "W/m2",                                          &
    29752979       kind              = "surface forcing",                               &
    2976        input_id          = 1,                                               &
     2980       input_id          = 1_iwp,                                           &
    29772981       output_file       = output_file,                                     &
    29782982       grid              = palm_grid,                                       &
     
    29862990       units             = "W/m2",                                          &
    29872991       kind              = "surface forcing",                               &
    2988        input_id          = 1,                                               &
     2992       input_id          = 1_iwp,                                           &
    29892993       output_file       = output_file,                                     &
    29902994       grid              = palm_grid,                                       &
     
    29983002       units             = "W/m2",                                          &
    29993003       kind              = "surface forcing",                               &
    3000        input_id          = 1,                                               &
     3004       input_id          = 1_iwp,                                           &
    30013005       output_file       = output_file,                                     &
    30023006       grid              = palm_grid,                                       &
     
    30103014       units             = "W/m2",                                          &
    30113015       kind              = "surface forcing",                               &
    3012        input_id          = 1,                                               &
     3016       input_id          = 1_iwp,                                           &
    30133017       output_file       = output_file,                                     &
    30143018       grid              = palm_grid,                                       &
     
    30253029       units             = "Pa",                                            &
    30263030       kind              = "time series",                                   &
    3027        input_id          = 2,                                               & ! second in (T, p) I/O group
     3031       input_id          = 2_iwp,                                           & ! second in (T, p) I/O group
    30283032       output_file       = output_file,                                     &
    30293033       grid              = palm_grid,                                       &
     
    30383042       units             = "m/s",                                           &
    30393043       kind              = "geostrophic",                                   &
    3040        input_id          = 1,                                               &
     3044       input_id          = 1_iwp,                                           &
    30413045       output_file       = output_file,                                     &
    30423046       grid              = averaged_scalar_profile,                         &
     
    30503054       units             = "m/s",                                           &
    30513055       kind              = "geostrophic",                                   &
    3052        input_id          = 1,                                               &
     3056       input_id          = 1_iwp,                                           &
    30533057       output_file       = output_file,                                     &
    30543058       grid              = averaged_scalar_profile,                         &
     
    30623066       units             = "m/s",                                           &
    30633067       kind              = "geostrophic",                                   &
    3064        input_id          = 1,                                               &
     3068       input_id          = 1_iwp,                                           &
    30653069       output_file       = output_file,                                     &
    30663070       grid              = averaged_scalar_profile,                         &
     
    30753079       units             = "m/s",                                           &
    30763080       kind              = "large-scale scalar forcing",                    &
    3077        input_id          = 1,                                               &
     3081       input_id          = 1_iwp,                                           &
    30783082       output_file       = output_file,                                     &
    30793083       grid              = averaged_scalar_profile,                         &
     
    30883092       units             = "m/s",                                           &
    30893093       kind              = "large-scale w forcing",                         &
    3090        input_id          = 1,                                               &
     3094       input_id          = 1_iwp,                                           &
    30913095       output_file       = output_file,                                     &
    30923096       grid              = averaged_scalar_profile,                         &
     
    31013105       units             = "m/s",                                           &
    31023106       kind              = "large-scale w forcing",                         &
    3103        input_id          = 1,                                               &
     3107       input_id          = 1_iwp,                                           &
    31043108       output_file       = output_file,                                     &
    31053109       grid              = averaged_w_profile,                              &
     
    31153119       units             = "K/s",                                           &
    31163120       kind              = "large-scale scalar forcing",                    &
    3117        input_id          = 1,                                               &
     3121       input_id          = 1_iwp,                                           &
    31183122       output_file       = output_file,                                     &
    31193123       grid              = averaged_scalar_profile,                         &
     
    31283132       units             = "K/s",                                           &
    31293133       kind              = "large-scale scalar forcing",                    &
    3130        input_id          = 1,                                               &
     3134       input_id          = 1_iwp,                                           &
    31313135       output_file       = output_file,                                     &
    31323136       grid              = averaged_scalar_profile,                         &
     
    31413145       units             = "K",                                             &
    31423146       kind              = "large-scale scalar forcing",                    &
    3143        input_id          = 1,                                               &
     3147       input_id          = 1_iwp,                                           &
    31443148       output_file       = output_file,                                     &
    31453149       grid              = averaged_scalar_profile,                         &
     
    31543158       units             = "kg/kg/s",                                       &
    31553159       kind              = "large-scale scalar forcing",                    &
    3156        input_id          = 3,                                               &
     3160       input_id          = 3_iwp,                                           &
    31573161       output_file       = output_file,                                     &
    31583162       grid              = averaged_scalar_profile,                         &
     
    31683172       units             = "kg/kg/s",                                       &
    31693173       kind              = "large-scale scalar forcing",                    &
    3170        input_id          = 3,                                               &
     3174       input_id          = 3_iwp,                                           &
    31713175       output_file       = output_file,                                     &
    31723176       grid              = averaged_scalar_profile,                         &
     
    31813185       units             = "kg/kg",                                         &
    31823186       kind              = "large-scale scalar forcing",                    &
    3183        input_id          = 3,                                               &
     3187       input_id          = 3_iwp,                                           &
    31843188       output_file       = output_file,                                     &
    31853189       grid              = averaged_scalar_profile,                         &
     
    31943198       units             = "s",                                             &
    31953199       kind              = "constant scalar profile",                       &
    3196        input_id          = 1,                                               &
     3200       input_id          = 1_iwp,                                           &
    31973201       output_file       = output_file,                                     &
    31983202       grid              = averaged_scalar_profile,                         &
     
    32083212       units             = "",                                              &
    32093213       kind              = "internal profile",                              &
    3210        input_id          = 4,                                               &
     3214       input_id          = 4_iwp,                                           &
    32113215       output_file       = output_file,                                     &
    32123216       grid              = averaged_scalar_profile,                         &
     
    32223226       units             = "",                                              &
    32233227       kind              = "internal profile",                              &
    3224        input_id          = 4,                                               &
     3228       input_id          = 4_iwp,                                           &
    32253229       output_file       = output_file,                                     &
    32263230       grid              = north_averaged_scalar_profile,                   &
     
    32373241       units             = "",                                              &
    32383242       kind              = "internal profile",                              &
    3239        input_id          = 4,                                               &
     3243       input_id          = 4_iwp,                                           &
    32403244       output_file       = output_file,                                     &
    32413245       grid              = south_averaged_scalar_profile,                   &
     
    32523256       units             = "",                                              &
    32533257       kind              = "internal profile",                              &
    3254        input_id          = 4,                                               &
     3258       input_id          = 4_iwp,                                           &
    32553259       output_file       = output_file,                                     &
    32563260       grid              = east_averaged_scalar_profile,                    &
     
    32673271       units             = "",                                              &
    32683272       kind              = "internal profile",                              &
    3269        input_id          = 4,                                               &
     3273       input_id          = 4_iwp,                                           &
    32703274       output_file       = output_file,                                     &
    32713275       grid              = west_averaged_scalar_profile,                    &
     
    32813285       units             = "",                                              &
    32823286       kind              = "internal profile",                              &
    3283        input_id          = 2,                                               &
     3287       input_id          = 2_iwp,                                           &
    32843288       output_file       = output_file,                                     &
    32853289       grid              = north_averaged_scalar_profile,                   &
     
    32963300       units             = "",                                              &
    32973301       kind              = "internal profile",                              &
    3298        input_id          = 2,                                               &
     3302       input_id          = 2_iwp,                                           &
    32993303       output_file       = output_file,                                     &
    33003304       grid              = south_averaged_scalar_profile,                   &
     
    33113315       units             = "",                                              &
    33123316       kind              = "internal profile",                              &
    3313        input_id          = 2,                                               &
     3317       input_id          = 2_iwp,                                           &
    33143318       output_file       = output_file,                                     &
    33153319       grid              = east_averaged_scalar_profile,                    &
     
    33263330       units             = "",                                              &
    33273331       kind              = "internal profile",                              &
    3328        input_id          = 2,                                               &
     3332       input_id          = 2_iwp,                                           &
    33293333       output_file       = output_file,                                     &
    33303334       grid              = west_averaged_scalar_profile,                    &
     
    33543358
    33553359    CHARACTER(LEN=*), INTENT(IN)      ::  name, std_name, long_name, units, kind
    3356     INTEGER, INTENT(IN)               ::  input_id
     3360    INTEGER(iwp), INTENT(IN)          ::  input_id
    33573361    TYPE(grid_definition), INTENT(IN), TARGET ::  grid, intermediate_grid
    33583362    TYPE(nc_file), INTENT(IN)         ::  output_file
     
    37333737    TYPE(container), INTENT(INOUT), ALLOCATABLE ::  input_buffer(:)
    37343738    TYPE(grid_definition), INTENT(IN)           ::  cosmo_grid
    3735     INTEGER, INTENT(IN)                         ::  iter
     3739    INTEGER(iwp), INTENT(IN)                    ::  iter
    37363740   
    37373741    REAL(wp), ALLOCATABLE                       ::  basic_state_pressure(:)
    37383742    TYPE(container), ALLOCATABLE                ::  preprocess_buffer(:)
    3739     INTEGER                                     ::  hour, dt
    3740     INTEGER                                     ::  i, j, k
    3741     INTEGER                                     ::  nx, ny, nz
     3743    INTEGER(iwp)                                ::  hour, dt
     3744    INTEGER(iwp)                                ::  i, j, k
     3745    INTEGER(iwp)                                ::  nx, ny, nz
    37423746   
    37433747    input_buffer(:)%is_preprocessed = .FALSE.
     
    39053909         
    39063910          CALL fill_water_cells(soiltyp, input_buffer(1)%array, &
    3907                                 SIZE(input_buffer(1)%array, 3), &
     3911                                SIZE(input_buffer(1)%array, 3, kind=iwp), &
    39083912                                FILL_ITERATIONS)
    39093913          input_buffer(:)%is_preprocessed = .TRUE.
     
    39123916
    39133917          CALL fill_water_cells(soiltyp, input_buffer(1)%array, &
    3914                                 SIZE(input_buffer(1)%array, 3), &
     3918                                SIZE(input_buffer(1)%array, 3, kind=iwp), &
    39153919                                FILL_ITERATIONS)
    39163920
     
    39413945          CALL report('preprocess', message)
    39423946
    3943           hour = iter - 1
    3944           dt = MODULO(hour, 3) + 1 ! averaging period
     3947          hour = iter - 1_iwp
     3948          dt = MODULO(hour, 3_iwp) + 1_iwp ! averaging period
    39453949          SELECT CASE(dt)
    39463950
     
    39863990          CALL report('preprocess', message)
    39873991
    3988           hour = iter - 1
     3992          hour = iter - 1_iwp
    39893993!
    39903994!--       averaging period
    3991           dt = MODULO(hour, 3) + 1
     3995          dt = MODULO(hour, 3_iwp) + 1_iwp
    39923996          SELECT CASE(dt)
    39933997!
     
    40354039
    40364040
    4037 !------------------------------------------------------------------------------!
    4038 ! Description:
    4039 ! ------------
    4040 !> Computes average soil values in COSMO-DE water cells from neighbouring
    4041 !> non-water cells. This is done as a preprocessing step for the COSMO-DE
    4042 !> soil input arrays, which contain unphysical values for water cells.
    4043 !>
    4044 !> This routine computes the average of up to all nine neighbouring cells
    4045 !> or keeps the original value, if not at least one non-water neightbour
    4046 !> is available.
    4047 !>
    4048 !> By repeatedly applying this step, soil data can be extrapolated into
    4049 !> 'water' regions occupying multiple cells, one cell per iteration.
    4050 !>
    4051 !> Input parameters:
    4052 !> -----------------
    4053 !> soiltyp : 2d map of COSMO-DE soil types
    4054 !> nz : number of layers in the COSMO-DE soil
    4055 !> niter : number iterations
    4056 !>
    4057 !> Output parameters:
    4058 !> ------------------
    4059 !> array : the soil array (i.e. water content or temperature)
    4060 !------------------------------------------------------------------------------!
    4061  SUBROUTINE fill_water_cells(soiltyp, array, nz, niter)
    4062     INTEGER(iwp), DIMENSION(:,:,:), INTENT(IN) :: soiltyp
    4063     REAL(wp), DIMENSION(:,:,:), INTENT(INOUT)  :: array
    4064     INTEGER, INTENT(IN)                        :: nz, niter
    4065 
    4066     REAL(wp), DIMENSION(nz)                    :: column
    4067     INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE  :: old_soiltyp, new_soiltyp
    4068     INTEGER                                    :: l, i, j, nx, ny, n_cells, ii, jj, iter
    4069     INTEGER, DIMENSION(8)                      :: di, dj
    4070 
    4071     nx = SIZE(array, 1)
    4072     ny = SIZE(array, 2)
    4073     di = (/ -1, -1, -1, 0,  0,  1, 1, 1 /)
    4074     dj = (/ -1,  0,  1, -1, 1, -1, 0, 1 /)
    4075 
    4076     ALLOCATE(old_soiltyp(SIZE(soiltyp,1), &
    4077                          SIZE(soiltyp,2) ))
    4078 
    4079     ALLOCATE(new_soiltyp(SIZE(soiltyp,1), &
    4080                          SIZE(soiltyp,2) ))
    4081 
    4082     old_soiltyp(:,:) = soiltyp(:,:,1)
    4083     new_soiltyp(:,:) = soiltyp(:,:,1)
    4084 
    4085     DO  iter = 1, niter
    4086 
    4087        DO  j = 1, ny
    4088        DO  i = 1, nx
    4089        
    4090           IF (old_soiltyp(i,j) == WATER_ID)  THEN
    4091 
    4092              n_cells = 0
    4093              column(:) = 0.0_wp
    4094              DO  l = 1, SIZE(di)
    4095 
    4096                 ii = MIN(nx, MAX(1, i + di(l)))
    4097                 jj = MIN(ny, MAX(1, j + dj(l)))
    4098 
    4099                 IF (old_soiltyp(ii,jj) .NE. WATER_ID)  THEN
    4100                    n_cells = n_cells + 1
    4101                    column(:) = column(:) + array(ii,jj,:)
    4102                 ENDIF
    4103 
    4104              ENDDO
    4105 
    4106 !
    4107 !--          Overwrite if at least one non-water neighbour cell is available
    4108              IF (n_cells > 0)  THEN
    4109                 array(i,j,:) = column(:) / n_cells
    4110                 new_soiltyp(i,j) = 0
    4111              ENDIF
    4112 
    4113           ENDIF
    4114 
    4115        ENDDO
    4116        ENDDO
    4117 
    4118        old_soiltyp(:,:) = new_soiltyp(:,:)
    4119 
    4120     ENDDO
    4121 
    4122     DEALLOCATE(old_soiltyp, new_soiltyp)
    4123 
    4124  END SUBROUTINE fill_water_cells
    4125 
    4126 
    41274041 END MODULE inifor_grid
    41284042#endif
  • palm/trunk/UTIL/inifor/src/inifor_io.f90

    r4481 r4523  
    2626! -----------------
    2727! $Id$
     28! respect integer working precision (iwp) specified in inifor_defs.f90
     29!
     30!
     31! 4481 2020-03-31 18:55:54Z maronga
    2832! Pass hhl_file directly instead of entire INIFOR configuration
    2933!
     
    135139               NC_DEPTH_NAME, NC_HHL_NAME, NC_RLAT_NAME, NC_RLON_NAME,         &
    136140               NC_ROTATED_POLE_NAME, NC_POLE_LATITUDE_NAME,                    &
    137                NC_POLE_LONGITUDE_NAME, RHO_L, wp, iwp
     141               NC_POLE_LONGITUDE_NAME, RHO_L, iwp, wp
    138142    USE inifor_types
    139143    USE inifor_util,                                                           &
     
    332336
    333337       message = "Failed reading NetCDF variable " //                       &
    334           TRIM(in_var%name) // " with " // TRIM(str(in_var%ndim)) //    &
     338          TRIM(in_var%name) // " with " //                                  &
     339          TRIM(str(INT(in_var%ndim, kind=iwp))) //                          &
    335340          " dimensions because only two- and and three-dimensional" //      &
    336341          " variables are supported."
     
    579584    CHARACTER (LEN=DATE), INTENT(IN) ::  start_date_string
    580585    CHARACTER (LEN=*),    INTENT(IN) ::  prefix, suffix, input_path
    581     INTEGER,              INTENT(IN) ::  start_hour, end_hour, step_hour
     586    INTEGER(iwp),         INTENT(IN) ::  start_hour, end_hour, step_hour
    582587    CHARACTER(LEN=*), ALLOCATABLE, INTENT(INOUT) ::  file_list(:)
    583588
    584     INTEGER             ::  number_of_intervals, hour, i
     589    INTEGER(iwp)        ::  number_of_intervals, hour, i
    585590    CHARACTER(LEN=DATE) ::  date_string
    586591
     
    612617    CHARACTER (LEN=DATE), INTENT(IN) ::  start_date_string
    613618    CHARACTER (LEN=*),    INTENT(IN) ::  prefix, suffix, input_path
    614     INTEGER,              INTENT(IN) ::  start_hour, end_hour, step_hour
     619    INTEGER(iwp),         INTENT(IN) ::  start_hour, end_hour, step_hour
    615620    CHARACTER(LEN=*), ALLOCATABLE, INTENT(INOUT) ::  file_list(:)
    616621    LOGICAL, OPTIONAL, INTENT(IN)    ::  nocheck
    617622
    618     INTEGER ::  i
    619     LOGICAL ::  check_files
     623    INTEGER(iwp) ::  i
     624    LOGICAL      ::  check_files
    620625
    621626    CALL get_datetime_file_list( start_date_string, start_hour, end_hour,    &
     
    786791    REAL(wp), INTENT(OUT)                                ::  latmin_cosmo !< Minimunm latitude of COSMO-DE's rotated-pole grid [COSMO rotated-pole rad]
    787792    REAL(wp), INTENT(OUT)                                ::  latmax_cosmo !< Maximum latitude of COSMO-DE's rotated-pole grid [COSMO rotated-pole rad]
    788     INTEGER, INTENt(OUT)                                 ::  nlon, nlat, nlev, ndepths
     793    INTEGER(iwp), INTENT(OUT)                            ::  nlon, nlat, nlev, ndepths
    789794
    790795    TYPE(nc_var) ::  cosmo_var !< COSMO dummy variable, used for reading HHL, rlon, rlat
    791     INTEGER      ::  k
     796    INTEGER(iwp) ::  k
    792797
    793798!
     
    916921    CHARACTER (LEN=5)     ::  zone_string
    917922    CHARACTER (LEN=SNAME) ::  history_string
    918     INTEGER               ::  ncid, nx, ny, nz, nt, dimids(3), dimvarids(3)
     923    INTEGER               ::  nx, ny, nz, nt
     924    INTEGER               ::  ncid, dimids(3), dimvarids(3)
    919925    REAL(wp)              ::  z0
    920926
     
    11011107
    11021108    TYPE(nc_var), POINTER                ::  var
    1103     INTEGER                              ::  i, ncid
     1109    INTEGER(iwp)                         ::  i
     1110    INTEGER                              ::  ncid
    11041111    LOGICAL                              ::  to_be_written
    11051112
     
    11521159 SUBROUTINE read_input_variables(group, iter, buffer)
    11531160    TYPE(io_group), INTENT(INOUT), TARGET       ::  group
    1154     INTEGER, INTENT(IN)                         ::  iter
     1161    INTEGER(iwp), INTENT(IN)                    ::  iter
    11551162    TYPE(container), ALLOCATABLE, INTENT(INOUT) ::  buffer(:)
    1156     INTEGER                                     ::  hour, buf_id
     1163    INTEGER(iwp)                                ::  hour, buf_id
    11571164    TYPE(nc_var), POINTER                       ::  input_var
    11581165    CHARACTER(LEN=PATH), POINTER                ::  input_file
    1159     INTEGER                                     ::  ivar, nbuffers
     1166    INTEGER(iwp)                                ::  ivar, nbuffers
    11601167
    11611168    message = "Reading data for I/O group '" // TRIM(group%in_var_list(1)%name) // "'."
     
    11771184                    "accumulated variable. Group '" // TRIM(group%kind) //&
    11781185                    "' contains " //                                        &
    1179                     TRIM( str(SIZE(group%in_var_list)) ) // "."
     1186                    TRIM( str(SIZE(group%in_var_list, kind=iwp)) ) // "."
    11801187          CALL inifor_abort('read_input_variables | accumulation', message)
    11811188       ENDIF
     
    12501257!> depending on the current hour.
    12511258!------------------------------------------------------------------------------!
    1252  INTEGER FUNCTION select_buffer(hour)
    1253     INTEGER, INTENT(IN) ::  hour
    1254     INTEGER             ::  step
    1255 
    1256     select_buffer = 0
    1257     step = MODULO(hour, 3) + 1
     1259 INTEGER(iwp) FUNCTION select_buffer(hour)
     1260    INTEGER(iwp), INTENT(IN) ::  hour
     1261    INTEGER(iwp)             ::  step
     1262
     1263    select_buffer = 0_iwp
     1264    step = MODULO(hour, 3_iwp) + 1_iwp
    12581265
    12591266    SELECT CASE(step)
    12601267       CASE(1, 3)
    1261            select_buffer = 1
     1268           select_buffer = 1_iwp
    12621269       CASE(2)
    1263            select_buffer = 2
     1270           select_buffer = 2_iwp
    12641271       CASE DEFAULT
    12651272           message = "Invalid step '" // TRIM(str(step))
     
    13691376    TYPE(nc_var), INTENT(IN)  ::  var
    13701377    REAL(wp), INTENT(IN)      ::  array(:,:,:)
    1371     INTEGER, INTENT(IN)       ::  iter
     1378    INTEGER(iwp), INTENT(IN)  ::  iter
    13721379    TYPE(nc_file), INTENT(IN) ::  output_file
    13731380    TYPE(inifor_config)       ::  cfg
    13741381
    1375     INTEGER ::  ncid, ndim, start(4), count(4)
    1376     LOGICAL ::  var_is_time_dependent
     1382    INTEGER      ::  ncid, ndim, start(4), count(4)
     1383    LOGICAL      ::  var_is_time_dependent
    13771384
    13781385    var_is_time_dependent = (                                               &
  • palm/trunk/UTIL/inifor/src/inifor_transform.f90

    r4481 r4523  
    2626! -----------------
    2727! $Id$
     28! bugfix: pressure extrapolation
     29! respect integer working precision (iwp) specified in inifor_defs.f90
     30! moved fill_water_cells() routine here
     31! remove unused routine, appropriately renamed constand_density_pressure()
     32!
     33!
     34! 4481 2020-03-31 18:55:54Z maronga
    2835! Use PALM's working precision
    2936! Improved coding style
     
    111118    USE inifor_control
    112119    USE inifor_defs,                                                           &
    113         ONLY: BETA, G, P_SL, PI, RD, T_SL, TO_DEGREES, TO_RADIANS, wp
     120        ONLY: BETA, G, P_SL, PI, RD, T_SL, TO_DEGREES, TO_RADIANS, WATER_ID,   &
     121              iwp, wp
    114122    USE inifor_types
    115123    USE inifor_util,                                                           &
     
    126134    REAL(wp), INTENT(OUT)             ::  out_arr(:)
    127135
    128     INTEGER :: k, l, nz
     136    INTEGER(iwp) :: k, l, nz
    129137
    130138    nz = UBOUND(out_arr, 1)
     
    179187    REAL(wp), INTENT(OUT)             ::  out_arr(0:,0:,:)
    180188
    181     INTEGER :: i, j, k, l, nz
     189    INTEGER(iwp) :: i, j, k, l, nz
    182190
    183191    nz = UBOUND(out_arr, 3)
     
    241249    TYPE(nc_var), INTENT(IN), OPTIONAL ::  ncvar
    242250
    243     INTEGER ::  i, j, k, l
     251    INTEGER(iwp) ::  i, j, k, l
    244252
    245253!
     
    247255    IF ( UBOUND(outvar, 3) .GT. UBOUND(invar, 3) )  THEN
    248256        message = "Output array for '" // TRIM(ncvar%name) // "' has ' more levels (" // &
    249            TRIM(str(UBOUND(outvar, 3))) // ") than input variable ("//&
    250            TRIM(str(UBOUND(invar, 3))) // ")."
     257           TRIM(str(UBOUND(outvar, 3, kind=iwp))) // ") than input variable ("//&
     258           TRIM(str(UBOUND(invar, 3, kind=iwp))) // ")."
    251259        CALL inifor_abort('interpolate_2d', message)
    252260    ENDIF
     
    277285!------------------------------------------------------------------------------!
    278286 SUBROUTINE average_2d(in_arr, out_arr, ii, jj)
    279     REAL(wp), INTENT(IN)              ::  in_arr(0:,0:,0:)
    280     REAL(wp), INTENT(OUT)             ::  out_arr(0:)
    281     INTEGER, INTENT(IN), DIMENSION(:) ::  ii, jj
    282 
    283     INTEGER  ::  i, j, k, l
    284     REAL(wp) ::  ni
     287    REAL(wp), INTENT(IN)                   ::  in_arr(0:,0:,0:)
     288    REAL(wp), INTENT(OUT)                  ::  out_arr(0:)
     289    INTEGER(iwp), INTENT(IN), DIMENSION(:) ::  ii, jj
     290
     291    INTEGER(iwp) ::  i, j, k, l
     292    REAL(wp)     ::  ni
    285293
    286294    IF (SIZE(ii) /= SIZE(jj))  THEN
    287295       message = "Length of 'ii' and 'jj' index lists do not match." //     &
    288           NEW_LINE(' ') // "ii has " // str(SIZE(ii)) // " elements, " //   &
    289           NEW_LINE(' ') // "jj has " // str(SIZE(jj)) // "."
     296          NEW_LINE(' ') // "ii has " // str(SIZE(ii, kind=iwp)) // " elements, " //   &
     297          NEW_LINE(' ') // "jj has " // str(SIZE(jj, kind=iwp)) // "."
    290298       CALL inifor_abort('average_2d', message)
    291299    ENDIF
     
    330338    REAL(wp), DIMENSION(:,:,:), INTENT(OUT) ::  palm_array
    331339    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  intermediate_array
    332     INTEGER ::  nx, ny, nlev
     340    INTEGER(iwp) ::  nx, ny, nlev
    333341
    334342    nx = palm_intermediate%nx
     
    365373    REAL(wp), DIMENSION(:), INTENT(OUT)        ::  profile_array
    366374
    367     INTEGER ::  i_source, j_source, k_profile, k_source, l, m
     375    INTEGER(iwp) ::  i_source, j_source, k_profile, k_source, l, m
    368376
    369377    REAL ::  ni_columns
     
    422430    REAL(wp), DIMENSION(:), INTENT(OUT)        ::  profile_array
    423431
    424     INTEGER ::  i_source, j_source, l, nz, nlev
     432    INTEGER(iwp) ::  i_source, j_source, l, nz, nlev
    425433
    426434    REAL(wp) ::  ni_columns
     
    468476    REAL(wp), DIMENSION(:), INTENT(OUT)        ::  profile_array
    469477
    470     INTEGER ::  i_source, j_source, l, nz, nlev
     478    INTEGER(iwp) ::  i_source, j_source, l, nz, nlev
    471479
    472480    REAL(wp)                            ::  ni_columns
     
    511519
    512520
    513 
    514 
    515 !------------------------------------------------------------------------------!
    516 ! Description:
    517 ! ------------
    518 !> Extrapolates density linearly from the level 'k_min' downwards.
    519 !------------------------------------------------------------------------------!
    520  SUBROUTINE extrapolate_density(rho, avg_grid)
    521     REAL(wp), DIMENSION(:), INTENT(INOUT) ::  rho
    522     TYPE(grid_definition), INTENT(IN)     ::  avg_grid
    523 
    524     REAL(wp) ::  drhodz, dz, zk, rhok
    525     INTEGER  ::  k_min
    526 
    527     k_min  = avg_grid%k_min
    528     zk     = avg_grid%z(k_min)
    529     rhok   = rho(k_min)
    530     dz     = avg_grid%z(k_min + 1) - avg_grid%z(k_min)
    531     drhodz = (rho(k_min + 1) - rho(k_min)) / dz
    532 
    533     rho(1:k_min-1) = rhok + drhodz * (avg_grid%z(1:k_min-1) - zk)
    534 
    535  END SUBROUTINE extrapolate_density
    536 
    537 
    538 !------------------------------------------------------------------------------!
    539 ! Description:
    540 ! ------------
    541 !> Driver for extrapolating pressure from PALM level k_min downwards
    542 !------------------------------------------------------------------------------!
    543  SUBROUTINE extrapolate_pressure(p, rho, avg_grid)
     521!------------------------------------------------------------------------------!
     522! Description:
     523! ------------
     524!> Computes average soil values in COSMO-DE water cells from neighbouring
     525!> non-water cells. This is done as a preprocessing step for the COSMO-DE
     526!> soil input arrays, which contain unphysical values for water cells.
     527!>
     528!> This routine computes the average of up to all nine neighbouring cells
     529!> or keeps the original value, if not at least one non-water neightbour
     530!> is available.
     531!>
     532!> By repeatedly applying this step, soil data can be extrapolated into
     533!> 'water' regions occupying multiple cells, one cell per iteration.
     534!>
     535!> Input parameters:
     536!> -----------------
     537!> soiltyp : 2d map of COSMO-DE soil types
     538!> nz : number of layers in the COSMO-DE soil
     539!> niter : number iterations
     540!>
     541!> Output parameters:
     542!> ------------------
     543!> array : the soil array (i.e. water content or temperature)
     544!------------------------------------------------------------------------------!
     545 SUBROUTINE fill_water_cells(soiltyp, array, nz, niter)
     546    INTEGER(iwp), DIMENSION(:,:,:), INTENT(IN) :: soiltyp
     547    REAL(wp), DIMENSION(:,:,:), INTENT(INOUT)  :: array
     548    INTEGER(iwp), INTENT(IN)                   :: nz, niter
     549
     550    REAL(wp), DIMENSION(nz)                    :: column
     551    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE  :: old_soiltyp, new_soiltyp
     552    INTEGER(iwp)                               :: l, i, j, nx, ny, n_cells, ii, jj, iter
     553    INTEGER(iwp), DIMENSION(8)                 :: di, dj
     554
     555    nx = SIZE(array, 1)
     556    ny = SIZE(array, 2)
     557    di = (/ -1, -1, -1, 0,  0,  1, 1, 1 /)
     558    dj = (/ -1,  0,  1, -1, 1, -1, 0, 1 /)
     559
     560    ALLOCATE(old_soiltyp(SIZE(soiltyp,1), &
     561                         SIZE(soiltyp,2) ))
     562
     563    ALLOCATE(new_soiltyp(SIZE(soiltyp,1), &
     564                         SIZE(soiltyp,2) ))
     565
     566    old_soiltyp(:,:) = soiltyp(:,:,1)
     567    new_soiltyp(:,:) = soiltyp(:,:,1)
     568
     569    DO  iter = 1, niter
     570
     571       DO  j = 1, ny
     572       DO  i = 1, nx
     573       
     574          IF (old_soiltyp(i,j) == WATER_ID)  THEN
     575
     576             n_cells = 0
     577             column(:) = 0.0_wp
     578             DO  l = 1, SIZE(di)
     579
     580                ii = MIN(nx, MAX(1_iwp, i + di(l)))
     581                jj = MIN(ny, MAX(1_iwp, j + dj(l)))
     582
     583                IF (old_soiltyp(ii,jj) .NE. WATER_ID)  THEN
     584                   n_cells = n_cells + 1
     585                   column(:) = column(:) + array(ii,jj,:)
     586                ENDIF
     587
     588             ENDDO
     589
     590!
     591!--          Overwrite if at least one non-water neighbour cell is available
     592             IF (n_cells > 0)  THEN
     593                array(i,j,:) = column(:) / n_cells
     594                new_soiltyp(i,j) = 0
     595             ENDIF
     596
     597          ENDIF
     598
     599       ENDDO
     600       ENDDO
     601
     602       old_soiltyp(:,:) = new_soiltyp(:,:)
     603
     604    ENDDO
     605
     606    DEALLOCATE(old_soiltyp, new_soiltyp)
     607
     608 END SUBROUTINE fill_water_cells
     609
     610
     611!------------------------------------------------------------------------------!
     612! Description:
     613! ------------
     614!> Takes the averaged pressure profile <p> and sets the lowest entry to the
     615!> extrapolated pressure at the surface.
     616!------------------------------------------------------------------------------!
     617 SUBROUTINE get_surface_pressure(p, rho, avg_grid)
    544618    REAL(wp), DIMENSION(:), INTENT(IN)    ::  rho
    545619    REAL(wp), DIMENSION(:), INTENT(INOUT) ::  p
    546620    TYPE(grid_definition), INTENT(IN)     ::  avg_grid
    547621
    548     REAL(wp) ::  drhodz, dz, zk, rhok
    549     INTEGER  ::  k, k_min
     622    REAL(wp)     ::  drhodz, dz, zk, rhok
     623    INTEGER(iwp) :: k_min
    550624
    551625    k_min = avg_grid%k_min
     
    553627    rhok  = rho(k_min)
    554628    dz    = avg_grid%z(k_min + 1) - avg_grid%z(k_min)
    555     drhodz = 0.5_wp * (rho(k_min + 1) - rho(k_min)) / dz
    556 
    557     DO  k = 1, k_min-1
    558        p(k) = constant_density_pressure(p(k_min), zk, rhok, drhodz,         &
    559                                         avg_grid%z(k), G)
    560     ENDDO
    561 
    562  END SUBROUTINE extrapolate_pressure
    563 
    564 
    565 !------------------------------------------------------------------------------!
    566 ! Description:
    567 ! ------------
    568 !> Takes the averaged pressure profile <p> and sets the lowest entry to the
    569 !> extrapolated pressure at the surface.
    570 !------------------------------------------------------------------------------!
    571  SUBROUTINE get_surface_pressure(p, rho, avg_grid)
    572     REAL(wp), DIMENSION(:), INTENT(IN)    ::  rho
    573     REAL(wp), DIMENSION(:), INTENT(INOUT) ::  p
    574     TYPE(grid_definition), INTENT(IN)     ::  avg_grid
    575 
    576     REAL(wp) ::  drhodz, dz, zk, rhok
    577     INTEGER  ::  k_min
    578 
    579     k_min = avg_grid%k_min
    580     zk    = avg_grid%z(k_min)
    581     rhok  = rho(k_min)
    582     dz    = avg_grid%z(k_min + 1) - avg_grid%z(k_min)
    583     drhodz = 0.5_wp * (rho(k_min + 1) - rho(k_min)) / dz
    584 
    585     p(1) = constant_density_pressure(p(k_min), zk, rhok, drhodz,            &
    586                                      0.0_wp, G)
     629    drhodz = ( rho(k_min + 1) - rho(k_min) ) / dz
     630
     631    p(1) = linear_density_pressure( p(k_min), zk, rhok, drhodz,                &
     632                                    z = 0.0_wp, g=G )
    587633
    588634 END SUBROUTINE get_surface_pressure
    589635
    590636
    591  FUNCTION constant_density_pressure(pk, zk, rhok, drhodz, z, g)  RESULT(p)
     637 FUNCTION linear_density_pressure(pk, zk, rhok, drhodz, z, g)  RESULT(p)
    592638
    593639    REAL(wp), INTENT(IN)  ::  pk, zk, rhok, drhodz, g, z
    594640    REAL(wp) ::  p
    595641
    596     p = pk + ( zk - z ) * g * ( rhok + 0.5*drhodz * (zk - z) )
    597 
    598  END FUNCTION constant_density_pressure
     642    p = pk + ( zk - z ) * g * ( rhok - 0.5_wp * drhodz * (zk - z) )
     643
     644 END FUNCTION linear_density_pressure
    599645
    600646!-----------------------------------------------------------------------------!
     
    769815    REAL(wp), INTENT(OUT) ::  phi(0:,0:), lam(0:,0:)
    770816
    771     INTEGER ::  i, j
     817    INTEGER(iwp) ::  i, j
    772818   
    773819    IF ( SIZE(phi, 1) .NE. SIZE(lam, 1) .OR. &
     
    816862    REAL(wp), INTENT(IN)                  :: angle !< rotation angle [deg]
    817863
    818     INTEGER  :: i
    819     REAL(wp) :: sine, cosine, v_rot(2), rotation(2,2)
     864    INTEGER(iwp) :: i
     865    REAL(wp)     :: sine, cosine, v_rot(2), rotation(2,2)
    820866
    821867    sine = SIN(angle * TO_RADIANS)
     
    912958                                       palm_ii, palm_jj)
    913959
    914     REAL(wp), DIMENSION(0:), INTENT(IN)        ::  cosmo_lat, cosmo_lon
    915     REAL(wp), DIMENSION(0:,0:), INTENT(IN)     ::  palm_clat, palm_clon
    916     REAL(wp)                                   ::  cosmo_dxi, cosmo_dyi
    917     INTEGER, DIMENSION(0:,0:,1:), INTENT(OUT) ::  palm_ii, palm_jj
    918 
    919     REAL(wp) ::  lonpos, latpos, lon0, lat0
    920     INTEGER  ::  i, j
     960    REAL(wp), DIMENSION(0:), INTENT(IN)            ::  cosmo_lat, cosmo_lon
     961    REAL(wp), DIMENSION(0:,0:), INTENT(IN)         ::  palm_clat, palm_clon
     962    REAL(wp)                                       ::  cosmo_dxi, cosmo_dyi
     963    INTEGER(iwp), DIMENSION(0:,0:,1:), INTENT(OUT) ::  palm_ii, palm_jj
     964
     965    REAL(wp)     ::  lonpos, latpos, lon0, lat0
     966    INTEGER(iwp) ::  i, j
    921967
    922968    lon0 = cosmo_lon(0)
     
    9681014!> column of the given palm grid.
    9691015!------------------------------------------------------------------------------!
    970  SUBROUTINE find_vertical_neighbours_and_weights_interp( palm_grid,         &
    971                                                             palm_intermediate )
     1016 SUBROUTINE find_vertical_neighbours_and_weights_interp( palm_grid,            &
     1017                                                         palm_intermediate )
    9721018    TYPE(grid_definition), INTENT(INOUT) ::  palm_grid
    9731019    TYPE(grid_definition), INTENT(IN)    ::  palm_intermediate
    9741020
    975     INTEGER  ::  i, j, k, nx, ny, nz, nlev, k_intermediate
    976     LOGICAL  ::  point_is_below_grid, point_is_above_grid,                  &
    977                  point_is_in_current_cell
    978     REAL(wp) ::  current_height, column_base, column_top, h_top, h_bottom, &
    979                  weight
     1021    INTEGER(iwp) ::  i, j, k, nx, ny, nz, nlev, k_intermediate
     1022    LOGICAL      ::  point_is_below_grid, point_is_above_grid,                 &
     1023                     point_is_in_current_cell
     1024    REAL(wp)     ::  current_height, column_base, column_top, h_top, h_bottom, &
     1025                     weight
    9801026
    9811027    nx   = palm_grid%nx
     
    10911137    LOGICAL                                      ::  level_based_averaging
    10921138
    1093     INTEGER           ::  i, j, k_palm, k_intermediate, l, nlev
     1139    INTEGER(iwp)      ::  i, j, k_palm, k_intermediate, l, nlev
    10941140    LOGICAL           ::  point_is_below_grid, point_is_above_grid,         &
    10951141                          point_is_in_current_cell
     
    12591305    palm_clat, palm_clon, palm_ii, palm_jj, palm_w_horiz)
    12601306       
    1261     REAL(wp), DIMENSION(0:), INTENT(IN)        ::  cosmo_lat, cosmo_lon
    1262     REAL(wp)                                   ::  cosmo_dxi, cosmo_dyi
    1263     REAL(wp), DIMENSION(0:,0:), INTENT(IN)     ::  palm_clat, palm_clon
    1264     INTEGER, DIMENSION(0:,0:,1:), INTENT(IN)  ::  palm_ii, palm_jj
     1307    REAL(wp), DIMENSION(0:), INTENT(IN)           ::  cosmo_lat, cosmo_lon
     1308    REAL(wp)                                      ::  cosmo_dxi, cosmo_dyi
     1309    REAL(wp), DIMENSION(0:,0:), INTENT(IN)        ::  palm_clat, palm_clon
     1310    INTEGER(iwp), DIMENSION(0:,0:,1:), INTENT(IN) ::  palm_ii, palm_jj
    12651311
    12661312    REAL(wp), DIMENSION(0:,0:,1:), INTENT(OUT) ::  palm_w_horiz
    12671313
    1268     REAL(wp) ::  wlambda, wphi
    1269     INTEGER  ::  i, j
     1314    REAL(wp)     ::  wlambda, wphi
     1315    INTEGER(iwp) ::  i, j
    12701316
    12711317    cosmo_dxi = 1.0_wp / (cosmo_lon(1) - cosmo_lon(0))
     
    13191365    REAL(wp), DIMENSION(0:,0:,0:), INTENT(IN)  ::  u_face, v_face
    13201366    REAL(wp), DIMENSION(0:,0:,0:), INTENT(OUT) ::  u_centre, v_centre
    1321     INTEGER ::  nx, ny
     1367    INTEGER(iwp) ::  nx, ny
    13221368
    13231369    nx = UBOUND(u_face, 1)
  • palm/trunk/UTIL/inifor/src/inifor_types.f90

    r4481 r4523  
    2626! -----------------
    2727! $Id$
     28! respect integer working precision (iwp) specified in inifor_defs.f90
     29!
     30!
     31! 4481 2020-03-31 18:55:54Z maronga
    2832! Added boolean indicator for --elevation option invocation, sorted varibles
    2933!
     
    7983 
    8084 USE inifor_defs,                                                              &
    81     ONLY:  DATE, PATH, SNAME, LNAME, wp
     85    ONLY:  DATE, PATH, SNAME, LNAME, iwp, wp
    8286
    8387#if defined ( __netcdf )
     
    142146    CHARACTER(LEN=SNAME)  ::  name(3)       !< names of the grid dimensions, e.g. (/'x', 'y', 'z'/) or (/'latitude', 'longitude', 'height'/)
    143147    CHARACTER(LEN=SNAME)  ::  kind          !< names of the grid dimensions, e.g. (/'x', 'y', 'z'/) or (/'latitude', 'longitude', 'height'/)
    144     INTEGER               ::  k_min         !< Index of lowest PALM grid level that is not cut by local COSMO orography; vertically separates interpolation and extrapolation region.
    145     INTEGER               ::  nx            !< number of gridpoints in the first dimension
    146     INTEGER               ::  ny            !< number of gridpoints in the second dimension
    147     INTEGER               ::  nz            !< number of gridpoints in the third dimension, used for PALM points
    148     INTEGER               ::  nlev          !< number of COSMO grid levels
    149     INTEGER               ::  n_columns     !< number of averaging columns of the source grid
    150     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.
    151     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.
    152     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.
    153     INTEGER, ALLOCATABLE  ::  iii(:)        !< profile averaging neighbour indices
    154     INTEGER, ALLOCATABLE  ::  jjj(:)        !< profile averaging neighbour indices
    155     INTEGER, ALLOCATABLE  ::  kkk(:,:,:)    !< indices of vertical interpolation neightbours, kkk(<source column>, <PALM k level>, <neighbour index>)
     148    INTEGER(iwp)               ::  k_min         !< Index of lowest PALM grid level that is not cut by local COSMO orography; vertically separates interpolation and extrapolation region.
     149    INTEGER(iwp)               ::  nx            !< number of gridpoints in the first dimension
     150    INTEGER(iwp)               ::  ny            !< number of gridpoints in the second dimension
     151    INTEGER(iwp)               ::  nz            !< number of gridpoints in the third dimension, used for PALM points
     152    INTEGER(iwp)               ::  nlev          !< number of COSMO grid levels
     153    INTEGER(iwp)               ::  n_columns     !< number of averaging columns of the source grid
     154    INTEGER(iwp), 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.
     155    INTEGER(iwp), 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.
     156    INTEGER(iwp), 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.
     157    INTEGER(iwp), ALLOCATABLE  ::  iii(:)        !< profile averaging neighbour indices
     158    INTEGER(iwp), ALLOCATABLE  ::  jjj(:)        !< profile averaging neighbour indices
     159    INTEGER(iwp), ALLOCATABLE  ::  kkk(:,:,:)    !< indices of vertical interpolation neightbours, kkk(<source column>, <PALM k level>, <neighbour index>)
    156160    REAL(wp)              ::  lx            !< domain length in the first dimension [m]
    157161    REAL(wp)              ::  ly            !< domain length in the second dimension [m]
     
    215219    INTEGER                               ::  input_id  !< ID of the correpsonding input variables, only valid for output variables
    216220    INTEGER                               ::  ndim      !< number of NetCDF dimensions
    217     INTEGER                               ::  nt        !< number of output time steps
     221    INTEGER(iwp)                          ::  nt        !< number of output time steps
    218222    INTEGER                               ::  lod       !< NetCDF attribute indicating the PALM-4U level of detail
    219223    INTEGER, DIMENSION(NF90_MAX_VAR_DIMS) ::  dimids    !< NetCDF IDs of the dimensions
     
    247251!------------------------------------------------------------------------------!
    248252 TYPE io_group
    249     INTEGER                          ::  nt             !< maximum number of output time steps across all output variables
    250     INTEGER                          ::  nv             !< number of netCDF output variables
    251     INTEGER                          ::  n_inputs       !< number of input variables
    252     INTEGER                          ::  n_output_quantities !< number of physical quantities required for computing netCDF output variables
     253    INTEGER(iwp)                          ::  nt             !< maximum number of output time steps across all output variables
     254    INTEGER(iwp)                          ::  nv             !< number of netCDF output variables
     255    INTEGER(iwp)                          ::  n_inputs       !< number of input variables
     256    INTEGER(iwp)                          ::  n_output_quantities !< number of physical quantities required for computing netCDF output variables
    253257    CHARACTER(LEN=SNAME)             ::  kind           !< kind of I/O group
    254258    CHARACTER(LEN=PATH), ALLOCATABLE ::  in_files(:)    !< list of nt input files
  • palm/trunk/UTIL/inifor/src/inifor_util.f90

    r4499 r4523  
    2626! -----------------
    2727! $Id$
     28! respect integer working precision (iwp) specified in inifor_defs.f90
     29!
     30!
     31! 4499 2020-04-16 15:51:56Z eckhard
    2832! Bugfix: avoid using already overwritten elements in 'reverse' subroutine
    2933!
     
    7377
    7478    USE inifor_defs,                                                           &
    75         ONLY :  PI, DATE, SNAME, wp
     79        ONLY :  PI, DATE, SNAME, iwp, wp
    7680    USE inifor_types,                                                          &
    7781        ONLY :  grid_definition
     
    169173 CHARACTER(LEN=DATE) FUNCTION add_hours_to(date_string, hours)
    170174    CHARACTER(LEN=DATE), INTENT(IN)          ::  date_string
    171     INTEGER, INTENT(IN)                      ::  hours
     175    INTEGER(iwp), INTENT(IN)                 ::  hours
    172176
    173177    CHARACTER(KIND=C_CHAR, LEN=*), PARAMETER ::  format_string = "%Y%m%d%H"
     
    175179    TYPE(C_PTR)                              ::  c_pointer
    176180    TYPE(tm_struct)                          ::  time_info
    177     INTEGER                                  ::  err
     181    INTEGER(iwp)                             ::  err
    178182
    179183    c_date_string = date_string
     
    249253    REAL(wp), INTENT(IN)    ::  start, stop
    250254    REAL(wp), INTENT(INOUT) ::  array(0:)
    251     INTEGER                 ::  i, n
     255    INTEGER(iwp)            ::  i, n
    252256
    253257    n = UBOUND(array, 1)
     
    276280 SUBROUTINE reverse(input_arr)
    277281
    278     INTEGER ::  idx, opposite_idx, half_idx
    279     INTEGER ::  size_1st_dimension
    280     INTEGER ::  size_2nd_dimension
    281     INTEGER ::  size_3rd_dimension
    282     INTEGER ::  lbound_3rd_dimension
    283     INTEGER ::  ubound_3rd_dimension
     282    INTEGER(iwp) ::  idx, opposite_idx, half_idx
     283    INTEGER(iwp) ::  size_1st_dimension
     284    INTEGER(iwp) ::  size_2nd_dimension
     285    INTEGER(iwp) ::  size_3rd_dimension
     286    INTEGER(iwp) ::  lbound_3rd_dimension
     287    INTEGER(iwp) ::  ubound_3rd_dimension
    284288
    285289    REAL(wp), INTENT(INOUT) ::  input_arr(:,:,:)
     
    432436 CHARACTER(LEN=10) FUNCTION str(val)
    433437
    434      INTEGER, INTENT(IN) ::  val
     438     INTEGER(iwp), INTENT(IN) ::  val
    435439
    436440     WRITE(str, '(i10)') val
     
    448452     
    449453     CHARACTER(LEN=*), INTENT(INOUT) ::  path
    450      INTEGER ::  n
     454     INTEGER(iwp) ::  n
    451455
    452456     n = LEN_TRIM(path)
Note: See TracChangeset for help on using the changeset viewer.