Changeset 3395 for palm/trunk/UTIL/inifor/src/io.f90
- Timestamp:
- Oct 22, 2018 5:32:49 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
palm/trunk/UTIL/inifor/src/io.f90
r3262 r3395 26 26 ! ----------------- 27 27 ! $Id$ 28 ! Removed unnecessary check for output file 28 ! Added command-line options for configuring the computation of geostrophic 29 ! winds (--averagin-mode, --averaging-angle) 30 ! Added command-line option --input-prefix for setting input file prefixes all 31 ! at once 32 ! Added --debug option for more verbose terminal output 33 ! Added option-specific *_is_set LOGICALs to indicate invocation from the 34 ! command-line 35 ! Improved error messages in case of empty file-name strings 36 ! Improved routine naming 29 37 ! 30 38 ! 3183 2018-07-27 14:25:55Z suehring … … 148 156 INTEGER :: arg_count, i 149 157 158 cfg % p0_is_set = .FALSE. 159 cfg % ug_is_set = .FALSE. 160 cfg % vg_is_set = .FALSE. 161 cfg % flow_prefix_is_set = .FALSE. 162 cfg % input_prefix_is_set = .FALSE. 163 cfg % radiation_prefix_is_set = .FALSE. 164 cfg % soil_prefix_is_set = .FALSE. 165 cfg % soilmoisture_prefix_is_set = .FALSE. 166 150 167 arg_count = COMMAND_ARGUMENT_COUNT() 151 168 IF (arg_count .GT. 0) THEN … … 170 187 SELECT CASE( TRIM(option) ) 171 188 189 CASE( '--averaging-mode' ) 190 CALL get_option_argument( i, arg ) 191 cfg % averaging_mode = TRIM(arg) 192 172 193 CASE( '-date', '-d', '--date' ) 173 194 CALL get_option_argument( i, arg ) 174 195 cfg % start_date = TRIM(arg) 196 197 CASE( '--debug' ) 198 cfg % debug = .TRUE. 175 199 176 200 ! Elevation of the PALM-4U domain above sea level … … 181 205 ! surface pressure, at z0 182 206 CASE( '-p0', '-r', '--surface-pressure' ) 207 cfg % p0_is_set = .TRUE. 183 208 CALL get_option_argument( i, arg ) 184 209 READ(arg, *) cfg % p0 … … 186 211 ! geostrophic wind in x direction 187 212 CASE( '-ug', '-u', '--geostrophic-u' ) 213 cfg % ug_is_set = .TRUE. 188 214 CALL get_option_argument( i, arg ) 189 215 READ(arg, *) cfg % ug … … 191 217 ! geostrophic wind in y direction 192 218 CASE( '-vg', '-v', '--geostrophic-v' ) 219 cfg % vg_is_set = .TRUE. 193 220 CALL get_option_argument( i, arg ) 194 221 READ(arg, *) cfg % vg … … 208 235 CASE( '-hhl', '-l', '--hhl-file' ) 209 236 CALL get_option_argument( i, arg ) 210 cfg % hhl_file = TRIM(arg) 237 cfg % hhl_file = TRIM(arg) 238 239 CASE( '--input-prefix') 240 CALL get_option_argument( i, arg ) 241 cfg % input_prefix = TRIM(arg) 242 cfg % input_prefix_is_set = .TRUE. 243 244 CASE( '-a', '--averaging-angle' ) 245 CALL get_option_argument( i, arg ) 246 READ(arg, *) cfg % averaging_angle 211 247 212 248 CASE( '-static', '-t', '--static-driver' ) 213 249 CALL get_option_argument( i, arg ) 214 250 cfg % static_driver_file = TRIM(arg) 215 251 216 252 CASE( '-soil', '-s', '--soil-file') 217 253 CALL get_option_argument( i, arg ) 218 254 cfg % soiltyp_file = TRIM(arg) 219 255 220 256 CASE( '--flow-prefix') 221 257 CALL get_option_argument( i, arg ) 222 cfg % flow_prefix = TRIM(arg) 223 258 cfg % flow_prefix = TRIM(arg) 259 cfg % flow_prefix_is_set = .TRUE. 260 224 261 CASE( '--radiation-prefix') 225 262 CALL get_option_argument( i, arg ) 226 cfg % radiation_prefix = TRIM(arg) 227 263 cfg % radiation_prefix = TRIM(arg) 264 cfg % radiation_prefix_is_set = .TRUE. 265 228 266 CASE( '--soil-prefix') 229 267 CALL get_option_argument( i, arg ) 230 cfg % soil_prefix = TRIM(arg) 231 268 cfg % soil_prefix = TRIM(arg) 269 cfg % soil_prefix_is_set = .TRUE. 270 232 271 CASE( '--soilmoisture-prefix') 233 272 CALL get_option_argument( i, arg ) 234 cfg % soilmoisture_prefix = TRIM(arg) 273 cfg % soilmoisture_prefix = TRIM(arg) 274 cfg % soilmoisture_prefix_is_set = .TRUE. 235 275 236 276 CASE( '-o', '--output' ) … … 297 337 298 338 all_files_present = .TRUE. 299 all_files_present = all_files_present .AND. file_present(cfg % hhl_file )300 all_files_present = all_files_present .AND. file_present(cfg % namelist_file )301 all_files_present = all_files_present .AND. file_present(cfg % soiltyp_file )339 all_files_present = all_files_present .AND. file_present(cfg % hhl_file, 'HHL') 340 all_files_present = all_files_present .AND. file_present(cfg % namelist_file, 'NAMELIST') 341 all_files_present = all_files_present .AND. file_present(cfg % soiltyp_file, 'SOILTYP') 302 342 303 343 ! Only check optional static driver file name, if it has been given. 304 344 IF (TRIM(cfg % static_driver_file) .NE. '') THEN 305 all_files_present = all_files_present .AND. file_present(cfg % static_driver_file )345 all_files_present = all_files_present .AND. file_present(cfg % static_driver_file, 'static driver') 306 346 END IF 307 347 … … 335 375 END SELECT 336 376 377 SELECT CASE( TRIM(cfg % averaging_mode) ) 378 CASE( 'level', 'height') 379 CASE DEFAULT 380 message = "Averaging mode '" // TRIM(cfg % averaging_mode) //& 381 "' is not supported. " //& 382 "Please select either 'height' or 'level', " //& 383 "or omit the --averaging-mode option entirely, which corresponds "//& 384 "to the latter." 385 CALL abort( 'validate_config', message ) 386 END SELECT 387 388 IF ( cfg % ug_is_set .NEQV. cfg % vg_is_set ) THEN 389 message = "You specified only one component of the geostrophic " // & 390 "wind. Please specify either both or none." 391 CALL abort( 'validate_config', message ) 392 END IF 337 393 338 394 END SUBROUTINE validate_config 339 395 340 396 341 LOGICAL FUNCTION file_present(filename )397 LOGICAL FUNCTION file_present(filename, kind) 342 398 CHARACTER(LEN=PATH), INTENT(IN) :: filename 343 344 INQUIRE(FILE=filename, EXIST=file_present) 345 346 IF (.NOT. file_present) THEN 347 message = "The given file '" // "' does not exist." 399 CHARACTER(LEN=*), INTENT(IN) :: kind 400 401 IF (LEN(TRIM(filename))==0) THEN 402 403 file_present = .FALSE. 404 message = "No name was given for the " // TRIM(kind) // " file." 348 405 CALL report('file_present', message) 406 407 ELSE 408 409 INQUIRE(FILE=filename, EXIST=file_present) 410 411 IF (.NOT. file_present) THEN 412 message = "The given " // TRIM(kind) // " file '" // & 413 TRIM(filename) // "' does not exist." 414 CALL report('file_present', message) 415 END IF 416 349 417 END IF 350 418 … … 388 456 #endif 389 457 390 ! 391 !------------------------------------------------------------------------------ 392 !- Section 1: Write global NetCDF attributes 458 !------------------------------------------------------------------------------ 459 !- Section 1: Define NetCDF dimensions and coordinates 460 !------------------------------------------------------------------------------ 461 nt = SIZE(output_file % time) 462 nx = palm_grid % nx 463 ny = palm_grid % ny 464 nz = palm_grid % nz 465 z0 = palm_grid % z0 466 467 468 ! 469 !------------------------------------------------------------------------------ 470 !- Section 2: Write global NetCDF attributes 393 471 !------------------------------------------------------------------------------ 394 472 CALL date_and_time(DATE=date_string, TIME=time_string, ZONE=zone_string) … … 406 484 CALL check(nf90_put_att(ncid, NF90_GLOBAL, 'origin_lat', TRIM(real_to_str(origin_lat*TO_DEGREES, '(F18.13)')))) 407 485 CALL check(nf90_put_att(ncid, NF90_GLOBAL, 'origin_lon', TRIM(real_to_str(origin_lon*TO_DEGREES, '(F18.13)')))) 486 ! FIXME: This is the elevation relative to COSMO-DE/D2 sea level and does 487 ! FIXME: not necessarily comply with DHHN2016 (c.f. PALM Input Data 488 ! FIXME: Standard v1.9., origin_z) 489 CALL check(nf90_put_att(ncid, NF90_GLOBAL, 'origin_z', TRIM(real_to_str(z0, '(F18.13)')))) 408 490 CALL check(nf90_put_att(ncid, NF90_GLOBAL, 'inifor_version', TRIM(VERSION))) 409 491 CALL check(nf90_put_att(ncid, NF90_GLOBAL, 'palm_version', '--')) 410 492 411 493 ! 412 !------------------------------------------------------------------------------413 !- Section 2: Define NetCDF dimensions and coordinates414 !------------------------------------------------------------------------------415 nt = SIZE(output_file % time)416 nx = palm_grid % nx417 ny = palm_grid % ny418 nz = palm_grid % nz419 z0 = palm_grid % z0420 421 494 ! 422 495 !------------------------------------------------------------------------------ … … 618 691 ELSE 619 692 620 nbuffers = SIZE( group % in_var_list ) 693 ! Allocate one input buffer per input_variable. If more quantities 694 ! have to be computed than input variables exist in this group, 695 ! allocate more buffers. For instance, in the thermodynamics group, 696 ! there are three input variabels (PP, T, Qv) and four quantities 697 ! necessart (P, Theta, Rho, qv) for the corresponding output fields 698 ! (p0, Theta, qv, ug, and vg) 699 nbuffers = MAX( group % n_inputs, group % n_output_quantities ) 621 700 ALLOCATE( buffer(nbuffers) ) 622 701 CALL run_control('time', 'alloc') 623 702 624 DO ivar = 1, nbuffers 703 ! Read in all input variables, leave extra buffers-if any-untouched. 704 DO ivar = 1, group % n_inputs 625 705 626 706 input_var => group % in_var_list(ivar) … … 628 708 ! Check wheather P or PP is present in input file 629 709 IF (input_var % name == 'P') THEN 630 input_var % name = TRIM( get_pressure_var (input_file) )710 input_var % name = TRIM( get_pressure_varname(input_file) ) 631 711 CALL run_control('time', 'read') 632 712 END IF … … 668 748 !> perturbation, 'PP', and returns the appropriate string. 669 749 !------------------------------------------------------------------------------! 670 CHARACTER(LEN=2) FUNCTION get_pressure_var (input_file) RESULT(var)750 CHARACTER(LEN=2) FUNCTION get_pressure_varname(input_file) RESULT(var) 671 751 CHARACTER(LEN=*) :: input_file 672 752 INTEGER :: ncid, varid … … 692 772 CALL check(nf90_close(ncid)) 693 773 694 END FUNCTION get_pressure_var 774 END FUNCTION get_pressure_varname 695 775 696 776 … … 805 885 start=start(1:ndim+1) ) ) 806 886 807 CASE ( 'constant scalar profile' )887 CASE ( 'constant scalar profile', 'geostrophic', 'internal profile' ) 808 888 809 889 CALL check(nf90_put_var( ncid, var%varid, array(1,1,:), &
Note: See TracChangeset
for help on using the changeset viewer.