Changeset 4790
- Timestamp:
- Nov 18, 2020 1:05:58 PM (4 years ago)
- Location:
- palm/trunk/UTIL/inifor/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
palm/trunk/UTIL/inifor/src/inifor_defs.f90
r4756 r4790 214 214 ACHAR( 10 ) // ' Copyright 2017-2020 Deutscher Wetterdienst Offenbach' !< Copyright notice 215 215 CHARACTER(LEN=*), PARAMETER :: LOG_FILE_NAME = 'inifor.log' !< Name of INIFOR's log file 216 CHARACTER(LEN=*), PARAMETER :: VERSION = '2.1. 2' !< INIFOR version number216 CHARACTER(LEN=*), PARAMETER :: VERSION = '2.1.3' !< INIFOR version number 217 217 218 218 END MODULE inifor_defs -
palm/trunk/UTIL/inifor/src/inifor_grid.f90
r4715 r4790 26 26 ! ----------------- 27 27 ! $Id$ 28 ! Call dataset validation 29 ! Fixed error message 30 ! 31 ! 32 ! 4715 2020-09-30 13:14:43Z eckhard 28 33 ! Make LODs for top boundary conditions consistent with PALM 29 34 ! … … 205 210 PIDS_ORIGIN_Z 206 211 USE inifor_io, & 207 ONLY: file_is_present, get_cosmo_grid, get_input_file_list, get_netcdf_attribute, & 208 get_netcdf_dim_vector, get_netcdf_variable, set_palm_origin, & 209 netcdf_variable_present_in_file, parse_command_line_arguments, validate_config, & 210 has_surface_value 212 ONLY: file_is_present, get_cosmo_grid, get_input_file_list, & 213 get_netcdf_attribute, get_netcdf_dim_vector, & 214 get_netcdf_variable, set_palm_origin, & 215 netcdf_variable_present_in_file, parse_command_line_arguments, & 216 validate_config, validate_dataset, has_surface_value 211 217 USE inifor_transform, & 212 218 ONLY: average_2d, rotate_to_cosmo, find_horizontal_neighbours, & … … 591 597 ! Section 3: Check for consistency 592 598 !------------------------------------------------------------------------------ 599 CALL validate_dataset( flow_files, cfg%hhl_file ) 593 600 594 601 ! … … 612 619 CALL log_runtime('time', 'read') 613 620 614 CALL get_cosmo_grid( cfg % hhl_file, soil_files(1), rlon, rlat, hhl, hfl,&621 CALL get_cosmo_grid( cfg%hhl_file, soil_files(1), rlon, rlat, hhl, hfl, & 615 622 depths, d_depth, d_depth_rho_inv, phi_n, lambda_n, & 616 623 phi_equat, & … … 2384 2391 ELSE 2385 2392 message = "Set up input file name '" // TRIM(filename) // "'" 2386 CALL report('v erify_file', message)2393 CALL report('validate_io_groups', message) 2387 2394 ENDIF 2388 2395 -
palm/trunk/UTIL/inifor/src/inifor_io.f90
r4675 r4790 26 26 ! ----------------- 27 27 ! $Id$ 28 ! Validate mesoscale input data by the number of dimensions and their lengths 29 ! 30 ! 31 ! 4675 2020-09-11 10:00:26Z eckhard 28 32 ! New command-line options for soil profile initialization and homogeneous 29 33 ! boundary conditions … … 409 413 SUBROUTINE netcdf_define_variable(var, ncid) 410 414 411 412 413 414 415 416 417 418 419 420 421 415 TYPE(nc_var), INTENT(INOUT) :: var 416 INTEGER, INTENT(IN) :: ncid 417 418 CALL check(nf90_def_var(ncid, var%name, NF90_FLOAT, var%dimids(1:var%ndim), var%varid)) 419 CALL check(nf90_put_att(ncid, var%varid, "long_name", var%long_name)) 420 CALL check(nf90_put_att(ncid, var%varid, "units", var%units)) 421 IF ( var%lod .GE. 0 ) THEN 422 CALL check(nf90_put_att(ncid, var%varid, "lod", var%lod)) 423 ENDIF 424 CALL check(nf90_put_att(ncid, var%varid, "source", var%source)) 425 CALL check(nf90_put_att(ncid, var%varid, "_FillValue", NF90_FILL_REAL)) 422 426 423 427 END SUBROUTINE netcdf_define_variable … … 433 437 SUBROUTINE netcdf_get_dimensions(var, ncid) 434 438 435 436 437 438 439 440 441 442 443 444 439 TYPE(nc_var), INTENT(INOUT) :: var 440 INTEGER, INTENT(IN) :: ncid 441 INTEGER :: i 442 CHARACTER(SNAME) :: null 443 444 DO i = 1, var%ndim 445 CALL check(nf90_inquire_dimension(ncid, var%dimids(i), & 446 name = null, & 447 len = var%dimlen(i) ) ) 448 ENDDO 445 449 446 450 END SUBROUTINE netcdf_get_dimensions … … 819 823 820 824 825 !------------------------------------------------------------------------------! 826 ! Description: 827 ! ------------ 828 !> Checks wheather the COSMO grid matches the shape of the meteorological input 829 !> data by comparing the number of netCDF dimensions and their lengths in the 830 !> hhl.nc and the first of the *-flow files. 831 !------------------------------------------------------------------------------! 832 SUBROUTINE validate_dataset(flow_files, hhl_file) 833 CHARACTER(LEN=PATH), INTENT(IN) :: flow_files(:) !< paths to files containing atmospheric variables 834 CHARACTER(LEN=PATH), INTENT(IN) :: hhl_file !< path to file containing the HHL variable (height of half layers) 835 836 CHARACTER(SNAME), PARAMETER :: NC_W_NAME = 'W' 837 TYPE(nc_var) :: hhl_var, flow_var 838 INTEGER :: dim_idx, ncid, ndims_flow, ndims_hhl, varid 839 REAL(wp), ALLOCATABLE :: hhl_dim_vector(:), flow_dim_vector(:) 840 LOGICAL :: dims_have_same_length 841 842 IF ( nf90_open( TRIM( flow_files(1) ), NF90_NOWRITE, ncid ) .EQ. NF90_NOERR ) THEN 843 844 CALL check( nf90_inq_varid( ncid, NC_W_NAME, varid=varid ) ) 845 CALL check( nf90_inquire_variable( ncid, varid, ndims=ndims_flow ) ) 846 CALL netcdf_get_dimensions( flow_var, ncid ) 847 CALL check( nf90_close( ncid ) ) 848 849 ELSE 850 851 message = "Failed to read netCDF dimensions'" // & 852 "' from file '" // TRIM( flow_files(1) ) // "'." 853 CALL inifor_abort( 'validate_dataset', message ) 854 855 ENDIF 856 857 IF ( nf90_open( TRIM( hhl_file ), NF90_NOWRITE, ncid ) .EQ. NF90_NOERR ) THEN 858 859 CALL check( nf90_inq_varid( ncid, NC_HHL_NAME, varid=varid ) ) 860 CALL check( nf90_inquire_variable( ncid, varid, ndims=ndims_hhl ) ) 861 CALL netcdf_get_dimensions( hhl_var, ncid ) 862 CALL check( nf90_close( ncid ) ) 863 864 ELSE 865 866 message = "Failed to read netCDF dimensions'" // & 867 "' from file '" // TRIM(hhl_file) // "'." 868 CALL inifor_abort( 'validate_dataset', message ) 869 870 ENDIF 871 872 ! 873 !-- Compare number dimensions of 'HHL' in hhl file and 'W' in first flow file 874 IF ( .NOT. ndims_flow .EQ. ndims_hhl ) THEN 875 message = "Mesoscale data inconsistent. Number of dimensions in the " //& 876 "hhl file does not match with the meteorologial fields " // & 877 "in the *-flow files (" // & 878 "HHL: ndims = " // TRIM( str( ndims_hhl ) ) // ", " // & 879 "W: ndims = " // TRIM( str( ndims_flow ) ) // ")." 880 CALL inifor_abort( 'validate_dataset', message ) 881 ENDIF 882 883 884 ! 885 !-- Compare lengths of each dimension, ignoring time (dim_idx = 1) 886 DO dim_idx = 2, ndims_hhl 887 888 CALL get_dimension_vector_of_variable( & 889 NC_HHL_NAME, & 890 dim_idx = dim_idx, & 891 filename = hhl_file, & 892 dim_vector = hhl_dim_vector & 893 ) 894 895 CALL get_dimension_vector_of_variable( & 896 NC_W_NAME, & 897 dim_idx = dim_idx, & 898 filename = flow_files(1), & 899 dim_vector = flow_dim_vector & 900 ) 901 902 dims_have_same_length = SIZE( flow_dim_vector ) .EQ. SIZE( hhl_dim_vector ) 903 IF ( .NOT. dims_have_same_length ) THEN 904 message = & 905 "Mesoscale data inconsistent. Number of grid points " // & 906 "in dimension #" // TRIM( str( dim_idx ) ) // & 907 " do not match in the hhl and *-flow files (" // & 908 "HHL: len = " // TRIM( str( SIZE( hhl_dim_vector ) ) ) // ", " // & 909 "W: len = " // TRIM( str( SIZE( flow_dim_vector ) ) )// ")." 910 CALL inifor_abort( 'validate_dataset', message ) 911 ENDIF 912 913 ENDDO 914 915 END SUBROUTINE validate_dataset 916 821 917 SUBROUTINE get_cosmo_grid( hhl_file, soil_file, rlon, rlat, hhl, hfl, depths, & 822 d_depth, d_depth_rho_inv, phi_n, lambda_n, &823 phi_equat, &824 lonmin_cosmo, lonmax_cosmo, &825 latmin_cosmo, latmax_cosmo, &918 d_depth, d_depth_rho_inv, phi_n, lambda_n, & 919 phi_equat, & 920 lonmin_cosmo, lonmax_cosmo, & 921 latmin_cosmo, latmax_cosmo, & 826 922 nlon, nlat, nlev, ndepths ) 827 923 -
palm/trunk/UTIL/inifor/src/inifor_util.f90
r4568 r4790 21 21 ! Current revisions: 22 22 ! ----------------- 23 ! 24 ! 23 ! 24 ! 25 25 ! Former revisions: 26 26 ! ----------------- 27 27 ! $Id$ 28 ! Support integer-string conversion for 8 and 4 bit types 29 ! 30 ! 31 ! 4568 2020-06-19 11:56:30Z eckhard 28 32 ! Added function for checking floating point equality 29 33 ! … … 166 170 END INTERFACE 167 171 172 173 INTERFACE str 174 MODULE PROCEDURE str_iwp 175 MODULE PROCEDURE str_4 176 END INTERFACE 177 178 168 179 CONTAINS 169 180 … … 438 449 !> Converts the given integer value to a string 439 450 !------------------------------------------------------------------------------! 440 CHARACTER(LEN=10) FUNCTION str (val)451 CHARACTER(LEN=10) FUNCTION str_iwp(val) 441 452 442 453 INTEGER(iwp), INTENT(IN) :: val 443 454 444 WRITE(str, '(i10)') val 445 str = ADJUSTL(str) 446 447 END FUNCTION str 448 449 455 WRITE(str_iwp, '(i10)') val 456 str_iwp= ADJUSTL(str_iwp) 457 458 END FUNCTION str_iwp 459 460 461 CHARACTER(LEN=10) FUNCTION str_4(val) 462 463 INTEGER(4), INTENT(IN) :: val 464 465 WRITE(str_4, '(i10)') val 466 str_4 = ADJUSTL(str_4) 467 468 END FUNCTION str_4 450 469 !------------------------------------------------------------------------------! 451 470 ! Description:
Note: See TracChangeset
for help on using the changeset viewer.