Changeset 4538 for palm/trunk/UTIL


Ignore:
Timestamp:
May 18, 2020 1:45:35 PM (4 years ago)
Author:
eckhard
Message:

inifor: Fix issue where --elevation/-z option was ignored, make it mandatory

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

Legend:

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

    r4523 r4538  
    2626! -----------------
    2727! $Id$
     28! Bumped version number
     29!
     30!
     31! 4523 2020-05-07 15:58:16Z eckhard
    2832! Updated copyright notice, bumped version number
    2933!
     
    188192    ACHAR( 10 ) // ' Copyright 2017-2020 Deutscher Wetterdienst Offenbach' !< Copyright notice
    189193 CHARACTER(LEN=*), PARAMETER ::  LOG_FILE_NAME = 'inifor.log' !< Name of INIFOR's log file
    190  CHARACTER(LEN=*), PARAMETER ::  VERSION = '1.4.13'           !< INIFOR version number
     194 CHARACTER(LEN=*), PARAMETER ::  VERSION = '1.4.14'           !< INIFOR version number
    191195 
    192196 END MODULE inifor_defs
  • palm/trunk/UTIL/inifor/src/inifor_grid.f90

    r4523 r4538  
    2626! -----------------
    2727! $Id$
     28! Modularize setup of PALM origin
     29!
     30!
     31! 4523 2020-05-07 15:58:16Z eckhard
    2832! respect integer working precision (iwp) specified in inifor_defs.f90
    2933!
     
    166170               PIDS_ORIGIN_Z
    167171    USE inifor_io,                                                             &
    168         ONLY:  get_cosmo_grid, get_netcdf_attribute, get_netcdf_dim_vector,    &
    169                get_netcdf_variable, parse_command_line_arguments,              &
    170                get_input_file_list, validate_config
     172        ONLY:  get_cosmo_grid, get_input_file_list, get_netcdf_attribute,      &
     173               get_netcdf_dim_vector, get_netcdf_variable, set_palm_origin,    &
     174               parse_command_line_arguments, validate_config
    171175    USE inifor_transform,                                                      &
    172176        ONLY:  average_2d, rotate_to_cosmo, find_horizontal_neighbours,        &
     
    561565    CALL get_netcdf_variable(cfg%soiltyp_file, cosmo_var, soiltyp)
    562566
    563     message = 'Reading PALM-4U origin from'
    564     IF (TRIM(cfg%static_driver_file) .NE. '')  THEN
    565 
    566        origin_lon = get_netcdf_attribute(cfg%static_driver_file, TRIM( PIDS_ORIGIN_LON ) )
    567        origin_lat = get_netcdf_attribute(cfg%static_driver_file, TRIM( PIDS_ORIGIN_LAT ) )
    568        z0         = get_netcdf_attribute(cfg%static_driver_file, TRIM( PIDS_ORIGIN_Z ) )
    569 
    570 
    571        message = TRIM(message) // " static driver file '"                   &
    572                                // TRIM(cfg%static_driver_file) // "'"
    573 
    574 
    575     ELSE
    576 
    577        origin_lon = longitude
    578        origin_lat = latitude
    579 
    580        message = TRIM(message) // " namlist file '"                         &
    581                                // TRIM(cfg%namelist_file) // "'"
    582 
    583     ENDIF
    584     origin_lon = origin_lon * TO_RADIANS
    585     origin_lat = origin_lat * TO_RADIANS
    586 
    587     CALL report('setup_parameters', message)
    588 
    589     IF ( cfg%z0_is_set .AND. TRIM( cfg%static_driver_file ) .NE. '' )  THEN
    590 
    591        message = 'You specified both --static-driver/-t and --elevation/-z0. ' // &
    592                  'Using the command line value (' // TRIM( real_to_str_f( cfg%z0 ) ) // &
    593                  ') instead of static driver value (' // TRIM( real_to_str_f( z0 ) ) // ').'
    594        CALL warn('setup_parameters', message)
    595 
    596        z0 = cfg%z0
    597 
    598     END IF
    599 
     567    CALL set_palm_origin(cfg, longitude, latitude, origin_lon, origin_lat, z0)
    600568    p0 = cfg%p0
    601569
     
    39803948             CASE DEFAULT
    39813949                message = "Invalid averaging period '" // TRIM(str(dt)) // " hours"
     3950                message = "Invalid averaging period '" // TRIM(str(dt)) // " hours"
    39823951                CALL inifor_abort('preprocess', message)
    39833952
  • palm/trunk/UTIL/inifor/src/inifor_io.f90

    r4523 r4538  
    2626! -----------------
    2727! $Id$
     28! Make setting the vertical PALM origin mandatory
     29!
     30!
     31! 4523 2020-05-07 15:58:16Z eckhard
    2832! respect integer working precision (iwp) specified in inifor_defs.f90
    2933!
     
    139143               NC_DEPTH_NAME, NC_HHL_NAME, NC_RLAT_NAME, NC_RLON_NAME,         &
    140144               NC_ROTATED_POLE_NAME, NC_POLE_LATITUDE_NAME,                    &
    141                NC_POLE_LONGITUDE_NAME, RHO_L, iwp, wp
     145               NC_POLE_LONGITUDE_NAME, RHO_L, iwp, wp,                         &
     146               PIDS_ORIGIN_LON, PIDS_ORIGIN_LAT, PIDS_ORIGIN_Z
    142147    USE inifor_types
    143148    USE inifor_util,                                                           &
     
    431436    cfg%soil_prefix_is_set = .FALSE.
    432437    cfg%soilmoisture_prefix_is_set = .FALSE.
     438    cfg%static_driver_is_set = .FALSE.
    433439    cfg%ug_defined_by_user = .FALSE.
    434440    cfg%vg_defined_by_user = .FALSE.
     
    503509
    504510             CASE( '-static', '-t', '--static-driver' )
     511                cfg%static_driver_is_set = .TRUE.
    505512                CALL get_option_argument( i, arg )
    506513                cfg%static_driver_file = TRIM(arg)
     
    762769       message = "You specified only one component of the geostrophic " // &
    763770                 "wind. Please specify either both or none."
     771       CALL inifor_abort( 'validate_config', message )
     772    ENDIF
     773
     774    IF ( .NOT. cfg%static_driver_is_set .AND. .NOT. cfg%z0_is_set )  THEN
     775       message =                                                               &
     776          "The vertical origin of the PALM grid has not been defined. " // NEW_LINE(" ") // &
     777          "Please specify the right value for your setup by either " // NEW_LINE(" ") // &
     778          "  - using the command-line option --elevation <height above sea level>, or by" // NEW_LINE(" ") // &
     779          "  - specifying a static driver file using --static <filename> in order to use " // NEW_LINE(" ") // &
     780          "    use the value of origin_z (and origin_lon and origin_lat) specifed therein."
    764781       CALL inifor_abort( 'validate_config', message )
    765782    ENDIF
     
    15121529 END SUBROUTINE check
    15131530
     1531
     1532!------------------------------------------------------------------------------!
     1533! Description:
     1534! ------------
     1535!> Setup the origin of the PALM coordinate system based on what is given in the
     1536!> INIFOR namelist file and via an optional static driver.
     1537!------------------------------------------------------------------------------!
     1538 SUBROUTINE set_palm_origin( cfg, namelist_longitude, namelist_latitude,       &
     1539                             origin_lon, origin_lat, z0 )
     1540
     1541    TYPE(inifor_config), INTENT(IN) ::  cfg
     1542    REAL(wp), INTENT(IN)            ::  namelist_longitude, namelist_latitude
     1543    REAL(wp), INTENT(OUT)           ::  origin_lon, origin_lat, z0
     1544
     1545    message = 'Reading PALM-4U origin from'
     1546    IF ( TRIM( cfg%static_driver_file ) .NE. '' )  THEN
     1547
     1548       origin_lon = get_netcdf_attribute( cfg%static_driver_file, TRIM( PIDS_ORIGIN_LON ) )
     1549       origin_lat = get_netcdf_attribute( cfg%static_driver_file, TRIM( PIDS_ORIGIN_LAT ) )
     1550       z0         = get_netcdf_attribute( cfg%static_driver_file, TRIM( PIDS_ORIGIN_Z ) )
     1551
     1552       message = TRIM(message) // " static driver file '"                      &
     1553                               // TRIM( cfg%static_driver_file ) // "'"
     1554
     1555
     1556    ELSE
     1557
     1558       origin_lon = namelist_longitude
     1559       origin_lat = namelist_latitude
     1560
     1561       message = TRIM( message ) // " namlist file '"                          &
     1562                                 // TRIM( cfg%namelist_file ) // "'"
     1563
     1564    ENDIF
     1565    origin_lon = origin_lon * TO_RADIANS
     1566    origin_lat = origin_lat * TO_RADIANS
     1567
     1568    CALL report('set_palm_origin', message)
     1569
     1570    IF ( cfg%z0_is_set )  THEN
     1571       z0 = cfg%z0
     1572       IF ( TRIM( cfg%static_driver_file ) .NE. '' )  THEN
     1573          message = 'You specified both --static-driver/-t and --elevation/-z0. ' // &
     1574                    'Using the command line value (' // TRIM( real_to_str_f( cfg%z0 ) ) // &
     1575                    ') instead of static driver value (' // TRIM( real_to_str_f( z0 ) ) // ').'
     1576          CALL warn( 'set_palm_origin', message )
     1577       ENDIF
     1578    ENDIF
     1579
     1580 END SUBROUTINE set_palm_origin
     1581
    15141582 END MODULE inifor_io
    15151583#endif
  • palm/trunk/UTIL/inifor/src/inifor_types.f90

    r4523 r4538  
    2626! -----------------
    2727! $Id$
     28! Added boolean indicator for --static-driver option invocation
     29!
     30!
     31! 4523 2020-05-07 15:58:16Z eckhard
    2832! respect integer working precision (iwp) specified in inifor_defs.f90
    2933!
     
    131135    LOGICAL              ::  soil_prefix_is_set          !< indicates whether the soil prefix was set manually
    132136    LOGICAL              ::  soilmoisture_prefix_is_set  !< indicates whether the soilmoisture prefix was set manually
     137    LOGICAL              ::  static_driver_is_set        !< indicates whether a static driver was given
    133138    LOGICAL              ::  ug_defined_by_user          !< indicates whether ug was set manually
    134139    LOGICAL              ::  vg_defined_by_user          !< indicates whether vg was set manually
Note: See TracChangeset for help on using the changeset viewer.