Changeset 4568
- Timestamp:
- Jun 19, 2020 11:56:30 AM (4 years ago)
- Location:
- palm/trunk/UTIL/inifor/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
palm/trunk/UTIL/inifor/src/inifor_defs.f90
r4553 r4568 26 26 ! ----------------- 27 27 ! $Id$ 28 ! Bumped version number 29 ! 30 ! 31 ! 4553 2020-06-03 16:34:15Z eckhard 28 32 ! Bumped version number 29 33 ! … … 178 182 179 183 ! 180 !-- COSMO netCDF names 184 !-- COSMO netCDF parameters 185 INTEGER, PARAMETER :: NC_DEPTH_DIM_IDX = 3 181 186 CHARACTER(SNAME), PARAMETER :: NC_DEPTH_NAME = 'depth_2' 182 187 CHARACTER(SNAME), PARAMETER :: NC_HHL_NAME = 'HHL' … … 196 201 ACHAR( 10 ) // ' Copyright 2017-2020 Deutscher Wetterdienst Offenbach' !< Copyright notice 197 202 CHARACTER(LEN=*), PARAMETER :: LOG_FILE_NAME = 'inifor.log' !< Name of INIFOR's log file 198 CHARACTER(LEN=*), PARAMETER :: VERSION = '1.4.1 5' !< INIFOR version number203 CHARACTER(LEN=*), PARAMETER :: VERSION = '1.4.16' !< INIFOR version number 199 204 200 205 END MODULE inifor_defs -
palm/trunk/UTIL/inifor/src/inifor_grid.f90
r4553 r4568 26 26 ! ----------------- 27 27 ! $Id$ 28 ! Handle COSMO soil data with and without additional surface temperature 29 ! Imporved messaging 30 ! 31 ! 32 ! 4553 2020-06-03 16:34:15Z eckhard 28 33 ! Fixed domain extent check 29 34 ! Added and fixed code documentation … … 177 182 ONLY: get_cosmo_grid, get_input_file_list, get_netcdf_attribute, & 178 183 get_netcdf_dim_vector, get_netcdf_variable, set_palm_origin, & 179 parse_command_line_arguments, validate_config 184 parse_command_line_arguments, validate_config, & 185 has_surface_value 180 186 USE inifor_transform, & 181 187 ONLY: average_2d, rotate_to_cosmo, find_horizontal_neighbours, & … … 639 645 CALL report ('setup_parameters', message) 640 646 641 message = " North pole of the rotated COSMO-DE system:" // NEW_LINE(' ') // &647 message = "COSMO rotated north pole:" // NEW_LINE(' ') // & 642 648 " lon (lambda) = " // & 643 649 TRIM(real_to_str_f(lambda_n * TO_DEGREES)) // " deg" // NEW_LINE(' ') //& … … 2384 2390 ENDIF 2385 2391 2386 nc_source_text = 'COSMO -DEanalysis from ' // TRIM(cfg%start_date)2392 nc_source_text = 'COSMO analysis from ' // TRIM(cfg%start_date) 2387 2393 2388 2394 n_invar = 17 … … 2395 2401 !- Section 1: NetCDF input variables 2396 2402 !------------------------------------------------------------------------------ 2403 2404 ! 2405 !-- COSMO's soil temperature T_SO may contain the surface temperature at 2406 !-- depth=0, which is a redundant copy the first soil layer. INIFOR uses this 2407 !-- flag to decide if this level is present and has to be ignored in 2408 !-- inifor_io:get_netcdf_start_and_count(). 2409 input_var_table(:)%has_redundant_first_level = .FALSE. 2410 2397 2411 var => input_var_table(1) 2398 2412 var%name = 'T_SO' 2399 2413 var%to_be_processed = .TRUE. 2400 2414 var%is_upside_down = .FALSE. 2415 input_var_table(1)%has_redundant_first_level = has_surface_value( var, soil_files(1) ) 2401 2416 2402 2417 var => input_var_table(2) -
palm/trunk/UTIL/inifor/src/inifor_io.f90
r4553 r4568 26 26 ! ----------------- 27 27 ! $Id$ 28 ! Handle COSMO soil data with and without additional surface temperature 29 ! 30 ! 31 ! 4553 2020-06-03 16:34:15Z eckhard 28 32 ! Option --help now points the user to INIFOR's wiki page 29 33 ! Remove deprecated command-line options -clon and -clat … … 146 150 USE inifor_defs, & 147 151 ONLY: DATE, SNAME, PATH, PI, TO_RADIANS, TO_DEGREES, VERSION, & 148 NC_DEPTH_ NAME, NC_HHL_NAME, NC_RLAT_NAME, NC_RLON_NAME,&149 NC_R OTATED_POLE_NAME, NC_POLE_LATITUDE_NAME,&152 NC_DEPTH_DIM_IDX, NC_DEPTH_NAME, NC_HHL_NAME, NC_RLAT_NAME, & 153 NC_RLON_NAME, NC_ROTATED_POLE_NAME, NC_POLE_LATITUDE_NAME, & 150 154 NC_POLE_LONGITUDE_NAME, RHO_L, iwp, wp, & 151 155 PIDS_ORIGIN_LON, PIDS_ORIGIN_LAT, PIDS_ORIGIN_Z 152 156 USE inifor_types 153 157 USE inifor_util, & 154 ONLY: add_hours_to, reverse, str, real_to_str158 ONLY: add_hours_to, nearly_equal, reverse, str, real_to_str 155 159 USE netcdf 156 160 … … 355 359 356 360 start = (/ 1, 1, 1 /) 357 IF ( TRIM(in_var%name) .EQ. 'T_SO' ) THEN 361 IF ( TRIM(in_var%name) .EQ. 'T_SO' .AND. & 362 in_var%has_redundant_first_level ) THEN 363 358 364 ! 359 365 !-- Skip depth = 0.0 for T_SO and reduce number of depths from 9 to 8 … … 1578 1584 END SUBROUTINE set_palm_origin 1579 1585 1586 1587 !------------------------------------------------------------------------------! 1588 ! Description: 1589 ! ------------ 1590 ! This function is meant to check weather a COSMO soil variable has an 1591 ! additional and redunant surface value at depth = 0.0. For instance operational 1592 ! DWD COSMO output contains the surface temperature in T_SO as a copy of the 1593 ! values in the first soil layer. 1594 !------------------------------------------------------------------------------! 1595 LOGICAL FUNCTION has_surface_value( soil_var, filename ) 1596 1597 TYPE(nc_var), INTENT(IN) :: soil_var 1598 CHARACTER(LEN=*), INTENT(IN) :: filename 1599 1600 CHARACTER(LEN=NF90_MAX_NAME) :: dimname 1601 REAL(wp), ALLOCATABLE :: depths(:) 1602 1603 CALL get_dimension_vector_of_variable( & 1604 soil_var%name, & 1605 dim_idx = NC_DEPTH_DIM_IDX, & 1606 filename = filename, & 1607 dim_vector = depths & 1608 ) 1609 1610 has_surface_value = nearly_equal( depths(1), 0.0_wp, 10 * EPSILON(1.0_wp) ) 1611 1612 END FUNCTION has_surface_value 1613 1614 1615 !------------------------------------------------------------------------------! 1616 ! Description: 1617 ! ------------ 1618 ! This routine reads the dim_idx-th dimension vector of the variable varname 1619 ! from netCDF file filename. It is used for finding the depth coordinate vector 1620 ! of COSMO soil variables without knowing its name. 1621 !------------------------------------------------------------------------------! 1622 SUBROUTINE get_dimension_vector_of_variable( varname, dim_idx, filename, dim_vector ) 1623 CHARACTER(LEN=*), INTENT(IN) :: varname, filename 1624 INTEGER, INTENT(IN) :: dim_idx 1625 1626 REAL(wp), INTENT(OUT), ALLOCATABLE :: dim_vector(:) 1627 1628 INTEGER :: dimids(NF90_MAX_VAR_DIMS) 1629 INTEGER :: varid 1630 CHARACTER(LEN=NF90_MAX_NAME) :: dimname 1631 1632 INTEGER :: ncid 1633 1634 IF ( nf90_open( TRIM( filename ), NF90_NOWRITE, ncid ) .EQ. NF90_NOERR ) THEN 1635 1636 ! 1637 !-- get id of variable varname 1638 CALL check( nf90_inq_varid( ncid, TRIM( varname ), varid ) ) 1639 1640 ! 1641 !-- get dimension ids of variable with varid 1642 CALL check( nf90_inquire_variable( ncid, varid, dimids = dimids ) ) 1643 1644 ! 1645 !-- get name of dim_idx-th dimension variable 1646 CALL check( nf90_inquire_dimension( ncid, dimids(dim_idx), name = dimname ) ) 1647 CALL check( nf90_close( ncid ) ) 1648 1649 ELSE 1650 1651 message = "Failed to open file '" // TRIM(filename) // "'." 1652 CALL inifor_abort('get_netcdf_variable', message) 1653 1654 ENDIF 1655 1656 ! get dimension vector with dimname 1657 CALL get_netcdf_dim_vector( filename, dimname, dim_vector ) 1658 1659 END SUBROUTINE get_dimension_vector_of_variable 1660 1661 1580 1662 END MODULE inifor_io 1581 1663 #endif -
palm/trunk/UTIL/inifor/src/inifor_types.f90
r4553 r4568 26 26 ! ----------------- 27 27 ! $Id$ 28 ! Handle COSMO soil data with and without additional surface temperature 29 ! 30 ! 31 ! 4553 2020-06-03 16:34:15Z eckhard 28 32 ! Minor code readability improvements 29 33 ! … … 245 249 LOGICAL :: is_read = .FALSE. !< INIFOR flag indicating whether variable has been read 246 250 LOGICAL :: is_upside_down = .FALSE. !< INIFOR flag indicating whether vertical dimension is reversed (typically the case with COSMO-DE atmospheric fields) 251 LOGICAL :: has_redundant_first_level !< INIFOR flag inidicating whether a soil variable has a redundant first level (e.g. COSMO's T_SO may contain the surface temperature at depth=0, which is a redundant copy the first model layer) 247 252 TYPE(grid_definition), POINTER :: grid !< Pointer to the corresponding output grid 248 253 TYPE(grid_definition), POINTER :: intermediate_grid !< Pointer to the corresponding intermediate grid -
palm/trunk/UTIL/inifor/src/inifor_util.f90
r4523 r4568 26 26 ! ----------------- 27 27 ! $Id$ 28 ! Added function for checking floating point equality 29 ! 30 ! 31 ! 4523 2020-05-07 15:58:16Z eckhard 28 32 ! respect integer working precision (iwp) specified in inifor_defs.f90 29 33 ! … … 462 466 END SUBROUTINE 463 467 468 469 !------------------------------------------------------------------------------! 470 ! Description: 471 ! ------------ 472 !> Check for exact or near equality of two floating point numbers. Inspired by 473 !> https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/ 474 !------------------------------------------------------------------------------! 475 LOGICAL FUNCTION nearly_equal(a, b, max_rel_diff) 476 477 REAL(wp), INTENT(IN) :: a, b, max_rel_diff 478 REAL(wp) :: diff, mag 479 480 diff = ABS( a - b ) 481 mag = MAX( ABS(a), ABS(b) ) 482 nearly_equal = ( diff .LE. mag * max_rel_diff ) 483 484 END FUNCTION nearly_equal 485 464 486 END MODULE inifor_util
Note: See TracChangeset
for help on using the changeset viewer.