Changeset 4577
- Timestamp:
- Jun 25, 2020 9:53:58 AM (5 years ago)
- Location:
- palm/trunk/SOURCE
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified palm/trunk/SOURCE/biometeorology_mod.f90 ¶
r4540 r4577 26 26 ! ----------------- 27 27 ! $Id$ 28 ! further re-formatting concerning Fortran parameter variables 29 ! 30 ! 4540 2020-05-18 15:23:29Z raasch 28 31 ! file re-formatted to follow the PALM coding standard 29 32 ! … … 187 190 ! 188 191 !-- Declare all global variables within the module (alphabetical order) 192 REAL(wp), PARAMETER :: bio_fill_value = -9999.0_wp !< set module fill value, replace by global fill value as soon as available 193 REAL(wp), PARAMETER :: human_absorb = 0.7_wp !< SW absorbtivity of a human body (Fanger 1972) 194 REAL(wp), PARAMETER :: human_emiss = 0.97_wp !< LW emissivity of a human body after (Fanger 1972) 195 189 196 INTEGER(iwp) :: bio_cell_level !< cell level biom calculates for 190 197 … … 209 216 210 217 REAL(wp) :: bio_output_height !< height output is calculated in m 211 212 REAL(wp), PARAMETER :: bio_fill_value = -9999.0_wp !< set module fill value, replace by global fill value as soon as available213 REAL(wp), PARAMETER :: human_absorb = 0.7_wp !< SW absorbtivity of a human body (Fanger 1972)214 REAL(wp), PARAMETER :: human_emiss = 0.97_wp !< LW emissivity of a human body after (Fanger 1972)215 218 216 219 REAL(wp), DIMENSION(:), ALLOCATABLE :: mrt_av_grid !< time average mean … … 2270 2273 ! 2271 2274 !-- Parameters for standard "Klima-Michel" 2272 REAL(wp), PARAMETER :: actlev = 134.6862_wp !< Workload by activity per standardized surface 2273 !< (A_Du) 2275 REAL(wp), PARAMETER :: actlev = 134.6862_wp !< Workload by activity per standardized surface (A_Du) 2274 2276 REAL(wp), PARAMETER :: eta = 0.0_wp !< Mechanical work efficiency for walking on flat 2275 2277 !< ground (compare to Fanger (1972) pp 24f) 2276 2278 ! 2277 2279 !-- Type of program variables 2280 REAL(wp), PARAMETER :: eps = 0.0005 !< Accuracy in clothing insulation (clo) for evaluation the root of Fanger's PMV (pmva=0) 2281 2278 2282 INTEGER(iwp) :: ncount !< running index 2279 2283 INTEGER(iwp) :: nerr_cold !< error number (cold conditions) … … 2281 2285 2282 2286 LOGICAL :: sultrieness 2283 2284 REAL(wp), PARAMETER :: eps = 0.0005 !< Accuracy in clothing insulation (clo) for evaluation the2285 !< root of Fanger's PMV (pmva=0)2286 2287 2287 2288 REAL(wp) :: clon !< clo for neutral conditions (clo) … … 2504 2505 !-- Type of program variables 2505 2506 INTEGER(iwp), PARAMETER :: max_iteration = 15_iwp !< max number of iterations 2507 2508 REAL(wp), PARAMETER :: guess_0 = -1.11e30_wp !< initial guess 2509 2506 2510 INTEGER(iwp) :: j !< running index 2507 2508 REAL(wp), PARAMETER :: guess_0 = -1.11e30_wp !< initial guess2509 2511 2510 2512 REAL(wp) :: clo_lower !< lower limit of clothing insulation (clo) … … 2788 2790 REAL(wp) :: dtmrt !< difference mean radiation to air temperature 2789 2791 REAL(wp) :: pa !< vapor pressure (hPa) with hard bounds 2790 REAL(wp) :: pa_p50 !< ratio actual water vapour pressure to that of relative humidity of 2792 REAL(wp) :: pa_p50 !< ratio actual water vapour pressure to that of relative humidity of 2791 2793 !< 50 % 2792 2794 REAL(wp) :: pmv !< temp storage og predicted mean vote … … 2973 2975 ! 2974 2976 !-- Additional output variables of argument list: 2975 REAL(wp), INTENT ( OUT ) :: dperctm !< Mean deviation perct (classical gt) to gt* (rational 2977 REAL(wp), INTENT ( OUT ) :: dperctm !< Mean deviation perct (classical gt) to gt* (rational 2976 2978 !< gt calculated based on Gagge's rational PMV*) 2977 2979 REAL(wp), INTENT ( OUT ) :: dperctstd !< dperctm plus its standard deviation times a factor … … 3039 3041 ! 3040 3042 !-- Type of output argument 3041 INTEGER(iwp), INTENT ( OUT ) :: nerr !< Error indicator: 0 = o.k., +1 = denominator for 3043 INTEGER(iwp), INTENT ( OUT ) :: nerr !< Error indicator: 0 = o.k., +1 = denominator for 3042 3044 !< intersection = 0 3043 3045 3044 REAL(wp), INTENT ( OUT ) :: dpmv_cold_res !< Increment to adjust pmva according to the 3046 REAL(wp), INTENT ( OUT ) :: dpmv_cold_res !< Increment to adjust pmva according to the 3045 3047 !< results of Gagge's 2 node model depending on the input 3046 3048 ! … … 3344 3346 ! 3345 3347 !-- Internal variables 3348 REAL(wp), PARAMETER :: eps = 0.0005_wp 3349 REAL(wp), PARAMETER :: eta = 0.0_wp 3350 3346 3351 INTEGER(iwp) :: ncount 3347 3352 INTEGER(iwp) :: nerr_cold … … 3349 3354 3350 3355 LOGICAL :: sultrieness 3351 3352 REAL(wp), PARAMETER :: eps = 0.0005_wp3353 REAL(wp), PARAMETER :: eta = 0.0_wp3354 3356 3355 3357 ! REAL(wp) :: acti … … 3639 3641 ! 3640 3642 !-- Internal variables 3643 REAL(wp), PARAMETER :: time_equil = 7200.0_wp 3644 3641 3645 INTEGER(iwp) :: i !< running index 3642 3646 INTEGER(iwp) :: niter !< Running index 3643 3644 REAL(wp), PARAMETER :: time_equil = 7200.0_wp3645 3647 3646 3648 REAL(wp) :: adjustrate !< Max storage adjustment rate … … 3661 3663 REAL(wp) :: ws !< wind speed (m/s) 3662 3664 REAL(wp) :: z1 !< Empiric factor for the adaption of the heat 3663 !< ballance equation to the psycho-physical scale 3665 !< ballance equation to the psycho-physical scale 3664 3666 !< (Equ. 40 in FANGER) 3665 3667 REAL(wp) :: z2 !< Water vapour diffution through the skin … … 4087 4089 IF ( eswdif <= 0.0_wp ) esw = eswpot !< Limit is evaporation 4088 4090 IF ( eswdif > 0.0_wp ) esw = eswphy !< Limit is sweat production 4089 IF ( esw > 0.0_wp ) esw = 0.0_wp !< Sweat can't be evaporated, no more cooling 4091 IF ( esw > 0.0_wp ) esw = 0.0_wp !< Sweat can't be evaporated, no more cooling 4090 4092 !< effect 4091 4093 ! -
TabularUnified palm/trunk/SOURCE/bulk_cloud_model_mod.f90 ¶
r4542 r4577 24 24 ! ----------------- 25 25 ! $Id$ 26 ! further re-formatting concerning Fortran parameter variables 27 ! 28 ! 4542 2020-05-19 15:45:12Z raasch 26 29 ! file re-formatted to follow the PALM coding standard 27 30 ! … … 2884 2887 IMPLICIT NONE 2885 2888 2889 REAL(wp), PARAMETER :: fill_value = -999.0_wp !< value for the _FillValue attribute 2890 2886 2891 CHARACTER (LEN=*), INTENT(INOUT) :: grid !< name of vertical grid 2887 2892 CHARACTER (LEN=*), INTENT(IN) :: mode !< either 'xy', 'xz' or 'yz' … … 2902 2907 LOGICAL, INTENT(INOUT) :: two_d !< flag parameter that indicates 2D variables 2903 2908 !< (horizontal cross sections) 2904 2905 2906 REAL(wp), PARAMETER :: fill_value = -999.0_wp !< value for the _FillValue attribute2907 2909 2908 2910 REAL(wp), DIMENSION(nxl:nxr,nys:nyn,nzb_do:nzt_do), INTENT(INOUT) :: local_pf !< local … … 6531 6533 INTEGER(iwp) :: j !< 6532 6534 6533 REAL(wp) :: gamm !<6534 REAL(wp) :: ser !<6535 REAL(wp) :: tmp !<6536 REAL(wp) :: x_gamm !<6537 REAL(wp) :: xx !<6538 REAL(wp) :: y_gamm !<6539 6540 6541 6535 REAL(wp), PARAMETER :: stp = 2.5066282746310005_wp !< 6542 6536 REAL(wp), PARAMETER :: cof(6) = (/ 76.18009172947146_wp, & … … 6547 6541 -0.5395239384953E-5_wp /) !< 6548 6542 6543 REAL(wp) :: gamm !< 6544 REAL(wp) :: ser !< 6545 REAL(wp) :: tmp !< 6546 REAL(wp) :: x_gamm !< 6547 REAL(wp) :: xx !< 6548 REAL(wp) :: y_gamm !< 6549 6550 6549 6551 x_gamm = xx 6550 6552 y_gamm = x_gamm -
TabularUnified palm/trunk/SOURCE/check_open.f90 ¶
r4546 r4577 25 25 ! ----------------- 26 26 ! $Id$ 27 ! further re-formatting to follow the PALM coding standard 28 ! 29 ! 4546 2020-05-24 12:16:41Z raasch 27 30 ! file re-formatted to follow the PALM coding standard 28 31 ! … … 201 204 !-- and the run crashes. Thus, if the file is not there, PARIN_O will be read. An ocean 202 205 !-- precursor run will be the only situation where this can happen. 203 INQUIRE( FILE = 'PARIN' // TRIM( coupling_char ), EXIST =file_exist )206 INQUIRE( FILE='PARIN' // TRIM( coupling_char ), EXIST=file_exist ) 204 207 205 208 IF ( file_exist ) THEN … … 209 212 ENDIF 210 213 211 OPEN ( 11, FILE= TRIM( filename ), FORM = 'FORMATTED', STATUS = 'OLD', IOSTAT =ioerr )214 OPEN ( 11, FILE=TRIM( filename ), FORM='FORMATTED', STATUS='OLD', IOSTAT=ioerr ) 212 215 213 216 IF ( ioerr /= 0 ) THEN … … 222 225 223 226 IF ( myid_char == '' ) THEN 224 OPEN ( 13, FILE = 'BININ' // TRIM( coupling_char ) // myid_char, FORM = 'UNFORMATTED',&225 STATUS ='OLD' )227 OPEN ( 13, FILE='BININ' // TRIM( coupling_char ) // myid_char, FORM='UNFORMATTED', & 228 STATUS='OLD' ) 226 229 ELSE 227 230 ! … … 229 232 !-- the global variables. 230 233 IF ( .NOT. openfile(file_id)%opened_before ) THEN 231 OPEN ( 13, FILE = 'BININ' // TRIM( coupling_char ) // '/_000000',&232 FORM = 'UNFORMATTED', STATUS ='OLD' )234 OPEN ( 13, FILE='BININ' // TRIM( coupling_char ) // '/_000000', FORM='UNFORMATTED',& 235 STATUS='OLD' ) 233 236 ELSE 234 OPEN ( 13, FILE = 'BININ' // TRIM( coupling_char ) // '/' // myid_char,&235 FORM = 'UNFORMATTED', STATUS ='OLD' )237 OPEN ( 13, FILE='BININ' // TRIM( coupling_char ) // '/' // myid_char, & 238 FORM='UNFORMATTED', STATUS='OLD' ) 236 239 ENDIF 237 240 ENDIF … … 240 243 241 244 IF ( myid_char == '' ) THEN 242 OPEN ( 14, FILE = 'BINOUT' // TRIM( coupling_char ) // myid_char,&243 FORM = 'UNFORMATTED', POSITION ='APPEND' )245 OPEN ( 14, FILE='BINOUT' // TRIM( coupling_char ) // myid_char, FORM='UNFORMATTED', & 246 POSITION='APPEND' ) 244 247 ELSE 245 248 IF ( myid == 0 .AND. .NOT. openfile(file_id)%opened_before ) THEN … … 254 257 ioerr = 1 255 258 DO WHILE ( ioerr /= 0 ) 256 OPEN ( 14, FILE = 'BINOUT' // TRIM(coupling_char)// '/' // myid_char,&257 FORM = 'UNFORMATTED', IOSTAT =ioerr )259 OPEN ( 14, FILE='BINOUT' // TRIM(coupling_char)// '/' // myid_char, & 260 FORM='UNFORMATTED', IOSTAT=ioerr ) 258 261 IF ( ioerr /= 0 ) THEN 259 262 WRITE( 9, * ) '*** could not open "BINOUT' // & … … 268 271 CASE ( 15 ) 269 272 270 OPEN ( 15, FILE = 'RUN_CONTROL' // TRIM( coupling_char ), FORM ='FORMATTED' )273 OPEN ( 15, FILE='RUN_CONTROL' // TRIM( coupling_char ), FORM='FORMATTED' ) 271 274 272 275 CASE ( 16 ) 273 276 274 OPEN ( 16, FILE = 'LIST_PROFIL' // TRIM( coupling_char ), FORM ='FORMATTED' )277 OPEN ( 16, FILE='LIST_PROFIL' // TRIM( coupling_char ), FORM='FORMATTED' ) 275 278 276 279 CASE ( 17 ) 277 280 278 OPEN ( 17, FILE = 'LIST_PROFIL_1D' // TRIM( coupling_char ), FORM ='FORMATTED' )281 OPEN ( 17, FILE='LIST_PROFIL_1D' // TRIM( coupling_char ), FORM='FORMATTED' ) 279 282 280 283 CASE ( 18 ) 281 284 282 OPEN ( 18, FILE = 'CPU_MEASURES' // TRIM( coupling_char ), FORM ='FORMATTED' )285 OPEN ( 18, FILE='CPU_MEASURES' // TRIM( coupling_char ), FORM='FORMATTED' ) 283 286 284 287 CASE ( 19 ) 285 288 286 OPEN ( 19, FILE = 'HEADER' // TRIM( coupling_char ), FORM ='FORMATTED' )289 OPEN ( 19, FILE='HEADER' // TRIM( coupling_char ), FORM='FORMATTED' ) 287 290 288 291 CASE ( 20 ) … … 292 295 ENDIF 293 296 IF ( myid_char == '' ) THEN 294 OPEN ( 20, FILE = 'DATA_LOG' // TRIM( coupling_char ) // '/_000000',&295 FORM = 'UNFORMATTED', POSITION ='APPEND' )297 OPEN ( 20, FILE='DATA_LOG' // TRIM( coupling_char ) // '/_000000', FORM='UNFORMATTED',& 298 POSITION='APPEND' ) 296 299 ELSE 297 300 #if defined( __parallel ) … … 303 306 ioerr = 1 304 307 DO WHILE ( ioerr /= 0 ) 305 OPEN ( 20, FILE = 'DATA_LOG' // TRIM( coupling_char ) // '/' // myid_char,&306 FORM = 'UNFORMATTED', POSITION = 'APPEND', IOSTAT =ioerr )308 OPEN ( 20, FILE='DATA_LOG' // TRIM( coupling_char ) // '/' // myid_char, & 309 FORM='UNFORMATTED', POSITION='APPEND', IOSTAT=ioerr ) 307 310 IF ( ioerr /= 0 ) THEN 308 311 WRITE( 9, * ) '*** could not open "DATA_LOG' // TRIM( coupling_char ) // '/' //& … … 317 320 318 321 IF ( data_output_2d_on_each_pe ) THEN 319 OPEN ( 21, FILE = 'PLOT2D_XY' // TRIM( coupling_char ) // myid_char,&320 FORM = 'UNFORMATTED', POSITION ='APPEND' )321 ELSE 322 OPEN ( 21, FILE = 'PLOT2D_XY' // TRIM( coupling_char ),&323 FORM ='UNFORMATTED', POSITION ='APPEND' )322 OPEN ( 21, FILE='PLOT2D_XY' // TRIM( coupling_char ) // myid_char, FORM='UNFORMATTED',& 323 POSITION='APPEND' ) 324 ELSE 325 OPEN ( 21, FILE='PLOT2D_XY' // TRIM( coupling_char ), FORM='UNFORMATTED', & 326 POSITION='APPEND' ) 324 327 ENDIF 325 328 … … 336 339 337 340 IF ( data_output_2d_on_each_pe ) THEN 338 OPEN ( 22, FILE = 'PLOT2D_XZ' // TRIM( coupling_char ) // myid_char,&339 FORM = 'UNFORMATTED', POSITION ='APPEND' )340 ELSE 341 OPEN ( 22, FILE = 'PLOT2D_XZ' // TRIM( coupling_char ), FORM = 'UNFORMATTED',&342 POSITION ='APPEND' )341 OPEN ( 22, FILE='PLOT2D_XZ' // TRIM( coupling_char ) // myid_char, FORM='UNFORMATTED',& 342 POSITION='APPEND' ) 343 ELSE 344 OPEN ( 22, FILE='PLOT2D_XZ' // TRIM( coupling_char ), FORM='UNFORMATTED', & 345 POSITION='APPEND' ) 343 346 ENDIF 344 347 … … 355 358 356 359 IF ( data_output_2d_on_each_pe ) THEN 357 OPEN ( 23, FILE = 'PLOT2D_YZ' // TRIM( coupling_char ) // myid_char,&358 FORM = 'UNFORMATTED',POSITION='APPEND' )359 ELSE 360 OPEN ( 23, FILE = 'PLOT2D_YZ' // TRIM( coupling_char ), FORM = 'UNFORMATTED',&361 POSITION ='APPEND' )360 OPEN ( 23, FILE='PLOT2D_YZ' // TRIM( coupling_char ) // myid_char, FORM='UNFORMATTED',& 361 POSITION='APPEND' ) 362 ELSE 363 OPEN ( 23, FILE='PLOT2D_YZ' // TRIM( coupling_char ), FORM='UNFORMATTED', & 364 POSITION='APPEND' ) 362 365 ENDIF 363 366 … … 374 377 ! 375 378 !-- Binary files for surface data 376 ! OPEN ( 25, FILE = 'SURFACE_DATA_BIN' // TRIM( coupling_char ) // myid_char,&377 ! FORM = 'UNFORMATTED', POSITION ='APPEND' )379 ! OPEN ( 25, FILE='SURFACE_DATA_BIN' // TRIM( coupling_char ) // myid_char, & 380 ! FORM='UNFORMATTED', POSITION='APPEND' ) 378 381 379 382 IF ( myid_char == '' ) THEN 380 OPEN ( 25, FILE = 'SURFACE_DATA_BIN' // TRIM( coupling_char ) // myid_char,&381 FORM = 'UNFORMATTED', POSITION ='APPEND' )383 OPEN ( 25, FILE='SURFACE_DATA_BIN' // TRIM( coupling_char ) // myid_char, & 384 FORM='UNFORMATTED', POSITION='APPEND' ) 382 385 ELSE 383 386 IF ( myid == 0 .AND. .NOT. openfile(file_id)%opened_before ) THEN … … 392 395 ioerr = 1 393 396 DO WHILE ( ioerr /= 0 ) 394 OPEN ( 25, FILE = 'SURFACE_DATA_BIN' // TRIM(coupling_char) // '/' // myid_char,&395 FORM = 'UNFORMATTED', IOSTAT =ioerr )397 OPEN ( 25, FILE='SURFACE_DATA_BIN' // TRIM(coupling_char) // '/' // myid_char, & 398 FORM='UNFORMATTED', IOSTAT=ioerr ) 396 399 IF ( ioerr /= 0 ) THEN 397 400 WRITE( 9, * ) '*** could not open "SURFACE_DATA_BIN'// TRIM(coupling_char) // & … … 406 409 ! 407 410 !-- Binary files for averaged surface data 408 ! OPEN ( 26, FILE = 'SURFACE_DATA_AV_BIN' // TRIM( coupling_char ) // myid_char,&409 ! FORM = 'UNFORMATTED', POSITION ='APPEND' )411 ! OPEN ( 26, FILE='SURFACE_DATA_AV_BIN' // TRIM( coupling_char ) // myid_char, & 412 ! FORM='UNFORMATTED', POSITION='APPEND' ) 410 413 411 414 IF ( myid_char == '' ) THEN 412 OPEN ( 26, FILE = 'SURFACE_DATA_AV_BIN' // TRIM( coupling_char ) // myid_char,&413 FORM = 'UNFORMATTED', POSITION ='APPEND' )415 OPEN ( 26, FILE='SURFACE_DATA_AV_BIN' // TRIM( coupling_char ) // myid_char, & 416 FORM='UNFORMATTED', POSITION='APPEND' ) 414 417 ELSE 415 418 IF ( myid == 0 .AND. .NOT. openfile(file_id)%opened_before ) THEN … … 424 427 ioerr = 1 425 428 DO WHILE ( ioerr /= 0 ) 426 OPEN ( 26, FILE = 'SURFACE_DATA_AV_BIN' // TRIM(coupling_char) // '/' // myid_char,&427 FORM = 'UNFORMATTED', IOSTAT =ioerr )429 OPEN ( 26, FILE='SURFACE_DATA_AV_BIN' // TRIM( coupling_char ) // '/' // myid_char,& 430 FORM='UNFORMATTED', IOSTAT=ioerr ) 428 431 IF ( ioerr /= 0 ) THEN 429 WRITE( 9, * ) '*** could not open "SURFACE_DATA_AV_BIN' // TRIM(coupling_char) & 430 // '/' // myid_char // '"! Trying again in 1 sec.' 432 WRITE( 9, * ) '*** could not open "SURFACE_DATA_AV_BIN' // & 433 TRIM( coupling_char ) // '/' // myid_char // & 434 '"! Trying again in 1 sec.' 431 435 CALL fortran_sleep( 1 ) 432 436 ENDIF … … 437 441 CASE ( 30 ) 438 442 439 OPEN ( 30, FILE = 'PLOT3D_DATA' // TRIM( coupling_char ) // myid_char, & 440 FORM = 'UNFORMATTED' ) 443 OPEN ( 30, FILE='PLOT3D_DATA' // TRIM( coupling_char ) // myid_char, FORM='UNFORMATTED' ) 441 444 ! 442 445 !-- Specifications for combine_plot_fields … … 450 453 451 454 IF ( myid_char == '' ) THEN 452 OPEN ( 80, FILE = 'PARTICLE_INFOS'//TRIM(coupling_char)//myid_char,&453 FORM = 'FORMATTED',POSITION='APPEND' )455 OPEN ( 80, FILE='PARTICLE_INFOS'//TRIM(coupling_char)//myid_char, FORM='FORMATTED', & 456 POSITION='APPEND' ) 454 457 ELSE 455 458 IF ( myid == 0 .AND. .NOT. openfile(80)%opened_before ) THEN … … 466 469 ENDIF 467 470 #endif 468 OPEN ( 80, FILE = 'PARTICLE_INFOS' // TRIM( coupling_char ) // '/' // myid_char,&469 FORM = 'FORMATTED', POSITION ='APPEND' )471 OPEN ( 80, FILE='PARTICLE_INFOS' // TRIM( coupling_char ) // '/' // myid_char, & 472 FORM='FORMATTED', POSITION='APPEND' ) 470 473 ENDIF 471 474 … … 477 480 478 481 IF ( myid_char == '' ) THEN 479 OPEN ( 85, FILE = 'PARTICLE_DATA' // TRIM(coupling_char) // myid_char,&480 FORM = 'UNFORMATTED', POSITION ='APPEND' )482 OPEN ( 85, FILE='PARTICLE_DATA' // TRIM(coupling_char) // myid_char, & 483 FORM='UNFORMATTED', POSITION='APPEND' ) 481 484 ELSE 482 485 IF ( myid == 0 .AND. .NOT. openfile(85)%opened_before ) THEN … … 491 494 ioerr = 1 492 495 DO WHILE ( ioerr /= 0 ) 493 OPEN ( 85, FILE = 'PARTICLE_DATA' // TRIM( coupling_char ) // '/' // myid_char,&494 FORM = 'UNFORMATTED', POSITION = 'APPEND', IOSTAT =ioerr )496 OPEN ( 85, FILE='PARTICLE_DATA' // TRIM( coupling_char ) // '/' // myid_char, & 497 FORM='UNFORMATTED', POSITION='APPEND', IOSTAT=ioerr ) 495 498 IF ( ioerr /= 0 ) THEN 496 499 WRITE( 9, * ) '*** could not open "PARTICLE_DATA' // TRIM( coupling_char ) // & … … 519 522 520 523 IF ( myid_char == '' ) THEN 521 OPEN ( 88, FILE = 'SVFIN' // TRIM( coupling_char ) // myid_char, FORM = 'UNFORMATTED',&522 STATUS = 'OLD', IOSTAT =ioerr )523 ELSE 524 525 OPEN ( 88, FILE = 'SVFIN' // TRIM( coupling_char ) // '/' // myid_char,&526 FORM = 'UNFORMATTED', STATUS = 'OLD', IOSTAT =ioerr )524 OPEN ( 88, FILE='SVFIN' // TRIM( coupling_char ) // myid_char, FORM='UNFORMATTED', & 525 STATUS='OLD', IOSTAT=ioerr ) 526 ELSE 527 528 OPEN ( 88, FILE='SVFIN' // TRIM( coupling_char ) // '/' // myid_char, & 529 FORM='UNFORMATTED', STATUS='OLD', IOSTAT=ioerr ) 527 530 ENDIF 528 531 … … 532 535 533 536 IF ( myid_char == '' ) THEN 534 OPEN ( 89, FILE = 'SVFOUT' // TRIM( coupling_char ) // myid_char,&535 FORM = 'UNFORMATTED', STATUS ='NEW' )537 OPEN ( 89, FILE='SVFOUT' // TRIM( coupling_char ) // myid_char, FORM='UNFORMATTED', & 538 STATUS='NEW' ) 536 539 ELSE 537 540 IF ( myid == 0 .AND. .NOT. openfile(file_id)%opened_before ) THEN … … 546 549 ioerr = 1 547 550 DO WHILE ( ioerr /= 0 ) 548 OPEN ( 89, FILE = 'SVFOUT' // TRIM(coupling_char) // '/' // myid_char, &549 FORM = 'UNFORMATTED', STATUS = 'NEW', IOSTAT =ioerr )551 OPEN ( 89, FILE='SVFOUT' // TRIM( coupling_char ) // '/' // myid_char, & 552 FORM='UNFORMATTED', STATUS='NEW', IOSTAT=ioerr ) 550 553 IF ( ioerr /= 0 ) THEN 551 WRITE( 9, * ) '*** could not open "SVFOUT' // TRIM( coupling_char) // '/' //&554 WRITE( 9, * ) '*** could not open "SVFOUT' // TRIM( coupling_char ) // '/' // & 552 555 myid_char // '"! Trying again in 1 sec.' 553 556 CALL fortran_sleep( 1 ) … … 561 564 CASE ( 117 ) 562 565 563 OPEN ( 117, FILE = 'PROGRESS' // TRIM( coupling_char ), STATUS = 'REPLACE', & 564 FORM = 'FORMATTED' ) 566 OPEN ( 117, FILE='PROGRESS' // TRIM( coupling_char ), STATUS='REPLACE', FORM='FORMATTED' ) 565 567 566 568 #if defined( __netcdf ) … … 578 580 !-- Inquire, if there is a netCDF file from a previous run. This should be opened for 579 581 !-- extension, if its dimensions and variables match the actual run. 580 INQUIRE( FILE = filename, EXIST =netcdf_extend )582 INQUIRE( FILE=filename, EXIST=netcdf_extend ) 581 583 IF ( netcdf_extend ) THEN 582 584 ! … … 618 620 !-- that nothing is to do. 619 621 IF ( myid == 0 .AND. netcdf_data_format > 4 ) THEN 620 OPEN( 99, FILE ='NO_COMBINE_PLOT_FIELDS_XY' )622 OPEN( 99, FILE='NO_COMBINE_PLOT_FIELDS_XY' ) 621 623 WRITE ( 99, '(A)' ) 'no combine_plot_fields.x neccessary' 622 624 CLOSE( 99 ) … … 638 640 !-- Inquire, if there is a netCDF file from a previous run. This should be opened for 639 641 !-- extension, if its dimensions and variables match the actual run. 640 INQUIRE( FILE = filename, EXIST =netcdf_extend )642 INQUIRE( FILE=filename, EXIST=netcdf_extend ) 641 643 642 644 IF ( netcdf_extend ) THEN … … 679 681 !-- that nothing is to do. 680 682 IF ( myid == 0 .AND. netcdf_data_format > 4 ) THEN 681 OPEN( 99, FILE ='NO_COMBINE_PLOT_FIELDS_XZ' )683 OPEN( 99, FILE='NO_COMBINE_PLOT_FIELDS_XZ' ) 682 684 WRITE ( 99, '(A)' ) 'no combine_plot_fields.x neccessary' 683 685 CLOSE( 99 ) … … 699 701 !-- Inquire, if there is a netCDF file from a previous run. This should be opened for 700 702 !-- extension, if its dimensions and variables match the actual run. 701 INQUIRE( FILE =filename, EXIST=netcdf_extend )703 INQUIRE( FILE=filename, EXIST=netcdf_extend ) 702 704 703 705 IF ( netcdf_extend ) THEN … … 740 742 !-- that nothing is to do. 741 743 IF ( myid == 0 .AND. netcdf_data_format > 4 ) THEN 742 OPEN( 99, FILE ='NO_COMBINE_PLOT_FIELDS_YZ' )744 OPEN( 99, FILE='NO_COMBINE_PLOT_FIELDS_YZ' ) 743 745 WRITE ( 99, '(A)' ) 'no combine_plot_fields.x neccessary' 744 746 CLOSE( 99 ) … … 755 757 !-- Inquire, if there is a netCDF file from a previous run. This should be opened for 756 758 !-- extension, if its variables match the actual run. 757 INQUIRE( FILE = filename, EXIST =netcdf_extend )759 INQUIRE( FILE=filename, EXIST=netcdf_extend ) 758 760 759 761 IF ( netcdf_extend ) THEN … … 794 796 !-- Inquire, if there is a netCDF file from a previous run. This should be opened for 795 797 !-- extension, if its variables match the actual run. 796 INQUIRE( FILE = filename, EXIST =netcdf_extend )798 INQUIRE( FILE=filename, EXIST=netcdf_extend ) 797 799 798 800 IF ( netcdf_extend ) THEN … … 839 841 !-- Inquire, if there is a netCDF file from a previous run. This should be opened for 840 842 !-- extension, if its dimensions and variables match the actual run. 841 INQUIRE( FILE = filename, EXIST =netcdf_extend )843 INQUIRE( FILE=filename, EXIST=netcdf_extend ) 842 844 IF ( netcdf_extend ) THEN 843 845 ! … … 998 1000 !-- Inquire, if there is a netCDF file from a previous run. This should be opened for 999 1001 !-- extension, if its variables match the actual run. 1000 INQUIRE( FILE = filename, EXIST =netcdf_extend )1002 INQUIRE( FILE=filename, EXIST=netcdf_extend ) 1001 1003 1002 1004 IF ( netcdf_extend ) THEN … … 1098 1100 !-- Inquire, if there is a netCDF file from a previous run. This should be opened for 1099 1101 !-- extension, if its variables match the actual run. 1100 INQUIRE( FILE = filename, EXIST =netcdf_extend )1102 INQUIRE( FILE=filename, EXIST=netcdf_extend ) 1101 1103 1102 1104 IF ( netcdf_extend ) THEN -
TabularUnified palm/trunk/SOURCE/chem_modules.f90 ¶
r4559 r4577 26 26 ! ----------------- 27 27 ! $Id$ 28 ! further re-formatting concerning Fortran parameter variables 29 ! 30 ! 4559 2020-06-11 08:51:48Z raasch 28 31 ! file re-formatted to follow the PALM coding standard 29 32 ! … … 95 98 96 99 IMPLICIT NONE 100 101 REAL, PARAMETER :: xm_air = 28.964e-3 !< air molecular weight (kg/mol) 102 REAL, PARAMETER :: xm_C = 12.01115e-3 !< C molecular weight (kg/mol) 103 REAL, PARAMETER :: xm_Ca = 40.07800e-3 !< Ca molecular weight (kg/mol) 104 REAL, PARAMETER :: xm_Cd = 112.41000e-3 !< Cd molecular weight (kg/mol) 105 REAL, PARAMETER :: xm_Cl = 35.45300e-3 !< Cl molecular weight (kg/mol) 106 REAL, PARAMETER :: xm_dummy = 1000.0e-3 !< dummy molecular weight (kg/mol) 107 REAL, PARAMETER :: xm_F = 18.99840e-3 !< F molecular weight (kg/mol) 108 REAL, PARAMETER :: xm_H = 1.00790e-3 !< H molecular weight (kg/mol) 109 REAL, PARAMETER :: xm_K = 39.09800e-3 !< K molecular weight (kg/mol) 110 REAL, PARAMETER :: xm_Mg = 24.30500e-3 !< Mg molecular weight (kg/mol) 111 REAL, PARAMETER :: xm_N = 14.00670e-3 !< N molecular weight (kg/mol) 112 REAL, PARAMETER :: xm_Na = 22.98977e-3 !< Na molecular weight (kg/mol) 113 REAL, PARAMETER :: xm_O = 15.99940e-3 !< O molecular weight (kg/mol) 114 REAL, PARAMETER :: xm_Pb = 207.20000e-3 !< Pb molecular weight (kg/mol) 115 REAL, PARAMETER :: xm_Pb210 = 210.00000e-3 !< Pb (210) molecular weight (kg/mol) 116 REAL, PARAMETER :: xm_Rn222 = 222.00000e-3 !< Rn (222) molecular weight (kg/mol) 117 REAL, PARAMETER :: xm_S = 32.06400e-3 !< S molecular weight (kg/mol) 118 REAL, PARAMETER :: xm_CO2 = xm_C + xm_O * 2 !< CO2 molecular weight (kg/mol) 119 REAL, PARAMETER :: xm_h2o = xm_H * 2 + xm_O !< H2O molecular weight (kg/mol) 120 REAL, PARAMETER :: xm_HNO3 = xm_H + xm_N + xm_O * 3 !< HNO3 molecular weight (kg/mol) 121 REAL, PARAMETER :: xm_o3 = xm_O * 3 !< O3 molecular weight (kg/mol) 122 REAL, PARAMETER :: xm_N2O5 = xm_N * 2 + xm_O * 5 !< N2O5 molecular weight (kg/mol) 123 REAL, PARAMETER :: xm_NH4 = xm_N + xm_H * 4 !< NH4 molecular weight (kg/mol) 124 REAL, PARAMETER :: xm_NO3 = xm_N + xm_O * 3 !< NO3 molecular weight (kg/mol) 125 REAL, PARAMETER :: xm_SO4 = xm_S + xm_O * 4 !< SO4 molecular weight (kg/mol) 97 126 98 127 CHARACTER (LEN=20) :: bc_cs_b = 'dirichlet' !< namelist parameter: surface … … 247 276 REAL(wp), DIMENSION(:,:,:), POINTER :: tcs_m !< pointer: to tcs array (temp) 248 277 249 REAL, PARAMETER :: xm_air = 28.964e-3 !< air molecular weight (kg/mol)250 REAL, PARAMETER :: xm_C = 12.01115e-3 !< C molecular weight (kg/mol)251 REAL, PARAMETER :: xm_Ca = 40.07800e-3 !< Ca molecular weight (kg/mol)252 REAL, PARAMETER :: xm_Cd = 112.41000e-3 !< Cd molecular weight (kg/mol)253 REAL, PARAMETER :: xm_Cl = 35.45300e-3 !< Cl molecular weight (kg/mol)254 REAL, PARAMETER :: xm_dummy = 1000.0e-3 !< dummy molecular weight (kg/mol)255 REAL, PARAMETER :: xm_F = 18.99840e-3 !< F molecular weight (kg/mol)256 REAL, PARAMETER :: xm_H = 1.00790e-3 !< H molecular weight (kg/mol)257 REAL, PARAMETER :: xm_K = 39.09800e-3 !< K molecular weight (kg/mol)258 REAL, PARAMETER :: xm_Mg = 24.30500e-3 !< Mg molecular weight (kg/mol)259 REAL, PARAMETER :: xm_N = 14.00670e-3 !< N molecular weight (kg/mol)260 REAL, PARAMETER :: xm_Na = 22.98977e-3 !< Na molecular weight (kg/mol)261 REAL, PARAMETER :: xm_O = 15.99940e-3 !< O molecular weight (kg/mol)262 REAL, PARAMETER :: xm_Pb = 207.20000e-3 !< Pb molecular weight (kg/mol)263 REAL, PARAMETER :: xm_Pb210 = 210.00000e-3 !< Pb (210) molecular weight (kg/mol)264 REAL, PARAMETER :: xm_Rn222 = 222.00000e-3 !< Rn (222) molecular weight (kg/mol)265 REAL, PARAMETER :: xm_S = 32.06400e-3 !< S molecular weight (kg/mol)266 REAL, PARAMETER :: xm_CO2 = xm_C + xm_O * 2 !< CO2 molecular weight (kg/mol)267 REAL, PARAMETER :: xm_h2o = xm_H * 2 + xm_O !< H2O molecular weight (kg/mol)268 REAL, PARAMETER :: xm_HNO3 = xm_H + xm_N + xm_O * 3 !< HNO3 molecular weight (kg/mol)269 REAL, PARAMETER :: xm_o3 = xm_O * 3 !< O3 molecular weight (kg/mol)270 REAL, PARAMETER :: xm_N2O5 = xm_N * 2 + xm_O * 5 !< N2O5 molecular weight (kg/mol)271 REAL, PARAMETER :: xm_NH4 = xm_N + xm_H * 4 !< NH4 molecular weight (kg/mol)272 REAL, PARAMETER :: xm_NO3 = xm_N + xm_O * 3 !< NO3 molecular weight (kg/mol)273 REAL, PARAMETER :: xm_SO4 = xm_S + xm_O * 4 !< SO4 molecular weight (kg/mol)274 278 ! 275 279 !- Define chemical variables within chem_species -
TabularUnified palm/trunk/SOURCE/chem_photolysis_mod.f90 ¶
r4559 r4577 25 25 ! ----------------- 26 26 ! $Id$ 27 ! further re-formatting to follow the PALM coding standard 28 ! 29 ! 4559 2020-06-11 08:51:48Z raasch 27 30 ! file re-formatted to follow the PALM coding standard 28 31 ! … … 89 92 90 93 91 ! LOGICAL :: unscheduled_photolysis_calls = .TRUE., & !< flag parameter indicating whether 92 ! !< additional calls of the photolysis code are allowed 93 ! constant_albedo = .FALSE., & !< flag parameter indicating whether the 94 ! !< albedo may change depending on zenith 95 ! force_photolysis_call = .FALSE., & !< flag parameter for unscheduled photolysis 96 ! !< calls 97 ! photolysis = .FALSE., & !< flag parameter indicating whether the 98 ! !< photolysis model is used 99 ! sun_up = .TRUE., & !< flag parameter indicating whether the sun 100 ! !< is up or down 101 ! photolysis = .TRUE., & !< flag parameter indicing whether 102 ! !< photolysis shall be calculated 103 ! sun_direction = .FALSE. !< flag parameter indicing whether solar 104 ! !< direction shall be calculated 105 94 ! LOGICAL :: unscheduled_photolysis_calls = .TRUE., & !< flag parameter indicating whether additional calls of the photolysis 95 ! !< code are allowed 96 ! constant_albedo = .FALSE., & !< flag parameter indicating whether the albedo may change depending on 97 ! !< zenith 98 ! force_photolysis_call = .FALSE., & !< flag parameter for unscheduled photolysis calls 99 ! photolysis = .FALSE., & !< flag parameter indicating whether the photolysis model is used 100 ! sun_up = .TRUE., & !< flag parameter indicating whether the sun is up or down 101 ! photolysis = .TRUE., & !< flag parameter indicing whether photolysis shall be calculated 102 ! sun_direction = .FALSE. !< flag parameter indicing whether solar direction shall be calculated 103 104 ! 106 105 !-- Parameters for constant photolysis frequencies 107 INTEGER,PARAMETER :: nconst = 15 !< available predefined photolysis prequencies 108 !< for constant 109 110 ! Names for predefined fixed photolysis frequencies at zenith angle 0 106 INTEGER,PARAMETER :: nconst = 15 !< available predefined photolysis prequencies for constant 107 ! 108 !-- Names for predefined fixed photolysis frequencies at zenith angle 0 111 109 CHARACTER(LEN=10), PARAMETER, DIMENSION(nconst) :: names_c = (/ & 112 110 'J_O31D ','J_O33P ','J_NO2 ','J_HNO3 ','J_RCHO ', & 113 111 'J ','J ','J ','J ','J ', & 114 112 'J ','J ','J ','J ','J ' /) 115 ! Photolysis frequency at zenith angle 0 degrees in 1/s 113 ! 114 !-- Photolysis frequency at zenith angle 0 degrees in 1/s 116 115 REAL(wp), PARAMETER, DIMENSION(nconst) :: phot0 = (/ & 117 116 2.489E-05_wp, 3.556E-04_wp, 8.89E-03_wp,5.334E-07_wp, 3.734E-05_wp, & 118 117 0.0000E00_wp, 0.0000E00_wp, 0.0000E00_wp,0.0000E00_wp, 0.0000E00_wp, & 119 118 0.0000E00_wp, 0.0000E00_wp, 0.0000E00_wp,0.0000E00_wp, 0.0000E00_wp /) 120 119 ! 121 120 !-- Parameters for simple photolysis frequencies from MCM (http://mcm.leeds.ac.uk/MCM) 122 121 !-- Saunders et al., 2003, Atmos. Chem. Phys., 3, 161-180 123 122 INTEGER,PARAMETER :: nsimple = 15 !< available predefined photolysis prequencies for simple parameterisation 123 ! 124 124 !-- Names for simple photolysis frequencies parameterisation ( 125 125 CHARACTER(LEN=10), PARAMETER, DIMENSION(nsimple) :: names_s = (/ & … … 127 127 'J_NO3_B ','J_HONO ','J_HNO3 ','J_HCHO_A ','J_HCHO_B ', & 128 128 'J_CH3CHO ','J ','J ','J ','J_RCHO ' /) 129 129 ! 130 130 !-- Species dependent parameters for simple photolysis frequencies from MCM 131 131 !-- (http://mcm.leeds.ac.uk/MCM) … … 136 136 7.344E-06_wp, 0.0000E00_wp, 0.0000E00_wp, 0.000E00_wp, 6.853E-05_wp /) 137 137 138 REAL(wp), PARAMETER, DIMENSION(nconst) :: par_m = (/&138 REAL(wp), PARAMETER, DIMENSION(nconst) :: par_m = (/ & 139 139 1.743_wp, 0.298_wp, 0.723_wp, 0.244_wp, 0.168_wp, & 140 140 0.155_wp, 0.261_wp, 1.230_wp, 0.762_wp, 0.477_wp, & 141 141 1.202_wp, 0.000_wp, 0.000_wp, 0.000_wp, 0.477_wp /) 142 142 143 REAL(wp), PARAMETER, DIMENSION(nconst) :: par_n = (/&143 REAL(wp), PARAMETER, DIMENSION(nconst) :: par_n = (/ & 144 144 0.474_wp, 0.080_wp, 0.279_wp, 0.267_wp, 0.108_wp, & 145 145 0.125_wp, 0.288_wp, 0.307_wp, 0.353_wp, 0.323_wp, & … … 150 150 !< specified otherwise) 151 151 152 ! 152 153 153 INTERFACE photolysis_constant 154 154 MODULE PROCEDURE photolysis_constant -
TabularUnified palm/trunk/SOURCE/chemistry_model_mod.f90 ¶
r4559 r4577 26 26 ! ----------------- 27 27 ! $Id$ 28 ! further re-formatting to follow the PALM coding standard 29 ! 30 ! 4559 2020-06-11 08:51:48Z raasch 28 31 ! file re-formatted to follow the PALM coding standard 29 32 ! … … 364 367 REAL(kind=wp), ALLOCATABLE, DIMENSION(:,:,:,:), TARGET :: spec_conc_3 !< pointer for swapping of timelevels for conc 365 368 REAL(kind=wp), ALLOCATABLE, DIMENSION(:,:,:,:), TARGET :: freq_1 !< pointer for phtolysis frequncies 366 !< (only 1 timelevel required) 367 !< (e.g. solver type) 368 369 !< (only 1 timelevel required) (e.g. solver type) 369 370 370 371 ! … … 1567 1568 USE control_parameters 1568 1569 1570 REAL(wp), PARAMETER :: fill_value = -9999.0_wp !< value for the _FillValue attribute 1571 1569 1572 CHARACTER(LEN=16) :: spec_name 1570 1573 CHARACTER(LEN=*) :: variable !< … … 1586 1589 REAL(wp), DIMENSION(mask_size_l(mid,1),mask_size_l(mid,2),mask_size_l(mid,3)) :: local_pf !< 1587 1590 1588 REAL(wp), PARAMETER :: fill_value = -9999.0_wp !< value for the _FillValue attribute1589 1591 1590 1592 ! … … 2279 2281 ONLY: dt_3d, intermediate_timestep_count, time_since_reference_point 2280 2282 2283 REAL(wp), PARAMETER :: fr2ppm = 1.0e6_wp !< Conversion factor fraction to ppm 2284 ! REAL(wp), PARAMETER :: xm_air = 28.96_wp !< Mole mass of dry air 2285 ! REAL(wp), PARAMETER :: xm_h2o = 18.01528_wp !< Mole mass of water vapor 2286 REAL(wp), PARAMETER :: p_std = 101325.0_wp !< standard pressure (Pa) 2287 REAL(wp), PARAMETER :: ppm2fr = 1.0e-6_wp !< Conversion factor ppm to fraction 2288 REAL(wp), PARAMETER :: t_std = 273.15_wp !< standard pressure (Pa) 2289 REAL(wp), PARAMETER :: vmolcm = 22.414e3_wp !< Mole volume (22.414 l) in cm^3 2290 REAL(wp), PARAMETER :: xna = 6.022e23_wp !< Avogadro number (molecules/mol) 2281 2291 2282 2292 INTEGER,INTENT(IN) :: i … … 2294 2304 REAL(wp) :: conv !< conversion factor 2295 2305 REAL(kind=wp) :: dt_chem 2296 2297 REAL(wp), PARAMETER :: fr2ppm = 1.0e6_wp !< Conversion factor2298 !< fraction to ppm2299 ! REAL(wp), PARAMETER :: xm_air = 28.96_wp !< Mole mass of dry air2300 ! REAL(wp), PARAMETER :: xm_h2o = 18.01528_wp !< Mole mass of water vapor2301 REAL(wp), PARAMETER :: p_std = 101325.0_wp !< standard pressure (Pa)2302 REAL(wp), PARAMETER :: ppm2fr = 1.0e-6_wp !< Conversion factor ppm to2303 !< fraction2304 REAL(wp), PARAMETER :: t_std = 273.15_wp !< standard pressure (Pa)2305 REAL(wp), PARAMETER :: vmolcm = 22.414e3_wp !< Mole volume (22.414 l)2306 !< in cm^32307 REAL(wp), PARAMETER :: xna = 6.022e23_wp !< Avogadro number2308 !< (molecules/mol)2309 2306 2310 2307 REAL(wp),DIMENSION(size(rcntrl)) :: rcntrl_local … … 3442 3439 !-- Particle parameters (PM10 (1), PM25 (2)) partsize (diameter in m), rhopart (density in kg/m3), 3443 3440 !-- slipcor (slip correction factor dimensionless, Seinfeld and Pandis 2006, Table 9.3) 3444 LOGICAL :: match_lsm !< flag indicating natural-type surface3445 LOGICAL :: match_usm !< flag indicating urban-type surface3446 3447 3441 REAL(wp), DIMENSION(1:3,1:2), PARAMETER :: particle_pars = RESHAPE( (/ & 3448 3442 8.0e-6_wp, 1.14e3_wp, 1.016_wp, & !< 1 3449 3443 0.7e-6_wp, 1.14e3_wp, 1.082_wp & !< 2 3450 3444 /), (/ 3, 2 /) ) 3445 3446 LOGICAL :: match_lsm !< flag indicating natural-type surface 3447 LOGICAL :: match_usm !< flag indicating urban-type surface 3448 3451 3449 ! 3452 3450 !-- List of names of possible tracers … … 5301 5299 ! 5302 5300 !-- Local variables 5301 REAL(wp), PARAMETER :: dO3 = 0.13e-4 !< diffusion coefficient of ozon (m2/s) 5302 5303 5303 REAL(wp) :: vpd !< vapour pressure deficit (kPa) 5304 5304 5305 REAL(wp), PARAMETER :: dO3 = 0.13e-4 !< diffusion coefficient of ozon (m2/s)5306 5305 ! 5307 5306 !-- Next line is to avoid compiler warning about unused variables … … 5395 5394 ! 5396 5395 !-- Local variables: 5396 REAL(wp), PARAMETER :: p_sealevel = 1.01325e05 !< Pa 5397 5397 5398 REAL(wp) :: bt 5398 5399 REAL(wp) :: f_env … … 5411 5412 REAL(wp) :: sinphi 5412 5413 5413 REAL(wp), PARAMETER :: p_sealevel = 1.01325e05 !< Pa5414 5414 ! 5415 5415 !-- Check whether vegetation is present: … … 6029 6029 ! 6030 6030 !-- const 6031 6032 6031 REAL(wp), PARAMETER :: kappa_stab = 0.35 !< von Karman constant 6033 6032 REAL(wp), PARAMETER :: thk = 0.19e-4 !< thermal diffusivity of dry air 20 C -
TabularUnified palm/trunk/SOURCE/cpulog_mod.f90 ¶
r4559 r4577 24 24 ! ----------------- 25 25 ! $Id$ 26 ! further re-formatting concerning Fortran parameter variables 27 ! 28 ! 4559 2020-06-11 08:51:48Z raasch 26 29 ! file re-formatted to follow the PALM coding standard 27 30 ! … … 131 134 INTEGER(iwp), PARAMETER :: cpu_log_stop = 3 !< 132 135 136 LOGICAL, PARAMETER :: cpu_log_nowait = .FALSE. !< 137 133 138 LOGICAL :: cpu_log_barrierwait = .FALSE. !< 134 LOGICAL, PARAMETER :: cpu_log_nowait = .FALSE. !<135 139 136 140 REAL(dp) :: initial_wallclock_time !< -
TabularUnified palm/trunk/SOURCE/data_output_binary_module.f90 ¶
r4559 r4577 24 24 ! ----------------- 25 25 ! $Id$ 26 ! further re-formatting to follow the PALM coding standard 27 ! 28 ! 4559 2020-06-11 08:51:48Z raasch 26 29 ! file re-formatted to follow the PALM coding standard 27 30 ! … … 64 67 65 68 66 CHARACTER(LEN=*), PARAMETER :: config_file_name = 'BINARY_TO_NETCDF_CONFIG' !< name of config 67 !< file 68 CHARACTER(LEN=*), PARAMETER :: file_prefix = 'BIN_' !< file prefix for 69 !< binary files 70 CHARACTER(LEN=*), PARAMETER :: mode_binary = 'binary' !< string to 71 !< select operation mode of module 69 CHARACTER(LEN=*), PARAMETER :: config_file_name = 'BINARY_TO_NETCDF_CONFIG' !< name of config file 70 CHARACTER(LEN=*), PARAMETER :: file_prefix = 'BIN_' !< file prefix for binary files 71 CHARACTER(LEN=*), PARAMETER :: mode_binary = 'binary' !< string to select operation mode of module 72 72 73 73 INTEGER, PARAMETER :: charlen = 100 !< maximum length of character variables 74 74 75 CHARACTER(LEN=charlen) :: file_suffix = '' !< file suffix added to each file 76 !< name 77 CHARACTER(LEN=800) :: internal_error_message = '' !< string containing the last error 78 !< message 75 CHARACTER(LEN=charlen) :: file_suffix = '' !< file suffix added to each file name 76 CHARACTER(LEN=800) :: internal_error_message = '' !< string containing the last error message 79 77 CHARACTER(LEN=800) :: temp_string !< dummy string 80 78 81 INTEGER :: binary_file_lowest_unit = 1000 !< lowest unit number of all binary files created by 82 !< this module 79 INTEGER :: binary_file_lowest_unit = 1000 !< lowest unit number of all binary files created by this module 83 80 INTEGER :: config_file_unit !< unit number of config file 84 81 INTEGER :: debug_output_unit !< Fortran Unit Number of the debug-output file 85 82 INTEGER :: global_id_in_file = -1 !< value of global ID within a file 86 INTEGER :: master_rank !< master rank for tasks to be executed by single PE 87 !< only 83 INTEGER :: master_rank !< master rank for tasks to be executed by single PE only 88 84 INTEGER :: next_available_unit !< next unit number available for new file 89 INTEGER :: output_group_comm !< MPI communicator addressing all MPI ranks which 90 !< participate in output 85 INTEGER :: output_group_comm !< MPI communicator addressing all MPI ranks which participate in output 91 86 92 87 INTEGER, DIMENSION(:), ALLOCATABLE :: files_highest_variable_id !< highest assigned ID of … … 194 189 SUBROUTINE binary_open_file( mode, file_name, file_id, return_value ) 195 190 191 CHARACTER(LEN=*), PARAMETER :: routine_name = 'binary_open_file' !< name of this routine 192 196 193 CHARACTER(LEN=charlen) :: bin_filename = '' !< actual name of binary file 197 CHARACTER(LEN=7) :: my_rank_char !< string containing value of my_rank 198 !< with leading zeros 194 CHARACTER(LEN=7) :: my_rank_char !< string containing value of my_rank with leading zeros 199 195 200 196 CHARACTER(LEN=charlen), INTENT(IN) :: file_name !< name of file 201 197 CHARACTER(LEN=*), INTENT(IN) :: mode !< operation mode 202 203 CHARACTER(LEN=*), PARAMETER :: routine_name = 'binary_open_file' !< name of this routine204 198 205 199 INTEGER :: my_rank !< MPI rank of local processor … … 256 250 ENDIF 257 251 258 OPEN( config_file_unit, FILE =TRIM( config_file_name ) // TRIM( file_suffix ), &259 FORM = 'UNFORMATTED', STATUS ='NEW', IOSTAT=return_value )252 OPEN( config_file_unit, FILE=TRIM( config_file_name ) // TRIM( file_suffix ), & 253 FORM='UNFORMATTED', STATUS='NEW', IOSTAT=return_value ) 260 254 261 255 IF ( return_value == 0 ) THEN … … 290 284 ! 291 285 !-- Remove any pre-existing file 292 INQUIRE( FILE = TRIM( bin_filename ), EXIST =file_exists )286 INQUIRE( FILE=TRIM( bin_filename ), EXIST=file_exists ) 293 287 294 288 IF ( file_exists ) THEN … … 304 298 !-- Open binary file 305 299 CALL internal_message( 'debug', routine_name // ': open file ' // TRIM( bin_filename ) ) 306 OPEN ( next_available_unit, FILE = TRIM( bin_filename ), FORM = 'UNFORMATTED',&307 STATUS = 'NEW', IOSTAT =return_value )300 OPEN ( next_available_unit, FILE=TRIM( bin_filename ), FORM='UNFORMATTED', STATUS='NEW', & 301 IOSTAT=return_value ) 308 302 309 303 IF ( return_value == 0 ) THEN … … 355 349 return_value ) 356 350 351 352 CHARACTER(LEN=*), PARAMETER :: routine_name = 'binary_write_attribute' !< name of this routine 353 357 354 CHARACTER(LEN=charlen) :: attribute_type !< data type of attribute 358 355 CHARACTER(LEN=charlen) :: output_string !< output string … … 361 358 CHARACTER(LEN=charlen), INTENT(IN), OPTIONAL :: value_char !< value of attribute 362 359 363 CHARACTER(LEN=*), PARAMETER :: routine_name = 'binary_write_attribute' !< name of this routine364 360 365 361 INTEGER, INTENT(IN) :: file_id !< file ID … … 429 425 dimension_type, dimension_length, return_value ) 430 426 427 CHARACTER(LEN=*), PARAMETER :: routine_name = 'binary_init_dimension' !< name of this routine 428 431 429 CHARACTER(LEN=charlen) :: output_string !< output string 432 430 … … 434 432 CHARACTER(LEN=charlen), INTENT(IN) :: dimension_type !< data type of dimension 435 433 CHARACTER(LEN=*), INTENT(IN) :: mode !< operation mode 436 437 CHARACTER(LEN=*), PARAMETER :: routine_name = 'binary_init_dimension' !< name of this routine438 434 439 435 INTEGER, INTENT(IN) :: dimension_length !< length of dimension … … 481 477 SUBROUTINE binary_init_variable( mode, file_id, variable_id, variable_name, variable_type, & 482 478 dimension_ids, is_global, return_value ) 479 CHARACTER(LEN=*), PARAMETER :: routine_name = 'binary_init_variable' !< name of this routine 483 480 484 481 CHARACTER(LEN=charlen) :: output_string !< output string … … 487 484 CHARACTER(LEN=charlen), INTENT(IN) :: variable_type !< data type of variable 488 485 489 CHARACTER(LEN=*), PARAMETER :: routine_name = 'binary_init_variable' !< name of this routine490 491 486 INTEGER, INTENT(IN) :: file_id !< file ID 487 INTEGER, INTENT(OUT) :: return_value !< return value 492 488 INTEGER, INTENT(OUT) :: variable_id !< variable ID 493 INTEGER, INTENT(OUT) :: return_value !< return value494 489 495 490 INTEGER, DIMENSION(:), INTENT(IN) :: dimension_ids !< list of dimension IDs used by variable … … 530 525 SUBROUTINE binary_stop_file_header_definition( file_id, return_value ) 531 526 527 CHARACTER(LEN=*), PARAMETER :: routine_name = 'binary_stop_file_header_definition' !< name of this routine 528 532 529 CHARACTER(LEN=charlen) :: output_string !< output string 533 534 CHARACTER(LEN=*), PARAMETER :: routine_name = 'binary_stop_file_header_definition' !< name of535 !< this routine536 530 537 531 INTEGER, INTENT(IN) :: file_id !< file ID … … 568 562 return_value ) 569 563 564 565 CHARACTER(LEN=*), PARAMETER :: routine_name = 'binary_write_variable' !< name of this routine 566 570 567 CHARACTER(LEN=charlen) :: output_string !< output string 571 572 CHARACTER(LEN=*), PARAMETER :: routine_name = 'binary_write_variable' !< name of this routine573 568 574 569 CHARACTER(LEN=1), POINTER, INTENT(IN), OPTIONAL :: values_char_0d !< output variable … … 790 785 SUBROUTINE binary_finalize( file_id, return_value ) 791 786 787 CHARACTER(LEN=*), PARAMETER :: routine_name = 'binary_finalize' !< name of this routine 788 792 789 CHARACTER(LEN=charlen) :: output_string !< output string 793 794 CHARACTER(LEN=*), PARAMETER :: routine_name = 'binary_finalize' !< name of this routine795 790 796 791 INTEGER, INTENT(IN) :: file_id !< file ID -
TabularUnified palm/trunk/SOURCE/data_output_module.f90 ¶
r4500 r4577 3 3 ! This file is part of the PALM model system. 4 4 ! 5 ! PALM is free software: you can redistribute it and/or modify it under the 6 ! terms of the GNU General Public License as published by the Free Software 7 ! Foundation, either version 3 of the License, or (at your option) any later 8 ! version. 9 ! 10 ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY 11 ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 12 ! A PARTICULAR PURPOSE. See the GNU General Public License for more details. 13 ! 14 ! You should have received a copy of the GNU General Public License along with 15 ! PALM. If not, see <http://www.gnu.org/licenses/>. 5 ! PALM is free software: you can redistribute it and/or modify it under the terms of the GNU General 6 ! Public License as published by the Free Software Foundation, either version 3 of the License, or 7 ! (at your option) any later version. 8 ! 9 ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the 10 ! implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 11 ! Public License for more details. 12 ! 13 ! You should have received a copy of the GNU General Public License along with PALM. If not, see 14 ! <http://www.gnu.org/licenses/>. 16 15 ! 17 16 ! Copyright 2019-2020 Leibniz Universitaet Hannover … … 25 24 ! ----------------- 26 25 ! $Id$ 26 ! file re-formatted to follow the PALM coding standard 27 ! 28 ! 4500 2020-04-17 10:12:45Z suehring 27 29 ! Avoid uninitialized variables 28 ! 30 ! 29 31 ! 4481 2020-03-31 18:55:54Z maronga 30 32 ! Enable character-array output … … 72 74 USE kinds 73 75 74 USE data_output_netcdf4_module, &75 ONLY: netcdf4_ init_dimension,&76 netcdf4_get_error_message, &77 netcdf4_ stop_file_header_definition,&78 netcdf4_init_module, &79 netcdf4_init_variable, &80 netcdf4_ finalize,&81 netcdf4_ open_file,&82 netcdf4_write_attribute, &76 USE data_output_netcdf4_module, & 77 ONLY: netcdf4_finalize, & 78 netcdf4_get_error_message, & 79 netcdf4_init_dimension, & 80 netcdf4_init_module, & 81 netcdf4_init_variable, & 82 netcdf4_open_file, & 83 netcdf4_stop_file_header_definition, & 84 netcdf4_write_attribute, & 83 85 netcdf4_write_variable 84 86 85 USE data_output_binary_module, &86 ONLY: binary_finalize, &87 binary_get_error_message, &88 binary_init_dimension, &89 binary_ stop_file_header_definition,&90 binary_init_ module,&91 binary_ init_variable,&92 binary_ open_file,&93 binary_write_attribute, &87 USE data_output_binary_module, & 88 ONLY: binary_finalize, & 89 binary_get_error_message, & 90 binary_init_dimension, & 91 binary_init_module, & 92 binary_init_variable, & 93 binary_open_file, & 94 binary_stop_file_header_definition, & 95 binary_write_attribute, & 94 96 binary_write_variable 95 97 … … 113 115 CHARACTER(LEN=charlen) :: data_type = '' !< data type 114 116 CHARACTER(LEN=charlen) :: name !< variable name 117 CHARACTER(LEN=charlen), DIMENSION(:), ALLOCATABLE :: dimension_names !< list of 118 !< dimension names used by variable 115 119 INTEGER :: id = no_id !< id within file 116 LOGICAL :: is_global = .FALSE. !< true if global variable 117 CHARACTER(LEN=charlen), DIMENSION(:), ALLOCATABLE :: dimension_names !< list of dimension names used by variable 118 INTEGER, DIMENSION(:), ALLOCATABLE :: dimension_ids !< list of dimension ids used by variable 119 TYPE(attribute_type), DIMENSION(:), ALLOCATABLE :: attributes !< list of attributes 120 LOGICAL :: is_global = .FALSE. !< true if global 121 !< variable 122 INTEGER, DIMENSION(:), ALLOCATABLE :: dimension_ids !< list of 123 !< dimension ids used by variable 124 TYPE(attribute_type), DIMENSION(:), ALLOCATABLE :: attributes !< list of 125 !< attributes 120 126 END TYPE variable_type 121 127 … … 123 129 CHARACTER(LEN=charlen) :: data_type = '' !< data type 124 130 CHARACTER(LEN=charlen) :: name !< dimension name 125 INTEGER :: id = no_id !< dimension id within file 131 INTEGER :: id = no_id !< dimension id within 132 !< file 126 133 INTEGER :: length !< length of dimension 127 INTEGER :: length_mask !< length of masked dimension 128 INTEGER :: variable_id = no_id !< associated variable id within file 134 INTEGER :: length_mask !< length of masked 135 !< dimension 136 INTEGER :: variable_id = no_id !< associated variable 137 !< id within file 129 138 LOGICAL :: is_masked = .FALSE. !< true if masked 130 INTEGER, DIMENSION(2) :: bounds !< lower and upper bound of dimension 131 INTEGER, DIMENSION(:), ALLOCATABLE :: masked_indices !< list of masked indices of dimension 132 INTEGER(KIND=1), DIMENSION(:), ALLOCATABLE :: masked_values_int8 !< masked dimension values if 16bit integer 133 INTEGER(KIND=2), DIMENSION(:), ALLOCATABLE :: masked_values_int16 !< masked dimension values if 16bit integer 134 INTEGER(KIND=4), DIMENSION(:), ALLOCATABLE :: masked_values_int32 !< masked dimension values if 32bit integer 135 INTEGER(iwp), DIMENSION(:), ALLOCATABLE :: masked_values_intwp !< masked dimension values if working-precision int 136 INTEGER(KIND=1), DIMENSION(:), ALLOCATABLE :: values_int8 !< dimension values if 16bit integer 137 INTEGER(KIND=2), DIMENSION(:), ALLOCATABLE :: values_int16 !< dimension values if 16bit integer 138 INTEGER(KIND=4), DIMENSION(:), ALLOCATABLE :: values_int32 !< dimension values if 32bit integer 139 INTEGER(iwp), DIMENSION(:), ALLOCATABLE :: values_intwp !< dimension values if working-precision integer 139 INTEGER, DIMENSION(2) :: bounds !< lower and upper bound 140 !< of dimension 141 INTEGER, DIMENSION(:), ALLOCATABLE :: masked_indices !< list of masked 142 !< indices of dimension 143 INTEGER(KIND=1), DIMENSION(:), ALLOCATABLE :: masked_values_int8 !< masked dimension 144 !< values if 16bit integer 145 INTEGER(KIND=2), DIMENSION(:), ALLOCATABLE :: masked_values_int16 !< masked dimension 146 !< values if 16bit integer 147 INTEGER(KIND=4), DIMENSION(:), ALLOCATABLE :: masked_values_int32 !< masked dimension 148 !< values if 32bit integer 149 INTEGER(iwp), DIMENSION(:), ALLOCATABLE :: masked_values_intwp !< masked dimension 150 !< values if working-precision int 151 INTEGER(KIND=1), DIMENSION(:), ALLOCATABLE :: values_int8 !< dimension values if 152 !< 16bit integer 153 INTEGER(KIND=2), DIMENSION(:), ALLOCATABLE :: values_int16 !< dimension values if 154 !< 16bit integer 155 INTEGER(KIND=4), DIMENSION(:), ALLOCATABLE :: values_int32 !< dimension values if 156 !< 32bit integer 157 INTEGER(iwp), DIMENSION(:), ALLOCATABLE :: values_intwp !< dimension values if 158 !< working-precision integer 140 159 LOGICAL, DIMENSION(:), ALLOCATABLE :: mask !< mask 141 REAL(KIND=4), DIMENSION(:), ALLOCATABLE :: masked_values_real32 !< masked dimension values if 32bit real 142 REAL(KIND=8), DIMENSION(:), ALLOCATABLE :: masked_values_real64 !< masked dimension values if 64bit real 143 REAL(wp), DIMENSION(:), ALLOCATABLE :: masked_values_realwp !< masked dimension values if working-precision real 144 REAL(KIND=4), DIMENSION(:), ALLOCATABLE :: values_real32 !< dimension values if 32bit real 145 REAL(KIND=8), DIMENSION(:), ALLOCATABLE :: values_real64 !< dimension values if 64bit real 146 REAL(wp), DIMENSION(:), ALLOCATABLE :: values_realwp !< dimension values if working-precision real 160 REAL(KIND=4), DIMENSION(:), ALLOCATABLE :: masked_values_real32 !< masked dimension 161 !< values if 32bit real 162 REAL(KIND=8), DIMENSION(:), ALLOCATABLE :: masked_values_real64 !< masked dimension 163 !< values if 64bit real 164 REAL(wp), DIMENSION(:), ALLOCATABLE :: masked_values_realwp !< masked dimension 165 !< values if working-precision real 166 REAL(KIND=4), DIMENSION(:), ALLOCATABLE :: values_real32 !< dimension values if 167 !< 32bit real 168 REAL(KIND=8), DIMENSION(:), ALLOCATABLE :: values_real64 !< dimension values if 169 !< 64bit real 170 REAL(wp), DIMENSION(:), ALLOCATABLE :: values_realwp !< dimension values if 171 !< working-precision real 147 172 TYPE(attribute_type), DIMENSION(:), ALLOCATABLE :: attributes !< list of attributes 148 173 END TYPE dimension_type … … 159 184 160 185 186 CHARACTER(LEN=800) :: internal_error_message = '' !< string containing the last error message 161 187 CHARACTER(LEN=charlen) :: output_file_suffix = '' !< file suffix added to each file name 162 CHARACTER(LEN=800) :: internal_error_message = '' !< string containing the last error message163 188 CHARACTER(LEN=800) :: temp_string !< dummy string 164 189 … … 296 321 FUNCTION dom_def_file( file_name, file_format ) RESULT( return_value ) 297 322 323 CHARACTER(LEN=*), PARAMETER :: routine_name = 'dom_def_file' !< name of this routine 324 298 325 CHARACTER(LEN=*), INTENT(IN) :: file_name !< name of file to be created 299 326 CHARACTER(LEN=*), INTENT(IN) :: file_format !< format of file to be created 300 301 CHARACTER(LEN=*), PARAMETER :: routine_name = 'dom_def_file' !< name of this routine302 327 303 328 INTEGER :: f !< loop index … … 385 410 mask ) RESULT( return_value ) 386 411 412 CHARACTER(LEN=*), PARAMETER :: routine_name = 'dom_def_dim' !< name of this routine 413 387 414 CHARACTER(LEN=*), INTENT(IN) :: file_name !< name of file 388 415 CHARACTER(LEN=*), INTENT(IN) :: dimension_name !< name of dimension 389 416 CHARACTER(LEN=*), INTENT(IN) :: output_type !< data type of dimension variable in output file 390 391 CHARACTER(LEN=*), PARAMETER :: routine_name = 'dom_def_dim' !< name of this routine392 417 393 418 INTEGER :: d !< loop index … … 416 441 return_value = 0 417 442 418 CALL internal_message( 'debug', routine_name // &419 ': define dimension ' // &420 '(dimension "' // TRIM( dimension_name ) // &443 CALL internal_message( 'debug', routine_name // & 444 ': define dimension ' // & 445 '(dimension "' // TRIM( dimension_name ) // & 421 446 '", file "' // TRIM( file_name ) // '")' ) 422 447 … … 427 452 IF ( SIZE( bounds ) == 1 ) THEN 428 453 ! 429 !-- Dimension has only lower bound, which means it changes its size 430 !-- during simulation. 454 !-- Dimension has only lower bound, which means it changes its size during simulation. 431 455 !-- Set length to -1 as indicator. 432 456 dimension%bounds(:) = bounds(1) … … 435 459 IF ( PRESENT( mask ) ) THEN 436 460 return_value = 1 437 CALL internal_message( 'error', routine_name // &438 ': unlimited dimensions cannot be masked ' // &439 '(dimension "' // TRIM( dimension_name ) // &461 CALL internal_message( 'error', routine_name // & 462 ': unlimited dimensions cannot be masked ' // & 463 '(dimension "' // TRIM( dimension_name ) // & 440 464 '", file "' // TRIM( file_name ) // '")!' ) 441 465 ENDIF … … 512 536 ELSE 513 537 return_value = 1 514 CALL internal_message( 'error', routine_name // &515 ': no values given ' // &516 '(dimension "' // TRIM( dimension_name ) // &538 CALL internal_message( 'error', routine_name // & 539 ': no values given ' // & 540 '(dimension "' // TRIM( dimension_name ) // & 517 541 '", file "' // TRIM( file_name ) // '")!' ) 518 542 ENDIF … … 520 544 IF ( return_value == 2 ) THEN 521 545 return_value = 1 522 CALL internal_message( 'error', routine_name // &523 ': number of values and given bounds do not match ' // &524 '(dimension "' // TRIM( dimension_name ) // &546 CALL internal_message( 'error', routine_name // & 547 ': number of values and given bounds do not match ' // & 548 '(dimension "' // TRIM( dimension_name ) // & 525 549 '", file "' // TRIM( file_name ) // '")!' ) 526 550 ENDIF … … 533 557 IF ( ALL( mask ) ) THEN 534 558 535 CALL internal_message( 'debug', routine_name // &536 ': mask contains only TRUE values. Ignoring mask ' // &537 '(dimension "' // TRIM( dimension_name ) // &559 CALL internal_message( 'debug', routine_name // & 560 ': mask contains only TRUE values. Ignoring mask ' // & 561 '(dimension "' // TRIM( dimension_name ) // & 538 562 '", file "' // TRIM( file_name ) // '")!' ) 539 563 … … 577 601 ALLOCATE( dimension%masked_values_int32(0:dimension%length_mask-1) ) 578 602 j = 0 579 DO i = dimension%bounds(1), dimension%bounds(2)603 DO i = dimension%bounds(1), dimension%bounds(2) 580 604 IF ( dimension%mask(i) ) THEN 581 605 dimension%masked_values_int32(j) = dimension%values_int32(i) … … 639 663 ELSE 640 664 return_value = 1 641 CALL internal_message( 'error', routine_name // &642 ': size of mask and given bounds do not match ' // &643 '(dimension "' // TRIM( dimension_name ) // &665 CALL internal_message( 'error', routine_name // & 666 ': size of mask and given bounds do not match ' // & 667 '(dimension "' // TRIM( dimension_name ) // & 644 668 '", file "' // TRIM( file_name ) // '")!' ) 645 669 ENDIF … … 650 674 651 675 return_value = 1 652 CALL internal_message( 'error', routine_name // &653 ': at least one but no more than two bounds must be given ' // &654 '(dimension "' // TRIM( dimension_name ) // &676 CALL internal_message( 'error', routine_name // & 677 ': at least one but no more than two bounds must be given ' // & 678 '(dimension "' // TRIM( dimension_name ) // & 655 679 '", file "' // TRIM( file_name ) // '")!' ) 656 680 … … 667 691 668 692 return_value = 1 669 CALL internal_message( 'error', routine_name // &670 ': file already initialized. ' // &671 'No further dimension definition allowed ' // &672 '(dimension "' // TRIM( dimension_name ) // &693 CALL internal_message( 'error', routine_name // & 694 ': file already initialized. ' // & 695 'No further dimension definition allowed ' // & 696 '(dimension "' // TRIM( dimension_name ) // & 673 697 '", file "' // TRIM( file_name ) // '")!' ) 674 698 EXIT … … 686 710 IF ( files(f)%variables(i)%name == dimension%name ) THEN 687 711 return_value = 1 688 CALL internal_message( 'error', routine_name // &689 ': file already has a variable of this name defined. ' // &690 'Defining a dimension of the same name is not allowed ' // &691 '(dimension "' // TRIM( dimension_name ) // &692 '", file "' // TRIM( file_name ) // '")!' )712 CALL internal_message( 'error', routine_name // & 713 ': file already has a variable of this name defined. ' // & 714 'Defining a dimension of the same name is not allowed ' // & 715 '(dimension "' // TRIM( dimension_name ) // & 716 '", file "' // TRIM( file_name ) // '")!' ) 693 717 EXIT 694 718 ENDIF … … 704 728 IF ( files(f)%dimensions(d)%name == dimension%name ) THEN 705 729 return_value = 1 706 CALL internal_message( 'error', routine_name // &707 ': dimension already exists in file ' //&708 '(dimension "' // TRIM( dimension_name ) //&709 '", file "' // TRIM( file_name ) // '")!' )730 CALL internal_message( 'error', routine_name // & 731 ': dimension already exists in file ' // & 732 '(dimension "' // TRIM( dimension_name ) // & 733 '", file "' // TRIM( file_name ) // '")!' ) 710 734 EXIT 711 735 ENDIF … … 736 760 IF ( f > nfiles ) THEN 737 761 return_value = 1 738 CALL internal_message( 'error', routine_name // &739 ': file not found (dimension "' // TRIM( dimension_name ) // &762 CALL internal_message( 'error', routine_name // & 763 ': file not found (dimension "' // TRIM( dimension_name ) // & 740 764 '", file "' // TRIM( file_name ) // '")!' ) 741 765 ENDIF … … 750 774 !> Add variable to database. 751 775 !> If a variable is identical for each MPI rank, the optional argument 'is_global' should be set to 752 !> TRUE. This flags the variable to be a global variable and is later only written once by the776 !> .TRUE. This flags the variable to be a global variable and is later only written once by the 753 777 !> master output rank. 754 778 !> Example call: … … 770 794 !> ALLOCATE( u(<z>,<y>,<x>) ) 771 795 !--------------------------------------------------------------------------------------------------! 772 FUNCTION dom_def_var( file_name, variable_name, dimension_names, output_type, is_global ) &796 FUNCTION dom_def_var( file_name, variable_name, dimension_names, output_type, is_global ) & 773 797 RESULT( return_value ) 774 798 799 CHARACTER(LEN=*), PARAMETER :: routine_name = 'dom_def_var' !< name of this routine 800 775 801 CHARACTER(LEN=*), INTENT(IN) :: file_name !< name of file 802 CHARACTER(LEN=*), INTENT(IN) :: output_type !< data type of variable 776 803 CHARACTER(LEN=*), INTENT(IN) :: variable_name !< name of variable 777 CHARACTER(LEN=*), INTENT(IN) :: output_type !< data type of variable778 779 CHARACTER(LEN=*), PARAMETER :: routine_name = 'dom_def_var' !< name of this routine780 804 781 805 CHARACTER(LEN=*), DIMENSION(:), INTENT(IN) :: dimension_names !< list of dimension names … … 797 821 found = .FALSE. 798 822 799 CALL internal_message( 'debug', routine_name // &800 ': define variable (variable "' // TRIM( variable_name ) // &823 CALL internal_message( 'debug', routine_name // & 824 ': define variable (variable "' // TRIM( variable_name ) // & 801 825 '", file "' // TRIM( file_name ) // '")' ) 802 826 … … 824 848 825 849 return_value = 1 826 CALL internal_message( 'error', routine_name // &827 ': file already initialized. No further variable definition allowed ' // &828 '(variable "' // TRIM( variable_name ) // &829 '", file "' // TRIM( file_name ) // '")!' )850 CALL internal_message( 'error', routine_name // & 851 ': file already initialized. No further variable definition allowed ' // & 852 '(variable "' // TRIM( variable_name ) // & 853 '", file "' // TRIM( file_name ) // '")!' ) 830 854 EXIT 831 855 … … 836 860 IF ( files(f)%dimensions(d)%name == variable%name ) THEN 837 861 return_value = 1 838 CALL internal_message( 'error', routine_name // &839 ': file already has a dimension of this name defined. ' // &840 'Defining a variable of the same name is not allowed ' // &841 '(variable "' // TRIM( variable_name ) // &842 '", file "' // TRIM( file_name ) // '")!' )862 CALL internal_message( 'error', routine_name // & 863 ': file already has a dimension of this name defined. ' // & 864 'Defining a variable of the same name is not allowed ' // & 865 '(variable "' // TRIM( variable_name ) // & 866 '", file "' // TRIM( file_name ) // '")!' ) 843 867 EXIT 844 868 ENDIF … … 857 881 IF ( .NOT. found ) THEN 858 882 return_value = 1 859 CALL internal_message( 'error', routine_name // &860 ': required dimension "'//TRIM( variable%dimension_names(i) ) // &861 '" for variable is not defined ' //&862 '(variable "' // TRIM( variable_name ) //&863 '", file "' // TRIM( file_name ) // '")!' )883 CALL internal_message( 'error', routine_name // & 884 ': required dimension "'// TRIM( variable%dimension_names(i) ) // & 885 '" for variable is not defined ' // & 886 '(variable "' // TRIM( variable_name ) // & 887 '", file "' // TRIM( file_name ) // '")!' ) 864 888 EXIT 865 889 ENDIF … … 870 894 871 895 return_value = 1 872 CALL internal_message( 'error', routine_name // &873 ': no dimensions defined in file. Cannot define variable '//&874 '(variable "' // TRIM( variable_name ) //&875 '", file "' // TRIM( file_name ) // '")!' )896 CALL internal_message( 'error', routine_name // & 897 ': no dimensions defined in file. Cannot define variable '// & 898 '(variable "' // TRIM( variable_name ) // & 899 '", file "' // TRIM( file_name ) // '")!' ) 876 900 877 901 ENDIF … … 891 915 IF ( files(f)%variables(i)%name == variable%name ) THEN 892 916 return_value = 1 893 CALL internal_message( 'error', routine_name // &894 ': variable already exists '//&895 '(variable "' // TRIM( variable_name ) //&896 '", file "' // TRIM( file_name ) // '")!' )917 CALL internal_message( 'error', routine_name // & 918 ': variable already exists '// & 919 '(variable "' // TRIM( variable_name ) // & 920 '", file "' // TRIM( file_name ) // '")!' ) 897 921 EXIT 898 922 ENDIF … … 926 950 IF ( f > nfiles ) THEN 927 951 return_value = 1 928 CALL internal_message( 'error', routine_name // &929 ': file not found (variable "' // TRIM( variable_name ) // &952 CALL internal_message( 'error', routine_name // & 953 ': file not found (variable "' // TRIM( variable_name ) // & 930 954 '", file "' // TRIM( file_name ) // '")!' ) 931 955 ENDIF … … 961 985 RESULT( return_value ) 962 986 987 CHARACTER(LEN=*), INTENT(IN) :: attribute_name !< name of attribute 963 988 CHARACTER(LEN=*), INTENT(IN) :: file_name !< name of file 964 CHARACTER(LEN=*), INTENT(IN) :: attribute_name !< name of attribute965 989 CHARACTER(LEN=*), INTENT(IN) :: value !< attribute value 966 990 CHARACTER(LEN=*), INTENT(IN), OPTIONAL :: variable_name !< name of variable … … 995 1019 ENDIF 996 1020 997 return_value = save_attribute_in_database( file_name=TRIM( file_name ), &998 variable_name=TRIM( variable_name_internal ),&999 attribute=attribute, append=append_internal )1021 return_value = save_attribute_in_database( file_name=TRIM( file_name ), & 1022 variable_name=TRIM( variable_name_internal ), & 1023 attribute=attribute, append=append_internal ) 1000 1024 1001 1025 END FUNCTION dom_def_att_char … … 1020 1044 !> value=1_1 ) 1021 1045 !--------------------------------------------------------------------------------------------------! 1022 FUNCTION dom_def_att_int8( file_name, variable_name, attribute_name, value, append ) &1046 FUNCTION dom_def_att_int8( file_name, variable_name, attribute_name, value, append ) & 1023 1047 RESULT( return_value ) 1024 1048 1049 CHARACTER(LEN=*), PARAMETER :: routine_name = 'dom_def_att_int8' !< name of routine 1050 1051 CHARACTER(LEN=*), INTENT(IN) :: attribute_name !< name of attribute 1025 1052 CHARACTER(LEN=*), INTENT(IN) :: file_name !< name of file 1026 CHARACTER(LEN=*), INTENT(IN) :: attribute_name !< name of attribute1027 1053 CHARACTER(LEN=*), INTENT(IN), OPTIONAL :: variable_name !< name of variable 1028 1054 CHARACTER(LEN=charlen) :: variable_name_internal !< internal copy of variable_name 1029 1030 CHARACTER(LEN=*), PARAMETER :: routine_name = 'dom_def_att_int8' !< name of routine1031 1055 1032 1056 INTEGER(KIND=1), INTENT(IN) :: value !< attribute value … … 1051 1075 IF ( append ) THEN 1052 1076 return_value = 1 1053 CALL internal_message( 'error', routine_name // &1054 ': numeric attribute cannot be appended ' // &1055 '(attribute "' // TRIM( attribute_name ) // &1056 '", variable "' // TRIM( variable_name_internal ) // &1077 CALL internal_message( 'error', routine_name // & 1078 ': numeric attribute cannot be appended ' // & 1079 '(attribute "' // TRIM( attribute_name ) // & 1080 '", variable "' // TRIM( variable_name_internal ) // & 1057 1081 '", file "' // TRIM( file_name ) // '")!' ) 1058 1082 ENDIF … … 1066 1090 attribute%value_int8 = value 1067 1091 1068 return_value = save_attribute_in_database( file_name=TRIM( file_name ), &1069 variable_name=TRIM( variable_name_internal ),&1070 attribute=attribute, append=append_internal )1092 return_value = save_attribute_in_database( file_name=TRIM( file_name ), & 1093 variable_name=TRIM( variable_name_internal ), & 1094 attribute=attribute, append=append_internal ) 1071 1095 ENDIF 1072 1096 … … 1092 1116 !> value=1_2 ) 1093 1117 !--------------------------------------------------------------------------------------------------! 1094 FUNCTION dom_def_att_int16( file_name, variable_name, attribute_name, value, append ) &1118 FUNCTION dom_def_att_int16( file_name, variable_name, attribute_name, value, append ) & 1095 1119 RESULT( return_value ) 1096 1120 1121 CHARACTER(LEN=*), PARAMETER :: routine_name = 'dom_def_att_int16' !< name of routine 1122 1123 CHARACTER(LEN=*), INTENT(IN) :: attribute_name !< name of attribute 1097 1124 CHARACTER(LEN=*), INTENT(IN) :: file_name !< name of file 1098 CHARACTER(LEN=*), INTENT(IN) :: attribute_name !< name of attribute1099 1125 CHARACTER(LEN=*), INTENT(IN), OPTIONAL :: variable_name !< name of variable 1100 1126 CHARACTER(LEN=charlen) :: variable_name_internal !< internal copy of variable_name 1101 1102 CHARACTER(LEN=*), PARAMETER :: routine_name = 'dom_def_att_int16' !< name of routine1103 1127 1104 1128 INTEGER(KIND=2), INTENT(IN) :: value !< attribute value … … 1123 1147 IF ( append ) THEN 1124 1148 return_value = 1 1125 CALL internal_message( 'error', routine_name // &1126 ': numeric attribute cannot be appended ' // &1127 '(attribute "' // TRIM( attribute_name ) // &1128 '", variable "' // TRIM( variable_name_internal ) // &1149 CALL internal_message( 'error', routine_name // & 1150 ': numeric attribute cannot be appended ' // & 1151 '(attribute "' // TRIM( attribute_name ) // & 1152 '", variable "' // TRIM( variable_name_internal ) // & 1129 1153 '", file "' // TRIM( file_name ) // '")!' ) 1130 1154 ENDIF … … 1138 1162 attribute%value_int16 = value 1139 1163 1140 return_value = save_attribute_in_database( file_name=TRIM( file_name ), &1141 variable_name=TRIM( variable_name_internal ),&1142 attribute=attribute, append=append_internal )1164 return_value = save_attribute_in_database( file_name=TRIM( file_name ), & 1165 variable_name=TRIM( variable_name_internal ), & 1166 attribute=attribute, append=append_internal ) 1143 1167 ENDIF 1144 1168 … … 1164 1188 !> value=1_4 ) 1165 1189 !--------------------------------------------------------------------------------------------------! 1166 FUNCTION dom_def_att_int32( file_name, variable_name, attribute_name, value, append ) &1190 FUNCTION dom_def_att_int32( file_name, variable_name, attribute_name, value, append ) & 1167 1191 RESULT( return_value ) 1168 1192 1193 CHARACTER(LEN=*), PARAMETER :: routine_name = 'dom_def_att_int32' !< name of routine 1194 1195 1196 CHARACTER(LEN=*), INTENT(IN) :: attribute_name !< name of attribute 1169 1197 CHARACTER(LEN=*), INTENT(IN) :: file_name !< name of file 1170 CHARACTER(LEN=*), INTENT(IN) :: attribute_name !< name of attribute1171 1198 CHARACTER(LEN=*), INTENT(IN), OPTIONAL :: variable_name !< name of variable 1172 1199 CHARACTER(LEN=charlen) :: variable_name_internal !< internal copy of variable_name 1173 1174 CHARACTER(LEN=*), PARAMETER :: routine_name = 'dom_def_att_int32' !< name of routine1175 1200 1176 1201 INTEGER(KIND=4), INTENT(IN) :: value !< attribute value … … 1195 1220 IF ( append ) THEN 1196 1221 return_value = 1 1197 CALL internal_message( 'error', routine_name // &1198 ': numeric attribute cannot be appended ' // &1199 '(attribute "' // TRIM( attribute_name ) // &1200 '", variable "' // TRIM( variable_name_internal ) // &1222 CALL internal_message( 'error', routine_name // & 1223 ': numeric attribute cannot be appended ' // & 1224 '(attribute "' // TRIM( attribute_name ) // & 1225 '", variable "' // TRIM( variable_name_internal ) // & 1201 1226 '", file "' // TRIM( file_name ) // '")!' ) 1202 1227 ENDIF … … 1210 1235 attribute%value_int32 = value 1211 1236 1212 return_value = save_attribute_in_database( file_name=TRIM( file_name ), &1213 variable_name=TRIM( variable_name_internal ),&1214 attribute=attribute, append=append_internal )1237 return_value = save_attribute_in_database( file_name=TRIM( file_name ), & 1238 variable_name=TRIM( variable_name_internal ), & 1239 attribute=attribute, append=append_internal ) 1215 1240 ENDIF 1216 1241 … … 1236 1261 !> value=1.0_4 ) 1237 1262 !--------------------------------------------------------------------------------------------------! 1238 FUNCTION dom_def_att_real32( file_name, variable_name, attribute_name, value, append ) &1263 FUNCTION dom_def_att_real32( file_name, variable_name, attribute_name, value, append ) & 1239 1264 RESULT( return_value ) 1240 1265 1266 CHARACTER(LEN=*), PARAMETER :: routine_name = 'dom_def_att_real32' !< name of routine 1267 1268 CHARACTER(LEN=*), INTENT(IN) :: attribute_name !< name of attribute 1241 1269 CHARACTER(LEN=*), INTENT(IN) :: file_name !< name of file 1242 CHARACTER(LEN=*), INTENT(IN) :: attribute_name !< name of attribute1243 1270 CHARACTER(LEN=*), INTENT(IN), OPTIONAL :: variable_name !< name of variable 1244 1271 CHARACTER(LEN=charlen) :: variable_name_internal !< internal copy of variable_name 1245 1246 CHARACTER(LEN=*), PARAMETER :: routine_name = 'dom_def_att_real32' !< name of routine1247 1272 1248 1273 INTEGER :: return_value !< return value … … 1267 1292 IF ( append ) THEN 1268 1293 return_value = 1 1269 CALL internal_message( 'error', routine_name // &1270 ': numeric attribute cannot be appended ' // &1271 '(attribute "' // TRIM( attribute_name ) // &1272 '", variable "' // TRIM( variable_name_internal ) // &1294 CALL internal_message( 'error', routine_name // & 1295 ': numeric attribute cannot be appended ' // & 1296 '(attribute "' // TRIM( attribute_name ) // & 1297 '", variable "' // TRIM( variable_name_internal ) // & 1273 1298 '", file "' // TRIM( file_name ) // '")!' ) 1274 1299 ENDIF … … 1282 1307 attribute%value_real32 = value 1283 1308 1284 return_value = save_attribute_in_database( file_name=TRIM( file_name ), &1285 variable_name=TRIM( variable_name_internal ),&1286 attribute=attribute, append=append_internal )1309 return_value = save_attribute_in_database( file_name=TRIM( file_name ), & 1310 variable_name=TRIM( variable_name_internal ), & 1311 attribute=attribute, append=append_internal ) 1287 1312 ENDIF 1288 1313 … … 1308 1333 !> value=1.0_8 ) 1309 1334 !--------------------------------------------------------------------------------------------------! 1310 FUNCTION dom_def_att_real64( file_name, variable_name, attribute_name, value, append ) &1335 FUNCTION dom_def_att_real64( file_name, variable_name, attribute_name, value, append ) & 1311 1336 RESULT( return_value ) 1312 1337 1338 CHARACTER(LEN=*), PARAMETER :: routine_name = 'dom_def_att_real64' !< name of routine 1339 1340 CHARACTER(LEN=*), INTENT(IN) :: attribute_name !< name of attribute 1313 1341 CHARACTER(LEN=*), INTENT(IN) :: file_name !< name of file 1314 CHARACTER(LEN=*), INTENT(IN) :: attribute_name !< name of attribute1315 1342 CHARACTER(LEN=*), INTENT(IN), OPTIONAL :: variable_name !< name of variable 1316 1343 CHARACTER(LEN=charlen) :: variable_name_internal !< internal copy of variable_name 1317 1318 CHARACTER(LEN=*), PARAMETER :: routine_name = 'dom_def_att_real64' !< name of routine1319 1344 1320 1345 INTEGER :: return_value !< return value … … 1339 1364 IF ( append ) THEN 1340 1365 return_value = 1 1341 CALL internal_message( 'error', routine_name // &1342 ': numeric attribute cannot be appended ' // &1343 '(attribute "' // TRIM( attribute_name ) // &1344 '", variable "' // TRIM( variable_name_internal ) // &1366 CALL internal_message( 'error', routine_name // & 1367 ': numeric attribute cannot be appended ' // & 1368 '(attribute "' // TRIM( attribute_name ) // & 1369 '", variable "' // TRIM( variable_name_internal ) // & 1345 1370 '", file "' // TRIM( file_name ) // '")!' ) 1346 1371 ENDIF … … 1354 1379 attribute%value_real64 = value 1355 1380 1356 return_value = save_attribute_in_database( file_name=TRIM( file_name ), &1357 variable_name=TRIM( variable_name_internal ),&1358 attribute=attribute, append=append_internal )1381 return_value = save_attribute_in_database( file_name=TRIM( file_name ), & 1382 variable_name=TRIM( variable_name_internal ), & 1383 attribute=attribute, append=append_internal ) 1359 1384 ENDIF 1360 1385 … … 1408 1433 IF ( files(f)%is_init ) CYCLE 1409 1434 1410 CALL internal_message( 'debug', routine_name // ': initialize file "' // &1435 CALL internal_message( 'debug', routine_name // ': initialize file "' // & 1411 1436 TRIM( files(f)%name ) // '"' ) 1412 1437 ! 1413 1438 !-- Open file 1414 CALL open_output_file( files(f)%format, files(f)%name, files(f)%id, &1439 CALL open_output_file( files(f)%format, files(f)%name, files(f)%id, & 1415 1440 return_value=return_value ) 1416 1441 ! 1417 1442 !-- Initialize file header: 1418 1443 !-- define dimensions and variables and write attributes 1419 IF ( return_value == 0 ) & 1420 CALL init_file_header( files(f), return_value=return_value ) 1444 IF ( return_value == 0 ) CALL init_file_header( files(f), return_value=return_value ) 1421 1445 ! 1422 1446 !-- End file definition 1423 IF ( return_value == 0 ) &1424 CALL stop_file_header_definition( files(f)%format, files(f)%id, &1425 files(f)%name,return_value )1447 IF ( return_value == 0 ) & 1448 CALL stop_file_header_definition( files(f)%format, files(f)%id, files(f)%name, & 1449 return_value ) 1426 1450 1427 1451 IF ( return_value == 0 ) THEN … … 1433 1457 DO d = 1, SIZE( files(f)%dimensions ) 1434 1458 IF ( ALLOCATED( files(f)%dimensions(d)%values_int8 ) ) THEN 1435 ALLOCATE( values_int8(files(f)%dimensions(d)%bounds(1): &1459 ALLOCATE( values_int8(files(f)%dimensions(d)%bounds(1): & 1436 1460 files(f)%dimensions(d)%bounds(2)) ) 1437 1461 values_int8 = files(f)%dimensions(d)%values_int8 1438 1462 values_int8_pointer => values_int8 1439 return_value = dom_write_var( files(f)%name, files(f)%dimensions(d)%name, &1440 bounds_start=(/ files(f)%dimensions(d)%bounds(1) /), &1441 bounds_end =(/ files(f)%dimensions(d)%bounds(2) /), &1463 return_value = dom_write_var( files(f)%name, files(f)%dimensions(d)%name, & 1464 bounds_start=(/ files(f)%dimensions(d)%bounds(1) /), & 1465 bounds_end =(/ files(f)%dimensions(d)%bounds(2) /), & 1442 1466 values_int8_1d=values_int8_pointer ) 1443 1467 DEALLOCATE( values_int8 ) 1444 1468 ELSEIF ( ALLOCATED( files(f)%dimensions(d)%values_int16 ) ) THEN 1445 ALLOCATE( values_int16(files(f)%dimensions(d)%bounds(1): &1469 ALLOCATE( values_int16(files(f)%dimensions(d)%bounds(1): & 1446 1470 files(f)%dimensions(d)%bounds(2)) ) 1447 1471 values_int16 = files(f)%dimensions(d)%values_int16 1448 1472 values_int16_pointer => values_int16 1449 return_value = dom_write_var( files(f)%name, files(f)%dimensions(d)%name, &1450 bounds_start=(/ files(f)%dimensions(d)%bounds(1) /), &1451 bounds_end =(/ files(f)%dimensions(d)%bounds(2) /), &1473 return_value = dom_write_var( files(f)%name, files(f)%dimensions(d)%name, & 1474 bounds_start=(/ files(f)%dimensions(d)%bounds(1) /), & 1475 bounds_end =(/ files(f)%dimensions(d)%bounds(2) /), & 1452 1476 values_int16_1d=values_int16_pointer ) 1453 1477 DEALLOCATE( values_int16 ) 1454 1478 ELSEIF ( ALLOCATED( files(f)%dimensions(d)%values_int32 ) ) THEN 1455 ALLOCATE( values_int32(files(f)%dimensions(d)%bounds(1): &1479 ALLOCATE( values_int32(files(f)%dimensions(d)%bounds(1): & 1456 1480 files(f)%dimensions(d)%bounds(2)) ) 1457 1481 values_int32 = files(f)%dimensions(d)%values_int32 1458 1482 values_int32_pointer => values_int32 1459 return_value = dom_write_var( files(f)%name, files(f)%dimensions(d)%name, &1460 bounds_start=(/ files(f)%dimensions(d)%bounds(1) /), &1461 bounds_end =(/ files(f)%dimensions(d)%bounds(2) /), &1483 return_value = dom_write_var( files(f)%name, files(f)%dimensions(d)%name, & 1484 bounds_start=(/ files(f)%dimensions(d)%bounds(1) /), & 1485 bounds_end =(/ files(f)%dimensions(d)%bounds(2) /), & 1462 1486 values_int32_1d=values_int32_pointer ) 1463 1487 DEALLOCATE( values_int32 ) 1464 1488 ELSEIF ( ALLOCATED( files(f)%dimensions(d)%values_intwp ) ) THEN 1465 ALLOCATE( values_intwp(files(f)%dimensions(d)%bounds(1): &1489 ALLOCATE( values_intwp(files(f)%dimensions(d)%bounds(1): & 1466 1490 files(f)%dimensions(d)%bounds(2)) ) 1467 1491 values_intwp = files(f)%dimensions(d)%values_intwp 1468 1492 values_intwp_pointer => values_intwp 1469 return_value = dom_write_var( files(f)%name, files(f)%dimensions(d)%name, &1470 bounds_start=(/ files(f)%dimensions(d)%bounds(1) /), &1471 bounds_end =(/ files(f)%dimensions(d)%bounds(2) /), &1493 return_value = dom_write_var( files(f)%name, files(f)%dimensions(d)%name, & 1494 bounds_start=(/ files(f)%dimensions(d)%bounds(1) /), & 1495 bounds_end =(/ files(f)%dimensions(d)%bounds(2) /), & 1472 1496 values_intwp_1d=values_intwp_pointer ) 1473 1497 DEALLOCATE( values_intwp ) 1474 1498 ELSEIF ( ALLOCATED( files(f)%dimensions(d)%values_real32 ) ) THEN 1475 ALLOCATE( values_real32(files(f)%dimensions(d)%bounds(1): &1499 ALLOCATE( values_real32(files(f)%dimensions(d)%bounds(1): & 1476 1500 files(f)%dimensions(d)%bounds(2)) ) 1477 1501 values_real32 = files(f)%dimensions(d)%values_real32 1478 1502 values_real32_pointer => values_real32 1479 return_value = dom_write_var( files(f)%name, files(f)%dimensions(d)%name, &1480 bounds_start=(/ files(f)%dimensions(d)%bounds(1) /), &1481 bounds_end =(/ files(f)%dimensions(d)%bounds(2) /), &1503 return_value = dom_write_var( files(f)%name, files(f)%dimensions(d)%name, & 1504 bounds_start=(/ files(f)%dimensions(d)%bounds(1) /), & 1505 bounds_end =(/ files(f)%dimensions(d)%bounds(2) /), & 1482 1506 values_real32_1d=values_real32_pointer ) 1483 1507 DEALLOCATE( values_real32 ) 1484 1508 ELSEIF ( ALLOCATED( files(f)%dimensions(d)%values_real64 ) ) THEN 1485 ALLOCATE( values_real64(files(f)%dimensions(d)%bounds(1): &1509 ALLOCATE( values_real64(files(f)%dimensions(d)%bounds(1): & 1486 1510 files(f)%dimensions(d)%bounds(2)) ) 1487 1511 values_real64 = files(f)%dimensions(d)%values_real64 1488 1512 values_real64_pointer => values_real64 1489 return_value = dom_write_var( files(f)%name, files(f)%dimensions(d)%name, &1490 bounds_start=(/ files(f)%dimensions(d)%bounds(1) /), &1491 bounds_end =(/ files(f)%dimensions(d)%bounds(2) /), &1513 return_value = dom_write_var( files(f)%name, files(f)%dimensions(d)%name, & 1514 bounds_start=(/ files(f)%dimensions(d)%bounds(1) /), & 1515 bounds_end =(/ files(f)%dimensions(d)%bounds(2) /), & 1492 1516 values_real64_1d=values_real64_pointer ) 1493 1517 DEALLOCATE( values_real64 ) 1494 1518 ELSEIF ( ALLOCATED( files(f)%dimensions(d)%values_realwp ) ) THEN 1495 ALLOCATE( values_realwp(files(f)%dimensions(d)%bounds(1): &1519 ALLOCATE( values_realwp(files(f)%dimensions(d)%bounds(1): & 1496 1520 files(f)%dimensions(d)%bounds(2)) ) 1497 1521 values_realwp = files(f)%dimensions(d)%values_realwp 1498 1522 values_realwp_pointer => values_realwp 1499 return_value = dom_write_var( files(f)%name, files(f)%dimensions(d)%name, &1500 bounds_start=(/ files(f)%dimensions(d)%bounds(1) /), &1501 bounds_end =(/ files(f)%dimensions(d)%bounds(2) /), &1523 return_value = dom_write_var( files(f)%name, files(f)%dimensions(d)%name, & 1524 bounds_start=(/ files(f)%dimensions(d)%bounds(1) /), & 1525 bounds_end =(/ files(f)%dimensions(d)%bounds(2) /), & 1502 1526 values_realwp_1d=values_realwp_pointer ) 1503 1527 DEALLOCATE( values_realwp ) … … 1538 1562 !> chosen, the values are written to file as given in the 'dom_write_var' call. 1539 1563 !--------------------------------------------------------------------------------------------------! 1540 FUNCTION dom_write_var( file_name, variable_name, bounds_start, bounds_end, &1541 values_char_0d, values_char_1d, values_char_2d, values_char_3d, &1542 values_int8_0d, values_int8_1d, values_int8_2d, values_int8_3d, &1543 values_int16_0d, values_int16_1d, values_int16_2d, values_int16_3d, &1544 values_int32_0d, values_int32_1d, values_int32_2d, values_int32_3d, &1545 values_intwp_0d, values_intwp_1d, values_intwp_2d, values_intwp_3d, &1546 values_real32_0d, values_real32_1d, values_real32_2d, values_real32_3d, &1547 values_real64_0d, values_real64_1d, values_real64_2d, values_real64_3d, &1548 values_realwp_0d, values_realwp_1d, values_realwp_2d, values_realwp_3d &1564 FUNCTION dom_write_var( file_name, variable_name, bounds_start, bounds_end, & 1565 values_char_0d, values_char_1d, values_char_2d, values_char_3d, & 1566 values_int8_0d, values_int8_1d, values_int8_2d, values_int8_3d, & 1567 values_int16_0d, values_int16_1d, values_int16_2d, values_int16_3d, & 1568 values_int32_0d, values_int32_1d, values_int32_2d, values_int32_3d, & 1569 values_intwp_0d, values_intwp_1d, values_intwp_2d, values_intwp_3d, & 1570 values_real32_0d, values_real32_1d, values_real32_2d, values_real32_3d, & 1571 values_real64_0d, values_real64_1d, values_real64_2d, values_real64_3d, & 1572 values_realwp_0d, values_realwp_1d, values_realwp_2d, values_realwp_3d & 1549 1573 ) RESULT( return_value ) 1574 1575 CHARACTER(LEN=*), PARAMETER :: routine_name = 'dom_write_var' !< name of routine 1550 1576 1551 1577 CHARACTER(LEN=charlen) :: file_format !< file format chosen for file 1552 1578 CHARACTER(LEN=*), INTENT(IN) :: file_name !< name of file 1553 1579 CHARACTER(LEN=*), INTENT(IN) :: variable_name !< name of variable 1554 1555 CHARACTER(LEN=*), PARAMETER :: routine_name = 'dom_write_var' !< name of routine1556 1580 1557 1581 CHARACTER(LEN=1), POINTER, INTENT(IN), OPTIONAL :: values_char_0d !< output variable … … 1579 1603 INTEGER, DIMENSION(:), INTENT(IN) :: bounds_end !< end index per dimension of variable 1580 1604 INTEGER, DIMENSION(:), INTENT(IN) :: bounds_start !< start index per dimension of variable 1605 1581 1606 INTEGER, DIMENSION(:), ALLOCATABLE :: bounds_origin !< first index of each dimension 1582 1607 INTEGER, DIMENSION(:), ALLOCATABLE :: bounds_start_internal !< start index per dim. for output after masking … … 1604 1629 INTEGER(iwp), POINTER, INTENT(IN), OPTIONAL, DIMENSION(:,:,:) :: values_intwp_3d !< output variable 1605 1630 1606 INTEGER(KIND=1), TARGET, ALLOCATABLE, DIMENSION(:) :: values_int8_1d_resorted !< resorted output variable1607 INTEGER(KIND=2), TARGET, ALLOCATABLE, DIMENSION(:) :: values_int16_1d_resorted !< resorted output variable1608 INTEGER(KIND=4), TARGET, ALLOCATABLE, DIMENSION(:) :: values_int32_1d_resorted !< resorted output variable1609 INTEGER(iwp), TARGET, ALLOCATABLE, DIMENSION(:) :: values_intwp_1d_resorted !< resorted output variable1610 INTEGER(KIND=1), TARGET, ALLOCATABLE, DIMENSION(:,:) :: values_int8_2d_resorted !< resorted output variable1611 INTEGER(KIND=2), TARGET, ALLOCATABLE, DIMENSION(:,:) :: values_int16_2d_resorted !< resorted output variable1612 INTEGER(KIND=4), TARGET, ALLOCATABLE, DIMENSION(:,:) :: values_int32_2d_resorted !< resorted output variable1613 INTEGER(iwp), TARGET, ALLOCATABLE, DIMENSION(:,:) :: values_intwp_2d_resorted !< resorted output variable1614 INTEGER(KIND=1), TARGET, ALLOCATABLE, DIMENSION(:,:,:) :: values_int8_3d_resorted !< resorted output variable1615 INTEGER(KIND=2), TARGET, ALLOCATABLE, DIMENSION(:,:,:) :: values_int16_3d_resorted !< resorted output variable1616 INTEGER(KIND=4), TARGET, ALLOCATABLE, DIMENSION(:,:,:) :: values_int32_3d_resorted !< resorted output variable1617 INTEGER(iwp), TARGET, ALLOCATABLE, DIMENSION(:,:,:) :: values_intwp_3d_resorted !< resorted output variable1618 1619 1631 INTEGER(KIND=1), POINTER :: values_int8_0d_pointer !< pointer to resortet array 1620 1632 INTEGER(KIND=2), POINTER :: values_int16_0d_pointer !< pointer to resortet array … … 1634 1646 INTEGER(iwp), POINTER, CONTIGUOUS, DIMENSION(:,:,:) :: values_intwp_3d_pointer !< pointer to resortet array 1635 1647 1648 INTEGER(KIND=1), TARGET, ALLOCATABLE, DIMENSION(:) :: values_int8_1d_resorted !< resorted output variable 1649 INTEGER(KIND=2), TARGET, ALLOCATABLE, DIMENSION(:) :: values_int16_1d_resorted !< resorted output variable 1650 INTEGER(KIND=4), TARGET, ALLOCATABLE, DIMENSION(:) :: values_int32_1d_resorted !< resorted output variable 1651 INTEGER(iwp), TARGET, ALLOCATABLE, DIMENSION(:) :: values_intwp_1d_resorted !< resorted output variable 1652 INTEGER(KIND=1), TARGET, ALLOCATABLE, DIMENSION(:,:) :: values_int8_2d_resorted !< resorted output variable 1653 INTEGER(KIND=2), TARGET, ALLOCATABLE, DIMENSION(:,:) :: values_int16_2d_resorted !< resorted output variable 1654 INTEGER(KIND=4), TARGET, ALLOCATABLE, DIMENSION(:,:) :: values_int32_2d_resorted !< resorted output variable 1655 INTEGER(iwp), TARGET, ALLOCATABLE, DIMENSION(:,:) :: values_intwp_2d_resorted !< resorted output variable 1656 INTEGER(KIND=1), TARGET, ALLOCATABLE, DIMENSION(:,:,:) :: values_int8_3d_resorted !< resorted output variable 1657 INTEGER(KIND=2), TARGET, ALLOCATABLE, DIMENSION(:,:,:) :: values_int16_3d_resorted !< resorted output variable 1658 INTEGER(KIND=4), TARGET, ALLOCATABLE, DIMENSION(:,:,:) :: values_int32_3d_resorted !< resorted output variable 1659 INTEGER(iwp), TARGET, ALLOCATABLE, DIMENSION(:,:,:) :: values_intwp_3d_resorted !< resorted output variable 1660 1636 1661 REAL(KIND=4), POINTER, INTENT(IN), OPTIONAL :: values_real32_0d !< output variable 1637 1662 REAL(KIND=8), POINTER, INTENT(IN), OPTIONAL :: values_real64_0d !< output variable … … 1647 1672 REAL(wp), POINTER, INTENT(IN), OPTIONAL, DIMENSION(:,:,:) :: values_realwp_3d !< output variable 1648 1673 1649 REAL(KIND=4), TARGET, ALLOCATABLE, DIMENSION(:) :: values_real32_1d_resorted !< resorted output variable1650 REAL(KIND=8), TARGET, ALLOCATABLE, DIMENSION(:) :: values_real64_1d_resorted !< resorted output variable1651 REAL(wp), TARGET, ALLOCATABLE, DIMENSION(:) :: values_realwp_1d_resorted !< resorted output variable1652 REAL(KIND=4), TARGET, ALLOCATABLE, DIMENSION(:,:) :: values_real32_2d_resorted !< resorted output variable1653 REAL(KIND=8), TARGET, ALLOCATABLE, DIMENSION(:,:) :: values_real64_2d_resorted !< resorted output variable1654 REAL(wp), TARGET, ALLOCATABLE, DIMENSION(:,:) :: values_realwp_2d_resorted !< resorted output variable1655 REAL(KIND=4), TARGET, ALLOCATABLE, DIMENSION(:,:,:) :: values_real32_3d_resorted !< resorted output variable1656 REAL(KIND=8), TARGET, ALLOCATABLE, DIMENSION(:,:,:) :: values_real64_3d_resorted !< resorted output variable1657 REAL(wp), TARGET, ALLOCATABLE, DIMENSION(:,:,:) :: values_realwp_3d_resorted !< resorted output variable1658 1659 1674 REAL(KIND=4), POINTER :: values_real32_0d_pointer !< pointer to resortet array 1660 1675 REAL(KIND=8), POINTER :: values_real64_0d_pointer !< pointer to resortet array … … 1670 1685 REAL(wp), POINTER, CONTIGUOUS, DIMENSION(:,:,:) :: values_realwp_3d_pointer !< pointer to resortet array 1671 1686 1687 REAL(KIND=4), TARGET, ALLOCATABLE, DIMENSION(:) :: values_real32_1d_resorted !< resorted output variable 1688 REAL(KIND=8), TARGET, ALLOCATABLE, DIMENSION(:) :: values_real64_1d_resorted !< resorted output variable 1689 REAL(wp), TARGET, ALLOCATABLE, DIMENSION(:) :: values_realwp_1d_resorted !< resorted output variable 1690 REAL(KIND=4), TARGET, ALLOCATABLE, DIMENSION(:,:) :: values_real32_2d_resorted !< resorted output variable 1691 REAL(KIND=8), TARGET, ALLOCATABLE, DIMENSION(:,:) :: values_real64_2d_resorted !< resorted output variable 1692 REAL(wp), TARGET, ALLOCATABLE, DIMENSION(:,:) :: values_realwp_2d_resorted !< resorted output variable 1693 REAL(KIND=4), TARGET, ALLOCATABLE, DIMENSION(:,:,:) :: values_real32_3d_resorted !< resorted output variable 1694 REAL(KIND=8), TARGET, ALLOCATABLE, DIMENSION(:,:,:) :: values_real64_3d_resorted !< resorted output variable 1695 REAL(wp), TARGET, ALLOCATABLE, DIMENSION(:,:,:) :: values_realwp_3d_resorted !< resorted output variable 1696 1672 1697 TYPE(dimension_type), DIMENSION(:), ALLOCATABLE :: dimension_list !< list of used dimensions of variable 1673 1698 … … 1676 1701 output_return_value = 0 1677 1702 1678 CALL internal_message( 'debug', routine_name // ': write ' // TRIM( variable_name ) // &1703 CALL internal_message( 'debug', routine_name // ': write ' // TRIM( variable_name ) // & 1679 1704 ' into file ' // TRIM( file_name ) ) 1680 1705 ! 1681 1706 !-- Search for variable within file 1682 CALL find_var_in_file( file_name, variable_name, file_format, file_id, variable_id, &1707 CALL find_var_in_file( file_name, variable_name, file_format, file_id, variable_id, & 1683 1708 is_global, dimension_list, return_value=return_value ) 1684 1709 … … 1686 1711 ! 1687 1712 !-- Check if the correct amount of variable bounds were given 1688 IF ( SIZE( bounds_start ) /= SIZE( dimension_list ) .OR. &1689 SIZE( bounds_end ) /= SIZE( dimension_list ) ) THEN1713 IF ( SIZE( bounds_start ) /= SIZE( dimension_list ) .OR. & 1714 SIZE( bounds_end ) /= SIZE( dimension_list ) ) THEN 1690 1715 return_value = 1 1691 CALL internal_message( 'error', routine_name // &1692 ': number bounds do not match with ' // &1693 'number of dimensions of variable ' // &1694 '(variable "' // TRIM( variable_name ) // &1716 CALL internal_message( 'error', routine_name // & 1717 ': number bounds do not match with ' // & 1718 'number of dimensions of variable ' // & 1719 '(variable "' // TRIM( variable_name ) // & 1695 1720 '", file "' // TRIM( file_name ) // '")!' ) 1696 1721 ENDIF … … 1706 1731 1707 1732 WRITE( temp_string, * ) bounds_start 1708 CALL internal_message( 'debug', routine_name // &1709 ': file "' // TRIM( file_name ) // &1710 '", variable "' // TRIM( variable_name ) // &1733 CALL internal_message( 'debug', routine_name // & 1734 ': file "' // TRIM( file_name ) // & 1735 '", variable "' // TRIM( variable_name ) // & 1711 1736 '", bounds_start =' // TRIM( temp_string ) ) 1712 1737 WRITE( temp_string, * ) bounds_end 1713 CALL internal_message( 'debug', routine_name // &1714 ': file "' // TRIM( file_name ) // &1715 '", variable "' // TRIM( variable_name ) // &1738 CALL internal_message( 'debug', routine_name // & 1739 ': file "' // TRIM( file_name ) // & 1740 '", variable "' // TRIM( variable_name ) // & 1716 1741 '", bounds_end =' // TRIM( temp_string ) ) 1717 1742 ! 1718 1743 !-- Get bounds for masking 1719 CALL get_masked_indices_and_masked_dimension_bounds( dimension_list, & 1720 bounds_start, bounds_end, bounds_start_internal, value_counts, bounds_origin, & 1721 masked_indices ) 1744 CALL get_masked_indices_and_masked_dimension_bounds( dimension_list, bounds_start, & 1745 bounds_end, bounds_start_internal, value_counts, bounds_origin, masked_indices ) 1722 1746 1723 1747 do_output = .NOT. ANY( value_counts == 0 ) 1724 1748 1725 1749 WRITE( temp_string, * ) bounds_start_internal 1726 CALL internal_message( 'debug', routine_name // &1727 ': file "' // TRIM( file_name ) // &1728 '", variable "' // TRIM( variable_name ) // &1750 CALL internal_message( 'debug', routine_name // & 1751 ': file "' // TRIM( file_name ) // & 1752 '", variable "' // TRIM( variable_name ) // & 1729 1753 '", bounds_start_internal =' // TRIM( temp_string ) ) 1730 1754 WRITE( temp_string, * ) value_counts 1731 CALL internal_message( 'debug', routine_name // &1732 ': file "' // TRIM( file_name ) // &1733 '", variable "' // TRIM( variable_name ) // &1755 CALL internal_message( 'debug', routine_name // & 1756 ': file "' // TRIM( file_name ) // & 1757 '", variable "' // TRIM( variable_name ) // & 1734 1758 '", value_counts =' // TRIM( temp_string ) ) 1735 1759 ! … … 1754 1778 ELSEIF ( PRESENT( values_char_2d ) ) THEN 1755 1779 IF ( do_output ) THEN 1756 ALLOCATE( values_char_2d_resorted(0:value_counts(1)-1, & 1757 0:value_counts(2)-1) ) 1780 ALLOCATE( values_char_2d_resorted(0:value_counts(1)-1,0:value_counts(2)-1) ) 1758 1781 !$OMP PARALLEL PRIVATE (i,j) 1759 1782 !$OMP DO 1760 1783 DO i = 0, value_counts(1) - 1 1761 1784 DO j = 0, value_counts(2) - 1 1762 values_char_2d_resorted(i,j) = values_char_2d(masked_indices(2,j), &1763 masked_indices(1,i) 1785 values_char_2d_resorted(i,j) = values_char_2d(masked_indices(2,j), & 1786 masked_indices(1,i)) 1764 1787 ENDDO 1765 1788 ENDDO … … 1772 1795 ELSEIF ( PRESENT( values_char_3d ) ) THEN 1773 1796 IF ( do_output ) THEN 1774 ALLOCATE( values_char_3d_resorted(0:value_counts(1)-1, &1775 0:value_counts(2)-1, &1797 ALLOCATE( values_char_3d_resorted(0:value_counts(1)-1, & 1798 0:value_counts(2)-1, & 1776 1799 0:value_counts(3)-1) ) 1777 1800 !$OMP PARALLEL PRIVATE (i,j,k) … … 1780 1803 DO j = 0, value_counts(2) - 1 1781 1804 DO k = 0, value_counts(3) - 1 1782 values_char_3d_resorted(i,j,k) = values_char_3d(masked_indices(3,k), &1783 masked_indices(2,j), &1784 masked_indices(1,i) 1805 values_char_3d_resorted(i,j,k) = values_char_3d(masked_indices(3,k), & 1806 masked_indices(2,j), & 1807 masked_indices(1,i)) 1785 1808 ENDDO 1786 1809 ENDDO … … 1812 1835 ELSEIF ( PRESENT( values_int8_2d ) ) THEN 1813 1836 IF ( do_output ) THEN 1814 ALLOCATE( values_int8_2d_resorted(0:value_counts(1)-1, & 1815 0:value_counts(2)-1) ) 1837 ALLOCATE( values_int8_2d_resorted(0:value_counts(1)-1,0:value_counts(2)-1) ) 1816 1838 !$OMP PARALLEL PRIVATE (i,j) 1817 1839 !$OMP DO 1818 1840 DO i = 0, value_counts(1) - 1 1819 1841 DO j = 0, value_counts(2) - 1 1820 values_int8_2d_resorted(i,j) = values_int8_2d(masked_indices(2,j), &1821 masked_indices(1,i) 1842 values_int8_2d_resorted(i,j) = values_int8_2d(masked_indices(2,j), & 1843 masked_indices(1,i)) 1822 1844 ENDDO 1823 1845 ENDDO … … 1830 1852 ELSEIF ( PRESENT( values_int8_3d ) ) THEN 1831 1853 IF ( do_output ) THEN 1832 ALLOCATE( values_int8_3d_resorted(0:value_counts(1)-1, &1833 0:value_counts(2)-1, &1854 ALLOCATE( values_int8_3d_resorted(0:value_counts(1)-1, & 1855 0:value_counts(2)-1, & 1834 1856 0:value_counts(3)-1) ) 1835 1857 !$OMP PARALLEL PRIVATE (i,j,k) … … 1838 1860 DO j = 0, value_counts(2) - 1 1839 1861 DO k = 0, value_counts(3) - 1 1840 values_int8_3d_resorted(i,j,k) = values_int8_3d(masked_indices(3,k), &1841 masked_indices(2,j), &1862 values_int8_3d_resorted(i,j,k) = values_int8_3d(masked_indices(3,k), & 1863 masked_indices(2,j), & 1842 1864 masked_indices(1,i) ) 1843 1865 ENDDO … … 1870 1892 ELSEIF ( PRESENT( values_int16_2d ) ) THEN 1871 1893 IF ( do_output ) THEN 1872 ALLOCATE( values_int16_2d_resorted(0:value_counts(1)-1, & 1873 0:value_counts(2)-1) ) 1894 ALLOCATE( values_int16_2d_resorted(0:value_counts(1)-1,0:value_counts(2)-1) ) 1874 1895 !$OMP PARALLEL PRIVATE (i,j) 1875 1896 !$OMP DO 1876 1897 DO i = 0, value_counts(1) - 1 1877 1898 DO j = 0, value_counts(2) - 1 1878 values_int16_2d_resorted(i,j) = values_int16_2d(masked_indices(2,j), &1899 values_int16_2d_resorted(i,j) = values_int16_2d(masked_indices(2,j), & 1879 1900 masked_indices(1,i)) 1880 1901 ENDDO … … 1888 1909 ELSEIF ( PRESENT( values_int16_3d ) ) THEN 1889 1910 IF ( do_output ) THEN 1890 ALLOCATE( values_int16_3d_resorted(0:value_counts(1)-1, &1891 0:value_counts(2)-1, &1911 ALLOCATE( values_int16_3d_resorted(0:value_counts(1)-1, & 1912 0:value_counts(2)-1, & 1892 1913 0:value_counts(3)-1) ) 1893 1914 !$OMP PARALLEL PRIVATE (i,j,k) … … 1896 1917 DO j = 0, value_counts(2) - 1 1897 1918 DO k = 0, value_counts(3) - 1 1898 values_int16_3d_resorted(i,j,k) = values_int16_3d(masked_indices(3,k), &1899 masked_indices(2,j), &1900 masked_indices(1,i) 1919 values_int16_3d_resorted(i,j,k) = values_int16_3d(masked_indices(3,k), & 1920 masked_indices(2,j), & 1921 masked_indices(1,i)) 1901 1922 ENDDO 1902 1923 ENDDO … … 1928 1949 ELSEIF ( PRESENT( values_int32_2d ) ) THEN 1929 1950 IF ( do_output ) THEN 1930 ALLOCATE( values_int32_2d_resorted(0:value_counts(1)-1, & 1931 0:value_counts(2)-1) ) 1951 ALLOCATE( values_int32_2d_resorted(0:value_counts(1)-1,0:value_counts(2)-1) ) 1932 1952 !$OMP PARALLEL PRIVATE (i,j) 1933 1953 !$OMP DO 1934 1954 DO i = 0, value_counts(1) - 1 1935 1955 DO j = 0, value_counts(2) - 1 1936 values_int32_2d_resorted(i,j) = values_int32_2d(masked_indices(2,j), &1937 masked_indices(1,i) 1956 values_int32_2d_resorted(i,j) = values_int32_2d(masked_indices(2,j), & 1957 masked_indices(1,i)) 1938 1958 ENDDO 1939 1959 ENDDO … … 1946 1966 ELSEIF ( PRESENT( values_int32_3d ) ) THEN 1947 1967 IF ( do_output ) THEN 1948 ALLOCATE( values_int32_3d_resorted(0:value_counts(1)-1, &1949 0:value_counts(2)-1, &1968 ALLOCATE( values_int32_3d_resorted(0:value_counts(1)-1, & 1969 0:value_counts(2)-1, & 1950 1970 0:value_counts(3)-1) ) 1951 1971 !$OMP PARALLEL PRIVATE (i,j,k) … … 1954 1974 DO j = 0, value_counts(2) - 1 1955 1975 DO k = 0, value_counts(3) - 1 1956 values_int32_3d_resorted(i,j,k) = values_int32_3d(masked_indices(3,k), &1957 masked_indices(2,j), &1958 masked_indices(1,i) 1976 values_int32_3d_resorted(i,j,k) = values_int32_3d(masked_indices(3,k), & 1977 masked_indices(2,j), & 1978 masked_indices(1,i)) 1959 1979 ENDDO 1960 1980 ENDDO … … 1967 1987 values_int32_3d_pointer => values_int32_3d_resorted 1968 1988 ! 1969 !-- working-precision integer output1989 !-- Working-precision integer output 1970 1990 ELSEIF ( PRESENT( values_intwp_0d ) ) THEN 1971 1991 values_intwp_0d_pointer => values_intwp_0d … … 1986 2006 ELSEIF ( PRESENT( values_intwp_2d ) ) THEN 1987 2007 IF ( do_output ) THEN 1988 ALLOCATE( values_intwp_2d_resorted(0:value_counts(1)-1, & 1989 0:value_counts(2)-1) ) 2008 ALLOCATE( values_intwp_2d_resorted(0:value_counts(1)-1,0:value_counts(2)-1) ) 1990 2009 !$OMP PARALLEL PRIVATE (i,j) 1991 2010 !$OMP DO 1992 2011 DO i = 0, value_counts(1) - 1 1993 2012 DO j = 0, value_counts(2) - 1 1994 values_intwp_2d_resorted(i,j) = values_intwp_2d(masked_indices(2,j), &1995 masked_indices(1,i) 2013 values_intwp_2d_resorted(i,j) = values_intwp_2d(masked_indices(2,j), & 2014 masked_indices(1,i)) 1996 2015 ENDDO 1997 2016 ENDDO … … 2004 2023 ELSEIF ( PRESENT( values_intwp_3d ) ) THEN 2005 2024 IF ( do_output ) THEN 2006 ALLOCATE( values_intwp_3d_resorted(0:value_counts(1)-1, &2007 0:value_counts(2)-1, &2025 ALLOCATE( values_intwp_3d_resorted(0:value_counts(1)-1, & 2026 0:value_counts(2)-1, & 2008 2027 0:value_counts(3)-1) ) 2009 2028 !$OMP PARALLEL PRIVATE (i,j,k) … … 2012 2031 DO j = 0, value_counts(2) - 1 2013 2032 DO k = 0, value_counts(3) - 1 2014 values_intwp_3d_resorted(i,j,k) = values_intwp_3d(masked_indices(3,k), &2015 masked_indices(2,j), &2016 masked_indices(1,i) 2033 values_intwp_3d_resorted(i,j,k) = values_intwp_3d(masked_indices(3,k), & 2034 masked_indices(2,j), & 2035 masked_indices(1,i)) 2017 2036 ENDDO 2018 2037 ENDDO … … 2044 2063 ELSEIF ( PRESENT( values_real32_2d ) ) THEN 2045 2064 IF ( do_output ) THEN 2046 ALLOCATE( values_real32_2d_resorted(0:value_counts(1)-1, & 2047 0:value_counts(2)-1) ) 2065 ALLOCATE( values_real32_2d_resorted(0:value_counts(1)-1,0:value_counts(2)-1) ) 2048 2066 !$OMP PARALLEL PRIVATE (i,j) 2049 2067 !$OMP DO 2050 2068 DO i = 0, value_counts(1) - 1 2051 2069 DO j = 0, value_counts(2) - 1 2052 values_real32_2d_resorted(i,j) = values_real32_2d(masked_indices(2,j), &2053 masked_indices(1,i) 2070 values_real32_2d_resorted(i,j) = values_real32_2d(masked_indices(2,j), & 2071 masked_indices(1,i)) 2054 2072 ENDDO 2055 2073 ENDDO … … 2062 2080 ELSEIF ( PRESENT( values_real32_3d ) ) THEN 2063 2081 IF ( do_output ) THEN 2064 ALLOCATE( values_real32_3d_resorted(0:value_counts(1)-1, &2065 0:value_counts(2)-1, &2082 ALLOCATE( values_real32_3d_resorted(0:value_counts(1)-1, & 2083 0:value_counts(2)-1, & 2066 2084 0:value_counts(3)-1) ) 2067 2085 !$OMP PARALLEL PRIVATE (i,j,k) … … 2070 2088 DO j = 0, value_counts(2) - 1 2071 2089 DO k = 0, value_counts(3) - 1 2072 values_real32_3d_resorted(i,j,k) = values_real32_3d(masked_indices(3,k), &2073 masked_indices(2,j), &2074 masked_indices(1,i) 2090 values_real32_3d_resorted(i,j,k) = values_real32_3d(masked_indices(3,k), & 2091 masked_indices(2,j), & 2092 masked_indices(1,i)) 2075 2093 ENDDO 2076 2094 ENDDO … … 2102 2120 ELSEIF ( PRESENT( values_real64_2d ) ) THEN 2103 2121 IF ( do_output ) THEN 2104 ALLOCATE( values_real64_2d_resorted(0:value_counts(1)-1, & 2105 0:value_counts(2)-1) ) 2122 ALLOCATE( values_real64_2d_resorted(0:value_counts(1)-1,0:value_counts(2)-1) ) 2106 2123 !$OMP PARALLEL PRIVATE (i,j) 2107 2124 !$OMP DO 2108 2125 DO i = 0, value_counts(1) - 1 2109 2126 DO j = 0, value_counts(2) - 1 2110 values_real64_2d_resorted(i,j) = values_real64_2d(masked_indices(2,j), &2111 masked_indices(1,i) 2127 values_real64_2d_resorted(i,j) = values_real64_2d(masked_indices(2,j), & 2128 masked_indices(1,i)) 2112 2129 ENDDO 2113 2130 ENDDO … … 2120 2137 ELSEIF ( PRESENT( values_real64_3d ) ) THEN 2121 2138 IF ( do_output ) THEN 2122 ALLOCATE( values_real64_3d_resorted(0:value_counts(1)-1, &2123 0:value_counts(2)-1, &2139 ALLOCATE( values_real64_3d_resorted(0:value_counts(1)-1, & 2140 0:value_counts(2)-1, & 2124 2141 0:value_counts(3)-1) ) 2125 2142 !$OMP PARALLEL PRIVATE (i,j,k) … … 2128 2145 DO j = 0, value_counts(2) - 1 2129 2146 DO k = 0, value_counts(3) - 1 2130 values_real64_3d_resorted(i,j,k) = values_real64_3d(masked_indices(3,k), &2131 masked_indices(2,j), &2132 masked_indices(1,i) 2147 values_real64_3d_resorted(i,j,k) = values_real64_3d(masked_indices(3,k), & 2148 masked_indices(2,j), & 2149 masked_indices(1,i)) 2133 2150 ENDDO 2134 2151 ENDDO … … 2141 2158 values_real64_3d_pointer => values_real64_3d_resorted 2142 2159 ! 2143 !-- working-precision real output2160 !-- Working-precision real output 2144 2161 ELSEIF ( PRESENT( values_realwp_0d ) ) THEN 2145 2162 values_realwp_0d_pointer => values_realwp_0d … … 2160 2177 ELSEIF ( PRESENT( values_realwp_2d ) ) THEN 2161 2178 IF ( do_output ) THEN 2162 ALLOCATE( values_realwp_2d_resorted(0:value_counts(1)-1, & 2163 0:value_counts(2)-1) ) 2179 ALLOCATE( values_realwp_2d_resorted(0:value_counts(1)-1,0:value_counts(2)-1) ) 2164 2180 !$OMP PARALLEL PRIVATE (i,j) 2165 2181 !$OMP DO 2166 2182 DO i = 0, value_counts(1) - 1 2167 2183 DO j = 0, value_counts(2) - 1 2168 values_realwp_2d_resorted(i,j) = values_realwp_2d(masked_indices(2,j), &2169 masked_indices(1,i) 2184 values_realwp_2d_resorted(i,j) = values_realwp_2d(masked_indices(2,j), & 2185 masked_indices(1,i)) 2170 2186 ENDDO 2171 2187 ENDDO … … 2178 2194 ELSEIF ( PRESENT( values_realwp_3d ) ) THEN 2179 2195 IF ( do_output ) THEN 2180 ALLOCATE( values_realwp_3d_resorted(0:value_counts(1)-1, &2181 0:value_counts(2)-1, &2196 ALLOCATE( values_realwp_3d_resorted(0:value_counts(1)-1, & 2197 0:value_counts(2)-1, & 2182 2198 0:value_counts(3)-1) ) 2183 2199 !$OMP PARALLEL PRIVATE (i,j,k) … … 2186 2202 DO j = 0, value_counts(2) - 1 2187 2203 DO k = 0, value_counts(3) - 1 2188 values_realwp_3d_resorted(i,j,k) = values_realwp_3d(masked_indices(3,k), &2189 masked_indices(2,j), &2190 masked_indices(1,i) 2204 values_realwp_3d_resorted(i,j,k) = values_realwp_3d(masked_indices(3,k), & 2205 masked_indices(2,j), & 2206 masked_indices(1,i)) 2191 2207 ENDDO 2192 2208 ENDDO … … 2201 2217 ELSE 2202 2218 return_value = 1 2203 CALL internal_message( 'error', routine_name // &2204 ': no output values given ' // &2205 '(variable "' // TRIM( variable_name ) // &2219 CALL internal_message( 'error', routine_name // & 2220 ': no output values given ' // & 2221 '(variable "' // TRIM( variable_name ) // & 2206 2222 '", file "' // TRIM( file_name ) // '")!' ) 2207 2223 ENDIF … … 2218 2234 CASE ( 'binary' ) 2219 2235 ! 2220 !-- character output2236 !-- Character output 2221 2237 IF ( PRESENT( values_char_0d ) ) THEN 2222 CALL binary_write_variable( file_id, variable_id, &2223 bounds_start_internal, value_counts, bounds_origin, is_global, &2238 CALL binary_write_variable( file_id, variable_id, & 2239 bounds_start_internal, value_counts, bounds_origin, is_global, & 2224 2240 values_char_0d=values_char_0d_pointer, return_value=output_return_value ) 2225 2241 ELSEIF ( PRESENT( values_char_1d ) ) THEN 2226 CALL binary_write_variable( file_id, variable_id, &2227 bounds_start_internal, value_counts, bounds_origin, is_global, &2242 CALL binary_write_variable( file_id, variable_id, & 2243 bounds_start_internal, value_counts, bounds_origin, is_global, & 2228 2244 values_char_1d=values_char_1d_pointer, return_value=output_return_value ) 2229 2245 ELSEIF ( PRESENT( values_char_2d ) ) THEN 2230 CALL binary_write_variable( file_id, variable_id, &2231 bounds_start_internal, value_counts, bounds_origin, is_global, &2246 CALL binary_write_variable( file_id, variable_id, & 2247 bounds_start_internal, value_counts, bounds_origin, is_global, & 2232 2248 values_char_2d=values_char_2d_pointer, return_value=output_return_value ) 2233 2249 ELSEIF ( PRESENT( values_char_3d ) ) THEN 2234 CALL binary_write_variable( file_id, variable_id, &2235 bounds_start_internal, value_counts, bounds_origin, is_global, &2250 CALL binary_write_variable( file_id, variable_id, & 2251 bounds_start_internal, value_counts, bounds_origin, is_global, & 2236 2252 values_char_3d=values_char_3d_pointer, return_value=output_return_value ) 2237 2253 ! 2238 2254 !-- 8bit integer output 2239 2255 ELSEIF ( PRESENT( values_int8_0d ) ) THEN 2240 CALL binary_write_variable( file_id, variable_id, &2241 bounds_start_internal, value_counts, bounds_origin, is_global, &2256 CALL binary_write_variable( file_id, variable_id, & 2257 bounds_start_internal, value_counts, bounds_origin, is_global, & 2242 2258 values_int8_0d=values_int8_0d_pointer, return_value=output_return_value ) 2243 2259 ELSEIF ( PRESENT( values_int8_1d ) ) THEN 2244 CALL binary_write_variable( file_id, variable_id, &2245 bounds_start_internal, value_counts, bounds_origin, is_global, &2260 CALL binary_write_variable( file_id, variable_id, & 2261 bounds_start_internal, value_counts, bounds_origin, is_global, & 2246 2262 values_int8_1d=values_int8_1d_pointer, return_value=output_return_value ) 2247 2263 ELSEIF ( PRESENT( values_int8_2d ) ) THEN 2248 CALL binary_write_variable( file_id, variable_id, &2249 bounds_start_internal, value_counts, bounds_origin, is_global, &2264 CALL binary_write_variable( file_id, variable_id, & 2265 bounds_start_internal, value_counts, bounds_origin, is_global, & 2250 2266 values_int8_2d=values_int8_2d_pointer, return_value=output_return_value ) 2251 2267 ELSEIF ( PRESENT( values_int8_3d ) ) THEN 2252 CALL binary_write_variable( file_id, variable_id, &2253 bounds_start_internal, value_counts, bounds_origin, is_global, &2268 CALL binary_write_variable( file_id, variable_id, & 2269 bounds_start_internal, value_counts, bounds_origin, is_global, & 2254 2270 values_int8_3d=values_int8_3d_pointer, return_value=output_return_value ) 2255 2271 ! 2256 2272 !-- 16bit integer output 2257 2273 ELSEIF ( PRESENT( values_int16_0d ) ) THEN 2258 CALL binary_write_variable( file_id, variable_id, &2259 bounds_start_internal, value_counts, bounds_origin, is_global, &2274 CALL binary_write_variable( file_id, variable_id, & 2275 bounds_start_internal, value_counts, bounds_origin, is_global, & 2260 2276 values_int16_0d=values_int16_0d_pointer, return_value=output_return_value ) 2261 2277 ELSEIF ( PRESENT( values_int16_1d ) ) THEN 2262 CALL binary_write_variable( file_id, variable_id, &2263 bounds_start_internal, value_counts, bounds_origin, is_global, &2278 CALL binary_write_variable( file_id, variable_id, & 2279 bounds_start_internal, value_counts, bounds_origin, is_global, & 2264 2280 values_int16_1d=values_int16_1d_pointer, return_value=output_return_value ) 2265 2281 ELSEIF ( PRESENT( values_int16_2d ) ) THEN 2266 CALL binary_write_variable( file_id, variable_id, &2267 bounds_start_internal, value_counts, bounds_origin, is_global, &2282 CALL binary_write_variable( file_id, variable_id, & 2283 bounds_start_internal, value_counts, bounds_origin, is_global, & 2268 2284 values_int16_2d=values_int16_2d_pointer, return_value=output_return_value ) 2269 2285 ELSEIF ( PRESENT( values_int16_3d ) ) THEN 2270 CALL binary_write_variable( file_id, variable_id, &2271 bounds_start_internal, value_counts, bounds_origin, is_global, &2286 CALL binary_write_variable( file_id, variable_id, & 2287 bounds_start_internal, value_counts, bounds_origin, is_global, & 2272 2288 values_int16_3d=values_int16_3d_pointer, return_value=output_return_value ) 2273 2289 ! 2274 2290 !-- 32bit integer output 2275 2291 ELSEIF ( PRESENT( values_int32_0d ) ) THEN 2276 CALL binary_write_variable( file_id, variable_id, &2277 bounds_start_internal, value_counts, bounds_origin, is_global, &2292 CALL binary_write_variable( file_id, variable_id, & 2293 bounds_start_internal, value_counts, bounds_origin, is_global, & 2278 2294 values_int32_0d=values_int32_0d_pointer, return_value=output_return_value ) 2279 2295 ELSEIF ( PRESENT( values_int32_1d ) ) THEN 2280 CALL binary_write_variable( file_id, variable_id, &2281 bounds_start_internal, value_counts, bounds_origin, is_global, &2296 CALL binary_write_variable( file_id, variable_id, & 2297 bounds_start_internal, value_counts, bounds_origin, is_global, & 2282 2298 values_int32_1d=values_int32_1d_pointer, return_value=output_return_value ) 2283 2299 ELSEIF ( PRESENT( values_int32_2d ) ) THEN 2284 CALL binary_write_variable( file_id, variable_id, &2285 bounds_start_internal, value_counts, bounds_origin, is_global, &2300 CALL binary_write_variable( file_id, variable_id, & 2301 bounds_start_internal, value_counts, bounds_origin, is_global, & 2286 2302 values_int32_2d=values_int32_2d_pointer, return_value=output_return_value ) 2287 2303 ELSEIF ( PRESENT( values_int32_3d ) ) THEN 2288 CALL binary_write_variable( file_id, variable_id, &2289 bounds_start_internal, value_counts, bounds_origin, is_global, &2304 CALL binary_write_variable( file_id, variable_id, & 2305 bounds_start_internal, value_counts, bounds_origin, is_global, & 2290 2306 values_int32_3d=values_int32_3d_pointer, return_value=output_return_value ) 2291 2307 ! 2292 !-- working-precision integer output2308 !-- Working-precision integer output 2293 2309 ELSEIF ( PRESENT( values_intwp_0d ) ) THEN 2294 CALL binary_write_variable( file_id, variable_id, &2295 bounds_start_internal, value_counts, bounds_origin, is_global, &2310 CALL binary_write_variable( file_id, variable_id, & 2311 bounds_start_internal, value_counts, bounds_origin, is_global, & 2296 2312 values_intwp_0d=values_intwp_0d_pointer, return_value=output_return_value ) 2297 2313 ELSEIF ( PRESENT( values_intwp_1d ) ) THEN 2298 CALL binary_write_variable( file_id, variable_id, &2299 bounds_start_internal, value_counts, bounds_origin, is_global, &2314 CALL binary_write_variable( file_id, variable_id, & 2315 bounds_start_internal, value_counts, bounds_origin, is_global, & 2300 2316 values_intwp_1d=values_intwp_1d_pointer, return_value=output_return_value ) 2301 2317 ELSEIF ( PRESENT( values_intwp_2d ) ) THEN 2302 CALL binary_write_variable( file_id, variable_id, &2303 bounds_start_internal, value_counts, bounds_origin, is_global, &2318 CALL binary_write_variable( file_id, variable_id, & 2319 bounds_start_internal, value_counts, bounds_origin, is_global, & 2304 2320 values_intwp_2d=values_intwp_2d_pointer, return_value=output_return_value ) 2305 2321 ELSEIF ( PRESENT( values_intwp_3d ) ) THEN 2306 CALL binary_write_variable( file_id, variable_id, &2307 bounds_start_internal, value_counts, bounds_origin, is_global, &2322 CALL binary_write_variable( file_id, variable_id, & 2323 bounds_start_internal, value_counts, bounds_origin, is_global, & 2308 2324 values_intwp_3d=values_intwp_3d_pointer, return_value=output_return_value ) 2309 2325 ! 2310 2326 !-- 32bit real output 2311 2327 ELSEIF ( PRESENT( values_real32_0d ) ) THEN 2312 CALL binary_write_variable( file_id, variable_id, &2313 bounds_start_internal, value_counts, bounds_origin, is_global, &2328 CALL binary_write_variable( file_id, variable_id, & 2329 bounds_start_internal, value_counts, bounds_origin, is_global, & 2314 2330 values_real32_0d=values_real32_0d_pointer, return_value=output_return_value ) 2315 2331 ELSEIF ( PRESENT( values_real32_1d ) ) THEN 2316 CALL binary_write_variable( file_id, variable_id, &2317 bounds_start_internal, value_counts, bounds_origin, is_global, &2332 CALL binary_write_variable( file_id, variable_id, & 2333 bounds_start_internal, value_counts, bounds_origin, is_global, & 2318 2334 values_real32_1d=values_real32_1d_pointer, return_value=output_return_value ) 2319 2335 ELSEIF ( PRESENT( values_real32_2d ) ) THEN 2320 CALL binary_write_variable( file_id, variable_id, &2321 bounds_start_internal, value_counts, bounds_origin, is_global, &2336 CALL binary_write_variable( file_id, variable_id, & 2337 bounds_start_internal, value_counts, bounds_origin, is_global, & 2322 2338 values_real32_2d=values_real32_2d_pointer, return_value=output_return_value ) 2323 2339 ELSEIF ( PRESENT( values_real32_3d ) ) THEN 2324 CALL binary_write_variable( file_id, variable_id, &2325 bounds_start_internal, value_counts, bounds_origin, is_global, &2340 CALL binary_write_variable( file_id, variable_id, & 2341 bounds_start_internal, value_counts, bounds_origin, is_global, & 2326 2342 values_real32_3d=values_real32_3d_pointer, return_value=output_return_value ) 2327 2343 ! 2328 2344 !-- 64bit real output 2329 2345 ELSEIF ( PRESENT( values_real64_0d ) ) THEN 2330 CALL binary_write_variable( file_id, variable_id, &2331 bounds_start_internal, value_counts, bounds_origin, is_global, &2346 CALL binary_write_variable( file_id, variable_id, & 2347 bounds_start_internal, value_counts, bounds_origin, is_global, & 2332 2348 values_real64_0d=values_real64_0d_pointer, return_value=output_return_value ) 2333 2349 ELSEIF ( PRESENT( values_real64_1d ) ) THEN 2334 CALL binary_write_variable( file_id, variable_id, &2335 bounds_start_internal, value_counts, bounds_origin, is_global, &2350 CALL binary_write_variable( file_id, variable_id, & 2351 bounds_start_internal, value_counts, bounds_origin, is_global, & 2336 2352 values_real64_1d=values_real64_1d_pointer, return_value=output_return_value ) 2337 2353 ELSEIF ( PRESENT( values_real64_2d ) ) THEN 2338 CALL binary_write_variable( file_id, variable_id, &2339 bounds_start_internal, value_counts, bounds_origin, is_global, &2354 CALL binary_write_variable( file_id, variable_id, & 2355 bounds_start_internal, value_counts, bounds_origin, is_global, & 2340 2356 values_real64_2d=values_real64_2d_pointer, return_value=output_return_value ) 2341 2357 ELSEIF ( PRESENT( values_real64_3d ) ) THEN 2342 CALL binary_write_variable( file_id, variable_id, &2343 bounds_start_internal, value_counts, bounds_origin, is_global, &2358 CALL binary_write_variable( file_id, variable_id, & 2359 bounds_start_internal, value_counts, bounds_origin, is_global, & 2344 2360 values_real64_3d=values_real64_3d_pointer, return_value=output_return_value ) 2345 2361 ! 2346 2362 !-- working-precision real output 2347 2363 ELSEIF ( PRESENT( values_realwp_0d ) ) THEN 2348 CALL binary_write_variable( file_id, variable_id, &2349 bounds_start_internal, value_counts, bounds_origin, is_global, &2364 CALL binary_write_variable( file_id, variable_id, & 2365 bounds_start_internal, value_counts, bounds_origin, is_global, & 2350 2366 values_realwp_0d=values_realwp_0d_pointer, return_value=output_return_value ) 2351 2367 ELSEIF ( PRESENT( values_realwp_1d ) ) THEN 2352 CALL binary_write_variable( file_id, variable_id, &2353 bounds_start_internal, value_counts, bounds_origin, is_global, &2368 CALL binary_write_variable( file_id, variable_id, & 2369 bounds_start_internal, value_counts, bounds_origin, is_global, & 2354 2370 values_realwp_1d=values_realwp_1d_pointer, return_value=output_return_value ) 2355 2371 ELSEIF ( PRESENT( values_realwp_2d ) ) THEN 2356 CALL binary_write_variable( file_id, variable_id, &2357 bounds_start_internal, value_counts, bounds_origin, is_global, &2372 CALL binary_write_variable( file_id, variable_id, & 2373 bounds_start_internal, value_counts, bounds_origin, is_global, & 2358 2374 values_realwp_2d=values_realwp_2d_pointer, return_value=output_return_value ) 2359 2375 ELSEIF ( PRESENT( values_realwp_3d ) ) THEN 2360 CALL binary_write_variable( file_id, variable_id, &2361 bounds_start_internal, value_counts, bounds_origin, is_global, &2376 CALL binary_write_variable( file_id, variable_id, & 2377 bounds_start_internal, value_counts, bounds_origin, is_global, & 2362 2378 values_realwp_3d=values_realwp_3d_pointer, return_value=output_return_value ) 2363 2379 ELSE 2364 2380 return_value = 1 2365 CALL internal_message( 'error', routine_name // &2366 ': output_type not supported by file format "' // &2367 TRIM( file_format ) // '" ' // &2368 '(variable "' // TRIM( variable_name ) // &2381 CALL internal_message( 'error', routine_name // & 2382 ': output_type not supported by file format "' // & 2383 TRIM( file_format ) // '" ' // & 2384 '(variable "' // TRIM( variable_name ) // & 2369 2385 '", file "' // TRIM( file_name ) // '")!' ) 2370 2386 ENDIF … … 2372 2388 CASE ( 'netcdf4-parallel', 'netcdf4-serial' ) 2373 2389 ! 2374 !-- character output2390 !-- Character output 2375 2391 IF ( PRESENT( values_char_0d ) ) THEN 2376 CALL netcdf4_write_variable( file_id, variable_id, &2377 bounds_start_internal, value_counts, bounds_origin, is_global, &2392 CALL netcdf4_write_variable( file_id, variable_id, & 2393 bounds_start_internal, value_counts, bounds_origin, is_global, & 2378 2394 values_char_0d=values_char_0d_pointer, return_value=output_return_value ) 2379 2395 ELSEIF ( PRESENT( values_char_1d ) ) THEN 2380 CALL netcdf4_write_variable( file_id, variable_id, &2381 bounds_start_internal, value_counts, bounds_origin, is_global, &2396 CALL netcdf4_write_variable( file_id, variable_id, & 2397 bounds_start_internal, value_counts, bounds_origin, is_global, & 2382 2398 values_char_1d=values_char_1d_pointer, return_value=output_return_value ) 2383 2399 ELSEIF ( PRESENT( values_char_2d ) ) THEN 2384 CALL netcdf4_write_variable( file_id, variable_id, &2385 bounds_start_internal, value_counts, bounds_origin, is_global, &2400 CALL netcdf4_write_variable( file_id, variable_id, & 2401 bounds_start_internal, value_counts, bounds_origin, is_global, & 2386 2402 values_char_2d=values_char_2d_pointer, return_value=output_return_value ) 2387 2403 ELSEIF ( PRESENT( values_char_3d ) ) THEN 2388 CALL netcdf4_write_variable( file_id, variable_id, &2389 bounds_start_internal, value_counts, bounds_origin, is_global, &2404 CALL netcdf4_write_variable( file_id, variable_id, & 2405 bounds_start_internal, value_counts, bounds_origin, is_global, & 2390 2406 values_char_3d=values_char_3d_pointer, return_value=output_return_value ) 2391 2407 ! 2392 2408 !-- 8bit integer output 2393 2409 ELSEIF ( PRESENT( values_int8_0d ) ) THEN 2394 CALL netcdf4_write_variable( file_id, variable_id, &2395 bounds_start_internal, value_counts, bounds_origin, is_global, &2410 CALL netcdf4_write_variable( file_id, variable_id, & 2411 bounds_start_internal, value_counts, bounds_origin, is_global, & 2396 2412 values_int8_0d=values_int8_0d_pointer, return_value=output_return_value ) 2397 2413 ELSEIF ( PRESENT( values_int8_1d ) ) THEN 2398 CALL netcdf4_write_variable( file_id, variable_id, &2399 bounds_start_internal, value_counts, bounds_origin, is_global, &2414 CALL netcdf4_write_variable( file_id, variable_id, & 2415 bounds_start_internal, value_counts, bounds_origin, is_global, & 2400 2416 values_int8_1d=values_int8_1d_pointer, return_value=output_return_value ) 2401 2417 ELSEIF ( PRESENT( values_int8_2d ) ) THEN 2402 CALL netcdf4_write_variable( file_id, variable_id, &2403 bounds_start_internal, value_counts, bounds_origin, is_global, &2418 CALL netcdf4_write_variable( file_id, variable_id, & 2419 bounds_start_internal, value_counts, bounds_origin, is_global, & 2404 2420 values_int8_2d=values_int8_2d_pointer, return_value=output_return_value ) 2405 2421 ELSEIF ( PRESENT( values_int8_3d ) ) THEN 2406 CALL netcdf4_write_variable( file_id, variable_id, &2407 bounds_start_internal, value_counts, bounds_origin, is_global, &2422 CALL netcdf4_write_variable( file_id, variable_id, & 2423 bounds_start_internal, value_counts, bounds_origin, is_global, & 2408 2424 values_int8_3d=values_int8_3d_pointer, return_value=output_return_value ) 2409 2425 ! 2410 2426 !-- 16bit integer output 2411 2427 ELSEIF ( PRESENT( values_int16_0d ) ) THEN 2412 CALL netcdf4_write_variable( file_id, variable_id, &2413 bounds_start_internal, value_counts, bounds_origin, is_global, &2428 CALL netcdf4_write_variable( file_id, variable_id, & 2429 bounds_start_internal, value_counts, bounds_origin, is_global, & 2414 2430 values_int16_0d=values_int16_0d_pointer, return_value=output_return_value ) 2415 2431 ELSEIF ( PRESENT( values_int16_1d ) ) THEN 2416 CALL netcdf4_write_variable( file_id, variable_id, &2417 bounds_start_internal, value_counts, bounds_origin, is_global, &2432 CALL netcdf4_write_variable( file_id, variable_id, & 2433 bounds_start_internal, value_counts, bounds_origin, is_global, & 2418 2434 values_int16_1d=values_int16_1d_pointer, return_value=output_return_value ) 2419 2435 ELSEIF ( PRESENT( values_int16_2d ) ) THEN 2420 CALL netcdf4_write_variable( file_id, variable_id, &2421 bounds_start_internal, value_counts, bounds_origin, is_global, &2436 CALL netcdf4_write_variable( file_id, variable_id, & 2437 bounds_start_internal, value_counts, bounds_origin, is_global, & 2422 2438 values_int16_2d=values_int16_2d_pointer, return_value=output_return_value ) 2423 2439 ELSEIF ( PRESENT( values_int16_3d ) ) THEN 2424 CALL netcdf4_write_variable( file_id, variable_id, &2425 bounds_start_internal, value_counts, bounds_origin, is_global, &2440 CALL netcdf4_write_variable( file_id, variable_id, & 2441 bounds_start_internal, value_counts, bounds_origin, is_global, & 2426 2442 values_int16_3d=values_int16_3d_pointer, return_value=output_return_value ) 2427 2443 ! 2428 2444 !-- 32bit integer output 2429 2445 ELSEIF ( PRESENT( values_int32_0d ) ) THEN 2430 CALL netcdf4_write_variable( file_id, variable_id, &2431 bounds_start_internal, value_counts, bounds_origin, is_global, &2446 CALL netcdf4_write_variable( file_id, variable_id, & 2447 bounds_start_internal, value_counts, bounds_origin, is_global, & 2432 2448 values_int32_0d=values_int32_0d_pointer, return_value=output_return_value ) 2433 2449 ELSEIF ( PRESENT( values_int32_1d ) ) THEN 2434 CALL netcdf4_write_variable( file_id, variable_id, &2435 bounds_start_internal, value_counts, bounds_origin, is_global, &2450 CALL netcdf4_write_variable( file_id, variable_id, & 2451 bounds_start_internal, value_counts, bounds_origin, is_global, & 2436 2452 values_int32_1d=values_int32_1d_pointer, return_value=output_return_value ) 2437 2453 ELSEIF ( PRESENT( values_int32_2d ) ) THEN 2438 CALL netcdf4_write_variable( file_id, variable_id, &2439 bounds_start_internal, value_counts, bounds_origin, is_global, &2454 CALL netcdf4_write_variable( file_id, variable_id, & 2455 bounds_start_internal, value_counts, bounds_origin, is_global, & 2440 2456 values_int32_2d=values_int32_2d_pointer, return_value=output_return_value ) 2441 2457 ELSEIF ( PRESENT( values_int32_3d ) ) THEN 2442 CALL netcdf4_write_variable( file_id, variable_id, &2443 bounds_start_internal, value_counts, bounds_origin, is_global, &2458 CALL netcdf4_write_variable( file_id, variable_id, & 2459 bounds_start_internal, value_counts, bounds_origin, is_global, & 2444 2460 values_int32_3d=values_int32_3d_pointer, return_value=output_return_value ) 2445 2461 ! 2446 !-- working-precision integer output2462 !-- Working-precision integer output 2447 2463 ELSEIF ( PRESENT( values_intwp_0d ) ) THEN 2448 CALL netcdf4_write_variable( file_id, variable_id, &2449 bounds_start_internal, value_counts, bounds_origin, is_global, &2464 CALL netcdf4_write_variable( file_id, variable_id, & 2465 bounds_start_internal, value_counts, bounds_origin, is_global, & 2450 2466 values_intwp_0d=values_intwp_0d_pointer, return_value=output_return_value ) 2451 2467 ELSEIF ( PRESENT( values_intwp_1d ) ) THEN 2452 CALL netcdf4_write_variable( file_id, variable_id, &2453 bounds_start_internal, value_counts, bounds_origin, is_global, &2468 CALL netcdf4_write_variable( file_id, variable_id, & 2469 bounds_start_internal, value_counts, bounds_origin, is_global, & 2454 2470 values_intwp_1d=values_intwp_1d_pointer, return_value=output_return_value ) 2455 2471 ELSEIF ( PRESENT( values_intwp_2d ) ) THEN 2456 CALL netcdf4_write_variable( file_id, variable_id, &2457 bounds_start_internal, value_counts, bounds_origin, is_global, &2472 CALL netcdf4_write_variable( file_id, variable_id, & 2473 bounds_start_internal, value_counts, bounds_origin, is_global, & 2458 2474 values_intwp_2d=values_intwp_2d_pointer, return_value=output_return_value ) 2459 2475 ELSEIF ( PRESENT( values_intwp_3d ) ) THEN 2460 CALL netcdf4_write_variable( file_id, variable_id, &2461 bounds_start_internal, value_counts, bounds_origin, is_global, &2476 CALL netcdf4_write_variable( file_id, variable_id, & 2477 bounds_start_internal, value_counts, bounds_origin, is_global, & 2462 2478 values_intwp_3d=values_intwp_3d_pointer, return_value=output_return_value ) 2463 2479 ! 2464 2480 !-- 32bit real output 2465 2481 ELSEIF ( PRESENT( values_real32_0d ) ) THEN 2466 CALL netcdf4_write_variable( file_id, variable_id, &2467 bounds_start_internal, value_counts, bounds_origin, is_global, &2482 CALL netcdf4_write_variable( file_id, variable_id, & 2483 bounds_start_internal, value_counts, bounds_origin, is_global, & 2468 2484 values_real32_0d=values_real32_0d_pointer, return_value=output_return_value ) 2469 2485 ELSEIF ( PRESENT( values_real32_1d ) ) THEN 2470 CALL netcdf4_write_variable( file_id, variable_id, &2471 bounds_start_internal, value_counts, bounds_origin, is_global, &2486 CALL netcdf4_write_variable( file_id, variable_id, & 2487 bounds_start_internal, value_counts, bounds_origin, is_global, & 2472 2488 values_real32_1d=values_real32_1d_pointer, return_value=output_return_value ) 2473 2489 ELSEIF ( PRESENT( values_real32_2d ) ) THEN 2474 CALL netcdf4_write_variable( file_id, variable_id, &2475 bounds_start_internal, value_counts, bounds_origin, is_global, &2490 CALL netcdf4_write_variable( file_id, variable_id, & 2491 bounds_start_internal, value_counts, bounds_origin, is_global, & 2476 2492 values_real32_2d=values_real32_2d_pointer, return_value=output_return_value ) 2477 2493 ELSEIF ( PRESENT( values_real32_3d ) ) THEN 2478 CALL netcdf4_write_variable( file_id, variable_id, &2479 bounds_start_internal, value_counts, bounds_origin, is_global, &2494 CALL netcdf4_write_variable( file_id, variable_id, & 2495 bounds_start_internal, value_counts, bounds_origin, is_global, & 2480 2496 values_real32_3d=values_real32_3d_pointer, return_value=output_return_value ) 2481 2497 ! 2482 2498 !-- 64bit real output 2483 2499 ELSEIF ( PRESENT( values_real64_0d ) ) THEN 2484 CALL netcdf4_write_variable( file_id, variable_id, &2485 bounds_start_internal, value_counts, bounds_origin, is_global, &2500 CALL netcdf4_write_variable( file_id, variable_id, & 2501 bounds_start_internal, value_counts, bounds_origin, is_global, & 2486 2502 values_real64_0d=values_real64_0d_pointer, return_value=output_return_value ) 2487 2503 ELSEIF ( PRESENT( values_real64_1d ) ) THEN 2488 CALL netcdf4_write_variable( file_id, variable_id, &2489 bounds_start_internal, value_counts, bounds_origin, is_global, &2504 CALL netcdf4_write_variable( file_id, variable_id, & 2505 bounds_start_internal, value_counts, bounds_origin, is_global, & 2490 2506 values_real64_1d=values_real64_1d_pointer, return_value=output_return_value ) 2491 2507 ELSEIF ( PRESENT( values_real64_2d ) ) THEN 2492 CALL netcdf4_write_variable( file_id, variable_id, &2493 bounds_start_internal, value_counts, bounds_origin, is_global, &2508 CALL netcdf4_write_variable( file_id, variable_id, & 2509 bounds_start_internal, value_counts, bounds_origin, is_global, & 2494 2510 values_real64_2d=values_real64_2d_pointer, return_value=output_return_value ) 2495 2511 ELSEIF ( PRESENT( values_real64_3d ) ) THEN 2496 CALL netcdf4_write_variable( file_id, variable_id, &2497 bounds_start_internal, value_counts, bounds_origin, is_global, &2512 CALL netcdf4_write_variable( file_id, variable_id, & 2513 bounds_start_internal, value_counts, bounds_origin, is_global, & 2498 2514 values_real64_3d=values_real64_3d_pointer, return_value=output_return_value ) 2499 2515 ! 2500 2516 !-- working-precision real output 2501 2517 ELSEIF ( PRESENT( values_realwp_0d ) ) THEN 2502 CALL netcdf4_write_variable( file_id, variable_id, &2503 bounds_start_internal, value_counts, bounds_origin, is_global, &2518 CALL netcdf4_write_variable( file_id, variable_id, & 2519 bounds_start_internal, value_counts, bounds_origin, is_global, & 2504 2520 values_realwp_0d=values_realwp_0d_pointer, return_value=output_return_value ) 2505 2521 ELSEIF ( PRESENT( values_realwp_1d ) ) THEN 2506 CALL netcdf4_write_variable( file_id, variable_id, &2507 bounds_start_internal, value_counts, bounds_origin, is_global, &2522 CALL netcdf4_write_variable( file_id, variable_id, & 2523 bounds_start_internal, value_counts, bounds_origin, is_global, & 2508 2524 values_realwp_1d=values_realwp_1d_pointer, return_value=output_return_value ) 2509 2525 ELSEIF ( PRESENT( values_realwp_2d ) ) THEN 2510 CALL netcdf4_write_variable( file_id, variable_id, &2511 bounds_start_internal, value_counts, bounds_origin, is_global, &2526 CALL netcdf4_write_variable( file_id, variable_id, & 2527 bounds_start_internal, value_counts, bounds_origin, is_global, & 2512 2528 values_realwp_2d=values_realwp_2d_pointer, return_value=output_return_value ) 2513 2529 ELSEIF ( PRESENT( values_realwp_3d ) ) THEN 2514 CALL netcdf4_write_variable( file_id, variable_id, &2515 bounds_start_internal, value_counts, bounds_origin, is_global, &2530 CALL netcdf4_write_variable( file_id, variable_id, & 2531 bounds_start_internal, value_counts, bounds_origin, is_global, & 2516 2532 values_realwp_3d=values_realwp_3d_pointer, return_value=output_return_value ) 2517 2533 ELSE 2518 2534 return_value = 1 2519 CALL internal_message( 'error', routine_name // &2520 ': output_type not supported by file format "' // &2521 TRIM( file_format ) // '" ' // &2522 '(variable "' // TRIM( variable_name ) // &2535 CALL internal_message( 'error', routine_name // & 2536 ': output_type not supported by file format "' // & 2537 TRIM( file_format ) // '" ' // & 2538 '(variable "' // TRIM( variable_name ) // & 2523 2539 '", file "' // TRIM( file_name ) // '")!' ) 2524 2540 ENDIF … … 2526 2542 CASE DEFAULT 2527 2543 return_value = 1 2528 CALL internal_message( 'error', routine_name // &2529 ': file format "' // TRIM( file_format ) // &2530 '" not supported ' // &2531 '(variable "' // TRIM( variable_name ) // &2544 CALL internal_message( 'error', routine_name // & 2545 ': file format "' // TRIM( file_format ) // & 2546 '" not supported ' // & 2547 '(variable "' // TRIM( variable_name ) // & 2532 2548 '", file "' // TRIM( file_name ) // '")!' ) 2533 2549 … … 2536 2552 IF ( return_value == 0 .AND. output_return_value /= 0 ) THEN 2537 2553 return_value = 1 2538 CALL internal_message( 'error', routine_name // &2539 ': error while writing variable ' // &2540 '(variable "' // TRIM( variable_name ) // &2554 CALL internal_message( 'error', routine_name // & 2555 ': error while writing variable ' // & 2556 '(variable "' // TRIM( variable_name ) // & 2541 2557 '", file "' // TRIM( file_name ) // '")!' ) 2542 2558 ENDIF … … 2589 2605 IF ( output_return_value /= 0 ) THEN 2590 2606 return_value = output_return_value 2591 CALL internal_message( 'error', routine_name // &2592 ': error while finalizing file "' // &2607 CALL internal_message( 'error', routine_name // & 2608 ': error while finalizing file "' // & 2593 2609 TRIM( files(f)%name ) // '"' ) 2594 2610 ELSEIF ( return_value_internal /= 0 ) THEN 2595 2611 return_value = return_value_internal 2596 CALL internal_message( 'error', routine_name // &2597 ': unsupported file format "' // &2598 TRIM( files(f)%format ) // '" for file "' // &2612 CALL internal_message( 'error', routine_name // & 2613 ': unsupported file format "' // & 2614 TRIM( files(f)%format ) // '" for file "' // & 2599 2615 TRIM( files(f)%name ) // '"' ) 2600 2616 ENDIF … … 2636 2652 RESULT( return_value ) 2637 2653 2654 CHARACTER(LEN=*), PARAMETER :: routine_name = 'save_attribute_in_database' !< name of routine 2655 2638 2656 CHARACTER(LEN=*), INTENT(IN) :: file_name !< name of file 2639 2657 CHARACTER(LEN=*), INTENT(IN) :: variable_name !< name of variable 2640 2641 CHARACTER(LEN=*), PARAMETER :: routine_name = 'save_attribute_in_database' !< name of routine2642 2658 2643 2659 INTEGER :: a !< loop index … … 2658 2674 found = .FALSE. 2659 2675 2660 CALL internal_message( 'debug', routine_name // &2661 ': define attribute "' // TRIM( attribute%name ) // &2662 '" of variable "' // TRIM( variable_name ) // &2676 CALL internal_message( 'debug', routine_name // & 2677 ': define attribute "' // TRIM( attribute%name ) // & 2678 '" of variable "' // TRIM( variable_name ) // & 2663 2679 '" in file "' // TRIM( file_name ) // '"' ) 2664 2680 … … 2669 2685 IF ( files(f)%is_init ) THEN 2670 2686 return_value = 1 2671 CALL internal_message( 'error', routine_name // ': file "' // TRIM( file_name ) // &2687 CALL internal_message( 'error', routine_name // ': file "' // TRIM( file_name ) // & 2672 2688 '" is already initialized. No further attribute definition allowed!' ) 2673 2689 EXIT … … 2690 2706 ! 2691 2707 !-- Append existing string attribute 2692 files(f)%attributes(a)%value_char = &2693 TRIM( files(f)%attributes(a)%value_char ) // &2694 TRIM( attribute%value_char )2708 files(f)%attributes(a)%value_char = & 2709 TRIM( files(f)%attributes(a)%value_char ) // & 2710 TRIM( attribute%value_char ) 2695 2711 ELSE 2696 2712 files(f)%attributes(a) = attribute … … 2745 2761 ! 2746 2762 !-- Append existing character attribute 2747 files(f)%dimensions(d)%attributes(a)%value_char = &2748 TRIM( files(f)%dimensions(d)%attributes(a)%value_char ) // &2763 files(f)%dimensions(d)%attributes(a)%value_char = & 2764 TRIM( files(f)%dimensions(d)%attributes(a)%value_char ) // & 2749 2765 TRIM( attribute%value_char ) 2750 2766 ELSE … … 2801 2817 !-- Check if attribute already exists 2802 2818 DO a = 1, natts 2803 IF ( files(f)%variables(d)%attributes(a)%name == attribute%name ) & 2804 THEN 2819 IF ( files(f)%variables(d)%attributes(a)%name == attribute%name ) THEN 2805 2820 IF ( append ) THEN 2806 2821 ! 2807 2822 !-- Append existing character attribute 2808 files(f)%variables(d)%attributes(a)%value_char = &2809 TRIM( files(f)%variables(d)%attributes(a)%value_char ) // &2823 files(f)%variables(d)%attributes(a)%value_char = & 2824 TRIM( files(f)%variables(d)%attributes(a)%value_char ) // & 2810 2825 TRIM( attribute%value_char ) 2811 2826 ELSE … … 2848 2863 IF ( .NOT. found ) THEN 2849 2864 return_value = 1 2850 CALL internal_message( 'error', &2851 routine_name // &2852 ': requested dimension/variable "' // TRIM( variable_name ) // &2853 '" for attribute "' // TRIM( attribute%name ) // &2854 '" does not exist in file "' // TRIM( file_name ) // '"' )2865 CALL internal_message( 'error', & 2866 routine_name // & 2867 ': requested dimension/variable "' // TRIM( variable_name ) // & 2868 '" for attribute "' // TRIM( attribute%name ) // & 2869 '" does not exist in file "' // TRIM( file_name ) // '"' ) 2855 2870 ENDIF 2856 2871 … … 2865 2880 IF ( .NOT. found .AND. return_value == 0 ) THEN 2866 2881 return_value = 1 2867 CALL internal_message( 'error', &2868 routine_name // &2869 ': requested file "' // TRIM( file_name ) // &2870 '" for attribute "' // TRIM( attribute%name ) // &2882 CALL internal_message( 'error', & 2883 routine_name // & 2884 ': requested file "' // TRIM( file_name ) // & 2885 '" for attribute "' // TRIM( attribute%name ) // & 2871 2886 '" does not exist' ) 2872 2887 ENDIF … … 2943 2958 DO d = 1, ndims 2944 2959 DO i = 1, nvars 2945 dimension_is_used(d) = &2946 ANY( files(f)%dimensions(d)%name == files(f)%variables(i)%dimension_names )2960 dimension_is_used(d) = & 2961 ANY( files(f)%dimensions(d)%name == files(f)%variables(i)%dimension_names ) 2947 2962 IF ( dimension_is_used(d) ) EXIT 2948 2963 ENDDO … … 2979 2994 SUBROUTINE open_output_file( file_format, file_name, file_id, return_value ) 2980 2995 2996 CHARACTER(LEN=*), PARAMETER :: routine_name = 'open_output_file' !< name of routine 2997 2981 2998 CHARACTER(LEN=*), INTENT(IN) :: file_format !< file format chosen for file 2982 2999 CHARACTER(LEN=*), INTENT(IN) :: file_name !< name of file to be checked 2983 2984 CHARACTER(LEN=*), PARAMETER :: routine_name = 'open_output_file' !< name of routine2985 3000 2986 3001 INTEGER, INTENT(OUT) :: file_id !< file ID … … 3010 3025 IF ( output_return_value /= 0 ) THEN 3011 3026 return_value = output_return_value 3012 CALL internal_message( 'error', routine_name // &3027 CALL internal_message( 'error', routine_name // & 3013 3028 ': error while opening file "' // TRIM( file_name ) // '"' ) 3014 3029 ELSEIF ( return_value /= 0 ) THEN 3015 CALL internal_message( 'error', routine_name // &3016 ': file "' // TRIM( file_name ) // &3017 '": file format "' // TRIM( file_format ) // &3030 CALL internal_message( 'error', routine_name // & 3031 ': file "' // TRIM( file_name ) // & 3032 '": file format "' // TRIM( file_format ) // & 3018 3033 '" not supported' ) 3019 3034 ENDIF … … 3042 3057 IF ( ALLOCATED( file%attributes ) ) THEN 3043 3058 DO a = 1, SIZE( file%attributes ) 3044 return_value = write_attribute( file%format, file%id, file%name, &3045 variable_id=no_id, variable_name='', &3059 return_value = write_attribute( file%format, file%id, file%name, & 3060 variable_id=no_id, variable_name='', & 3046 3061 attribute=file%attributes(a) ) 3047 3062 IF ( return_value /= 0 ) EXIT … … 3057 3072 ! 3058 3073 !-- Initialize non-masked dimension 3059 CALL init_file_dimension( file%format, file%id, file%name, &3060 file%dimensions(d)%id, file%dimensions(d)%name,&3061 file%dimensions(d)%data_type, file%dimensions(d)%length,&3062 file%dimensions(d)%variable_id, return_value )3074 CALL init_file_dimension( file%format, file%id, file%name, & 3075 file%dimensions(d)%id, file%dimensions(d)%name, & 3076 file%dimensions(d)%data_type, file%dimensions(d)%length, & 3077 file%dimensions(d)%variable_id, return_value ) 3063 3078 3064 3079 ELSE 3065 3080 ! 3066 3081 !-- Initialize masked dimension 3067 CALL init_file_dimension( file%format, file%id, file%name, &3068 file%dimensions(d)%id, file%dimensions(d)%name,&3069 file%dimensions(d)%data_type, file%dimensions(d)%length_mask,&3070 file%dimensions(d)%variable_id, return_value )3082 CALL init_file_dimension( file%format, file%id, file%name, & 3083 file%dimensions(d)%id, file%dimensions(d)%name, & 3084 file%dimensions(d)%data_type, file%dimensions(d)%length_mask,& 3085 file%dimensions(d)%variable_id, return_value ) 3071 3086 3072 3087 ENDIF … … 3076 3091 !-- Write dimension attributes 3077 3092 DO a = 1, SIZE( file%dimensions(d)%attributes ) 3078 return_value = write_attribute( file%format, file%id, file%name, &3079 variable_id=file%dimensions(d)%variable_id,&3080 variable_name=file%dimensions(d)%name,&3081 attribute=file%dimensions(d)%attributes(a) )3093 return_value = write_attribute( file%format, file%id, file%name, & 3094 variable_id=file%dimensions(d)%variable_id, & 3095 variable_name=file%dimensions(d)%name, & 3096 attribute=file%dimensions(d)%attributes(a) ) 3082 3097 IF ( return_value /= 0 ) EXIT 3083 3098 ENDDO … … 3089 3104 ! 3090 3105 !-- Save dimension IDs for variables wihtin database 3091 IF ( return_value == 0 ) &3106 IF ( return_value == 0 ) & 3092 3107 CALL collect_dimesion_ids_for_variables( file%name, file%variables, file%dimensions, & 3093 3108 return_value ) … … 3097 3112 DO d = 1, SIZE( file%variables ) 3098 3113 3099 CALL init_file_variable( file%format, file%id, file%name, &3100 file%variables(d)%id, file%variables(d)%name, file%variables(d)%data_type, &3101 file%variables(d)%dimension_ids, &3114 CALL init_file_variable( file%format, file%id, file%name, & 3115 file%variables(d)%id, file%variables(d)%name, file%variables(d)%data_type, & 3116 file%variables(d)%dimension_ids, & 3102 3117 file%variables(d)%is_global, return_value ) 3103 3118 … … 3106 3121 !-- Write variable attributes 3107 3122 DO a = 1, SIZE( file%variables(d)%attributes ) 3108 return_value = write_attribute( file%format, file%id, file%name, &3109 variable_id=file%variables(d)%id,&3110 variable_name=file%variables(d)%name,&3111 attribute=file%variables(d)%attributes(a) )3123 return_value = write_attribute( file%format, file%id, file%name, & 3124 variable_id=file%variables(d)%id, & 3125 variable_name=file%variables(d)%name, & 3126 attribute=file%variables(d)%attributes(a) ) 3112 3127 IF ( return_value /= 0 ) EXIT 3113 3128 ENDDO … … 3128 3143 !> Initialize dimension in file. 3129 3144 !--------------------------------------------------------------------------------------------------! 3130 SUBROUTINE init_file_dimension( file_format, file_id, file_name, & 3131 dimension_id, dimension_name, dimension_type, dimension_length, & 3132 variable_id, return_value ) 3145 SUBROUTINE init_file_dimension( file_format, file_id, file_name, & 3146 dimension_id, dimension_name, dimension_type, dimension_length, & 3147 variable_id, return_value ) 3148 3149 CHARACTER(LEN=*), PARAMETER :: routine_name = 'init_file_dimension' !< file format chosen for file 3133 3150 3134 3151 CHARACTER(LEN=*), INTENT(IN) :: dimension_name !< name of dimension … … 3136 3153 CHARACTER(LEN=*), INTENT(IN) :: file_format !< file format chosen for file 3137 3154 CHARACTER(LEN=*), INTENT(IN) :: file_name !< name of file 3138 3139 CHARACTER(LEN=*), PARAMETER :: routine_name = 'init_file_dimension' !< file format chosen for file3140 3155 3141 3156 INTEGER, INTENT(OUT) :: dimension_id !< dimension ID … … 3150 3165 output_return_value = 0 3151 3166 3152 temp_string = '(file "' // TRIM( file_name ) // &3167 temp_string = '(file "' // TRIM( file_name ) // & 3153 3168 '", dimension "' // TRIM( dimension_name ) // '")' 3154 3169 … … 3156 3171 3157 3172 CASE ( 'binary' ) 3158 CALL binary_init_dimension( 'binary', file_id, dimension_id, variable_id, &3159 dimension_name, dimension_type, dimension_length,&3160 return_value=output_return_value )3173 CALL binary_init_dimension( 'binary', file_id, dimension_id, variable_id, & 3174 dimension_name, dimension_type, dimension_length, & 3175 return_value=output_return_value ) 3161 3176 3162 3177 CASE ( 'netcdf4-serial' ) 3163 CALL netcdf4_init_dimension( 'serial', file_id, dimension_id, variable_id, &3164 dimension_name, dimension_type, dimension_length,&3165 return_value=output_return_value )3178 CALL netcdf4_init_dimension( 'serial', file_id, dimension_id, variable_id, & 3179 dimension_name, dimension_type, dimension_length, & 3180 return_value=output_return_value ) 3166 3181 3167 3182 CASE ( 'netcdf4-parallel' ) 3168 CALL netcdf4_init_dimension( 'parallel', file_id, dimension_id, variable_id, &3169 dimension_name, dimension_type, dimension_length,&3170 return_value=output_return_value )3183 CALL netcdf4_init_dimension( 'parallel', file_id, dimension_id, variable_id, & 3184 dimension_name, dimension_type, dimension_length, & 3185 return_value=output_return_value ) 3171 3186 3172 3187 CASE DEFAULT 3173 3188 return_value = 1 3174 CALL internal_message( 'error', routine_name // &3175 ': file format "' // TRIM( file_format ) // &3189 CALL internal_message( 'error', routine_name // & 3190 ': file format "' // TRIM( file_format ) // & 3176 3191 '" not supported ' // TRIM( temp_string ) ) 3177 3192 … … 3180 3195 IF ( output_return_value /= 0 ) THEN 3181 3196 return_value = output_return_value 3182 CALL internal_message( 'error', routine_name // &3197 CALL internal_message( 'error', routine_name // & 3183 3198 ': error while defining dimension ' // TRIM( temp_string ) ) 3184 3199 ENDIF … … 3191 3206 !> Initialize variable. 3192 3207 !--------------------------------------------------------------------------------------------------! 3193 SUBROUTINE init_file_variable( file_format, file_id, file_name, &3194 variable_id, variable_name, variable_type, dimension_ids, &3208 SUBROUTINE init_file_variable( file_format, file_id, file_name, & 3209 variable_id, variable_name, variable_type, dimension_ids, & 3195 3210 is_global, return_value ) 3211 3212 CHARACTER(LEN=*), PARAMETER :: routine_name = 'init_file_variable' !< file format chosen for file 3196 3213 3197 3214 CHARACTER(LEN=*), INTENT(IN) :: file_format !< file format chosen for file … … 3200 3217 CHARACTER(LEN=*), INTENT(IN) :: variable_type !< data type of variable 3201 3218 3202 CHARACTER(LEN=*), PARAMETER :: routine_name = 'init_file_variable' !< file format chosen for file3203 3204 3219 INTEGER, INTENT(IN) :: file_id !< file ID 3205 3220 INTEGER :: output_return_value !< return value of a called output routine … … 3221 3236 3222 3237 CASE ( 'binary' ) 3223 CALL binary_init_variable( 'binary', file_id, variable_id, variable_name, &3238 CALL binary_init_variable( 'binary', file_id, variable_id, variable_name, & 3224 3239 variable_type, dimension_ids, is_global, return_value=output_return_value ) 3225 3240 3226 3241 CASE ( 'netcdf4-serial' ) 3227 CALL netcdf4_init_variable( 'serial', file_id, variable_id, variable_name, &3242 CALL netcdf4_init_variable( 'serial', file_id, variable_id, variable_name, & 3228 3243 variable_type, dimension_ids, is_global, return_value=output_return_value ) 3229 3244 3230 3245 CASE ( 'netcdf4-parallel' ) 3231 CALL netcdf4_init_variable( 'parallel', file_id, variable_id, variable_name, &3246 CALL netcdf4_init_variable( 'parallel', file_id, variable_id, variable_name, & 3232 3247 variable_type, dimension_ids, is_global, return_value=output_return_value ) 3233 3248 3234 3249 CASE DEFAULT 3235 3250 return_value = 1 3236 CALL internal_message( 'error', routine_name // &3237 ': file format "' // TRIM( file_format ) // &3251 CALL internal_message( 'error', routine_name // & 3252 ': file format "' // TRIM( file_format ) // & 3238 3253 '" not supported ' // TRIM( temp_string ) ) 3239 3254 … … 3253 3268 !> Write attribute to file. 3254 3269 !--------------------------------------------------------------------------------------------------! 3255 FUNCTION write_attribute( file_format, file_id, file_name, & 3256 variable_id, variable_name, attribute ) RESULT( return_value ) 3270 FUNCTION write_attribute( file_format, file_id, file_name, variable_id, variable_name, attribute )& 3271 RESULT( return_value ) 3272 3273 CHARACTER(LEN=*), PARAMETER :: routine_name = 'write_attribute' !< file format chosen for file 3257 3274 3258 3275 CHARACTER(LEN=*), INTENT(IN) :: file_format !< file format chosen for file … … 3260 3277 CHARACTER(LEN=*), INTENT(IN) :: variable_name !< variable name 3261 3278 3262 CHARACTER(LEN=*), PARAMETER :: routine_name = 'write_attribute' !< file format chosen for file3263 3264 3279 INTEGER, INTENT(IN) :: file_id !< file ID 3280 INTEGER :: output_return_value !< return value of a called output routine 3265 3281 INTEGER :: return_value !< return value 3266 INTEGER :: output_return_value !< return value of a called output routine3267 3282 INTEGER, INTENT(IN) :: variable_id !< variable ID 3268 3283 … … 3274 3289 ! 3275 3290 !-- Prepare for possible error message 3276 temp_string = '(file "' // TRIM( file_name ) // &3277 '", variable "' // TRIM( variable_name ) // &3291 temp_string = '(file "' // TRIM( file_name ) // & 3292 '", variable "' // TRIM( variable_name ) // & 3278 3293 '", attribute "' // TRIM( attribute%name ) // '")' 3279 3294 ! … … 3286 3301 3287 3302 CASE( 'char' ) 3288 CALL binary_write_attribute( file_id=file_id, variable_id=variable_id, &3289 attribute_name=attribute%name, value_char=attribute%value_char, &3303 CALL binary_write_attribute( file_id=file_id, variable_id=variable_id, & 3304 attribute_name=attribute%name, value_char=attribute%value_char, & 3290 3305 return_value=output_return_value ) 3291 3306 3292 3307 CASE( 'int8' ) 3293 CALL binary_write_attribute( file_id=file_id, variable_id=variable_id, &3294 attribute_name=attribute%name, value_int8=attribute%value_int8, &3308 CALL binary_write_attribute( file_id=file_id, variable_id=variable_id, & 3309 attribute_name=attribute%name, value_int8=attribute%value_int8, & 3295 3310 return_value=output_return_value ) 3296 3311 3297 3312 CASE( 'int16' ) 3298 CALL binary_write_attribute( file_id=file_id, variable_id=variable_id, &3299 attribute_name=attribute%name, value_int16=attribute%value_int16, &3313 CALL binary_write_attribute( file_id=file_id, variable_id=variable_id, & 3314 attribute_name=attribute%name, value_int16=attribute%value_int16, & 3300 3315 return_value=output_return_value ) 3301 3316 3302 3317 CASE( 'int32' ) 3303 CALL binary_write_attribute( file_id=file_id, variable_id=variable_id, &3304 attribute_name=attribute%name, value_int32=attribute%value_int32, &3318 CALL binary_write_attribute( file_id=file_id, variable_id=variable_id, & 3319 attribute_name=attribute%name, value_int32=attribute%value_int32, & 3305 3320 return_value=output_return_value ) 3306 3321 3307 3322 CASE( 'real32' ) 3308 CALL binary_write_attribute( file_id=file_id, variable_id=variable_id, &3309 attribute_name=attribute%name, value_real32=attribute%value_real32, &3323 CALL binary_write_attribute( file_id=file_id, variable_id=variable_id, & 3324 attribute_name=attribute%name, value_real32=attribute%value_real32, & 3310 3325 return_value=output_return_value ) 3311 3326 3312 3327 CASE( 'real64' ) 3313 CALL binary_write_attribute( file_id=file_id, variable_id=variable_id, &3314 attribute_name=attribute%name, value_real64=attribute%value_real64, &3328 CALL binary_write_attribute( file_id=file_id, variable_id=variable_id, & 3329 attribute_name=attribute%name, value_real64=attribute%value_real64, & 3315 3330 return_value=output_return_value ) 3316 3331 3317 3332 CASE DEFAULT 3318 3333 return_value = 1 3319 CALL internal_message( 'error', routine_name // &3320 ': file format "' // TRIM( file_format ) // &3321 '" does not support attribute data type "'// &3322 TRIM( attribute%data_type ) // &3334 CALL internal_message( 'error', routine_name // & 3335 ': file format "' // TRIM( file_format ) // & 3336 '" does not support attribute data type "'// & 3337 TRIM( attribute%data_type ) // & 3323 3338 '" ' // TRIM( temp_string ) ) 3324 3339 … … 3330 3345 3331 3346 CASE( 'char' ) 3332 CALL netcdf4_write_attribute( file_id=file_id, variable_id=variable_id, &3333 attribute_name=attribute%name, value_char=attribute%value_char, &3347 CALL netcdf4_write_attribute( file_id=file_id, variable_id=variable_id, & 3348 attribute_name=attribute%name, value_char=attribute%value_char, & 3334 3349 return_value=output_return_value ) 3335 3350 3336 3351 CASE( 'int8' ) 3337 CALL netcdf4_write_attribute( file_id=file_id, variable_id=variable_id, &3338 attribute_name=attribute%name, value_int8=attribute%value_int8, &3352 CALL netcdf4_write_attribute( file_id=file_id, variable_id=variable_id, & 3353 attribute_name=attribute%name, value_int8=attribute%value_int8, & 3339 3354 return_value=output_return_value ) 3340 3355 3341 3356 CASE( 'int16' ) 3342 CALL netcdf4_write_attribute( file_id=file_id, variable_id=variable_id, &3343 attribute_name=attribute%name, value_int16=attribute%value_int16, &3357 CALL netcdf4_write_attribute( file_id=file_id, variable_id=variable_id, & 3358 attribute_name=attribute%name, value_int16=attribute%value_int16, & 3344 3359 return_value=output_return_value ) 3345 3360 3346 3361 CASE( 'int32' ) 3347 CALL netcdf4_write_attribute( file_id=file_id, variable_id=variable_id, &3348 attribute_name=attribute%name, value_int32=attribute%value_int32, &3362 CALL netcdf4_write_attribute( file_id=file_id, variable_id=variable_id, & 3363 attribute_name=attribute%name, value_int32=attribute%value_int32, & 3349 3364 return_value=output_return_value ) 3350 3365 3351 3366 CASE( 'real32' ) 3352 CALL netcdf4_write_attribute( file_id=file_id, variable_id=variable_id, &3353 attribute_name=attribute%name, value_real32=attribute%value_real32, &3367 CALL netcdf4_write_attribute( file_id=file_id, variable_id=variable_id, & 3368 attribute_name=attribute%name, value_real32=attribute%value_real32, & 3354 3369 return_value=output_return_value ) 3355 3370 3356 3371 CASE( 'real64' ) 3357 CALL netcdf4_write_attribute( file_id=file_id, variable_id=variable_id, &3358 attribute_name=attribute%name, value_real64=attribute%value_real64, &3372 CALL netcdf4_write_attribute( file_id=file_id, variable_id=variable_id, & 3373 attribute_name=attribute%name, value_real64=attribute%value_real64, & 3359 3374 return_value=output_return_value ) 3360 3375 3361 3376 CASE DEFAULT 3362 3377 return_value = 1 3363 CALL internal_message( 'error', routine_name // &3364 ': file format "' // TRIM( file_format ) // &3365 '" does not support attribute data type "'// &3366 TRIM( attribute%data_type ) // &3378 CALL internal_message( 'error', routine_name // & 3379 ': file format "' // TRIM( file_format ) // & 3380 '" does not support attribute data type "'// & 3381 TRIM( attribute%data_type ) // & 3367 3382 '" ' // TRIM( temp_string ) ) 3368 3383 … … 3371 3386 CASE DEFAULT 3372 3387 return_value = 1 3373 CALL internal_message( 'error', routine_name // &3374 ': unsupported file format "' // TRIM( file_format ) // &3388 CALL internal_message( 'error', routine_name // & 3389 ': unsupported file format "' // TRIM( file_format ) // & 3375 3390 '" ' // TRIM( temp_string ) ) 3376 3391 … … 3379 3394 IF ( output_return_value /= 0 ) THEN 3380 3395 return_value = output_return_value 3381 CALL internal_message( 'error', routine_name // &3396 CALL internal_message( 'error', routine_name // & 3382 3397 ': error while writing attribute ' // TRIM( temp_string ) ) 3383 3398 ENDIF … … 3392 3407 SUBROUTINE collect_dimesion_ids_for_variables( file_name, variables, dimensions, return_value ) 3393 3408 3409 CHARACTER(LEN=*), PARAMETER :: routine_name = 'collect_dimesion_ids_for_variables' !< file format chosen for file 3410 3394 3411 CHARACTER(LEN=*), INTENT(IN) :: file_name !< name of file 3395 3396 CHARACTER(LEN=*), PARAMETER :: routine_name = 'collect_dimesion_ids_for_variables' !< file format chosen for file3397 3412 3398 3413 INTEGER :: d !< loop index … … 3403 3418 INTEGER, INTENT(OUT) :: return_value !< return value 3404 3419 3405 LOGICAL :: found = .F alse. !< true if dimension required by variable was found in dimension list3420 LOGICAL :: found = .FALSE. !< true if dimension required by variable was found in dimension list 3406 3421 3407 3422 TYPE(dimension_type), DIMENSION(:), INTENT(IN) :: dimensions !< list of dimensions in file … … 3426 3441 IF ( .NOT. found ) THEN 3427 3442 return_value = 1 3428 CALL internal_message( 'error', routine_name // &3429 ': required dimension "' // TRIM( variables(i)%dimension_names(j) ) // &3430 '" is undefined (variable "' // TRIM( variables(i)%name ) // &3443 CALL internal_message( 'error', routine_name // & 3444 ': required dimension "' // TRIM( variables(i)%dimension_names(j) ) // & 3445 '" is undefined (variable "' // TRIM( variables(i)%name ) // & 3431 3446 '", file "' // TRIM( file_name ) // '")!' ) 3432 3447 EXIT … … 3447 3462 SUBROUTINE stop_file_header_definition( file_format, file_id, file_name, return_value ) 3448 3463 3464 CHARACTER(LEN=*), PARAMETER :: routine_name = 'stop_file_header_definition' !< name of routine 3465 3449 3466 CHARACTER(LEN=*), INTENT(IN) :: file_format !< file format 3450 3467 CHARACTER(LEN=*), INTENT(IN) :: file_name !< file name 3451 3452 CHARACTER(LEN=*), PARAMETER :: routine_name = 'stop_file_header_definition' !< name of routine3453 3468 3454 3469 INTEGER, INTENT(IN) :: file_id !< file id … … 3472 3487 CASE DEFAULT 3473 3488 return_value = 1 3474 CALL internal_message( 'error', routine_name // &3475 ': file format "' // TRIM( file_format ) // &3489 CALL internal_message( 'error', routine_name // & 3490 ': file format "' // TRIM( file_format ) // & 3476 3491 '" not supported ' // TRIM( temp_string ) ) 3477 3492 … … 3480 3495 IF ( output_return_value /= 0 ) THEN 3481 3496 return_value = output_return_value 3482 CALL internal_message( 'error', routine_name // &3483 ': error while leaving file-definition state ' // &3497 CALL internal_message( 'error', routine_name // & 3498 ': error while leaving file-definition state ' // & 3484 3499 TRIM( temp_string ) ) 3485 3500 ENDIF … … 3494 3509 !> Find a requested variable 'variable_name' and its used dimensions in requested file 'file_name'. 3495 3510 !--------------------------------------------------------------------------------------------------! 3496 SUBROUTINE find_var_in_file( file_name, variable_name, file_format, file_id, variable_id, &3511 SUBROUTINE find_var_in_file( file_name, variable_name, file_format, file_id, variable_id, & 3497 3512 is_global, dimensions, return_value ) 3513 3514 CHARACTER(LEN=*), PARAMETER :: routine_name = 'find_var_in_file' !< name of routine 3498 3515 3499 3516 CHARACTER(LEN=charlen), INTENT(OUT) :: file_format !< file format chosen for file 3500 3517 CHARACTER(LEN=*), INTENT(IN) :: file_name !< name of file 3501 3518 CHARACTER(LEN=*), INTENT(IN) :: variable_name !< name of variable 3502 3503 CHARACTER(LEN=*), PARAMETER :: routine_name = 'find_var_in_file' !< name of routine3504 3519 3505 3520 INTEGER :: d !< loop index … … 3526 3541 IF ( .NOT. files(f)%is_init ) THEN 3527 3542 return_value = 1 3528 CALL internal_message( 'error', routine_name // &3529 ': file not initialized. ' // &3530 'Writing variable to file is impossible ' // &3531 '(variable "' // TRIM( variable_name ) // &3543 CALL internal_message( 'error', routine_name // & 3544 ': file not initialized. ' // & 3545 'Writing variable to file is impossible ' // & 3546 '(variable "' // TRIM( variable_name ) // & 3532 3547 '", file "' // TRIM( file_name ) // '")!' ) 3533 3548 EXIT … … 3591 3606 IF ( .NOT. found ) THEN 3592 3607 return_value = 1 3593 CALL internal_message( 'error', routine_name // &3594 ': variable not found in file ' // &3595 '(variable "' // TRIM( variable_name ) // &3608 CALL internal_message( 'error', routine_name // & 3609 ': variable not found in file ' // & 3610 '(variable "' // TRIM( variable_name ) // & 3596 3611 '", file "' // TRIM( file_name ) // '")!' ) 3597 3612 ENDIF … … 3604 3619 IF ( .NOT. found .AND. return_value == 0 ) THEN 3605 3620 return_value = 1 3606 CALL internal_message( 'error', routine_name // &3607 ': file not found ' // &3608 '(variable "' // TRIM( variable_name ) // &3621 CALL internal_message( 'error', routine_name // & 3622 ': file not found ' // & 3623 '(variable "' // TRIM( variable_name ) // & 3609 3624 '", file "' // TRIM( file_name ) // '")!' ) 3610 3625 ENDIF … … 3622 3637 !> starts and origins are set to zero for all dimensions. 3623 3638 !--------------------------------------------------------------------------------------------------! 3624 SUBROUTINE get_masked_indices_and_masked_dimension_bounds( &3625 dimensions, bounds_start, bounds_end, bounds_masked_start, value_counts, &3639 SUBROUTINE get_masked_indices_and_masked_dimension_bounds( & 3640 dimensions, bounds_start, bounds_end, bounds_masked_start, value_counts, & 3626 3641 bounds_origin, masked_indices ) 3627 3642 … … 3656 3671 !-- Find number of masked values within given variable bounds 3657 3672 value_counts(d) = 0 3658 DO i = LBOUND( dimensions(d)%masked_indices, DIM=1 ), &3673 DO i = LBOUND( dimensions(d)%masked_indices, DIM=1 ), & 3659 3674 UBOUND( dimensions(d)%masked_indices, DIM=1 ) 3660 3675 ! 3661 3676 !-- Is masked index within given bounds? 3662 IF ( dimensions(d)%masked_indices(i) >= bounds_start(d) .AND. &3677 IF ( dimensions(d)%masked_indices(i) >= bounds_start(d) .AND. & 3663 3678 dimensions(d)%masked_indices(i) <= bounds_end(d) ) THEN 3664 3679 ! … … 3702 3717 ! Description: 3703 3718 ! ------------ 3704 !> Message routine writing debug information into the debug file 3705 !> or creating the error messagestring.3719 !> Message routine writing debug information into the debug file or creating the error message 3720 !> string. 3706 3721 !--------------------------------------------------------------------------------------------------! 3707 3722 SUBROUTINE internal_message( level, string ) … … 3733 3748 3734 3749 CHARACTER(LEN=*), PARAMETER :: separation_string = '---' !< string separating blocks in output 3750 CHARACTER(LEN=*), PARAMETER :: routine_name = 'dom_database_debug_output' !< name of this routine 3751 3752 INTEGER, PARAMETER :: indent_depth = 3 !< space per indentation 3753 INTEGER, PARAMETER :: max_keyname_length = 6 !< length of longest key name 3754 3735 3755 CHARACTER(LEN=50) :: write_format1 !< format for write statements 3736 CHARACTER(LEN=*), PARAMETER :: routine_name = 'dom_database_debug_output' !< name of this routine3737 3756 3738 3757 INTEGER :: f !< loop index 3739 INTEGER, PARAMETER :: indent_depth = 3 !< space per indentation3740 3758 INTEGER :: indent_level !< indentation level 3741 INTEGER, PARAMETER :: max_keyname_length = 6 !< length of longest key name3742 3759 INTEGER :: natts !< number of attributes 3743 3760 INTEGER :: ndims !< number of dimensions … … 3750 3767 WRITE( debug_output_unit, '(A)' ) REPEAT( separation_string // ' ', 4 ) 3751 3768 3752 IF ( .NOT. ALLOCATED( files ) .OR.nfiles == 0 ) THEN3769 IF ( .NOT. ALLOCATED( files ) .OR. nfiles == 0 ) THEN 3753 3770 3754 3771 WRITE( debug_output_unit, '(A)' ) 'database is empty' … … 3757 3774 3758 3775 indent_level = 1 3759 WRITE( write_format1, '(A,I3,A,I3,A)' ) '(T', indent_level * indent_depth + 1, ',A,T', &3760 indent_level * indent_depth + 1 + max_keyname_length, &3761 ',(": ")'3776 WRITE( write_format1, '(A,I3,A,I3,A)' ) '(T', indent_level * indent_depth + 1, ',A,T', & 3777 indent_level * indent_depth + 1 + max_keyname_length, & 3778 ',(": ")' 3762 3779 3763 3780 DO f = 1, nfiles … … 3791 3808 CONTAINS 3792 3809 3793 !-------------------------------------------------------------------------------------------- !3794 3795 3796 3797 !-------------------------------------------------------------------------------------------- !3810 !--------------------------------------------------------------------------------------------------! 3811 ! Description: 3812 ! ------------ 3813 !> Print list of attributes. 3814 !--------------------------------------------------------------------------------------------------! 3798 3815 SUBROUTINE print_attributes( indent_level, attributes ) 3816 3817 INTEGER, PARAMETER :: max_keyname_length = 6 !< length of longest key name 3799 3818 3800 3819 CHARACTER(LEN=50) :: write_format1 !< format for write statements … … 3803 3822 INTEGER :: i !< loop index 3804 3823 INTEGER, INTENT(IN) :: indent_level !< indentation level 3805 INTEGER, PARAMETER :: max_keyname_length = 6 !< length of longest key name3806 3824 INTEGER :: nelement !< number of elements to print 3807 3825 … … 3810 3828 3811 3829 WRITE( write_format1, '(A,I3,A)' ) '(T', indent_level * indent_depth + 1, ',A' 3812 WRITE( write_format2, '(A,I3,A,I3,A)' ) &3813 '(T', ( indent_level + 1 ) * indent_depth + 1, ',A,T', &3830 WRITE( write_format2, '(A,I3,A,I3,A)' ) & 3831 '(T', ( indent_level + 1 ) * indent_depth + 1, ',A,T', & 3814 3832 ( indent_level + 1 ) * indent_depth + 1 + max_keyname_length, ',(": ")' 3815 3833 3816 WRITE( debug_output_unit, TRIM( write_format1 ) // ',A)' ) &3834 WRITE( debug_output_unit, TRIM( write_format1 ) // ',A)' ) & 3817 3835 REPEAT( separation_string // ' ', 4 ) 3818 3836 WRITE( debug_output_unit, TRIM( write_format1 ) // ')' ) 'attributes:' … … 3820 3838 nelement = SIZE( attributes ) 3821 3839 DO i = 1, nelement 3822 WRITE( debug_output_unit, TRIM( write_format2 ) // ',A)' ) &3840 WRITE( debug_output_unit, TRIM( write_format2 ) // ',A)' ) & 3823 3841 'name', TRIM( attributes(i)%name ) 3824 WRITE( debug_output_unit, TRIM( write_format2 ) // ',A)' ) &3842 WRITE( debug_output_unit, TRIM( write_format2 ) // ',A)' ) & 3825 3843 'type', TRIM( attributes(i)%data_type ) 3826 3844 3827 3845 IF ( TRIM( attributes(i)%data_type ) == 'char' ) THEN 3828 WRITE( debug_output_unit, TRIM( write_format2 ) // ',A)' ) &3846 WRITE( debug_output_unit, TRIM( write_format2 ) // ',A)' ) & 3829 3847 'value', TRIM( attributes(i)%value_char ) 3830 3848 ELSEIF ( TRIM( attributes(i)%data_type ) == 'int8' ) THEN 3831 WRITE( debug_output_unit, TRIM( write_format2 ) // ',I4)' ) &3849 WRITE( debug_output_unit, TRIM( write_format2 ) // ',I4)' ) & 3832 3850 'value', attributes(i)%value_int8 3833 3851 ELSEIF ( TRIM( attributes(i)%data_type ) == 'int16' ) THEN 3834 WRITE( debug_output_unit, TRIM( write_format2 ) // ',I6)' ) &3852 WRITE( debug_output_unit, TRIM( write_format2 ) // ',I6)' ) & 3835 3853 'value', attributes(i)%value_int16 3836 3854 ELSEIF ( TRIM( attributes(i)%data_type ) == 'int32' ) THEN 3837 WRITE( debug_output_unit, TRIM( write_format2 ) // ',I11)' ) &3855 WRITE( debug_output_unit, TRIM( write_format2 ) // ',I11)' ) & 3838 3856 'value', attributes(i)%value_int32 3839 3857 ELSEIF ( TRIM( attributes(i)%data_type ) == 'real32' ) THEN 3840 WRITE( debug_output_unit, TRIM( write_format2 ) // ',E14.7)' ) &3858 WRITE( debug_output_unit, TRIM( write_format2 ) // ',E14.7)' ) & 3841 3859 'value', attributes(i)%value_real32 3842 3860 ELSEIF ( TRIM(attributes(i)%data_type) == 'real64' ) THEN 3843 WRITE( debug_output_unit, TRIM( write_format2 ) // ',E22.15)' ) &3861 WRITE( debug_output_unit, TRIM( write_format2 ) // ',E22.15)' ) & 3844 3862 'value', attributes(i)%value_real64 3845 3863 ENDIF 3846 IF ( i < nelement ) &3864 IF ( i < nelement ) & 3847 3865 WRITE( debug_output_unit, TRIM( write_format1 ) // ')' ) separation_string 3848 3866 ENDDO … … 3850 3868 END SUBROUTINE print_attributes 3851 3869 3852 !-------------------------------------------------------------------------------------------- !3853 3854 3855 3856 !-------------------------------------------------------------------------------------------- !3870 !--------------------------------------------------------------------------------------------------! 3871 ! Description: 3872 ! ------------ 3873 !> Print list of dimensions. 3874 !--------------------------------------------------------------------------------------------------! 3857 3875 SUBROUTINE print_dimensions( indent_level, dimensions ) 3876 3877 INTEGER, PARAMETER :: max_keyname_length = 15 !< length of longest key name 3858 3878 3859 3879 CHARACTER(LEN=50) :: write_format1 !< format for write statements … … 3863 3883 INTEGER, INTENT(IN) :: indent_level !< indentation level 3864 3884 INTEGER :: j !< loop index 3865 INTEGER, PARAMETER :: max_keyname_length = 15 !< length of longest key name3866 3885 INTEGER :: nelement !< number of elements to print 3867 3886 … … 3872 3891 3873 3892 WRITE( write_format1, '(A,I3,A)' ) '(T', indent_level * indent_depth + 1, ',A' 3874 WRITE( write_format2, '(A,I3,A,I3,A)' ) &3875 '(T', ( indent_level + 1 ) * indent_depth + 1, ',A,T', &3893 WRITE( write_format2, '(A,I3,A,I3,A)' ) & 3894 '(T', ( indent_level + 1 ) * indent_depth + 1, ',A,T', & 3876 3895 ( indent_level + 1 ) * indent_depth + 1 + max_keyname_length, ',(": ")' 3877 3896 3878 WRITE( debug_output_unit, TRIM( write_format1 ) // ',A)' ) &3897 WRITE( debug_output_unit, TRIM( write_format1 ) // ',A)' ) & 3879 3898 REPEAT( separation_string // ' ', 4 ) 3880 3899 WRITE( debug_output_unit, TRIM( write_format1 ) // ')' ) 'dimensions:' … … 3885 3904 ! 3886 3905 !-- Print general information 3887 WRITE( debug_output_unit, TRIM( write_format2 ) // ',A)' ) &3906 WRITE( debug_output_unit, TRIM( write_format2 ) // ',A)' ) & 3888 3907 'name', TRIM( dimensions(i)%name ) 3889 WRITE( debug_output_unit, TRIM( write_format2 ) // ',A)' ) &3908 WRITE( debug_output_unit, TRIM( write_format2 ) // ',A)' ) & 3890 3909 'type', TRIM( dimensions(i)%data_type ) 3891 WRITE( debug_output_unit, TRIM( write_format2 ) // ',I7)' ) &3910 WRITE( debug_output_unit, TRIM( write_format2 ) // ',I7)' ) & 3892 3911 'id', dimensions(i)%id 3893 WRITE( debug_output_unit, TRIM( write_format2 ) // ',I7)' ) &3912 WRITE( debug_output_unit, TRIM( write_format2 ) // ',I7)' ) & 3894 3913 'length', dimensions(i)%length 3895 WRITE( debug_output_unit, TRIM( write_format2 ) // ',I7,A,I7)' ) &3914 WRITE( debug_output_unit, TRIM( write_format2 ) // ',I7,A,I7)' ) & 3896 3915 'bounds', dimensions(i)%bounds(1), ',', dimensions(i)%bounds(2) 3897 WRITE( debug_output_unit, TRIM( write_format2 ) // ',L1)' ) &3916 WRITE( debug_output_unit, TRIM( write_format2 ) // ',L1)' ) & 3898 3917 'is masked', dimensions(i)%is_masked 3899 3918 ! 3900 3919 !-- Print information about mask 3901 3920 IF ( is_masked ) THEN 3902 WRITE( debug_output_unit, TRIM( write_format2 ) // ',I7)' ) &3921 WRITE( debug_output_unit, TRIM( write_format2 ) // ',I7)' ) & 3903 3922 'masked length', dimensions(i)%length_mask 3904 3923 3905 WRITE( debug_output_unit, TRIM( write_format2 ) // ',L1)', ADVANCE='no' ) &3924 WRITE( debug_output_unit, TRIM( write_format2 ) // ',L1)', ADVANCE='no' ) & 3906 3925 'mask', dimensions(i)%mask(dimensions(i)%bounds(1)) 3907 3926 DO j = dimensions(i)%bounds(1)+1, dimensions(i)%bounds(2) … … 3910 3929 WRITE( debug_output_unit, '(A)' ) '' ! write line-end 3911 3930 3912 WRITE( debug_output_unit, TRIM( write_format2 ) // ',I6)', ADVANCE='no' ) &3931 WRITE( debug_output_unit, TRIM( write_format2 ) // ',I6)', ADVANCE='no' ) & 3913 3932 'masked indices', dimensions(i)%masked_indices(0) 3914 3933 DO j = 1, dimensions(i)%length_mask-1 3915 WRITE( debug_output_unit, '(A,I6)', ADVANCE='no' ) &3934 WRITE( debug_output_unit, '(A,I6)', ADVANCE='no' ) & 3916 3935 ',', dimensions(i)%masked_indices(j) 3917 3936 ENDDO … … 3922 3941 IF ( ALLOCATED( dimensions(i)%values_int8 ) ) THEN 3923 3942 3924 WRITE( debug_output_unit, TRIM( write_format2 ) // ',I4)', ADVANCE='no' ) &3943 WRITE( debug_output_unit, TRIM( write_format2 ) // ',I4)', ADVANCE='no' ) & 3925 3944 'values', dimensions(i)%values_int8(dimensions(i)%bounds(1)) 3926 3945 DO j = dimensions(i)%bounds(1)+1, dimensions(i)%bounds(2) 3927 WRITE( debug_output_unit, '(A,I4)', ADVANCE='no' ) &3946 WRITE( debug_output_unit, '(A,I4)', ADVANCE='no' ) & 3928 3947 ',', dimensions(i)%values_int8(j) 3929 3948 ENDDO 3930 3949 WRITE( debug_output_unit, '(A)' ) '' ! write line-end 3931 3950 IF ( is_masked ) THEN 3932 WRITE( debug_output_unit, TRIM( write_format2 ) // ',I4)', ADVANCE='no' ) &3951 WRITE( debug_output_unit, TRIM( write_format2 ) // ',I4)', ADVANCE='no' ) & 3933 3952 'masked values', dimensions(i)%masked_values_int8(0) 3934 3953 DO j = 1, dimensions(i)%length_mask-1 3935 WRITE( debug_output_unit, '(A,I4)', ADVANCE='no' ) &3954 WRITE( debug_output_unit, '(A,I4)', ADVANCE='no' ) & 3936 3955 ',', dimensions(i)%masked_values_int8(j) 3937 3956 ENDDO … … 3941 3960 ELSEIF ( ALLOCATED( dimensions(i)%values_int16 ) ) THEN 3942 3961 3943 WRITE( debug_output_unit, TRIM( write_format2 ) // ',I6)', ADVANCE='no' ) &3962 WRITE( debug_output_unit, TRIM( write_format2 ) // ',I6)', ADVANCE='no' ) & 3944 3963 'values', dimensions(i)%values_int16(dimensions(i)%bounds(1)) 3945 3964 DO j = dimensions(i)%bounds(1)+1, dimensions(i)%bounds(2) 3946 WRITE( debug_output_unit, '(A,I6)', ADVANCE='no' ) &3965 WRITE( debug_output_unit, '(A,I6)', ADVANCE='no' ) & 3947 3966 ',', dimensions(i)%values_int16(j) 3948 3967 ENDDO 3949 3968 WRITE( debug_output_unit, '(A)' ) '' ! write line-end 3950 3969 IF ( is_masked ) THEN 3951 WRITE( debug_output_unit, TRIM( write_format2 ) // ',I6)', ADVANCE='no' ) &3970 WRITE( debug_output_unit, TRIM( write_format2 ) // ',I6)', ADVANCE='no' ) & 3952 3971 'masked values', dimensions(i)%masked_values_int16(0) 3953 3972 DO j = 1, dimensions(i)%length_mask-1 3954 WRITE( debug_output_unit, '(A,I6)', ADVANCE='no' ) &3973 WRITE( debug_output_unit, '(A,I6)', ADVANCE='no' ) & 3955 3974 ',', dimensions(i)%masked_values_int16(j) 3956 3975 ENDDO … … 3960 3979 ELSEIF ( ALLOCATED( dimensions(i)%values_int32 ) ) THEN 3961 3980 3962 WRITE( debug_output_unit, TRIM( write_format2 ) // ',I11)', ADVANCE='no' ) &3981 WRITE( debug_output_unit, TRIM( write_format2 ) // ',I11)', ADVANCE='no' ) & 3963 3982 'values', dimensions(i)%values_int32(dimensions(i)%bounds(1)) 3964 3983 DO j = dimensions(i)%bounds(1)+1, dimensions(i)%bounds(2) 3965 WRITE( debug_output_unit, '(A,I11)', ADVANCE='no' ) &3984 WRITE( debug_output_unit, '(A,I11)', ADVANCE='no' ) & 3966 3985 ',', dimensions(i)%values_int32(j) 3967 3986 ENDDO 3968 3987 WRITE( debug_output_unit, '(A)' ) '' ! write line-end 3969 3988 IF ( is_masked ) THEN 3970 WRITE( debug_output_unit, TRIM( write_format2 ) // ',I11)', ADVANCE='no' ) &3989 WRITE( debug_output_unit, TRIM( write_format2 ) // ',I11)', ADVANCE='no' ) & 3971 3990 'masked values', dimensions(i)%masked_values_int32(0) 3972 3991 DO j = 1, dimensions(i)%length_mask-1 3973 WRITE( debug_output_unit, '(A,I11)', ADVANCE='no' ) &3992 WRITE( debug_output_unit, '(A,I11)', ADVANCE='no' ) & 3974 3993 ',', dimensions(i)%masked_values_int32(j) 3975 3994 ENDDO … … 3979 3998 ELSEIF ( ALLOCATED( dimensions(i)%values_intwp ) ) THEN 3980 3999 3981 WRITE( debug_output_unit, TRIM( write_format2 ) // ',I11)', ADVANCE='no' ) &4000 WRITE( debug_output_unit, TRIM( write_format2 ) // ',I11)', ADVANCE='no' ) & 3982 4001 'values', dimensions(i)%values_intwp(dimensions(i)%bounds(1)) 3983 4002 DO j = dimensions(i)%bounds(1)+1, dimensions(i)%bounds(2) 3984 WRITE( debug_output_unit, '(A,I11)', ADVANCE='no' ) &4003 WRITE( debug_output_unit, '(A,I11)', ADVANCE='no' ) & 3985 4004 ',', dimensions(i)%values_intwp(j) 3986 4005 ENDDO 3987 4006 WRITE( debug_output_unit, '(A)' ) '' ! write line-end 3988 4007 IF ( is_masked ) THEN 3989 WRITE( debug_output_unit, TRIM( write_format2 ) // ',I11)', ADVANCE='no' ) &4008 WRITE( debug_output_unit, TRIM( write_format2 ) // ',I11)', ADVANCE='no' ) & 3990 4009 'masked values', dimensions(i)%masked_values_intwp(0) 3991 4010 DO j = 1, dimensions(i)%length_mask-1 3992 WRITE( debug_output_unit, '(A,I11)', ADVANCE='no' ) &4011 WRITE( debug_output_unit, '(A,I11)', ADVANCE='no' ) & 3993 4012 ',', dimensions(i)%masked_values_intwp(j) 3994 4013 ENDDO … … 3998 4017 ELSEIF ( ALLOCATED( dimensions(i)%values_real32 ) ) THEN 3999 4018 4000 WRITE( debug_output_unit, TRIM( write_format2 ) // ',E14.7)', ADVANCE='no' ) &4019 WRITE( debug_output_unit, TRIM( write_format2 ) // ',E14.7)', ADVANCE='no' ) & 4001 4020 'values', dimensions(i)%values_real32(dimensions(i)%bounds(1)) 4002 4021 DO j = dimensions(i)%bounds(1)+1, dimensions(i)%bounds(2) 4003 WRITE( debug_output_unit, '(A,E14.7)', ADVANCE='no' ) &4022 WRITE( debug_output_unit, '(A,E14.7)', ADVANCE='no' ) & 4004 4023 ',', dimensions(i)%values_real32(j) 4005 4024 ENDDO 4006 4025 WRITE( debug_output_unit, '(A)' ) '' ! write line-end 4007 4026 IF ( is_masked ) THEN 4008 WRITE( debug_output_unit, TRIM( write_format2 ) // ',E14.7)', ADVANCE='no' ) &4027 WRITE( debug_output_unit, TRIM( write_format2 ) // ',E14.7)', ADVANCE='no' ) & 4009 4028 'masked values', dimensions(i)%masked_values_real32(0) 4010 4029 DO j = 1, dimensions(i)%length_mask-1 4011 WRITE( debug_output_unit, '(A,E14.7)', ADVANCE='no' ) &4030 WRITE( debug_output_unit, '(A,E14.7)', ADVANCE='no' ) & 4012 4031 ',', dimensions(i)%masked_values_real32(j) 4013 4032 ENDDO … … 4017 4036 ELSEIF ( ALLOCATED( dimensions(i)%values_real64 ) ) THEN 4018 4037 4019 WRITE( debug_output_unit, TRIM( write_format2 ) // ',E22.15)', ADVANCE='no' ) &4038 WRITE( debug_output_unit, TRIM( write_format2 ) // ',E22.15)', ADVANCE='no' ) & 4020 4039 'values', dimensions(i)%values_real64(dimensions(i)%bounds(1)) 4021 4040 DO j = dimensions(i)%bounds(1)+1, dimensions(i)%bounds(2) 4022 WRITE( debug_output_unit, '(A,E22.15)', ADVANCE='no' ) &4041 WRITE( debug_output_unit, '(A,E22.15)', ADVANCE='no' ) & 4023 4042 ',', dimensions(i)%values_real64(j) 4024 4043 ENDDO 4025 4044 WRITE( debug_output_unit, '(A)' ) '' ! write line-end 4026 4045 IF ( is_masked ) THEN 4027 WRITE( debug_output_unit, TRIM( write_format2 ) // ',E22.15)', ADVANCE='no' ) &4046 WRITE( debug_output_unit, TRIM( write_format2 ) // ',E22.15)', ADVANCE='no' ) & 4028 4047 'masked values', dimensions(i)%masked_values_real64(0) 4029 4048 DO j = 1, dimensions(i)%length_mask-1 4030 WRITE( debug_output_unit, '(A,E22.15)', ADVANCE='no' ) &4049 WRITE( debug_output_unit, '(A,E22.15)', ADVANCE='no' ) & 4031 4050 ',', dimensions(i)%masked_values_real64(j) 4032 4051 ENDDO … … 4036 4055 ELSEIF ( ALLOCATED( dimensions(i)%values_realwp ) ) THEN 4037 4056 4038 WRITE( debug_output_unit, TRIM( write_format2 ) // ',E22.15)', ADVANCE='no' ) &4057 WRITE( debug_output_unit, TRIM( write_format2 ) // ',E22.15)', ADVANCE='no' ) & 4039 4058 'values', dimensions(i)%values_realwp(dimensions(i)%bounds(1)) 4040 4059 DO j = dimensions(i)%bounds(1)+1, dimensions(i)%bounds(2) 4041 WRITE( debug_output_unit, '(A,E22.15)', ADVANCE='no' ) &4060 WRITE( debug_output_unit, '(A,E22.15)', ADVANCE='no' ) & 4042 4061 ',', dimensions(i)%values_realwp(j) 4043 4062 ENDDO 4044 4063 WRITE( debug_output_unit, '(A)' ) '' ! write line-end 4045 4064 IF ( is_masked ) THEN 4046 WRITE( debug_output_unit, TRIM( write_format2 ) // ',E22.15)', ADVANCE='no' ) &4065 WRITE( debug_output_unit, TRIM( write_format2 ) // ',E22.15)', ADVANCE='no' ) & 4047 4066 'masked values', dimensions(i)%masked_values_realwp(0) 4048 4067 DO j = 1, dimensions(i)%length_mask-1 4049 WRITE( debug_output_unit, '(A,E22.15)', ADVANCE='no' ) &4068 WRITE( debug_output_unit, '(A,E22.15)', ADVANCE='no' ) & 4050 4069 ',', dimensions(i)%masked_values_realwp(j) 4051 4070 ENDDO … … 4055 4074 ENDIF 4056 4075 4057 IF ( ALLOCATED( dimensions(i)%attributes ) ) &4076 IF ( ALLOCATED( dimensions(i)%attributes ) ) & 4058 4077 CALL print_attributes( indent_level+1, dimensions(i)%attributes ) 4059 4078 4060 IF ( i < nelement ) &4079 IF ( i < nelement ) & 4061 4080 WRITE( debug_output_unit, TRIM( write_format1 ) // ')' ) separation_string 4062 4081 ENDDO … … 4064 4083 END SUBROUTINE print_dimensions 4065 4084 4066 !-------------------------------------------------------------------------------------------- !4067 4068 4069 4070 !-------------------------------------------------------------------------------------------- !4085 !--------------------------------------------------------------------------------------------------! 4086 ! Description: 4087 ! ------------ 4088 !> Print list of variables. 4089 !--------------------------------------------------------------------------------------------------! 4071 4090 SUBROUTINE print_variables( indent_level, variables ) 4091 4092 INTEGER, PARAMETER :: max_keyname_length = 16 !< length of longest key name 4072 4093 4073 4094 CHARACTER(LEN=50) :: write_format1 !< format for write statements … … 4077 4098 INTEGER, INTENT(IN) :: indent_level !< indentation level 4078 4099 INTEGER :: j !< loop index 4079 INTEGER, PARAMETER :: max_keyname_length = 16 !< length of longest key name4080 4100 INTEGER :: nelement !< number of elements to print 4081 4101 … … 4084 4104 4085 4105 WRITE( write_format1, '(A,I3,A)' ) '(T', indent_level * indent_depth + 1, ',A' 4086 WRITE( write_format2, '(A,I3,A,I3,A)' ) &4087 '(T', ( indent_level + 1 ) * indent_depth + 1, ',A,T', &4106 WRITE( write_format2, '(A,I3,A,I3,A)' ) & 4107 '(T', ( indent_level + 1 ) * indent_depth + 1, ',A,T', & 4088 4108 ( indent_level + 1 ) * indent_depth + 1 + max_keyname_length, ',(": ")' 4089 4109 4090 WRITE( debug_output_unit, TRIM( write_format1 ) // ',A)' ) &4110 WRITE( debug_output_unit, TRIM( write_format1 ) // ',A)' ) & 4091 4111 REPEAT( separation_string // ' ', 4 ) 4092 4112 WRITE( debug_output_unit, TRIM( write_format1 ) // ')' ) 'variables:' … … 4094 4114 nelement = SIZE( variables ) 4095 4115 DO i = 1, nelement 4096 WRITE( debug_output_unit, TRIM( write_format2 ) // ',A)' ) &4116 WRITE( debug_output_unit, TRIM( write_format2 ) // ',A)' ) & 4097 4117 'name', TRIM( variables(i)%name ) 4098 WRITE( debug_output_unit, TRIM( write_format2 ) // ',A)' ) &4118 WRITE( debug_output_unit, TRIM( write_format2 ) // ',A)' ) & 4099 4119 'type', TRIM( variables(i)%data_type ) 4100 WRITE( debug_output_unit, TRIM( write_format2 ) // ',I7)' ) &4120 WRITE( debug_output_unit, TRIM( write_format2 ) // ',I7)' ) & 4101 4121 'id', variables(i)%id 4102 WRITE( debug_output_unit, TRIM( write_format2 ) // ',L1)' ) &4122 WRITE( debug_output_unit, TRIM( write_format2 ) // ',L1)' ) & 4103 4123 'is global', variables(i)%is_global 4104 4124 4105 WRITE( debug_output_unit, TRIM( write_format2 ) // ',A)', ADVANCE='no' ) &4125 WRITE( debug_output_unit, TRIM( write_format2 ) // ',A)', ADVANCE='no' ) & 4106 4126 'dimension names', TRIM( variables(i)%dimension_names(1) ) 4107 4127 DO j = 2, SIZE( variables(i)%dimension_names ) 4108 WRITE( debug_output_unit, '(A,A)', ADVANCE='no' ) &4128 WRITE( debug_output_unit, '(A,A)', ADVANCE='no' ) & 4109 4129 ',', TRIM( variables(i)%dimension_names(j) ) 4110 4130 ENDDO 4111 4131 WRITE( debug_output_unit, '(A)' ) '' ! write line-end 4112 4132 4113 WRITE( debug_output_unit, TRIM( write_format2 ) // ',I7)', ADVANCE='no' ) &4133 WRITE( debug_output_unit, TRIM( write_format2 ) // ',I7)', ADVANCE='no' ) & 4114 4134 'dimension ids', variables(i)%dimension_ids(1) 4115 4135 DO j = 2, SIZE( variables(i)%dimension_names ) 4116 WRITE( debug_output_unit, '(A,I7)', ADVANCE='no' ) &4136 WRITE( debug_output_unit, '(A,I7)', ADVANCE='no' ) & 4117 4137 ',', variables(i)%dimension_ids(j) 4118 4138 ENDDO 4119 4139 WRITE( debug_output_unit, '(A)' ) '' ! write line-end 4120 4140 4121 IF ( ALLOCATED( variables(i)%attributes ) ) &4141 IF ( ALLOCATED( variables(i)%attributes ) ) & 4122 4142 CALL print_attributes( indent_level+1, variables(i)%attributes ) 4123 IF ( i < nelement ) &4143 IF ( i < nelement ) & 4124 4144 WRITE( debug_output_unit, TRIM( write_format1 ) // ')' ) separation_string 4125 4145 ENDDO -
TabularUnified palm/trunk/SOURCE/data_output_netcdf4_module.f90 ¶
r4481 r4577 3 3 ! This file is part of the PALM model system. 4 4 ! 5 ! PALM is free software: you can redistribute it and/or modify it under the 6 ! terms of the GNU General Public License as published by the Free Software 7 ! Foundation, either version 3 of the License, or (at your option) any later 8 ! version. 9 ! 10 ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY 11 ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 12 ! A PARTICULAR PURPOSE. See the GNU General Public License for more details. 13 ! 14 ! You should have received a copy of the GNU General Public License along with 15 ! PALM. If not, see <http://www.gnu.org/licenses/>. 5 ! PALM is free software: you can redistribute it and/or modify it under the terms of the GNU General 6 ! Public License as published by the Free Software Foundation, either version 3 of the License, or 7 ! (at your option) any later version. 8 ! 9 ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the 10 ! implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 11 ! Public License for more details. 12 ! 13 ! You should have received a copy of the GNU General Public License along with PALM. If not, see 14 ! <http://www.gnu.org/licenses/>. 16 15 ! 17 16 ! Copyright 2019-2020 Leibniz Universitaet Hannover … … 25 24 ! ----------------- 26 25 ! $Id$ 26 ! file re-formatted to follow the PALM coding standard 27 ! 28 ! 4481 2020-03-31 18:55:54Z maronga 27 29 ! bugfix: cpp-directive moved to avoid compile error due to unused dummy argument 28 ! 30 ! 29 31 ! 4408 2020-02-14 10:04:39Z gronemeier 30 32 ! Enable character-array output … … 67 69 #endif 68 70 69 CHARACTER(LEN=800) :: internal_error_message = '' !< string containing the last error message70 CHARACTER(LEN=100) :: file_suffix = '' !< file suffix added to each file name71 CHARACTER(LEN=800) :: temp_string !< dummy string72 73 71 CHARACTER(LEN=*), PARAMETER :: mode_parallel = 'parallel' !< string selecting netcdf4 parallel mode 74 72 CHARACTER(LEN=*), PARAMETER :: mode_serial = 'serial' !< string selecting netcdf4 serial mode 73 74 CHARACTER(LEN=100) :: file_suffix = '' !< file suffix added to each file name 75 CHARACTER(LEN=800) :: internal_error_message = '' !< string containing the last error message 76 CHARACTER(LEN=800) :: temp_string !< dummy string 75 77 76 78 INTEGER :: debug_output_unit !< Fortran Unit Number of the debug-output file … … 121 123 END INTERFACE netcdf4_get_error_message 122 124 123 PUBLIC &124 netcdf4_finalize, &125 netcdf4_get_error_message, &126 netcdf4_init_dimension, &127 netcdf4_ stop_file_header_definition,&128 netcdf4_init_ module,&129 netcdf4_ init_variable,&130 netcdf4_ open_file,&131 netcdf4_write_attribute, &125 PUBLIC & 126 netcdf4_finalize, & 127 netcdf4_get_error_message, & 128 netcdf4_init_dimension, & 129 netcdf4_init_module, & 130 netcdf4_init_variable, & 131 netcdf4_open_file, & 132 netcdf4_stop_file_header_definition, & 133 netcdf4_write_attribute, & 132 134 netcdf4_write_variable 133 135 … … 141 143 !> Initialize data-output module. 142 144 !--------------------------------------------------------------------------------------------------! 143 SUBROUTINE netcdf4_init_module( file_suffix_of_output_group, mpi_comm_of_output_group, &144 master_output_rank, &145 SUBROUTINE netcdf4_init_module( file_suffix_of_output_group, mpi_comm_of_output_group, & 146 master_output_rank, & 145 147 program_debug_output_unit, debug_output, dom_global_id ) 146 148 … … 174 176 SUBROUTINE netcdf4_open_file( mode, file_name, file_id, return_value ) 175 177 178 CHARACTER(LEN=*), PARAMETER :: routine_name = 'netcdf4_open_file' !< name of this routine 179 176 180 CHARACTER(LEN=*), INTENT(IN) :: file_name !< name of file 177 181 CHARACTER(LEN=*), INTENT(IN) :: mode !< operation mode (either parallel or serial) 178 179 CHARACTER(LEN=*), PARAMETER :: routine_name = 'netcdf4_open_file' !< name of this routine180 182 181 183 INTEGER, INTENT(OUT) :: file_id !< file ID … … 201 203 IF ( my_rank /= master_rank ) THEN 202 204 return_value = 1 203 CALL internal_message( 'error', routine_name // &204 ': trying to define a NetCDF file in serial mode by an MPI ' // &205 'rank other than the master output rank. Serial NetCDF ' // &205 CALL internal_message( 'error', routine_name // & 206 ': trying to define a NetCDF file in serial mode by an MPI ' // & 207 'rank other than the master output rank. Serial NetCDF ' // & 206 208 'files can only be defined by the master output rank!' ) 207 209 ENDIF … … 212 214 213 215 IF ( return_value == 0 ) & 214 nc_stat = NF90_CREATE( TRIM( file_name ) // TRIM( file_suffix ), & 215 IOR( NF90_NOCLOBBER, NF90_NETCDF4 ), & 216 file_id ) 216 nc_stat = NF90_CREATE( TRIM( file_name ) // TRIM( file_suffix ), & 217 IOR( NF90_NOCLOBBER, NF90_NETCDF4 ), file_id ) 217 218 #else 218 219 nc_stat = 0 219 220 return_value = 1 220 CALL internal_message( 'error', routine_name // &221 ': pre-processor directive "__netcdf4" not given. ' // &221 CALL internal_message( 'error', routine_name // & 222 ': pre-processor directive "__netcdf4" not given. ' // & 222 223 'Using NetCDF4 output not possible' ) 223 224 #endif … … 226 227 227 228 #if defined( __parallel ) && defined( __netcdf4 ) && defined( __netcdf4_parallel ) 228 nc_stat = NF90_CREATE( TRIM( file_name ) // TRIM( file_suffix ), &229 IOR( NF90_NOCLOBBER, IOR( NF90_NETCDF4, NF90_MPIIO ) ), &229 nc_stat = NF90_CREATE( TRIM( file_name ) // TRIM( file_suffix ), & 230 IOR( NF90_NOCLOBBER, IOR( NF90_NETCDF4, NF90_MPIIO ) ), & 230 231 file_id, COMM = output_group_comm, INFO = MPI_INFO_NULL ) 231 232 #else 232 233 nc_stat = 0 233 234 return_value = 1 234 CALL internal_message( 'error', routine_name // &235 ': pre-processor directives "__parallel" and/or ' // &236 '"__netcdf4" and/or "__netcdf4_parallel" not given. ' // &235 CALL internal_message( 'error', routine_name // & 236 ': pre-processor directives "__parallel" and/or ' // & 237 '"__netcdf4" and/or "__netcdf4_parallel" not given. ' // & 237 238 'Using parallel NetCDF4 output not possible' ) 238 239 #endif … … 241 242 nc_stat = 0 242 243 return_value = 1 243 CALL internal_message( 'error', routine_name // ': selected mode "' // &244 TRIM( mode ) // '" must be either "' // &244 CALL internal_message( 'error', routine_name // ': selected mode "' // & 245 TRIM( mode ) // '" must be either "' // & 245 246 mode_serial // '" or "' // mode_parallel // '"' ) 246 247 ENDIF … … 249 250 IF ( nc_stat /= NF90_NOERR .AND. return_value == 0 ) THEN 250 251 return_value = 1 251 CALL internal_message( 'error', routine_name // &252 ': NetCDF error while opening file "' // &252 CALL internal_message( 'error', routine_name // & 253 ': NetCDF error while opening file "' // & 253 254 TRIM( file_name ) // '": ' // NF90_STRERROR( nc_stat ) ) 254 255 ENDIF … … 262 263 !> Write attribute to netcdf file. 263 264 !--------------------------------------------------------------------------------------------------! 264 SUBROUTINE netcdf4_write_attribute( file_id, variable_id, attribute_name, & 265 value_char, value_int8, value_int16, value_int32, & 266 value_real32, value_real64, return_value ) 265 SUBROUTINE netcdf4_write_attribute( file_id, variable_id, attribute_name, & 266 value_char, value_int8, value_int16, value_int32, & 267 value_real32, value_real64, return_value ) 268 269 CHARACTER(LEN=*), PARAMETER :: routine_name = 'netcdf4_write_attribute' !< name of this routine 267 270 268 271 CHARACTER(LEN=*), INTENT(IN) :: attribute_name !< name of attribute 269 272 CHARACTER(LEN=*), INTENT(IN), OPTIONAL :: value_char !< value of attribute 270 271 CHARACTER(LEN=*), PARAMETER :: routine_name = 'netcdf4_write_attribute' !< name of this routine272 273 273 274 INTEGER :: nc_stat !< netcdf return value … … 295 296 ENDIF 296 297 297 CALL internal_message( 'debug', routine_name // &298 CALL internal_message( 'debug', routine_name // & 298 299 ': write attribute "' // TRIM( attribute_name ) // '"' ) 299 300 … … 312 313 ELSE 313 314 return_value = 1 314 CALL internal_message( 'error', routine_name // &315 CALL internal_message( 'error', routine_name // & 315 316 ': no value given for attribute "' // TRIM( attribute_name ) // '"' ) 316 317 ENDIF … … 319 320 IF ( nc_stat /= NF90_NOERR ) THEN 320 321 return_value = 1 321 CALL internal_message( 'error', routine_name // &322 ': NetCDF error while writing attribute "' // &322 CALL internal_message( 'error', routine_name // & 323 ': NetCDF error while writing attribute "' // & 323 324 TRIM( attribute_name ) // '": ' // NF90_STRERROR( nc_stat ) ) 324 325 ENDIF … … 337 338 SUBROUTINE netcdf4_init_dimension( mode, file_id, dimension_id, variable_id, & 338 339 dimension_name, dimension_type, dimension_length, return_value ) 340 341 CHARACTER(LEN=*), PARAMETER :: routine_name = 'netcdf4_init_dimension' !< name of this routine 339 342 340 343 CHARACTER(LEN=*), INTENT(IN) :: dimension_name !< name of dimension 341 344 CHARACTER(LEN=*), INTENT(IN) :: dimension_type !< data type of dimension 342 345 CHARACTER(LEN=*), INTENT(IN) :: mode !< operation mode (either parallel or serial) 343 344 CHARACTER(LEN=*), PARAMETER :: routine_name = 'netcdf4_init_dimension' !< name of this routine345 346 346 347 INTEGER, INTENT(OUT) :: dimension_id !< dimension ID … … 357 358 variable_id = -1 358 359 359 CALL internal_message( 'debug', routine_name // &360 CALL internal_message( 'debug', routine_name // & 360 361 ': init dimension "' // TRIM( dimension_name ) // '"' ) 361 362 ! … … 378 379 ELSE 379 380 return_value = 1 380 CALL internal_message( 'error', routine_name // &381 ': NetCDF error while initializing dimension "' // &381 CALL internal_message( 'error', routine_name // & 382 ': NetCDF error while initializing dimension "' // & 382 383 TRIM( dimension_name ) // '": ' // NF90_STRERROR( nc_stat ) ) 383 384 ENDIF … … 395 396 !> Initialize variable. 396 397 !--------------------------------------------------------------------------------------------------! 397 SUBROUTINE netcdf4_init_variable( mode, file_id, variable_id, variable_name, variable_type, &398 SUBROUTINE netcdf4_init_variable( mode, file_id, variable_id, variable_name, variable_type, & 398 399 dimension_ids, is_global, return_value ) 400 401 CHARACTER(LEN=*), PARAMETER :: routine_name = 'netcdf4_init_variable' !< name of this routine 399 402 400 403 CHARACTER(LEN=*), INTENT(IN) :: mode !< operation mode (either parallel or serial) 401 404 CHARACTER(LEN=*), INTENT(IN) :: variable_name !< name of variable 402 405 CHARACTER(LEN=*), INTENT(IN) :: variable_type !< data type of variable 403 404 CHARACTER(LEN=*), PARAMETER :: routine_name = 'netcdf4_init_variable' !< name of this routine405 406 406 407 INTEGER, INTENT(IN) :: file_id !< file ID … … 419 420 420 421 WRITE( temp_string, * ) is_global 421 CALL internal_message( 'debug', routine_name // &422 ': init variable "' // TRIM( variable_name ) // &422 CALL internal_message( 'debug', routine_name // & 423 ': init variable "' // TRIM( variable_name ) // & 423 424 '" ( is_global = ' // TRIM( temp_string ) // ')' ) 424 425 … … 446 447 IF ( nc_stat /= NF90_NOERR ) THEN 447 448 return_value = 1 448 CALL internal_message( 'error', routine_name // &449 ': NetCDF error while initializing variable "' // &449 CALL internal_message( 'error', routine_name // & 450 ': NetCDF error while initializing variable "' // & 450 451 TRIM( variable_name ) // '": ' // NF90_STRERROR( nc_stat ) ) 451 452 ENDIF … … 507 508 !> Write variable of different kind into netcdf file. 508 509 !--------------------------------------------------------------------------------------------------! 509 SUBROUTINE netcdf4_write_variable( &510 file_id, variable_id, bounds_start, value_counts, bounds_origin, &511 is_global, &512 values_char_0d, values_char_1d, values_char_2d, values_char_3d, &513 values_int8_0d, values_int8_1d, values_int8_2d, values_int8_3d, &514 values_int16_0d, values_int16_1d, values_int16_2d, values_int16_3d, &515 values_int32_0d, values_int32_1d, values_int32_2d, values_int32_3d, &516 values_intwp_0d, values_intwp_1d, values_intwp_2d, values_intwp_3d, &517 values_real32_0d, values_real32_1d, values_real32_2d, values_real32_3d, &518 values_real64_0d, values_real64_1d, values_real64_2d, values_real64_3d, &519 values_realwp_0d, values_realwp_1d, values_realwp_2d, values_realwp_3d, &510 SUBROUTINE netcdf4_write_variable( & 511 file_id, variable_id, bounds_start, value_counts, bounds_origin, & 512 is_global, & 513 values_char_0d, values_char_1d, values_char_2d, values_char_3d, & 514 values_int8_0d, values_int8_1d, values_int8_2d, values_int8_3d, & 515 values_int16_0d, values_int16_1d, values_int16_2d, values_int16_3d, & 516 values_int32_0d, values_int32_1d, values_int32_2d, values_int32_3d, & 517 values_intwp_0d, values_intwp_1d, values_intwp_2d, values_intwp_3d, & 518 values_real32_0d, values_real32_1d, values_real32_2d, values_real32_3d, & 519 values_real64_0d, values_real64_1d, values_real64_2d, values_real64_3d, & 520 values_realwp_0d, values_realwp_1d, values_realwp_2d, values_realwp_3d, & 520 521 return_value ) 521 522 … … 586 587 #endif 587 588 588 IF ( return_value == 0 .AND. ( .NOT. is_global .OR.my_rank == master_rank ) ) THEN589 IF ( return_value == 0 .AND. ( .NOT. is_global .OR. my_rank == master_rank ) ) THEN 589 590 590 591 WRITE( temp_string, * ) variable_id … … 596 597 !-- character output 597 598 IF ( PRESENT( values_char_0d ) ) THEN 598 nc_stat = NF90_PUT_VAR( file_id, variable_id, (/ values_char_0d /), &599 start = bounds_start - bounds_origin + 1, &599 nc_stat = NF90_PUT_VAR( file_id, variable_id, (/ values_char_0d /), & 600 start = bounds_start - bounds_origin + 1, & 600 601 count = value_counts ) 601 602 ELSEIF ( PRESENT( values_char_1d ) ) THEN 602 nc_stat = NF90_PUT_VAR( file_id, variable_id, values_char_1d, &603 start = bounds_start - bounds_origin + 1, &603 nc_stat = NF90_PUT_VAR( file_id, variable_id, values_char_1d, & 604 start = bounds_start - bounds_origin + 1, & 604 605 count = value_counts ) 605 606 ELSEIF ( PRESENT( values_char_2d ) ) THEN 606 nc_stat = NF90_PUT_VAR( file_id, variable_id, values_char_2d, &607 start = bounds_start - bounds_origin + 1, &607 nc_stat = NF90_PUT_VAR( file_id, variable_id, values_char_2d, & 608 start = bounds_start - bounds_origin + 1, & 608 609 count = value_counts ) 609 610 ELSEIF ( PRESENT( values_char_3d ) ) THEN 610 nc_stat = NF90_PUT_VAR( file_id, variable_id, values_char_3d, &611 start = bounds_start - bounds_origin + 1, &611 nc_stat = NF90_PUT_VAR( file_id, variable_id, values_char_3d, & 612 start = bounds_start - bounds_origin + 1, & 612 613 count = value_counts ) 613 614 ! 614 615 !-- 8bit integer output 615 616 ELSEIF ( PRESENT( values_int8_0d ) ) THEN 616 nc_stat = NF90_PUT_VAR( file_id, variable_id, (/ values_int8_0d /), &617 start = bounds_start - bounds_origin + 1, &617 nc_stat = NF90_PUT_VAR( file_id, variable_id, (/ values_int8_0d /), & 618 start = bounds_start - bounds_origin + 1, & 618 619 count = value_counts ) 619 620 ELSEIF ( PRESENT( values_int8_1d ) ) THEN 620 nc_stat = NF90_PUT_VAR( file_id, variable_id, values_int8_1d, &621 start = bounds_start - bounds_origin + 1, &621 nc_stat = NF90_PUT_VAR( file_id, variable_id, values_int8_1d, & 622 start = bounds_start - bounds_origin + 1, & 622 623 count = value_counts ) 623 624 ELSEIF ( PRESENT( values_int8_2d ) ) THEN 624 nc_stat = NF90_PUT_VAR( file_id, variable_id, values_int8_2d, &625 start = bounds_start - bounds_origin + 1, &625 nc_stat = NF90_PUT_VAR( file_id, variable_id, values_int8_2d, & 626 start = bounds_start - bounds_origin + 1, & 626 627 count = value_counts ) 627 628 ELSEIF ( PRESENT( values_int8_3d ) ) THEN 628 nc_stat = NF90_PUT_VAR( file_id, variable_id, values_int8_3d, &629 start = bounds_start - bounds_origin + 1, &629 nc_stat = NF90_PUT_VAR( file_id, variable_id, values_int8_3d, & 630 start = bounds_start - bounds_origin + 1, & 630 631 count = value_counts ) 631 632 ! 632 633 !-- 16bit integer output 633 634 ELSEIF ( PRESENT( values_int16_0d ) ) THEN 634 nc_stat = NF90_PUT_VAR( file_id, variable_id, (/ values_int16_0d /), &635 start = bounds_start - bounds_origin + 1, &635 nc_stat = NF90_PUT_VAR( file_id, variable_id, (/ values_int16_0d /), & 636 start = bounds_start - bounds_origin + 1, & 636 637 count = value_counts ) 637 638 ELSEIF ( PRESENT( values_int16_1d ) ) THEN 638 nc_stat = NF90_PUT_VAR( file_id, variable_id, values_int16_1d, &639 start = bounds_start - bounds_origin + 1, &639 nc_stat = NF90_PUT_VAR( file_id, variable_id, values_int16_1d, & 640 start = bounds_start - bounds_origin + 1, & 640 641 count = value_counts ) 641 642 ELSEIF ( PRESENT( values_int16_2d ) ) THEN 642 nc_stat = NF90_PUT_VAR( file_id, variable_id, values_int16_2d, &643 start = bounds_start - bounds_origin + 1, &643 nc_stat = NF90_PUT_VAR( file_id, variable_id, values_int16_2d, & 644 start = bounds_start - bounds_origin + 1, & 644 645 count = value_counts ) 645 646 ELSEIF ( PRESENT( values_int16_3d ) ) THEN 646 nc_stat = NF90_PUT_VAR( file_id, variable_id, values_int16_3d, &647 start = bounds_start - bounds_origin + 1, &647 nc_stat = NF90_PUT_VAR( file_id, variable_id, values_int16_3d, & 648 start = bounds_start - bounds_origin + 1, & 648 649 count = value_counts ) 649 650 ! 650 651 !-- 32bit integer output 651 652 ELSEIF ( PRESENT( values_int32_0d ) ) THEN 652 nc_stat = NF90_PUT_VAR( file_id, variable_id, (/ values_int32_0d /), &653 start = bounds_start - bounds_origin + 1, &653 nc_stat = NF90_PUT_VAR( file_id, variable_id, (/ values_int32_0d /), & 654 start = bounds_start - bounds_origin + 1, & 654 655 count = value_counts ) 655 656 ELSEIF ( PRESENT( values_int32_1d ) ) THEN 656 nc_stat = NF90_PUT_VAR( file_id, variable_id, values_int32_1d, &657 start = bounds_start - bounds_origin + 1, &657 nc_stat = NF90_PUT_VAR( file_id, variable_id, values_int32_1d, & 658 start = bounds_start - bounds_origin + 1, & 658 659 count = value_counts ) 659 660 ELSEIF ( PRESENT( values_int32_2d ) ) THEN 660 nc_stat = NF90_PUT_VAR( file_id, variable_id, values_int32_2d, &661 start = bounds_start - bounds_origin + 1, &661 nc_stat = NF90_PUT_VAR( file_id, variable_id, values_int32_2d, & 662 start = bounds_start - bounds_origin + 1, & 662 663 count = value_counts ) 663 664 ELSEIF ( PRESENT( values_int32_3d ) ) THEN 664 nc_stat = NF90_PUT_VAR( file_id, variable_id, values_int32_3d, &665 start = bounds_start - bounds_origin + 1, &666 count = value_counts ) 667 ! 668 !-- working-precision integer output665 nc_stat = NF90_PUT_VAR( file_id, variable_id, values_int32_3d, & 666 start = bounds_start - bounds_origin + 1, & 667 count = value_counts ) 668 ! 669 !-- Working-precision integer output 669 670 ELSEIF ( PRESENT( values_intwp_0d ) ) THEN 670 nc_stat = NF90_PUT_VAR( file_id, variable_id, (/ values_intwp_0d /), &671 start = bounds_start - bounds_origin + 1, &671 nc_stat = NF90_PUT_VAR( file_id, variable_id, (/ values_intwp_0d /), & 672 start = bounds_start - bounds_origin + 1, & 672 673 count = value_counts ) 673 674 ELSEIF ( PRESENT( values_intwp_1d ) ) THEN 674 nc_stat = NF90_PUT_VAR( file_id, variable_id, values_intwp_1d, &675 start = bounds_start - bounds_origin + 1, &675 nc_stat = NF90_PUT_VAR( file_id, variable_id, values_intwp_1d, & 676 start = bounds_start - bounds_origin + 1, & 676 677 count = value_counts ) 677 678 ELSEIF ( PRESENT( values_intwp_2d ) ) THEN 678 nc_stat = NF90_PUT_VAR( file_id, variable_id, values_intwp_2d, &679 start = bounds_start - bounds_origin + 1, &679 nc_stat = NF90_PUT_VAR( file_id, variable_id, values_intwp_2d, & 680 start = bounds_start - bounds_origin + 1, & 680 681 count = value_counts ) 681 682 ELSEIF ( PRESENT( values_intwp_3d ) ) THEN 682 nc_stat = NF90_PUT_VAR( file_id, variable_id, values_intwp_3d, &683 start = bounds_start - bounds_origin + 1, &683 nc_stat = NF90_PUT_VAR( file_id, variable_id, values_intwp_3d, & 684 start = bounds_start - bounds_origin + 1, & 684 685 count = value_counts ) 685 686 ! 686 687 !-- 32bit real output 687 688 ELSEIF ( PRESENT( values_real32_0d ) ) THEN 688 nc_stat = NF90_PUT_VAR( file_id, variable_id, (/ values_real32_0d /), &689 start = bounds_start - bounds_origin + 1, &689 nc_stat = NF90_PUT_VAR( file_id, variable_id, (/ values_real32_0d /), & 690 start = bounds_start - bounds_origin + 1, & 690 691 count = value_counts ) 691 692 ELSEIF ( PRESENT( values_real32_1d ) ) THEN 692 nc_stat = NF90_PUT_VAR( file_id, variable_id, values_real32_1d, &693 start = bounds_start - bounds_origin + 1, &693 nc_stat = NF90_PUT_VAR( file_id, variable_id, values_real32_1d, & 694 start = bounds_start - bounds_origin + 1, & 694 695 count = value_counts ) 695 696 ELSEIF ( PRESENT( values_real32_2d ) ) THEN 696 nc_stat = NF90_PUT_VAR( file_id, variable_id, values_real32_2d, &697 start = bounds_start - bounds_origin + 1, &697 nc_stat = NF90_PUT_VAR( file_id, variable_id, values_real32_2d, & 698 start = bounds_start - bounds_origin + 1, & 698 699 count = value_counts ) 699 700 ELSEIF ( PRESENT( values_real32_3d ) ) THEN 700 nc_stat = NF90_PUT_VAR( file_id, variable_id, values_real32_3d, &701 start = bounds_start - bounds_origin + 1, &701 nc_stat = NF90_PUT_VAR( file_id, variable_id, values_real32_3d, & 702 start = bounds_start - bounds_origin + 1, & 702 703 count = value_counts ) 703 704 ! 704 705 !-- 64bit real output 705 706 ELSEIF ( PRESENT( values_real64_0d ) ) THEN 706 nc_stat = NF90_PUT_VAR( file_id, variable_id, (/ values_real64_0d /), &707 start = bounds_start - bounds_origin + 1, &707 nc_stat = NF90_PUT_VAR( file_id, variable_id, (/ values_real64_0d /), & 708 start = bounds_start - bounds_origin + 1, & 708 709 count = value_counts ) 709 710 ELSEIF ( PRESENT( values_real64_1d ) ) THEN 710 nc_stat = NF90_PUT_VAR( file_id, variable_id, values_real64_1d, &711 start = bounds_start - bounds_origin + 1, &711 nc_stat = NF90_PUT_VAR( file_id, variable_id, values_real64_1d, & 712 start = bounds_start - bounds_origin + 1, & 712 713 count = value_counts ) 713 714 ELSEIF ( PRESENT( values_real64_2d ) ) THEN 714 nc_stat = NF90_PUT_VAR( file_id, variable_id, values_real64_2d, &715 start = bounds_start - bounds_origin + 1, &715 nc_stat = NF90_PUT_VAR( file_id, variable_id, values_real64_2d, & 716 start = bounds_start - bounds_origin + 1, & 716 717 count = value_counts ) 717 718 ELSEIF ( PRESENT( values_real64_3d ) ) THEN 718 nc_stat = NF90_PUT_VAR( file_id, variable_id, values_real64_3d, &719 start = bounds_start - bounds_origin + 1, &719 nc_stat = NF90_PUT_VAR( file_id, variable_id, values_real64_3d, & 720 start = bounds_start - bounds_origin + 1, & 720 721 count = value_counts ) 721 722 ! 722 723 !-- working-precision real output 723 724 ELSEIF ( PRESENT( values_realwp_0d ) ) THEN 724 nc_stat = NF90_PUT_VAR( file_id, variable_id, (/ values_realwp_0d /), &725 start = bounds_start - bounds_origin + 1, &725 nc_stat = NF90_PUT_VAR( file_id, variable_id, (/ values_realwp_0d /), & 726 start = bounds_start - bounds_origin + 1, & 726 727 count = value_counts ) 727 728 ELSEIF ( PRESENT( values_realwp_1d ) ) THEN 728 nc_stat = NF90_PUT_VAR( file_id, variable_id, values_realwp_1d, &729 start = bounds_start - bounds_origin + 1, &729 nc_stat = NF90_PUT_VAR( file_id, variable_id, values_realwp_1d, & 730 start = bounds_start - bounds_origin + 1, & 730 731 count = value_counts ) 731 732 ELSEIF ( PRESENT( values_realwp_2d ) ) THEN 732 nc_stat = NF90_PUT_VAR( file_id, variable_id, values_realwp_2d, &733 start = bounds_start - bounds_origin + 1, &733 nc_stat = NF90_PUT_VAR( file_id, variable_id, values_realwp_2d, & 734 start = bounds_start - bounds_origin + 1, & 734 735 count = value_counts ) 735 736 ELSEIF ( PRESENT( values_realwp_3d ) ) THEN 736 nc_stat = NF90_PUT_VAR( file_id, variable_id, values_realwp_3d, &737 start = bounds_start - bounds_origin + 1, &737 nc_stat = NF90_PUT_VAR( file_id, variable_id, values_realwp_3d, & 738 start = bounds_start - bounds_origin + 1, & 738 739 count = value_counts ) 739 740 ELSE … … 741 742 nc_stat = NF90_NOERR 742 743 WRITE( temp_string, '(": variable_id=",I6,", file_id=",I6)' ) variable_id, file_id 743 CALL internal_message( 'error', routine_name // &744 CALL internal_message( 'error', routine_name // & 744 745 ': no output values given ' // TRIM( temp_string ) ) 745 746 ENDIF … … 761 762 d = 1 762 763 DO WHILE ( d <= ndims .AND. nc_stat == NF90_NOERR ) 763 nc_stat = NF90_INQUIRE_DIMENSION( file_id, dimension_ids(d), &764 nc_stat = NF90_INQUIRE_DIMENSION( file_id, dimension_ids(d), & 764 765 LEN=dimension_lengths(d) ) 765 766 d = d + 1 … … 767 768 768 769 IF ( nc_stat == NF90_NOERR ) THEN 769 WRITE( temp_string, * ) TRIM( temp_string ) // '; given variable bounds: ' // &770 WRITE( temp_string, * ) TRIM( temp_string ) // '; given variable bounds: ' // & 770 771 'start=', bounds_start, ', count=', value_counts, ', origin=', bounds_origin 771 CALL internal_message( 'error', routine_name // &772 CALL internal_message( 'error', routine_name // & 772 773 ': error while writing: ' // TRIM( temp_string ) ) 773 774 ELSE 774 775 ! 775 776 !-- Error occured during NF90_INQUIRE_VARIABLE or NF90_INQUIRE_DIMENSION 776 CALL internal_message( 'error', routine_name // &777 ': error while accessing file: ' // &777 CALL internal_message( 'error', routine_name // & 778 ': error while accessing file: ' // & 778 779 NF90_STRERROR( nc_stat ) ) 779 780 ENDIF … … 782 783 ! 783 784 !-- Other NetCDF error 784 CALL internal_message( 'error', routine_name // &785 CALL internal_message( 'error', routine_name // & 785 786 ': error while writing: ' // NF90_STRERROR( nc_stat ) ) 786 787 ENDIF … … 810 811 #if defined( __netcdf4 ) 811 812 WRITE( temp_string, * ) file_id 812 CALL internal_message( 'debug', routine_name // &813 CALL internal_message( 'debug', routine_name // & 813 814 ': close file (file_id=' // TRIM( temp_string ) // ')' ) 814 815 … … 818 819 ELSE 819 820 return_value = 1 820 CALL internal_message( 'error', routine_name // &821 CALL internal_message( 'error', routine_name // & 821 822 ': NetCDF error: ' // NF90_STRERROR( nc_stat ) ) 822 823 ENDIF … … 834 835 FUNCTION get_netcdf_data_type( data_type ) RESULT( return_value ) 835 836 837 CHARACTER(LEN=*), PARAMETER :: routine_name = 'get_netcdf_data_type' !< name of this routine 838 836 839 CHARACTER(LEN=*), INTENT(IN) :: data_type !< requested data type 837 838 CHARACTER(LEN=*), PARAMETER :: routine_name = 'get_netcdf_data_type' !< name of this routine839 840 840 841 INTEGER :: return_value !< netcdf data type … … 864 865 865 866 CASE DEFAULT 866 CALL internal_message( 'error', routine_name // &867 CALL internal_message( 'error', routine_name // & 867 868 ': data type unknown (' // TRIM( data_type ) // ')' ) 868 869 return_value = -1 … … 875 876 ! Description: 876 877 ! ------------ 877 !> Message routine writing debug information into the debug file 878 !> or creating the error messagestring.878 !> Message routine writing debug information into the debug file or creating the error message 879 !> string. 879 880 !--------------------------------------------------------------------------------------------------! 880 881 SUBROUTINE internal_message( level, string ) -
TabularUnified palm/trunk/SOURCE/data_output_profiles.f90 ¶
r4360 r4577 1 1 !> @file data_output_profiles.f90 2 !------------------------------------------------------------------------------ !2 !--------------------------------------------------------------------------------------------------! 3 3 ! This file is part of the PALM model system. 4 4 ! 5 ! PALM is free software: you can redistribute it and/or modify it under the 6 ! terms of the GNU General Public License as published by the Free Software 7 ! Foundation, either version 3 of the License, or (at your option) any later 8 ! version. 9 ! 10 ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY 11 ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 12 ! A PARTICULAR PURPOSE. See the GNU General Public License for more details. 13 ! 14 ! You should have received a copy of the GNU General Public License along with 15 ! PALM. If not, see <http://www.gnu.org/licenses/>. 5 ! PALM is free software: you can redistribute it and/or modify it under the terms of the GNU General 6 ! Public License as published by the Free Software Foundation, either version 3 of the License, or 7 ! (at your option) any later version. 8 ! 9 ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the 10 ! implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 11 ! Public License for more details. 12 ! 13 ! You should have received a copy of the GNU General Public License along with PALM. If not, see 14 ! <http://www.gnu.org/licenses/>. 16 15 ! 17 16 ! Copyright 1997-2020 Leibniz Universitaet Hannover 18 !------------------------------------------------------------------------------ !17 !--------------------------------------------------------------------------------------------------! 19 18 ! 20 19 ! Current revisions: … … 25 24 ! ----------------- 26 25 ! $Id$ 26 ! file re-formatted to follow the PALM coding standard 27 ! 28 ! 4360 2020-01-07 11:25:50Z suehring 27 29 ! Corrected "Former revisions" section 28 ! 30 ! 29 31 ! 3655 2019-01-07 16:51:22Z knoop 30 32 ! add variable description … … 37 39 ! ------------ 38 40 !> Plot output of 1D-profiles for PROFIL 39 !------------------------------------------------------------------------------ !41 !--------------------------------------------------------------------------------------------------! 40 42 SUBROUTINE data_output_profiles 41 42 43 USE control_parameters, & 44 ONLY: average_count_pr, averaging_interval_pr, coupling_start_time, & 45 dopr_n, dopr_time_count, normalizing_region, & 46 time_since_reference_point 47 48 USE cpulog, & 43 44 45 USE control_parameters, & 46 ONLY: average_count_pr, averaging_interval_pr, coupling_start_time, & 47 dopr_n, dopr_time_count, normalizing_region, time_since_reference_point 48 49 USE cpulog, & 49 50 ONLY: cpu_log, log_point 50 51 51 USE indices, &52 USE indices, & 52 53 ONLY: nzb, nzt 53 54 … … 58 59 #endif 59 60 60 USE netcdf_interface, &61 ONLY: id_set_pr, id_var_dopr, id_var_norm_dopr, id_var_time_pr, &62 n c_stat, netcdf_handle_error, output_for_t061 USE netcdf_interface, & 62 ONLY: id_set_pr, id_var_dopr, id_var_norm_dopr, id_var_time_pr, nc_stat, & 63 netcdf_handle_error, output_for_t0 63 64 64 65 USE pegrid … … 66 67 USE profil_parameter 67 68 68 USE statistics, &69 USE statistics, & 69 70 ONLY: flow_statistics_called, hom, hom_sum, pr_palm, statistic_regions 70 71 … … 92 93 ELSE 93 94 ! 94 !-- This case may happen if dt_dopr is changed in the 95 !-- runtime_parameters-list of a restart run 95 !-- This case may happen if dt_dopr is changed in the runtime_parameters-list of a restart run 96 96 RETURN 97 97 ENDIF 98 98 ENDIF 99 99 100 100 101 101 IF ( myid == 0 ) THEN 102 102 … … 115 115 !-- Output of initial profiles 116 116 IF ( dopr_time_count == 1 ) THEN 117 118 IF ( .NOT. output_for_t0 ) THEN 119 120 #if defined( __netcdf ) 121 ! 122 !-- Store initial time to time axis, but only if an output 123 !-- is required for at least one of the profiles. The initial time 124 !-- is either 0, or, in case of a prerun for coupled atmosphere-ocean 125 !-- runs, has a negative value 117 118 IF ( .NOT. output_for_t0 ) THEN 119 120 #if defined( __netcdf ) 121 ! 122 !-- Store initial time to time axis, but only if an output is required for at least one of 123 !-- the profiles. The initial time is either 0, or, in case of a prerun for coupled 124 !-- atmosphere-ocean runs, has a negative value 126 125 DO i = 1, dopr_n 127 126 IF ( dopr_initial_index(i) /= 0 ) THEN 128 nc_stat = NF90_PUT_VAR( id_set_pr, id_var_time_pr, &129 (/ -coupling_start_time /),&130 start = (/ 1 /), count = (/ 1 /) )127 nc_stat = NF90_PUT_VAR( id_set_pr, id_var_time_pr, & 128 (/ -coupling_start_time /), & 129 start = (/ 1 /), count = (/ 1 /) ) 131 130 CALL netcdf_handle_error( 'data_output_profiles', 329 ) 132 131 output_for_t0 = .TRUE. … … 138 137 !-- Store normalization factors 139 138 nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(1), & ! wpt0 140 (/ hom_sum(nzb,18,normalizing_region) /),&139 (/ hom_sum(nzb,18,normalizing_region) /), & 141 140 start = (/ 1 /), count = (/ 1 /) ) 142 141 CALL netcdf_handle_error( 'data_output_profiles', 330 ) 143 142 144 143 nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(2), & ! ws2 145 (/ hom_sum(nzb+8,pr_palm,normalizing_region)**2 /),&144 (/ hom_sum(nzb+8,pr_palm,normalizing_region)**2 /), & 146 145 start = (/ 1 /), count = (/ 1 /) ) 147 146 CALL netcdf_handle_error( 'data_output_profiles', 331 ) 148 147 nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(3), & ! tsw2 149 (/ hom_sum(nzb+3,pr_palm,normalizing_region)**2 /),&150 start = (/ 1 /), count = (/ 1 /) )148 (/ hom_sum(nzb+3,pr_palm,normalizing_region)**2 /), & 149 start = (/ 1 /), count = (/ 1 /) ) 151 150 CALL netcdf_handle_error( 'data_output_profiles', 332 ) 152 151 nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(4), & ! ws3 153 (/ hom_sum(nzb+8,pr_palm,normalizing_region)**3 /),&152 (/ hom_sum(nzb+8,pr_palm,normalizing_region)**3 /), & 154 153 start = (/ 1 /), count = (/ 1 /) ) 155 154 CALL netcdf_handle_error( 'data_output_profiles', 333 ) 156 155 157 nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(5), & !ws2tsw158 (/ hom_sum(nzb+8,pr_palm,normalizing_region)**3 *&159 hom_sum(nzb+3,pr_palm,normalizing_region) /),&156 nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(5), & ! ws2tsw 157 (/ hom_sum(nzb+8,pr_palm,normalizing_region)**3 * & 158 hom_sum(nzb+3,pr_palm,normalizing_region) /), & 160 159 start = (/ 1 /), count = (/ 1 /) ) 161 160 CALL netcdf_handle_error( 'data_output_profiles', 334 ) 162 161 163 nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(6), & !wstsw2164 (/ hom_sum(nzb+8,pr_palm,normalizing_region) *&165 hom_sum(nzb+3,pr_palm,normalizing_region)**2 /),&162 nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(6), & ! wstsw2 163 (/ hom_sum(nzb+8,pr_palm,normalizing_region) * & 164 hom_sum(nzb+3,pr_palm,normalizing_region)**2 /), & 166 165 start = (/ 1 /), count = (/ 1 /) ) 167 166 CALL netcdf_handle_error( 'data_output_profiles', 335 ) 168 167 169 168 nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(7), & ! z_i 170 (/ hom_sum(nzb+6,pr_palm,normalizing_region) /),&169 (/ hom_sum(nzb+6,pr_palm,normalizing_region) /), & 171 170 start = (/ 1 /), count = (/ 1 /) ) 172 171 CALL netcdf_handle_error( 'data_output_profiles', 336 ) 173 172 174 173 #endif 175 174 ! … … 186 185 ! 187 186 !-- Write data to netcdf file 188 nc_stat = NF90_PUT_VAR( id_set_pr, id_var_dopr(i,sr), &189 hom(nzb:nzt+1,1,dopr_initial_index(i),sr),&190 start = (/ 1, 1 /), &187 nc_stat = NF90_PUT_VAR( id_set_pr, id_var_dopr(i,sr), & 188 hom(nzb:nzt+1,1,dopr_initial_index(i),sr), & 189 start = (/ 1, 1 /), & 191 190 count = (/ nzt-nzb+2, 1 /) ) 192 191 CALL netcdf_handle_error( 'data_output_profiles', 337 ) … … 210 209 ! 211 210 !-- Store time to time axis 212 nc_stat = NF90_PUT_VAR( id_set_pr, id_var_time_pr, &213 (/ time_since_reference_point /), &214 start = (/ dopr_time_count /), &211 nc_stat = NF90_PUT_VAR( id_set_pr, id_var_time_pr, & 212 (/ time_since_reference_point /), & 213 start = (/ dopr_time_count /), & 215 214 count = (/ 1 /) ) 216 215 CALL netcdf_handle_error( 'data_output_profiles', 338 ) … … 219 218 !-- Store normalization factors 220 219 nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(1), & ! wpt0 221 (/ hom_sum(nzb,18,normalizing_region) /), & 220 (/ hom_sum(nzb,18,normalizing_region) /), & 221 start = (/ dopr_time_count /), & 222 count = (/ 1 /) ) 223 CALL netcdf_handle_error( 'data_output_profiles', 339 ) 224 225 nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(2), & ! ws2 226 (/ hom_sum(nzb+8,pr_palm,normalizing_region)**2 /), & 227 start = (/ dopr_time_count /), & 228 count = (/ 1 /) ) 229 CALL netcdf_handle_error( 'data_output_profiles', 340 ) 230 231 nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(3), & ! tsw2 232 (/ hom_sum(nzb+3,pr_palm,normalizing_region)**2 /), & 233 start = (/ dopr_time_count /), & 234 count = (/ 1 /) ) 235 CALL netcdf_handle_error( 'data_output_profiles', 341 ) 236 237 nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(4), & ! ws3 238 (/ hom_sum(nzb+8,pr_palm,normalizing_region)**3 /), & 239 start = (/ dopr_time_count /), & 240 count = (/ 1 /) ) 241 CALL netcdf_handle_error( 'data_output_profiles', 342 ) 242 243 nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(5), & ! ws2tsw 244 (/ hom_sum(nzb+8,pr_palm,normalizing_region)**3 * & 245 hom_sum(nzb+3,pr_palm,normalizing_region) /), & 222 246 start = (/ dopr_time_count /), & 223 247 count = (/ 1 /) ) 224 CALL netcdf_handle_error( 'data_output_profiles', 339 )225 226 nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(2), & ! ws2227 (/ hom_sum(nzb+8,pr_palm,normalizing_region)**2 /), &228 start = (/ dopr_time_count /), &229 count = (/ 1 /) )230 CALL netcdf_handle_error( 'data_output_profiles', 340 )231 232 nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(3), & ! tsw2233 (/ hom_sum(nzb+3,pr_palm,normalizing_region)**2 /), &234 start = (/ dopr_time_count /), &235 count = (/ 1 /) )236 CALL netcdf_handle_error( 'data_output_profiles', 341 )237 238 nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(4), & ! ws3239 (/ hom_sum(nzb+8,pr_palm,normalizing_region)**3 /), &240 start = (/ dopr_time_count /), &241 count = (/ 1 /) )242 CALL netcdf_handle_error( 'data_output_profiles', 342 )243 244 nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(5), & ! ws2tsw245 (/ hom_sum(nzb+8,pr_palm,normalizing_region)**3 * &246 hom_sum(nzb+3,pr_palm,normalizing_region) /), &247 start = (/ dopr_time_count /), &248 count = (/ 1 /) )249 248 CALL netcdf_handle_error( 'data_output_profiles', 343 ) 250 249 251 250 nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(6), & ! wstsw2 252 (/ hom_sum(nzb+8,pr_palm,normalizing_region) *&253 hom_sum(nzb+3,pr_palm,normalizing_region)**2 /),&254 start = (/ dopr_time_count /), &251 (/ hom_sum(nzb+8,pr_palm,normalizing_region) * & 252 hom_sum(nzb+3,pr_palm,normalizing_region)**2 /), & 253 start = (/ dopr_time_count /), & 255 254 count = (/ 1 /) ) 256 255 CALL netcdf_handle_error( 'data_output_profiles', 344 ) 257 256 258 257 nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(7), & ! z_i 259 (/ hom_sum(nzb+6,pr_palm,normalizing_region) /),&260 start = (/ dopr_time_count /), &258 (/ hom_sum(nzb+6,pr_palm,normalizing_region) /), & 259 start = (/ dopr_time_count /), & 261 260 count = (/ 1 /) ) 262 261 CALL netcdf_handle_error( 'data_output_profiles', 345 ) … … 274 273 ! 275 274 !-- Write data to netcdf file 276 nc_stat = NF90_PUT_VAR( id_set_pr, id_var_dopr(i,sr), &277 hom_sum(nzb:nzt+1,dopr_index(i),sr), &278 start = (/ 1, dopr_time_count /), &275 nc_stat = NF90_PUT_VAR( id_set_pr, id_var_dopr(i,sr), & 276 hom_sum(nzb:nzt+1,dopr_index(i),sr), & 277 start = (/ 1, dopr_time_count /), & 279 278 count = (/ nzt-nzb+2, 1 /) ) 280 279 CALL netcdf_handle_error( 'data_output_profiles', 346 ) -
TabularUnified palm/trunk/SOURCE/data_output_spectra.f90 ¶
r4360 r4577 1 1 !> @file data_output_spectra.f90 2 !------------------------------------------------------------------------------ !2 !--------------------------------------------------------------------------------------------------! 3 3 ! This file is part of the PALM model system. 4 4 ! 5 ! PALM is free software: you can redistribute it and/or modify it under the 6 ! terms of the GNU General Public License as published by the Free Software 7 ! Foundation, either version 3 of the License, or (at your option) any later 8 ! version. 9 ! 10 ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY 11 ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 12 ! A PARTICULAR PURPOSE. See the GNU General Public License for more details. 13 ! 14 ! You should have received a copy of the GNU General Public License along with 15 ! PALM. If not, see <http://www.gnu.org/licenses/>. 5 ! PALM is free software: you can redistribute it and/or modify it under the terms of the GNU General 6 ! Public License as published by the Free Software Foundation, either version 3 of the License, or 7 ! (at your option) any later version. 8 ! 9 ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the 10 ! implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 11 ! Public License for more details. 12 ! 13 ! You should have received a copy of the GNU General Public License along with PALM. If not, see 14 ! <http://www.gnu.org/licenses/>. 16 15 ! 17 16 ! Copyright 1997-2020 Leibniz Universitaet Hannover 18 !------------------------------------------------------------------------------ !17 !--------------------------------------------------------------------------------------------------! 19 18 ! 20 19 ! Current revisions: … … 25 24 ! ----------------- 26 25 ! $Id$ 26 ! file re-formatted to follow the PALM coding standard 27 ! 28 ! 4360 2020-01-07 11:25:50Z suehring 27 29 ! Corrected "Former revisions" section 28 ! 30 ! 29 31 ! 3655 2019-01-07 16:51:22Z knoop 30 32 ! variables documented … … 38 40 !> Writing spectra data on file, using a special format which allows 39 41 !> plotting of these data with PROFIL-graphic-software 40 !------------------------------------------------------------------------------ !42 !--------------------------------------------------------------------------------------------------! 41 43 SUBROUTINE data_output_spectra 42 44 43 45 #if defined( __netcdf ) 44 USE control_parameters, &46 USE control_parameters, & 45 47 ONLY: message_string, time_since_reference_point 46 48 47 USE cpulog, &49 USE cpulog, & 48 50 ONLY: cpu_log, log_point 49 51 … … 52 54 USE NETCDF 53 55 54 USE netcdf_interface, &56 USE netcdf_interface, & 55 57 ONLY: id_set_sp, id_var_time_sp, nc_stat, netcdf_handle_error 56 58 57 59 USE pegrid 58 60 59 USE spectra_mod, & 60 ONLY: average_count_sp, averaging_interval_sp, comp_spectra_level, & 61 data_output_sp, dosp_time_count, spectra_direction, spectrum_x, & 62 spectrum_y 61 USE spectra_mod, & 62 ONLY: average_count_sp, averaging_interval_sp, comp_spectra_level, data_output_sp, & 63 dosp_time_count, spectra_direction, spectrum_x, spectrum_y 63 64 64 65 … … 67 68 INTEGER(iwp) :: m !< running index over spectra output 68 69 INTEGER(iwp) :: pr !< index used to assign default quantities to data output 69 70 70 71 CALL cpu_log( log_point(31), 'data_output_spectra', 'start' ) 71 72 … … 88 89 ! 89 90 !-- Update the spectra time axis 90 nc_stat = NF90_PUT_VAR( id_set_sp, id_var_time_sp, &91 (/ time_since_reference_point /), &91 nc_stat = NF90_PUT_VAR( id_set_sp, id_var_time_sp, & 92 (/ time_since_reference_point /), & 92 93 start = (/ dosp_time_count /), count = (/ 1 /) ) 93 94 CALL netcdf_handle_error( 'data_output_spectra', 47 ) … … 96 97 !-- If necessary, calculate time average and reset average counter 97 98 IF ( average_count_sp == 0 ) THEN 98 99 99 message_string = 'no spectra data available' 100 CALL message( 'data_output_spectra', 'PA0186', 0, 0, 0, 6, 0 ) 100 101 ENDIF 101 102 IF ( average_count_sp /= 1 ) THEN … … 132 133 CASE DEFAULT 133 134 ! 134 !-- The DEFAULT case is reached either if the parameter 135 !-- data_output_sp(m) contains a wrong character string or if the 136 !-- user has coded a special case in the user interface. There, the 137 !-- subroutine user_spectra checks which of these two conditions 135 !-- The DEFAULT case is reached either if the parameter data_output_sp(m) contains a 136 !-- wrong character string or if the user has coded a special case in the user 137 !-- interface. There, the subroutine user_spectra checks which of these two conditions 138 138 !-- applies. 139 139 CALL user_spectra( 'data_output', m, pr ) … … 175 175 176 176 177 !------------------------------------------------------------------------------ !177 !--------------------------------------------------------------------------------------------------! 178 178 ! Description: 179 179 ! ------------ 180 180 !> @todo Missing subroutine description. 181 !------------------------------------------------------------------------------ !181 !--------------------------------------------------------------------------------------------------! 182 182 SUBROUTINE output_spectra_netcdf( nsp, direction ) 183 183 #if defined( __netcdf ) 184 184 185 USE basic_constants_and_equations_mod, &185 USE basic_constants_and_equations_mod, & 186 186 ONLY: pi 187 187 188 USE grid_variables, &188 USE grid_variables, & 189 189 ONLY: dx, dy 190 190 191 USE indices, &191 USE indices, & 192 192 ONLY: nx, ny 193 193 … … 196 196 USE NETCDF 197 197 198 USE netcdf_interface, & 199 ONLY: id_set_sp, id_var_dospx, id_var_dospy, nc_stat, & 200 netcdf_handle_error 201 202 USE spectra_mod, & 198 USE netcdf_interface, & 199 ONLY: id_set_sp, id_var_dospx, id_var_dospy, nc_stat, netcdf_handle_error 200 201 USE spectra_mod, & 203 202 ONLY: dosp_time_count, n_sp_x, n_sp_y, spectrum_x, spectrum_y 204 203 … … 228 227 ENDDO 229 228 230 nc_stat = NF90_PUT_VAR( id_set_sp, id_var_dospx(nsp), netcdf_data_x, &231 start = (/ 1, k, dosp_time_count /), &229 nc_stat = NF90_PUT_VAR( id_set_sp, id_var_dospx(nsp), netcdf_data_x, & 230 start = (/ 1, k, dosp_time_count /), & 232 231 count = (/ nx/2, 1, 1 /) ) 233 232 CALL netcdf_handle_error( 'data_output_spectra', 348 ) … … 246 245 ENDDO 247 246 248 nc_stat = NF90_PUT_VAR( id_set_sp, id_var_dospy(nsp), netcdf_data_y, &249 start = (/ 1, k, dosp_time_count /), &247 nc_stat = NF90_PUT_VAR( id_set_sp, id_var_dospy(nsp), netcdf_data_y, & 248 start = (/ 1, k, dosp_time_count /), & 250 249 count = (/ ny/2, 1, 1 /) ) 251 250 CALL netcdf_handle_error( 'data_output_spectra', 349 ) -
TabularUnified palm/trunk/SOURCE/surface_data_output_mod.f90 ¶
r4547 r4577 1 1 !> @file surface_data_output_mod.f90 2 !------------------------------------------------------------------------------ !2 !--------------------------------------------------------------------------------------------------! 3 3 ! This file is part of the PALM model system. 4 4 ! 5 ! PALM is free software: you can redistribute it and/or modify it under the 6 ! terms of the GNU General Public License as published by the Free Software 7 ! Foundation, either version 3 of the License, or (at your option) any later 8 ! version. 9 ! 10 ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY 11 ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 12 ! A PARTICULAR PURPOSE. See the GNU General Public License for more details. 13 ! 14 ! You should have received a copy of the GNU General Public License along with 15 ! PALM. If not, see <http://www.gnu.org/licenses/>. 5 ! PALM is free software: you can redistribute it and/or modify it under the terms of the GNU General 6 ! Public License as published by the Free Software Foundation, either version 3 of the License, or 7 ! (at your option) any later version. 8 ! 9 ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the 10 ! implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 11 ! Public License for more details. 12 ! 13 ! You should have received a copy of the GNU General Public License along with PALM. If not, see 14 ! <http://www.gnu.org/licenses/>. 16 15 ! 17 16 ! Copyright 1997-2020 Leibniz Universitaet Hannover 18 !------------------------------------------------------------------------------! 17 !--------------------------------------------------------------------------------------------------! 18 ! 19 19 ! 20 20 ! Current revisions: 21 ! ----------------- -21 ! ----------------- 22 22 ! 23 23 ! … … 25 25 ! ----------------- 26 26 ! $Id$ 27 ! Added surface albedo and emissivity, which are defined using 28 ! the tile approach 29 ! 27 ! File re-formatted to follow the PALM coding standard 28 ! 29 ! 30 ! 4547 2020-05-27 09:05:24Z moh.hefny 31 ! Added surface albedo and emissivity, which are defined using the tile approach 32 ! 30 33 ! 4535 2020-05-15 12:07:23Z raasch 31 ! bugfix for restart data format query32 ! 34 ! Bugfix for restart data format query 35 ! 33 36 ! 4535 2020-05-15 12:07:23Z raasch 34 ! bugfix for restart data format query35 ! 37 ! Bugfix for restart data format query 38 ! 36 39 ! 4517 2020-05-03 14:29:30Z raasch 37 ! added restart with MPI-IO for reading local arrays38 ! 40 ! Added restart with MPI-IO for reading local arrays 41 ! 39 42 ! 4502 2020-04-17 16:14:16Z schwenkel 40 43 ! Implementation of ice microphysics 41 ! 44 ! 42 45 ! 4500 2020-04-17 10:12:45Z suehring 43 46 ! - Correct output of ground/wall heat flux at USM surfaces … … 45 48 ! 46 49 ! 4495 2020-04-13 20:11:20Z raasch 47 ! restart data handling with MPI-IO added48 ! 50 ! Restart data handling with MPI-IO added 51 ! 49 52 ! 4444 2020-03-05 15:59:50Z raasch 50 ! bugfix: cpp-directives for serial mode added51 ! 53 ! Bugfix: cpp-directives for serial mode added 54 ! 52 55 ! 4360 2020-01-07 11:25:50Z suehring 53 56 ! Fix wrongly declared nc_stat variable in surface_data_output_mod 54 ! 57 ! 55 58 ! 4205 2019-08-30 13:25:00Z suehring 56 59 ! - Correct x,y-coordinates of vertical surfaces in netcdf output 57 60 ! - Change definition of azimuth angle, reference is north 0 degree 58 ! - zenith angle is always defined, also for vertical surfaces where it is 59 ! 90 degree, while azimuth angle is only defined for vertical surfaces, not 60 ! for horizontal ones 61 ! 61 ! - Zenith angle is always defined, also for vertical surfaces where it is 90 degree, while azimuth 62 ! angle is only defined for vertical surfaces, not for horizontal ones 63 ! 62 64 ! 4182 2019-08-22 15:20:23Z scharf 63 65 ! Corrected "Former revisions" section 64 ! 66 ! 65 67 ! 4129 2019-07-31 12:56:07Z gronemeier 66 ! - bugfix: corrected loop over horizontal default surfaces67 ! - change default setting of to_vtk and to_netcdf68 ! - Bugfix: corrected loop over horizontal default surfaces 69 ! - Change default setting of to_vtk and to_netcdf 68 70 ! 69 71 ! 4029 2019-06-14 14:04:35Z raasch 70 ! netcdf variable NF90_NOFILL is used as argument instead of "1" in call to NF90_DEF_VAR_FILL72 ! Netcdf variable NF90_NOFILL is used as argument instead of "1" in call to NF90_DEF_VAR_FILL 71 73 ! 72 74 ! 3881 2019-04-10 09:31:22Z suehring … … 77 79 ! 78 80 ! 3766 2019-02-26 16:23:41Z raasch 79 ! bugfix in surface_data_output_rrd_local (variable k removed)81 ! Bugfix in surface_data_output_rrd_local (variable k removed) 80 82 ! 81 83 ! 3762 2019-02-25 16:54:16Z suehring 82 ! Remove unused variables and add preprocessor directives for variables that 83 ! are used only whennetcdf4 is defined84 ! Remove unused variables and add preprocessor directives for variables that are used only when 85 ! netcdf4 is defined 84 86 ! 85 87 ! 3745 2019-02-15 18:57:56Z suehring … … 87 89 ! 88 90 ! 3744 2019-02-15 18:38:58Z suehring 89 ! Add azimuth and zenith to output file; set long-name attributes; 90 ! clean-up coding layout 91 ! Add azimuth and zenith to output file; set long-name attributes; clean-up coding layout 91 92 ! 92 93 ! 3735 2019-02-12 09:52:40Z suehring 93 ! - Split initialization into initialization of arrays and further initialization 94 ! in order to enablereading of restart data.94 ! - Split initialization into initialization of arrays and further initialization in order to enable 95 ! reading of restart data. 95 96 ! - Consider restarts in surface data averaging. 96 97 ! - Correct error message numbers … … 115 116 ! @author Klaus Ketelsen, Matthias Suehring, Tobias Gronemeier 116 117 ! 118 !--------------------------------------------------------------------------------------------------! 117 119 ! Description: 118 120 ! ------------ … … 120 122 !> 121 123 !> @todo Create namelist file for post-processing tool. 122 !------------------------------------------------------------------------------ !124 !--------------------------------------------------------------------------------------------------! 123 125 124 126 MODULE surface_data_output_mod … … 134 136 135 137 USE control_parameters, & 136 ONLY: coupling_char, data_output_during_spinup, end_time, & 138 ONLY: coupling_char, & 139 data_output_during_spinup, & 140 end_time, & 137 141 message_string, & 138 restart_data_format_output, run_description_header, simulated_time_at_begin, & 139 spinup_time, surface_output 140 141 USE grid_variables, & 142 ONLY: dx,dy 143 144 USE indices, & 145 ONLY: nxl, nxr, nys, nyn, nzb, nzt 142 restart_data_format_output, & 143 run_description_header, & 144 simulated_time_at_begin, & 145 spinup_time, & 146 surface_output 147 148 USE grid_variables, & 149 ONLY: dx, & 150 dy 151 152 USE indices, & 153 ONLY: nxl, & 154 nxr, & 155 nys, & 156 nyn, & 157 nzb, & 158 nzt 146 159 147 160 #if defined( __netcdf ) … … 149 162 #endif 150 163 151 USE netcdf_data_input_mod, &164 USE netcdf_data_input_mod, & 152 165 ONLY: init_model 153 166 154 USE netcdf_interface, & 155 ONLY: nc_stat, netcdf_create_att, netcdf_create_dim, & 156 netcdf_create_file, netcdf_create_global_atts, & 157 netcdf_create_var, netcdf_data_format, netcdf_handle_error 167 USE netcdf_interface, & 168 ONLY: nc_stat, & 169 netcdf_create_att, & 170 netcdf_create_dim, & 171 netcdf_create_file, & 172 netcdf_create_global_atts, & 173 netcdf_create_var, & 174 netcdf_data_format, & 175 netcdf_handle_error 158 176 159 177 USE pegrid 160 178 161 179 USE restart_data_mpi_io_mod, & 162 ONLY: rd_mpi_io_check_array, rrd_mpi_io, wrd_mpi_io 180 ONLY: rd_mpi_io_check_array, & 181 rrd_mpi_io, & 182 wrd_mpi_io 163 183 164 184 USE surface_mod, & … … 182 202 INTEGER(iwp) :: npoints_total !< total number of points / vertices which define a surface element 183 203 184 INTEGER(iwp), DIMENSION(:), ALLOCATABLE :: s!< coordinate for NetCDF output, number of the surface element185 186 REAL(wp) :: fillvalue = -9999.0_wp !< fillvalue for surface elements which are not defined187 188 REAL(wp), DIMENSION(:), ALLOCATABLE :: azimuth !< azimuth orientation coordinate for NetCDF output189 REAL(wp), DIMENSION(:), ALLOCATABLE :: es_utm !< E-UTM coordinate for NetCDF output190 REAL(wp), DIMENSION(:), ALLOCATABLE :: ns_utm !< E-UTM coordinate for NetCDF output191 REAL(wp), DIMENSION(:), ALLOCATABLE :: xs !< x-coordinate for NetCDF output192 REAL(wp), DIMENSION(:), ALLOCATABLE :: ys !< y-coordinate for NetCDF output193 REAL(wp), DIMENSION(:), ALLOCATABLE :: zs !< z-coordinate for NetCDF output194 REAL(wp), DIMENSION(:), ALLOCATABLE :: zenith !< zenith orientation coordinate for NetCDF output195 REAL(wp), DIMENSION(:), ALLOCATABLE :: var_out !< output variables196 REAL(wp), DIMENSION(:,:), ALLOCATABLE :: var_av !< variables used for averaging197 REAL(wp), DIMENSION(:,:), ALLOCATABLE :: points !< points / vertices of a surface element198 REAL(wp), DIMENSION(:,:), ALLOCATABLE :: polygons !< polygon data of a surface element204 INTEGER(iwp), DIMENSION(:), ALLOCATABLE :: s !< coordinate for NetCDF output, number of the surface element 205 206 REAL(wp) :: fillvalue = -9999.0_wp !< fillvalue for surface elements which are not defined 207 208 REAL(wp), DIMENSION(:), ALLOCATABLE :: azimuth !< azimuth orientation coordinate for NetCDF output 209 REAL(wp), DIMENSION(:), ALLOCATABLE :: es_utm !< E-UTM coordinate for NetCDF output 210 REAL(wp), DIMENSION(:), ALLOCATABLE :: ns_utm !< E-UTM coordinate for NetCDF output 211 REAL(wp), DIMENSION(:), ALLOCATABLE :: xs !< x-coordinate for NetCDF output 212 REAL(wp), DIMENSION(:), ALLOCATABLE :: ys !< y-coordinate for NetCDF output 213 REAL(wp), DIMENSION(:), ALLOCATABLE :: zs !< z-coordinate for NetCDF output 214 REAL(wp), DIMENSION(:), ALLOCATABLE :: zenith !< zenith orientation coordinate for NetCDF output 215 REAL(wp), DIMENSION(:), ALLOCATABLE :: var_out !< output variables 216 REAL(wp), DIMENSION(:,:), ALLOCATABLE :: var_av !< variables used for averaging 217 REAL(wp), DIMENSION(:,:), ALLOCATABLE :: points !< points / vertices of a surface element 218 REAL(wp), DIMENSION(:,:), ALLOCATABLE :: polygons !< polygon data of a surface element 199 219 END TYPE surf_out 200 220 201 CHARACTER(LEN=100), DIMENSION(300) :: data_output_surf = ' ' !< namelist variable which describes the output variables 202 CHARACTER(LEN=100), DIMENSION(0:1,300) :: dosurf = ' ' !< internal variable which describes the output variables 203 !< and separates averaged from non-averaged output 204 CHARACTER(LEN=100), DIMENSION(0:1,300) :: dosurf_unit = ' ' !< internal variable which holds the unit of the given output variable 205 206 INTEGER(iwp) :: average_count_surf = 0 !< number of ensemble members used for averaging 207 INTEGER(iwp) :: dosurf_no(0:1) = 0 !< number of surface output quantities 221 CHARACTER(LEN=100), DIMENSION(300) :: data_output_surf = ' ' !< namelist variable which describes the output variables 222 CHARACTER(LEN=100), DIMENSION(0:1,300) :: dosurf = ' ' !< internal variable which describes the output variables 223 !< and separates averaged from non-averaged output 224 CHARACTER(LEN=100), DIMENSION(0:1,300) :: dosurf_unit = ' ' !< internal variable which holds the unit of the given output 225 !< variable 226 227 INTEGER(iwp) :: average_count_surf = 0 !< number of ensemble members used for averaging 228 INTEGER(iwp) :: dosurf_no(0:1) = 0 !< number of surface output quantities 208 229 #if defined( __netcdf4_parallel ) 209 INTEGER(iwp) :: oldmode 210 211 INTEGER(iwp), DIMENSION(0:1) :: dosurf_time_count = 0 !< count of output time steps212 INTEGER(iwp), DIMENSION(0:1) :: id_dim_s_surf !< netcdf ID for dimension s213 INTEGER(iwp), DIMENSION(0:1) :: id_dim_time_surf !< netcdf ID for dimension time214 INTEGER(iwp), DIMENSION(0:1) :: id_set_surf !< netcdf ID for file215 INTEGER(iwp), DIMENSION(0:1) :: id_var_azimuth_surf !< netcdf ID for variable azimuth216 INTEGER(iwp), DIMENSION(0:1) :: id_var_etum_surf !< netcdf ID for variable Es_UTM217 INTEGER(iwp), DIMENSION(0:1) :: id_var_nutm_surf !< netcdf ID for variable Ns_UTM218 INTEGER(iwp), DIMENSION(0:1) :: id_var_time_surf !< netcdf ID for variable time219 INTEGER(iwp), DIMENSION(0:1) :: id_var_s_surf !< netcdf ID for variable s220 INTEGER(iwp), DIMENSION(0:1) :: id_var_xs_surf !< netcdf ID for variable xs221 INTEGER(iwp), DIMENSION(0:1) :: id_var_ys_surf !< netcdf ID for variable ys222 INTEGER(iwp), DIMENSION(0:1) :: id_var_zenith_surf !< netcdf ID for variable zenith223 INTEGER(iwp), DIMENSION(0:1) :: id_var_zs_surf !< netcdf ID for variable zs224 INTEGER(iwp), DIMENSION(0:1) :: ntdim_surf !< number of output time steps225 226 INTEGER(iwp), DIMENSION(0:1,300) :: id_var_dosurf !< netcdf ID for output variables230 INTEGER(iwp) :: oldmode !< save old set-fill-mode of netcdf file (not needed, but required for routine call) 231 232 INTEGER(iwp), DIMENSION(0:1) :: dosurf_time_count = 0 !< count of output time steps 233 INTEGER(iwp), DIMENSION(0:1) :: id_dim_s_surf !< netcdf ID for dimension s 234 INTEGER(iwp), DIMENSION(0:1) :: id_dim_time_surf !< netcdf ID for dimension time 235 INTEGER(iwp), DIMENSION(0:1) :: id_set_surf !< netcdf ID for file 236 INTEGER(iwp), DIMENSION(0:1) :: id_var_azimuth_surf !< netcdf ID for variable azimuth 237 INTEGER(iwp), DIMENSION(0:1) :: id_var_etum_surf !< netcdf ID for variable Es_UTM 238 INTEGER(iwp), DIMENSION(0:1) :: id_var_nutm_surf !< netcdf ID for variable Ns_UTM 239 INTEGER(iwp), DIMENSION(0:1) :: id_var_time_surf !< netcdf ID for variable time 240 INTEGER(iwp), DIMENSION(0:1) :: id_var_s_surf !< netcdf ID for variable s 241 INTEGER(iwp), DIMENSION(0:1) :: id_var_xs_surf !< netcdf ID for variable xs 242 INTEGER(iwp), DIMENSION(0:1) :: id_var_ys_surf !< netcdf ID for variable ys 243 INTEGER(iwp), DIMENSION(0:1) :: id_var_zenith_surf !< netcdf ID for variable zenith 244 INTEGER(iwp), DIMENSION(0:1) :: id_var_zs_surf !< netcdf ID for variable zs 245 INTEGER(iwp), DIMENSION(0:1) :: ntdim_surf !< number of output time steps 246 247 INTEGER(iwp), DIMENSION(0:1,300) :: id_var_dosurf !< netcdf ID for output variables 227 248 #endif 228 249 229 LOGICAL :: first_output(0:1) = .FALSE.!< true if first output was already called230 LOGICAL :: to_netcdf = .FALSE.!< flag indicating parallel NetCDF output231 LOGICAL :: to_vtk = .FALSE.!< flag indicating binary surface-data output that can be further232 233 234 REAL(wp) :: averaging_interval_surf = 9999999.9_wp 235 REAL(wp) :: dt_dosurf = 9999999.9_wp!< time interval for instantaneous data output236 REAL(wp) :: dt_dosurf_av = 9999999.9_wp!< time interval for averaged data output237 REAL(wp) :: skip_time_dosurf = 0.0_wp!< skip time for instantaneous data output238 REAL(wp) :: skip_time_dosurf_av = 0.0_wp!< skip time for averaged data output239 REAL(wp) :: time_dosurf = 0.0_wp!< internal counter variable to check for instantaneous data output240 REAL(wp) :: time_dosurf_av = 0.0_wp!< internal counter variable to check for averaged data output241 242 TYPE(surf_out) :: surfaces 250 LOGICAL :: first_output(0:1) = .FALSE. !< true if first output was already called 251 LOGICAL :: to_netcdf = .FALSE. !< flag indicating parallel NetCDF output 252 LOGICAL :: to_vtk = .FALSE. !< flag indicating binary surface-data output that can be further 253 !< processed to VTK format 254 255 REAL(wp) :: averaging_interval_surf = 9999999.9_wp !< averaging interval 256 REAL(wp) :: dt_dosurf = 9999999.9_wp !< time interval for instantaneous data output 257 REAL(wp) :: dt_dosurf_av = 9999999.9_wp !< time interval for averaged data output 258 REAL(wp) :: skip_time_dosurf = 0.0_wp !< skip time for instantaneous data output 259 REAL(wp) :: skip_time_dosurf_av = 0.0_wp !< skip time for averaged data output 260 REAL(wp) :: time_dosurf = 0.0_wp !< internal counter variable to check for instantaneous data output 261 REAL(wp) :: time_dosurf_av = 0.0_wp !< internal counter variable to check for averaged data output 262 263 TYPE(surf_out) :: surfaces !< variable which contains all required output information 243 264 244 265 SAVE … … 304 325 ! 305 326 !--Public subroutines 306 PUBLIC surface_data_output, surface_data_output_averaging, & 307 surface_data_output_check_parameters, surface_data_output_init, & 308 surface_data_output_init_arrays, surface_data_output_last_action, & 309 surface_data_output_parin, surface_data_output_rrd_global, & 310 surface_data_output_rrd_local, surface_data_output_wrd_local, & 327 PUBLIC surface_data_output, & 328 surface_data_output_averaging, & 329 surface_data_output_check_parameters, & 330 surface_data_output_init, & 331 surface_data_output_init_arrays, & 332 surface_data_output_last_action, & 333 surface_data_output_parin, & 334 surface_data_output_rrd_global, & 335 surface_data_output_rrd_local, & 336 surface_data_output_wrd_local, & 311 337 surface_data_output_wrd_global 312 338 ! 313 339 !--Public variables 314 PUBLIC average_count_surf, averaging_interval_surf, dt_dosurf, dt_dosurf_av,& 315 skip_time_dosurf, skip_time_dosurf_av, time_dosurf, time_dosurf_av 340 PUBLIC average_count_surf, & 341 averaging_interval_surf, & 342 dt_dosurf, & 343 dt_dosurf_av, & 344 skip_time_dosurf, & 345 skip_time_dosurf_av, & 346 time_dosurf, & 347 time_dosurf_av 316 348 317 349 CONTAINS 318 350 319 !------------------------------------------------------------------------------ !351 !--------------------------------------------------------------------------------------------------! 320 352 ! Description: 321 353 ! ------------ 322 !> This routine counts the number of surfaces on each core and allocates 323 !> arrays. 324 !------------------------------------------------------------------------------! 325 SUBROUTINE surface_data_output_init_arrays 326 327 IMPLICIT NONE 328 329 ! 330 !-- Determine the number of surface elements on subdomain 331 surfaces%ns = surf_def_h(0)%ns + surf_lsm_h%ns + surf_usm_h%ns & !horizontal upward-facing 332 + surf_def_h(1)%ns & !horizontal downard-facing 333 + surf_def_v(0)%ns + surf_lsm_v(0)%ns + surf_usm_v(0)%ns & !northward-facing 334 + surf_def_v(1)%ns + surf_lsm_v(1)%ns + surf_usm_v(1)%ns & !southward-facing 335 + surf_def_v(2)%ns + surf_lsm_v(2)%ns + surf_usm_v(2)%ns & !westward-facing 336 + surf_def_v(3)%ns + surf_lsm_v(3)%ns + surf_usm_v(3)%ns !eastward-facing 337 ! 338 !-- Determine the total number of surfaces in the model domain 354 !> This routine counts the number of surfaces on each core and allocates arrays. 355 !--------------------------------------------------------------------------------------------------! 356 SUBROUTINE surface_data_output_init_arrays 357 358 IMPLICIT NONE 359 360 ! 361 !-- Determine the number of surface elements on subdomain 362 surfaces%ns = surf_def_h(0)%ns + surf_lsm_h%ns + surf_usm_h%ns & !horizontal upward-facing 363 + surf_def_h(1)%ns & !horizontal downard-facing 364 + surf_def_v(0)%ns + surf_lsm_v(0)%ns + surf_usm_v(0)%ns & !northward-facing 365 + surf_def_v(1)%ns + surf_lsm_v(1)%ns + surf_usm_v(1)%ns & !southward-facing 366 + surf_def_v(2)%ns + surf_lsm_v(2)%ns + surf_usm_v(2)%ns & !westward-facing 367 + surf_def_v(3)%ns + surf_lsm_v(3)%ns + surf_usm_v(3)%ns !eastward-facing 368 ! 369 !-- Determine the total number of surfaces in the model domain 339 370 #if defined( __parallel ) 340 CALL MPI_ALLREDUCE( surfaces%ns, surfaces%ns_total, 1, & 341 MPI_INTEGER, MPI_SUM, comm2d, ierr ) 371 CALL MPI_ALLREDUCE( surfaces%ns, surfaces%ns_total, 1, MPI_INTEGER, MPI_SUM, comm2d, ierr ) 342 372 #else 343 373 surfaces%ns_total = surfaces%ns 344 374 #endif 345 375 ! 346 !-- Allocate output variable and set to _FillValue attribute 347 ALLOCATE ( surfaces%var_out(1:surfaces%ns) ) 348 surfaces%var_out = surfaces%fillvalue 349 ! 350 !-- If there is an output of time average output variables, allocate the 351 !-- required array. 352 IF ( dosurf_no(1) > 0 ) THEN 353 ALLOCATE ( surfaces%var_av(1:surfaces%ns,1:dosurf_no(1)) ) 354 surfaces%var_av = 0.0_wp 355 ENDIF 356 357 END SUBROUTINE surface_data_output_init_arrays 358 359 360 !------------------------------------------------------------------------------! 376 !-- Allocate output variable and set to _FillValue attribute 377 ALLOCATE ( surfaces%var_out(1:surfaces%ns) ) 378 surfaces%var_out = surfaces%fillvalue 379 ! 380 !-- If there is an output of time average output variables, allocate the required array. 381 IF ( dosurf_no(1) > 0 ) THEN 382 ALLOCATE ( surfaces%var_av(1:surfaces%ns,1:dosurf_no(1)) ) 383 surfaces%var_av = 0.0_wp 384 ENDIF 385 386 END SUBROUTINE surface_data_output_init_arrays 387 388 389 !--------------------------------------------------------------------------------------------------! 361 390 ! Description: 362 391 ! ------------ 363 !> Initialization surface-data output data structure: calculation of vertices 364 !> and polygon data forthe surface elements, allocation of required arrays.365 !------------------------------------------------------------------------------ !366 367 368 392 !> Initialization surface-data output data structure: calculation of vertices and polygon data for 393 !> the surface elements, allocation of required arrays. 394 !--------------------------------------------------------------------------------------------------! 395 SUBROUTINE surface_data_output_init 396 397 IMPLICIT NONE 369 398 370 399 #if defined( __netcdf4_parallel ) 371 CHARACTER (LEN=100) ::filename !< name of output file372 CHARACTER (LEN=80) ::time_average_text !< string written to file attribute time_avg373 CHARACTER (LEN=4000) ::var_list !< list of variables written to NetCDF file374 375 INTEGER(iwp) :: av!< flag for averaged (=1) and non-averaged (=0) data400 CHARACTER (LEN=100) :: filename !< name of output file 401 CHARACTER (LEN=80) :: time_average_text !< string written to file attribute time_avg 402 CHARACTER (LEN=4000) :: var_list !< list of variables written to NetCDF file 403 404 INTEGER(iwp) :: av !< flag for averaged (=1) and non-averaged (=0) data 376 405 #endif 377 INTEGER(iwp) :: i !< grid index in x-direction, also running variable for counting non-average data output 378 INTEGER(iwp) :: j !< grid index in y-direction, also running variable for counting average data output 379 INTEGER(iwp) :: k !< grid index in z-direction 380 INTEGER(iwp) :: l !< running index for surface-element orientation 381 INTEGER(iwp) :: m !< running index for surface elements 382 INTEGER(iwp) :: mm !< local counting variable for surface elements 383 INTEGER(iwp) :: npg !< counter variable for all surface elements ( or polygons ) 384 INTEGER(iwp) :: point_index_count !< local counter variable for point index 385 INTEGER(iwp) :: start_count !< local start counter for the surface index 386 387 INTEGER(iwp), DIMENSION(0:numprocs-1) :: num_points_on_pe !< array which contains the number of points on all mpi ranks 388 INTEGER(iwp), DIMENSION(0:numprocs-1) :: num_surfaces_on_pe !< array which contains the number of surfaces on all mpi ranks 389 INTEGER(iwp), ALLOCATABLE, DIMENSION(:,:,:) :: point_index !< dummy array used to check where the reference points for surface polygons are located 390 391 REAL(wp) :: az !< azimuth angle, indicated the vertical orientation of a surface element 392 REAL(wp) :: off_x !< grid offset in x-direction between the stored grid index and the actual wall 393 REAL(wp) :: off_y !< grid offset in y-direction between the stored grid index and the actual wall 406 INTEGER(iwp) :: i !< grid index in x-direction, also running variable for counting non-average data output 407 INTEGER(iwp) :: j !< grid index in y-direction, also running variable for counting average data output 408 INTEGER(iwp) :: k !< grid index in z-direction 409 INTEGER(iwp) :: l !< running index for surface-element orientation 410 INTEGER(iwp) :: m !< running index for surface elements 411 INTEGER(iwp) :: mm !< local counting variable for surface elements 412 INTEGER(iwp) :: npg !< counter variable for all surface elements ( or polygons ) 413 INTEGER(iwp) :: point_index_count !< local counter variable for point index 414 INTEGER(iwp) :: start_count !< local start counter for the surface index 415 416 INTEGER(iwp), DIMENSION(0:numprocs-1) :: num_points_on_pe !< array which contains the number of points on all mpi ranks 417 INTEGER(iwp), DIMENSION(0:numprocs-1) :: num_surfaces_on_pe !< array which contains the number of surfaces on all mpi ranks 418 INTEGER(iwp), ALLOCATABLE, DIMENSION(:,:,:) :: point_index !< dummy array used to check where the reference points for 419 !< surface polygons are located 420 421 REAL(wp) :: az !< azimuth angle, indicated the vertical orientation of a surface element 422 REAL(wp) :: off_x !< grid offset in x-direction between the stored grid index and the actual wall 423 REAL(wp) :: off_y !< grid offset in y-direction between the stored grid index and the actual wall 394 424 #if defined( __netcdf4_parallel ) 395 425 REAL(wp), DIMENSION(:), ALLOCATABLE :: netcdf_data_1d !< dummy array to output 1D data into netcdf file 396 426 #endif 397 427 398 428 ! 399 !-- If output to VTK format is enabled, initialize point and polygon data. 400 !-- In a first step, count the number of points which are defining 401 !-- the surfaces and the polygons. 402 IF ( to_vtk ) THEN 403 ALLOCATE( point_index(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) 404 point_index = -1 405 ! 406 !-- Horizontal default surfaces 407 surfaces%npoints = 0 408 DO l = 0, 1 409 DO m = 1, surf_def_h(0)%ns 410 ! 411 !-- Determine the indices of the respective grid cell inside the topography 412 i = surf_def_h(0)%i(m) + surf_def_h(0)%ioff 413 j = surf_def_h(0)%j(m) + surf_def_h(0)%joff 414 k = surf_def_h(0)%k(m) + surf_def_h(0)%koff 415 ! 416 !-- Check if the vertices that define the surface element are already 417 !-- defined, if not, increment the counter. 418 IF ( point_index(k,j,i) < 0 ) THEN 419 surfaces%npoints = surfaces%npoints + 1 420 point_index(k,j,i) = surfaces%npoints - 1 421 ENDIF 422 IF ( point_index(k,j,i+1) < 0 ) THEN 423 surfaces%npoints = surfaces%npoints + 1 424 point_index(k,j,i+1) = surfaces%npoints - 1 425 ENDIF 426 IF ( point_index(k,j+1,i+1) < 0 ) THEN 427 surfaces%npoints = surfaces%npoints + 1 428 point_index(k,j+1,i+1) = surfaces%npoints - 1 429 ENDIF 430 IF ( point_index(k,j+1,i) < 0 ) THEN 431 surfaces%npoints = surfaces%npoints + 1 432 point_index(k,j+1,i) = surfaces%npoints - 1 433 ENDIF 434 ENDDO 435 ENDDO 436 DO m = 1, surf_lsm_h%ns 437 i = surf_lsm_h%i(m) + surf_lsm_h%ioff 438 j = surf_lsm_h%j(m) + surf_lsm_h%joff 439 k = surf_lsm_h%k(m) + surf_lsm_h%koff 440 441 IF ( point_index(k,j,i) < 0 ) THEN 442 surfaces%npoints = surfaces%npoints + 1 443 point_index(k,j,i) = surfaces%npoints - 1 444 ENDIF 445 IF ( point_index(k,j,i+1) < 0 ) THEN 446 surfaces%npoints = surfaces%npoints + 1 447 point_index(k,j,i+1) = surfaces%npoints - 1 448 ENDIF 449 IF ( point_index(k,j+1,i+1) < 0 ) THEN 450 surfaces%npoints = surfaces%npoints + 1 451 point_index(k,j+1,i+1) = surfaces%npoints - 1 452 ENDIF 453 IF ( point_index(k,j+1,i) < 0 ) THEN 454 surfaces%npoints = surfaces%npoints + 1 455 point_index(k,j+1,i) = surfaces%npoints - 1 456 ENDIF 457 ENDDO 458 DO m = 1, surf_usm_h%ns 459 i = surf_usm_h%i(m) + surf_usm_h%ioff 460 j = surf_usm_h%j(m) + surf_usm_h%joff 461 k = surf_usm_h%k(m) + surf_usm_h%koff 462 463 IF ( point_index(k,j,i) < 0 ) THEN 464 surfaces%npoints = surfaces%npoints + 1 465 point_index(k,j,i) = surfaces%npoints - 1 466 ENDIF 467 IF ( point_index(k,j,i+1) < 0 ) THEN 468 surfaces%npoints = surfaces%npoints + 1 469 point_index(k,j,i+1) = surfaces%npoints - 1 470 ENDIF 471 IF ( point_index(k,j+1,i+1) < 0 ) THEN 472 surfaces%npoints = surfaces%npoints + 1 473 point_index(k,j+1,i+1) = surfaces%npoints - 1 474 ENDIF 475 IF ( point_index(k,j+1,i) < 0 ) THEN 476 surfaces%npoints = surfaces%npoints + 1 477 point_index(k,j+1,i) = surfaces%npoints - 1 478 ENDIF 479 ENDDO 480 ! 481 !-- Vertical surfaces 482 DO l = 0, 3 483 DO m = 1, surf_def_v(l)%ns 484 ! 485 !-- Determine the indices of the respective grid cell inside the 486 !-- topography. Please note, j-index for north-facing surfaces 487 !-- ( l==0 ) is identical to the reference j-index outside the grid 488 !-- box. Equivalent for east-facing surfaces and i-index. 489 i = surf_def_v(l)%i(m) + MERGE( surf_def_v(l)%ioff, 0, l == 3 ) 490 j = surf_def_v(l)%j(m) + MERGE( surf_def_v(l)%joff, 0, l == 1 ) 491 k = surf_def_v(l)%k(m) + surf_def_v(l)%koff 492 ! 493 !-- Lower left /front vertex 494 IF ( point_index(k,j,i) < 0 ) THEN 495 surfaces%npoints = surfaces%npoints + 1 496 point_index(k,j,i) = surfaces%npoints - 1 497 ENDIF 498 ! 499 !-- Upper / lower right index for north- and south-facing surfaces 500 IF ( l == 0 .OR. l == 1 ) THEN 501 IF ( point_index(k,j,i+1) < 0 ) THEN 502 surfaces%npoints = surfaces%npoints + 1 503 point_index(k,j,i+1) = surfaces%npoints - 1 504 ENDIF 505 IF ( point_index(k+1,j,i+1) < 0 ) THEN 506 surfaces%npoints = surfaces%npoints + 1 507 point_index(k+1,j,i+1) = surfaces%npoints - 1 508 ENDIF 509 ! 510 !-- Upper / lower front index for east- and west-facing surfaces 511 ELSEIF ( l == 2 .OR. l == 3 ) THEN 512 IF ( point_index(k,j+1,i) < 0 ) THEN 513 surfaces%npoints = surfaces%npoints + 1 514 point_index(k,j+1,i) = surfaces%npoints - 1 515 ENDIF 516 IF ( point_index(k+1,j+1,i) < 0 ) THEN 517 surfaces%npoints = surfaces%npoints + 1 518 point_index(k+1,j+1,i) = surfaces%npoints - 1 519 ENDIF 520 ENDIF 521 ! 522 !-- Upper left / front vertex 523 IF ( point_index(k+1,j,i) < 0 ) THEN 524 surfaces%npoints = surfaces%npoints + 1 525 point_index(k+1,j,i) = surfaces%npoints - 1 526 ENDIF 527 ENDDO 528 DO m = 1, surf_lsm_v(l)%ns 529 i = surf_lsm_v(l)%i(m) + MERGE( surf_lsm_v(l)%ioff, 0, l == 3 ) 530 j = surf_lsm_v(l)%j(m) + MERGE( surf_lsm_v(l)%joff, 0, l == 1 ) 531 k = surf_lsm_v(l)%k(m) + surf_lsm_v(l)%koff 532 ! 533 !-- Lower left /front vertex 534 IF ( point_index(k,j,i) < 0 ) THEN 535 surfaces%npoints = surfaces%npoints + 1 536 point_index(k,j,i) = surfaces%npoints - 1 537 ENDIF 538 ! 539 !-- Upper / lower right index for north- and south-facing surfaces 540 IF ( l == 0 .OR. l == 1 ) THEN 541 IF ( point_index(k,j,i+1) < 0 ) THEN 542 surfaces%npoints = surfaces%npoints + 1 543 point_index(k,j,i+1) = surfaces%npoints - 1 544 ENDIF 545 IF ( point_index(k+1,j,i+1) < 0 ) THEN 546 surfaces%npoints = surfaces%npoints + 1 547 point_index(k+1,j,i+1) = surfaces%npoints - 1 548 ENDIF 549 ! 550 !-- Upper / lower front index for east- and west-facing surfaces 551 ELSEIF ( l == 2 .OR. l == 3 ) THEN 552 IF ( point_index(k,j+1,i) < 0 ) THEN 553 surfaces%npoints = surfaces%npoints + 1 554 point_index(k,j+1,i) = surfaces%npoints - 1 555 ENDIF 556 IF ( point_index(k+1,j+1,i) < 0 ) THEN 557 surfaces%npoints = surfaces%npoints + 1 558 point_index(k+1,j+1,i) = surfaces%npoints - 1 559 ENDIF 560 ENDIF 561 ! 562 !-- Upper left / front vertex 563 IF ( point_index(k+1,j,i) < 0 ) THEN 564 surfaces%npoints = surfaces%npoints + 1 565 point_index(k+1,j,i) = surfaces%npoints - 1 566 ENDIF 567 ENDDO 568 569 DO m = 1, surf_usm_v(l)%ns 570 i = surf_usm_v(l)%i(m) + MERGE( surf_usm_v(l)%ioff, 0, l == 3 ) 571 j = surf_usm_v(l)%j(m) + MERGE( surf_usm_v(l)%joff, 0, l == 1 ) 572 k = surf_usm_v(l)%k(m) + surf_usm_v(l)%koff 573 ! 574 !-- Lower left /front vertex 575 IF ( point_index(k,j,i) < 0 ) THEN 576 surfaces%npoints = surfaces%npoints + 1 577 point_index(k,j,i) = surfaces%npoints - 1 578 ENDIF 579 ! 580 !-- Upper / lower right index for north- and south-facing surfaces 581 IF ( l == 0 .OR. l == 1 ) THEN 582 IF ( point_index(k,j,i+1) < 0 ) THEN 583 surfaces%npoints = surfaces%npoints + 1 584 point_index(k,j,i+1) = surfaces%npoints - 1 585 ENDIF 586 IF ( point_index(k+1,j,i+1) < 0 ) THEN 587 surfaces%npoints = surfaces%npoints + 1 588 point_index(k+1,j,i+1) = surfaces%npoints - 1 589 ENDIF 590 ! 591 !-- Upper / lower front index for east- and west-facing surfaces 592 ELSEIF ( l == 2 .OR. l == 3 ) THEN 593 IF ( point_index(k,j+1,i) < 0 ) THEN 594 surfaces%npoints = surfaces%npoints + 1 595 point_index(k,j+1,i) = surfaces%npoints - 1 596 ENDIF 597 IF ( point_index(k+1,j+1,i) < 0 ) THEN 598 surfaces%npoints = surfaces%npoints + 1 599 point_index(k+1,j+1,i) = surfaces%npoints - 1 600 ENDIF 601 ENDIF 602 ! 603 !-- Upper left / front vertex 604 IF ( point_index(k+1,j,i) < 0 ) THEN 605 surfaces%npoints = surfaces%npoints + 1 606 point_index(k+1,j,i) = surfaces%npoints - 1 607 ENDIF 608 ENDDO 609 610 ENDDO 611 ! 612 !-- Allocate the number of points and polygons. Note, the number of 613 !-- polygons is identical to the number of surfaces elements, whereas the 614 !-- number of points (vertices), which define the polygons, can be larger. 615 ALLOCATE( surfaces%points(3,1:surfaces%npoints) ) 616 ALLOCATE( surfaces%polygons(5,1:surfaces%ns) ) 617 ! 618 !-- Note, PARAVIEW expects consecutively ordered points, in order to 619 !-- unambiguously identify surfaces. 620 !-- Hence, all PEs should know where they start counting, depending on the 621 !-- number of points on the other PE's with lower MPI rank. 429 !-- If output to VTK format is enabled, initialize point and polygon data. 430 !-- In a first step, count the number of points which are defining the surfaces and the polygons. 431 IF ( to_vtk ) THEN 432 ALLOCATE( point_index(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) 433 point_index = -1 434 ! 435 !-- Horizontal default surfaces 436 surfaces%npoints = 0 437 DO l = 0, 1 438 DO m = 1, surf_def_h(0)%ns 439 ! 440 !-- Determine the indices of the respective grid cell inside the topography 441 i = surf_def_h(0)%i(m) + surf_def_h(0)%ioff 442 j = surf_def_h(0)%j(m) + surf_def_h(0)%joff 443 k = surf_def_h(0)%k(m) + surf_def_h(0)%koff 444 ! 445 !-- Check if the vertices that define the surface element are already defined, if not, 446 !-- increment the counter. 447 IF ( point_index(k,j,i) < 0 ) THEN 448 surfaces%npoints = surfaces%npoints + 1 449 point_index(k,j,i) = surfaces%npoints - 1 450 ENDIF 451 IF ( point_index(k,j,i+1) < 0 ) THEN 452 surfaces%npoints = surfaces%npoints + 1 453 point_index(k,j,i+1) = surfaces%npoints - 1 454 ENDIF 455 IF ( point_index(k,j+1,i+1) < 0 ) THEN 456 surfaces%npoints = surfaces%npoints + 1 457 point_index(k,j+1,i+1) = surfaces%npoints - 1 458 ENDIF 459 IF ( point_index(k,j+1,i) < 0 ) THEN 460 surfaces%npoints = surfaces%npoints + 1 461 point_index(k,j+1,i) = surfaces%npoints - 1 462 ENDIF 463 ENDDO 464 ENDDO 465 DO m = 1, surf_lsm_h%ns 466 i = surf_lsm_h%i(m) + surf_lsm_h%ioff 467 j = surf_lsm_h%j(m) + surf_lsm_h%joff 468 k = surf_lsm_h%k(m) + surf_lsm_h%koff 469 470 IF ( point_index(k,j,i) < 0 ) THEN 471 surfaces%npoints = surfaces%npoints + 1 472 point_index(k,j,i) = surfaces%npoints - 1 473 ENDIF 474 IF ( point_index(k,j,i+1) < 0 ) THEN 475 surfaces%npoints = surfaces%npoints + 1 476 point_index(k,j,i+1) = surfaces%npoints - 1 477 ENDIF 478 IF ( point_index(k,j+1,i+1) < 0 ) THEN 479 surfaces%npoints = surfaces%npoints + 1 480 point_index(k,j+1,i+1) = surfaces%npoints - 1 481 ENDIF 482 IF ( point_index(k,j+1,i) < 0 ) THEN 483 surfaces%npoints = surfaces%npoints + 1 484 point_index(k,j+1,i) = surfaces%npoints - 1 485 ENDIF 486 ENDDO 487 DO m = 1, surf_usm_h%ns 488 i = surf_usm_h%i(m) + surf_usm_h%ioff 489 j = surf_usm_h%j(m) + surf_usm_h%joff 490 k = surf_usm_h%k(m) + surf_usm_h%koff 491 492 IF ( point_index(k,j,i) < 0 ) THEN 493 surfaces%npoints = surfaces%npoints + 1 494 point_index(k,j,i) = surfaces%npoints - 1 495 ENDIF 496 IF ( point_index(k,j,i+1) < 0 ) THEN 497 surfaces%npoints = surfaces%npoints + 1 498 point_index(k,j,i+1) = surfaces%npoints - 1 499 ENDIF 500 IF ( point_index(k,j+1,i+1) < 0 ) THEN 501 surfaces%npoints = surfaces%npoints + 1 502 point_index(k,j+1,i+1) = surfaces%npoints - 1 503 ENDIF 504 IF ( point_index(k,j+1,i) < 0 ) THEN 505 surfaces%npoints = surfaces%npoints + 1 506 point_index(k,j+1,i) = surfaces%npoints - 1 507 ENDIF 508 ENDDO 509 ! 510 !-- Vertical surfaces 511 DO l = 0, 3 512 DO m = 1, surf_def_v(l)%ns 513 ! 514 !-- Determine the indices of the respective grid cell inside the topography. Please note, 515 !-- j-index for north-facing surfaces ( l==0 ) is identical to the reference j-index 516 !-- outside the grid box. Equivalent for east-facing surfaces and i-index. 517 i = surf_def_v(l)%i(m) + MERGE( surf_def_v(l)%ioff, 0, l == 3 ) 518 j = surf_def_v(l)%j(m) + MERGE( surf_def_v(l)%joff, 0, l == 1 ) 519 k = surf_def_v(l)%k(m) + surf_def_v(l)%koff 520 ! 521 !-- Lower left /front vertex 522 IF ( point_index(k,j,i) < 0 ) THEN 523 surfaces%npoints = surfaces%npoints + 1 524 point_index(k,j,i) = surfaces%npoints - 1 525 ENDIF 526 ! 527 !-- Upper / lower right index for north- and south-facing surfaces 528 IF ( l == 0 .OR. l == 1 ) THEN 529 IF ( point_index(k,j,i+1) < 0 ) THEN 530 surfaces%npoints = surfaces%npoints + 1 531 point_index(k,j,i+1) = surfaces%npoints - 1 532 ENDIF 533 IF ( point_index(k+1,j,i+1) < 0 ) THEN 534 surfaces%npoints = surfaces%npoints + 1 535 point_index(k+1,j,i+1) = surfaces%npoints - 1 536 ENDIF 537 ! 538 !-- Upper / lower front index for east- and west-facing surfaces 539 ELSEIF ( l == 2 .OR. l == 3 ) THEN 540 IF ( point_index(k,j+1,i) < 0 ) THEN 541 surfaces%npoints = surfaces%npoints + 1 542 point_index(k,j+1,i) = surfaces%npoints - 1 543 ENDIF 544 IF ( point_index(k+1,j+1,i) < 0 ) THEN 545 surfaces%npoints = surfaces%npoints + 1 546 point_index(k+1,j+1,i) = surfaces%npoints - 1 547 ENDIF 548 ENDIF 549 ! 550 !-- Upper left / front vertex 551 IF ( point_index(k+1,j,i) < 0 ) THEN 552 surfaces%npoints = surfaces%npoints + 1 553 point_index(k+1,j,i) = surfaces%npoints - 1 554 ENDIF 555 ENDDO 556 DO m = 1, surf_lsm_v(l)%ns 557 i = surf_lsm_v(l)%i(m) + MERGE( surf_lsm_v(l)%ioff, 0, l == 3 ) 558 j = surf_lsm_v(l)%j(m) + MERGE( surf_lsm_v(l)%joff, 0, l == 1 ) 559 k = surf_lsm_v(l)%k(m) + surf_lsm_v(l)%koff 560 ! 561 !-- Lower left /front vertex 562 IF ( point_index(k,j,i) < 0 ) THEN 563 surfaces%npoints = surfaces%npoints + 1 564 point_index(k,j,i) = surfaces%npoints - 1 565 ENDIF 566 ! 567 !-- Upper / lower right index for north- and south-facing surfaces 568 IF ( l == 0 .OR. l == 1 ) THEN 569 IF ( point_index(k,j,i+1) < 0 ) THEN 570 surfaces%npoints = surfaces%npoints + 1 571 point_index(k,j,i+1) = surfaces%npoints - 1 572 ENDIF 573 IF ( point_index(k+1,j,i+1) < 0 ) THEN 574 surfaces%npoints = surfaces%npoints + 1 575 point_index(k+1,j,i+1) = surfaces%npoints - 1 576 ENDIF 577 ! 578 !-- Upper / lower front index for east- and west-facing surfaces 579 ELSEIF ( l == 2 .OR. l == 3 ) THEN 580 IF ( point_index(k,j+1,i) < 0 ) THEN 581 surfaces%npoints = surfaces%npoints + 1 582 point_index(k,j+1,i) = surfaces%npoints - 1 583 ENDIF 584 IF ( point_index(k+1,j+1,i) < 0 ) THEN 585 surfaces%npoints = surfaces%npoints + 1 586 point_index(k+1,j+1,i) = surfaces%npoints - 1 587 ENDIF 588 ENDIF 589 ! 590 !-- Upper left / front vertex 591 IF ( point_index(k+1,j,i) < 0 ) THEN 592 surfaces%npoints = surfaces%npoints + 1 593 point_index(k+1,j,i) = surfaces%npoints - 1 594 ENDIF 595 ENDDO 596 597 DO m = 1, surf_usm_v(l)%ns 598 i = surf_usm_v(l)%i(m) + MERGE( surf_usm_v(l)%ioff, 0, l == 3 ) 599 j = surf_usm_v(l)%j(m) + MERGE( surf_usm_v(l)%joff, 0, l == 1 ) 600 k = surf_usm_v(l)%k(m) + surf_usm_v(l)%koff 601 ! 602 !-- Lower left /front vertex 603 IF ( point_index(k,j,i) < 0 ) THEN 604 surfaces%npoints = surfaces%npoints + 1 605 point_index(k,j,i) = surfaces%npoints - 1 606 ENDIF 607 ! 608 !-- Upper / lower right index for north- and south-facing surfaces 609 IF ( l == 0 .OR. l == 1 ) THEN 610 IF ( point_index(k,j,i+1) < 0 ) THEN 611 surfaces%npoints = surfaces%npoints + 1 612 point_index(k,j,i+1) = surfaces%npoints - 1 613 ENDIF 614 IF ( point_index(k+1,j,i+1) < 0 ) THEN 615 surfaces%npoints = surfaces%npoints + 1 616 point_index(k+1,j,i+1) = surfaces%npoints - 1 617 ENDIF 618 ! 619 !-- Upper / lower front index for east- and west-facing surfaces 620 ELSEIF ( l == 2 .OR. l == 3 ) THEN 621 IF ( point_index(k,j+1,i) < 0 ) THEN 622 surfaces%npoints = surfaces%npoints + 1 623 point_index(k,j+1,i) = surfaces%npoints - 1 624 ENDIF 625 IF ( point_index(k+1,j+1,i) < 0 ) THEN 626 surfaces%npoints = surfaces%npoints + 1 627 point_index(k+1,j+1,i) = surfaces%npoints - 1 628 ENDIF 629 ENDIF 630 ! 631 !-- Upper left / front vertex 632 IF ( point_index(k+1,j,i) < 0 ) THEN 633 surfaces%npoints = surfaces%npoints + 1 634 point_index(k+1,j,i) = surfaces%npoints - 1 635 ENDIF 636 ENDDO 637 638 ENDDO 639 ! 640 !-- Allocate the number of points and polygons. Note, the number of polygons is identical to the 641 !-- number of surfaces elements, whereas the number of points (vertices), which define the 642 !-- polygons, can be larger. 643 ALLOCATE( surfaces%points(3,1:surfaces%npoints) ) 644 ALLOCATE( surfaces%polygons(5,1:surfaces%ns) ) 645 ! 646 !-- Note, PARAVIEW expects consecutively ordered points, in order to unambiguously identify 647 !-- surfaces. Hence, all PEs should know where they start counting, depending on the number of 648 !-- points on the other PE's with lower MPI rank. 622 649 #if defined( __parallel ) 623 CALL MPI_ALLGATHER( surfaces%npoints, 1, MPI_INTEGER,&624 num_points_on_pe, 1, MPI_INTEGER,comm2d, ierr )650 CALL MPI_ALLGATHER( surfaces%npoints, 1, MPI_INTEGER, num_points_on_pe, 1, MPI_INTEGER, & 651 comm2d, ierr ) 625 652 #else 626 653 num_points_on_pe = surfaces%npoints 627 654 #endif 628 655 629 656 ! 630 !-- After the number of vertices is counted, repeat the loops and define 631 !-- the vertices. Start with the horizontal default surfaces. 632 !-- First, however, determine the offset where couting of points should be 633 !-- started, which is the sum of points of all PE's with lower MPI rank. 634 i = 0 635 point_index_count = 0 636 DO WHILE ( i < myid .AND. i <= SIZE( num_points_on_pe ) ) 637 point_index_count = point_index_count + num_points_on_pe(i) 638 i = i + 1 639 ENDDO 640 641 surfaces%npoints = 0 642 point_index = -1 643 npg = 0 644 645 DO l = 0, 1 646 DO m = 1, surf_def_h(l)%ns 647 ! 648 !-- Determine the indices of the respective grid cell inside the 649 !-- topography. 650 i = surf_def_h(l)%i(m) + surf_def_h(l)%ioff 651 j = surf_def_h(l)%j(m) + surf_def_h(l)%joff 652 k = surf_def_h(l)%k(m) + surf_def_h(l)%koff 653 ! 654 !-- Check if the vertices that define the surface element are 655 !-- already defined, if not, increment the counter. 656 IF ( point_index(k,j,i) < 0 ) THEN 657 surfaces%npoints = surfaces%npoints + 1 658 point_index(k,j,i) = point_index_count 659 point_index_count = point_index_count + 1 660 surfaces%points(1,surfaces%npoints) = ( i - 0.5_wp ) * dx 661 surfaces%points(2,surfaces%npoints) = ( j - 0.5_wp ) * dy 662 surfaces%points(3,surfaces%npoints) = zw(k) 663 ENDIF 664 IF ( point_index(k,j,i+1) < 0 ) THEN 665 surfaces%npoints = surfaces%npoints + 1 666 point_index(k,j,i+1) = point_index_count 667 point_index_count = point_index_count + 1 668 surfaces%points(1,surfaces%npoints) = ( i + 1 - 0.5_wp ) * dx 669 surfaces%points(2,surfaces%npoints) = ( j - 0.5_wp ) * dy 670 surfaces%points(3,surfaces%npoints) = zw(k) 671 ENDIF 672 IF ( point_index(k,j+1,i+1) < 0 ) THEN 673 surfaces%npoints = surfaces%npoints + 1 674 point_index(k,j+1,i+1) = point_index_count 675 point_index_count = point_index_count + 1 676 surfaces%points(1,surfaces%npoints) = ( i + 1 - 0.5_wp ) * dx 677 surfaces%points(2,surfaces%npoints) = ( j + 1 - 0.5_wp ) * dy 678 surfaces%points(3,surfaces%npoints) = zw(k) 679 ENDIF 680 IF ( point_index(k,j+1,i) < 0 ) THEN 681 surfaces%npoints = surfaces%npoints + 1 682 point_index(k,j+1,i) = point_index_count 683 point_index_count = point_index_count + 1 684 surfaces%points(1,surfaces%npoints) = ( i - 0.5_wp ) * dx 685 surfaces%points(2,surfaces%npoints) = ( j + 1 - 0.5_wp ) * dy 686 surfaces%points(3,surfaces%npoints) = zw(k) 687 ENDIF 688 689 npg = npg + 1 690 surfaces%polygons(1,npg) = 4 691 surfaces%polygons(2,npg) = point_index(k,j,i) 692 surfaces%polygons(3,npg) = point_index(k,j,i+1) 693 surfaces%polygons(4,npg) = point_index(k,j+1,i+1) 694 surfaces%polygons(5,npg) = point_index(k,j+1,i) 695 ENDDO 696 ENDDO 697 DO m = 1, surf_lsm_h%ns 698 i = surf_lsm_h%i(m) + surf_lsm_h%ioff 699 j = surf_lsm_h%j(m) + surf_lsm_h%joff 700 k = surf_lsm_h%k(m) + surf_lsm_h%koff 701 IF ( point_index(k,j,i) < 0 ) THEN 702 surfaces%npoints = surfaces%npoints + 1 703 point_index(k,j,i) = point_index_count 704 point_index_count = point_index_count + 1 705 surfaces%points(1,surfaces%npoints) = ( i - 0.5_wp ) * dx 706 surfaces%points(2,surfaces%npoints) = ( j - 0.5_wp ) * dy 707 surfaces%points(3,surfaces%npoints) = zw(k) 708 ENDIF 709 IF ( point_index(k,j,i+1) < 0 ) THEN 710 surfaces%npoints = surfaces%npoints + 1 711 point_index(k,j,i+1) = point_index_count 712 point_index_count = point_index_count + 1 713 surfaces%points(1,surfaces%npoints) = ( i + 1 - 0.5_wp ) * dx 714 surfaces%points(2,surfaces%npoints) = ( j - 0.5_wp ) * dy 715 surfaces%points(3,surfaces%npoints) = zw(k) 716 ENDIF 717 IF ( point_index(k,j+1,i+1) < 0 ) THEN 718 surfaces%npoints = surfaces%npoints + 1 719 point_index(k,j+1,i+1) = point_index_count 720 point_index_count = point_index_count + 1 721 surfaces%points(1,surfaces%npoints) = ( i + 1 - 0.5_wp ) * dx 722 surfaces%points(2,surfaces%npoints) = ( j + 1 - 0.5_wp ) * dy 723 surfaces%points(3,surfaces%npoints) = zw(k) 724 ENDIF 725 IF ( point_index(k,j+1,i) < 0 ) THEN 726 surfaces%npoints = surfaces%npoints + 1 727 point_index(k,j+1,i) = point_index_count 728 point_index_count = point_index_count + 1 729 surfaces%points(1,surfaces%npoints) = ( i - 0.5_wp ) * dx 730 surfaces%points(2,surfaces%npoints) = ( j + 1 - 0.5_wp ) * dy 731 surfaces%points(3,surfaces%npoints) = zw(k) 732 ENDIF 733 734 npg = npg + 1 735 surfaces%polygons(1,npg) = 4 736 surfaces%polygons(2,npg) = point_index(k,j,i) 737 surfaces%polygons(3,npg) = point_index(k,j,i+1) 738 surfaces%polygons(4,npg) = point_index(k,j+1,i+1) 739 surfaces%polygons(5,npg) = point_index(k,j+1,i) 740 ENDDO 741 742 DO m = 1, surf_usm_h%ns 743 i = surf_usm_h%i(m) + surf_usm_h%ioff 744 j = surf_usm_h%j(m) + surf_usm_h%joff 745 k = surf_usm_h%k(m) + surf_usm_h%koff 746 747 IF ( point_index(k,j,i) < 0 ) THEN 748 surfaces%npoints = surfaces%npoints + 1 749 point_index(k,j,i) = point_index_count 750 point_index_count = point_index_count + 1 751 surfaces%points(1,surfaces%npoints) = ( i - 0.5_wp ) * dx 752 surfaces%points(2,surfaces%npoints) = ( j - 0.5_wp ) * dy 753 surfaces%points(3,surfaces%npoints) = zw(k) 754 ENDIF 755 IF ( point_index(k,j,i+1) < 0 ) THEN 756 surfaces%npoints = surfaces%npoints + 1 757 point_index(k,j,i+1) = point_index_count 758 point_index_count = point_index_count + 1 759 surfaces%points(1,surfaces%npoints) = ( i + 1 - 0.5_wp ) * dx 760 surfaces%points(2,surfaces%npoints) = ( j - 0.5_wp ) * dy 761 surfaces%points(3,surfaces%npoints) = zw(k) 762 ENDIF 763 IF ( point_index(k,j+1,i+1) < 0 ) THEN 764 surfaces%npoints = surfaces%npoints + 1 765 point_index(k,j+1,i+1) = point_index_count 766 point_index_count = point_index_count + 1 767 surfaces%points(1,surfaces%npoints) = ( i + 1 - 0.5_wp ) * dx 768 surfaces%points(2,surfaces%npoints) = ( j + 1 - 0.5_wp ) * dy 769 surfaces%points(3,surfaces%npoints) = zw(k) 770 ENDIF 771 IF ( point_index(k,j+1,i) < 0 ) THEN 772 surfaces%npoints = surfaces%npoints + 1 773 point_index(k,j+1,i) = point_index_count 774 point_index_count = point_index_count + 1 775 surfaces%points(1,surfaces%npoints) = ( i - 0.5_wp ) * dx 776 surfaces%points(2,surfaces%npoints) = ( j + 1 - 0.5_wp ) * dy 777 surfaces%points(3,surfaces%npoints) = zw(k) 778 ENDIF 779 780 npg = npg + 1 781 surfaces%polygons(1,npg) = 4 782 surfaces%polygons(2,npg) = point_index(k,j,i) 783 surfaces%polygons(3,npg) = point_index(k,j,i+1) 784 surfaces%polygons(4,npg) = point_index(k,j+1,i+1) 785 surfaces%polygons(5,npg) = point_index(k,j+1,i) 786 ENDDO 787 788 DO l = 0, 3 789 DO m = 1, surf_def_v(l)%ns 790 ! 791 !-- Determine the indices of the respective grid cell inside the 792 !-- topography. 793 !-- NOTE, j-index for north-facing surfaces ( l==0 ) is 794 !-- identical to the reference j-index outside the grid box. 795 !-- Equivalent for east-facing surfaces and i-index. 796 i = surf_def_v(l)%i(m) + MERGE( surf_def_v(l)%ioff, 0, l == 3 ) 797 j = surf_def_v(l)%j(m) + MERGE( surf_def_v(l)%joff, 0, l == 1 ) 798 k = surf_def_v(l)%k(m) + surf_def_v(l)%koff 799 ! 800 !-- Lower left /front vertex 801 IF ( point_index(k,j,i) < 0 ) THEN 802 surfaces%npoints = surfaces%npoints + 1 803 point_index(k,j,i) = point_index_count 804 point_index_count = point_index_count + 1 805 surfaces%points(1,surfaces%npoints) = ( i - 0.5_wp ) * dx 806 surfaces%points(2,surfaces%npoints) = ( j - 0.5_wp ) * dy 807 surfaces%points(3,surfaces%npoints) = zw(k-1) 808 ENDIF 809 ! 810 !-- Upper / lower right index for north- and south-facing surfaces 811 IF ( l == 0 .OR. l == 1 ) THEN 812 IF ( point_index(k,j,i+1) < 0 ) THEN 813 surfaces%npoints = surfaces%npoints + 1 814 point_index(k,j,i+1) = point_index_count 815 point_index_count = point_index_count + 1 816 surfaces%points(1,surfaces%npoints) = ( i + 1 - 0.5_wp ) * dx 817 surfaces%points(2,surfaces%npoints) = ( j - 0.5_wp ) * dy 818 surfaces%points(3,surfaces%npoints) = zw(k-1) 819 ENDIF 820 IF ( point_index(k+1,j,i+1) < 0 ) THEN 821 surfaces%npoints = surfaces%npoints + 1 822 point_index(k+1,j,i+1) = point_index_count 823 point_index_count = point_index_count + 1 824 surfaces%points(1,surfaces%npoints) = ( i + 1 - 0.5_wp ) * dx 825 surfaces%points(2,surfaces%npoints) = ( j - 0.5_wp ) * dy 826 surfaces%points(3,surfaces%npoints) = zw(k) 827 ENDIF 828 ! 829 !-- Upper / lower front index for east- and west-facing surfaces 830 ELSEIF ( l == 2 .OR. l == 3 ) THEN 831 IF ( point_index(k,j+1,i) < 0 ) THEN 832 surfaces%npoints = surfaces%npoints + 1 833 point_index(k,j+1,i) = point_index_count 834 point_index_count = point_index_count + 1 835 surfaces%points(1,surfaces%npoints) = ( i - 0.5_wp ) * dx 836 surfaces%points(2,surfaces%npoints) = ( j + 1 - 0.5_wp ) * dy 837 surfaces%points(3,surfaces%npoints) = zw(k-1) 838 ENDIF 839 IF ( point_index(k+1,j+1,i) < 0 ) THEN 840 surfaces%npoints = surfaces%npoints + 1 841 point_index(k+1,j+1,i) = point_index_count 842 point_index_count = point_index_count + 1 843 surfaces%points(1,surfaces%npoints) = ( i - 0.5_wp ) * dx 844 surfaces%points(2,surfaces%npoints) = ( j + 1 - 0.5_wp ) * dy 845 surfaces%points(3,surfaces%npoints) = zw(k) 846 ENDIF 847 ENDIF 848 ! 849 !-- Upper left / front vertex 850 IF ( point_index(k+1,j,i) < 0 ) THEN 851 surfaces%npoints = surfaces%npoints + 1 852 point_index(k+1,j,i) = point_index_count 853 point_index_count = point_index_count + 1 854 surfaces%points(1,surfaces%npoints) = ( i - 0.5_wp ) * dx 855 surfaces%points(2,surfaces%npoints) = ( j - 0.5_wp ) * dy 856 surfaces%points(3,surfaces%npoints) = zw(k) 857 ENDIF 858 859 npg = npg + 1 860 IF ( l == 0 .OR. l == 1 ) THEN 861 surfaces%polygons(1,npg) = 4 862 surfaces%polygons(2,npg) = point_index(k,j,i) 863 surfaces%polygons(3,npg) = point_index(k,j,i+1) 864 surfaces%polygons(4,npg) = point_index(k+1,j,i+1) 865 surfaces%polygons(5,npg) = point_index(k+1,j,i) 866 ELSE 867 surfaces%polygons(1,npg) = 4 868 surfaces%polygons(2,npg) = point_index(k,j,i) 869 surfaces%polygons(3,npg) = point_index(k,j+1,i) 870 surfaces%polygons(4,npg) = point_index(k+1,j+1,i) 871 surfaces%polygons(5,npg) = point_index(k+1,j,i) 872 ENDIF 873 874 ENDDO 875 876 DO m = 1, surf_lsm_v(l)%ns 877 i = surf_lsm_v(l)%i(m) + MERGE( surf_lsm_v(l)%ioff, 0, l == 3 ) 878 j = surf_lsm_v(l)%j(m) + MERGE( surf_lsm_v(l)%joff, 0, l == 1 ) 879 k = surf_lsm_v(l)%k(m) + surf_lsm_v(l)%koff 880 ! 881 !-- Lower left /front vertex 882 IF ( point_index(k,j,i) < 0 ) THEN 883 surfaces%npoints = surfaces%npoints + 1 884 point_index(k,j,i) = point_index_count 885 point_index_count = point_index_count + 1 886 surfaces%points(1,surfaces%npoints) = ( i - 0.5_wp ) * dx 887 surfaces%points(2,surfaces%npoints) = ( j - 0.5_wp ) * dy 888 surfaces%points(3,surfaces%npoints) = zw(k-1) 889 ENDIF 890 ! 891 !-- Upper / lower right index for north- and south-facing surfaces 892 IF ( l == 0 .OR. l == 1 ) THEN 893 IF ( point_index(k,j,i+1) < 0 ) THEN 894 surfaces%npoints = surfaces%npoints + 1 895 point_index(k,j,i+1) = point_index_count 896 point_index_count = point_index_count + 1 897 surfaces%points(1,surfaces%npoints) = ( i + 1 - 0.5_wp ) * dx 898 surfaces%points(2,surfaces%npoints) = ( j - 0.5_wp ) * dy 899 surfaces%points(3,surfaces%npoints) = zw(k-1) 900 ENDIF 901 IF ( point_index(k+1,j,i+1) < 0 ) THEN 902 surfaces%npoints = surfaces%npoints + 1 903 point_index(k+1,j,i+1) = point_index_count 904 point_index_count = point_index_count + 1 905 surfaces%points(1,surfaces%npoints) = ( i + 1 - 0.5_wp ) * dx 906 surfaces%points(2,surfaces%npoints) = ( j - 0.5_wp ) * dy 907 surfaces%points(3,surfaces%npoints) = zw(k) 908 ENDIF 909 ! 910 !-- Upper / lower front index for east- and west-facing surfaces 911 ELSEIF ( l == 2 .OR. l == 3 ) THEN 912 IF ( point_index(k,j+1,i) < 0 ) THEN 913 surfaces%npoints = surfaces%npoints + 1 914 point_index(k,j+1,i) = point_index_count 915 point_index_count = point_index_count + 1 916 surfaces%points(1,surfaces%npoints) = ( i - 0.5_wp ) * dx 917 surfaces%points(2,surfaces%npoints) = ( j + 1 - 0.5_wp ) * dy 918 surfaces%points(3,surfaces%npoints) = zw(k-1) 919 ENDIF 920 IF ( point_index(k+1,j+1,i) < 0 ) THEN 921 surfaces%npoints = surfaces%npoints + 1 922 point_index(k+1,j+1,i) = point_index_count 923 point_index_count = point_index_count + 1 924 surfaces%points(1,surfaces%npoints) = ( i - 0.5_wp ) * dx 925 surfaces%points(2,surfaces%npoints) = ( j + 1 - 0.5_wp ) * dy 926 surfaces%points(3,surfaces%npoints) = zw(k) 927 ENDIF 928 ENDIF 929 ! 930 !-- Upper left / front vertex 931 IF ( point_index(k+1,j,i) < 0 ) THEN 932 surfaces%npoints = surfaces%npoints + 1 933 point_index(k+1,j,i) = point_index_count 934 point_index_count = point_index_count + 1 935 surfaces%points(1,surfaces%npoints) = ( i - 0.5_wp ) * dx 936 surfaces%points(2,surfaces%npoints) = ( j - 0.5_wp ) * dy 937 surfaces%points(3,surfaces%npoints) = zw(k) 938 ENDIF 939 940 npg = npg + 1 941 IF ( l == 0 .OR. l == 1 ) THEN 942 surfaces%polygons(1,npg) = 4 943 surfaces%polygons(2,npg) = point_index(k,j,i) 944 surfaces%polygons(3,npg) = point_index(k,j,i+1) 945 surfaces%polygons(4,npg) = point_index(k+1,j,i+1) 946 surfaces%polygons(5,npg) = point_index(k+1,j,i) 947 ELSE 948 surfaces%polygons(1,npg) = 4 949 surfaces%polygons(2,npg) = point_index(k,j,i) 950 surfaces%polygons(3,npg) = point_index(k,j+1,i) 951 surfaces%polygons(4,npg) = point_index(k+1,j+1,i) 952 surfaces%polygons(5,npg) = point_index(k+1,j,i) 953 ENDIF 954 ENDDO 955 DO m = 1, surf_usm_v(l)%ns 956 i = surf_usm_v(l)%i(m) + MERGE( surf_usm_v(l)%ioff, 0, l == 3 ) 957 j = surf_usm_v(l)%j(m) + MERGE( surf_usm_v(l)%joff, 0, l == 1 ) 958 k = surf_usm_v(l)%k(m) + surf_usm_v(l)%koff 959 ! 960 !-- Lower left /front vertex 961 IF ( point_index(k,j,i) < 0 ) THEN 962 surfaces%npoints = surfaces%npoints + 1 963 point_index(k,j,i) = point_index_count 964 point_index_count = point_index_count + 1 965 surfaces%points(1,surfaces%npoints) = ( i - 0.5_wp ) * dx 966 surfaces%points(2,surfaces%npoints) = ( j - 0.5_wp ) * dy 967 surfaces%points(3,surfaces%npoints) = zw(k-1) 968 ENDIF 969 ! 970 !-- Upper / lower right index for north- and south-facing surfaces 971 IF ( l == 0 .OR. l == 1 ) THEN 972 IF ( point_index(k,j,i+1) < 0 ) THEN 973 surfaces%npoints = surfaces%npoints + 1 974 point_index(k,j,i+1) = point_index_count 975 point_index_count = point_index_count + 1 976 surfaces%points(1,surfaces%npoints) = ( i + 1 - 0.5_wp ) * dx 977 surfaces%points(2,surfaces%npoints) = ( j - 0.5_wp ) * dy 978 surfaces%points(3,surfaces%npoints) = zw(k-1) 979 ENDIF 980 IF ( point_index(k+1,j,i+1) < 0 ) THEN 981 surfaces%npoints = surfaces%npoints + 1 982 point_index(k+1,j,i+1) = point_index_count 983 point_index_count = point_index_count + 1 984 surfaces%points(1,surfaces%npoints) = ( i + 1 - 0.5_wp ) * dx 985 surfaces%points(2,surfaces%npoints) = ( j - 0.5_wp ) * dy 986 surfaces%points(3,surfaces%npoints) = zw(k) 987 ENDIF 988 ! 989 !-- Upper / lower front index for east- and west-facing surfaces 990 ELSEIF ( l == 2 .OR. l == 3 ) THEN 991 IF ( point_index(k,j+1,i) < 0 ) THEN 992 surfaces%npoints = surfaces%npoints + 1 993 point_index(k,j+1,i) = point_index_count 994 point_index_count = point_index_count + 1 995 surfaces%points(1,surfaces%npoints) = ( i - 0.5_wp ) * dx 996 surfaces%points(2,surfaces%npoints) = ( j + 1 - 0.5_wp ) * dy 997 surfaces%points(3,surfaces%npoints) = zw(k-1) 998 ENDIF 999 IF ( point_index(k+1,j+1,i) < 0 ) THEN 1000 surfaces%npoints = surfaces%npoints + 1 1001 point_index(k+1,j+1,i) = point_index_count 1002 point_index_count = point_index_count + 1 1003 surfaces%points(1,surfaces%npoints) = ( i - 0.5_wp ) * dx 1004 surfaces%points(2,surfaces%npoints) = ( j + 1 - 0.5_wp ) * dy 1005 surfaces%points(3,surfaces%npoints) = zw(k) 1006 ENDIF 1007 ENDIF 1008 ! 1009 !-- Upper left / front vertex 1010 IF ( point_index(k+1,j,i) < 0 ) THEN 1011 surfaces%npoints = surfaces%npoints + 1 1012 point_index(k+1,j,i) = point_index_count 1013 point_index_count = point_index_count + 1 1014 surfaces%points(1,surfaces%npoints) = ( i - 0.5_wp ) * dx 1015 surfaces%points(2,surfaces%npoints) = ( j - 0.5_wp ) * dy 1016 surfaces%points(3,surfaces%npoints) = zw(k) 1017 ENDIF 1018 1019 npg = npg + 1 1020 IF ( l == 0 .OR. l == 1 ) THEN 1021 surfaces%polygons(1,npg) = 4 1022 surfaces%polygons(2,npg) = point_index(k,j,i) 1023 surfaces%polygons(3,npg) = point_index(k,j,i+1) 1024 surfaces%polygons(4,npg) = point_index(k+1,j,i+1) 1025 surfaces%polygons(5,npg) = point_index(k+1,j,i) 1026 ELSE 1027 surfaces%polygons(1,npg) = 4 1028 surfaces%polygons(2,npg) = point_index(k,j,i) 1029 surfaces%polygons(3,npg) = point_index(k,j+1,i) 1030 surfaces%polygons(4,npg) = point_index(k+1,j+1,i) 1031 surfaces%polygons(5,npg) = point_index(k+1,j,i) 1032 ENDIF 1033 ENDDO 1034 1035 ENDDO 1036 ! 1037 !-- Deallocate temporary dummy variable 1038 DEALLOCATE ( point_index ) 1039 ! 1040 !-- Sum-up total number of vertices on domain. This 1041 !-- will be needed for post-processing. 1042 surfaces%npoints_total = 0 657 !-- After the number of vertices is counted, repeat the loops and define the vertices. Start with 658 !-- the horizontal default surfaces. First, however, determine the offset where couting of points 659 !-- should be started, which is the sum of points of all PE's with lower MPI rank. 660 i = 0 661 point_index_count = 0 662 DO WHILE ( i < myid .AND. i <= SIZE( num_points_on_pe ) ) 663 point_index_count = point_index_count + num_points_on_pe(i) 664 i = i + 1 665 ENDDO 666 667 surfaces%npoints = 0 668 point_index = -1 669 npg = 0 670 671 DO l = 0, 1 672 DO m = 1, surf_def_h(l)%ns 673 ! 674 !-- Determine the indices of the respective grid cell inside the topography. 675 i = surf_def_h(l)%i(m) + surf_def_h(l)%ioff 676 j = surf_def_h(l)%j(m) + surf_def_h(l)%joff 677 k = surf_def_h(l)%k(m) + surf_def_h(l)%koff 678 ! 679 !-- Check if the vertices that define the surface element are already defined, if not, 680 !-- increment the counter. 681 IF ( point_index(k,j,i) < 0 ) THEN 682 surfaces%npoints = surfaces%npoints + 1 683 point_index(k,j,i) = point_index_count 684 point_index_count = point_index_count + 1 685 surfaces%points(1,surfaces%npoints) = ( i - 0.5_wp ) * dx 686 surfaces%points(2,surfaces%npoints) = ( j - 0.5_wp ) * dy 687 surfaces%points(3,surfaces%npoints) = zw(k) 688 ENDIF 689 IF ( point_index(k,j,i+1) < 0 ) THEN 690 surfaces%npoints = surfaces%npoints + 1 691 point_index(k,j,i+1) = point_index_count 692 point_index_count = point_index_count + 1 693 surfaces%points(1,surfaces%npoints) = ( i + 1 - 0.5_wp ) * dx 694 surfaces%points(2,surfaces%npoints) = ( j - 0.5_wp ) * dy 695 surfaces%points(3,surfaces%npoints) = zw(k) 696 ENDIF 697 IF ( point_index(k,j+1,i+1) < 0 ) THEN 698 surfaces%npoints = surfaces%npoints + 1 699 point_index(k,j+1,i+1) = point_index_count 700 point_index_count = point_index_count + 1 701 surfaces%points(1,surfaces%npoints) = ( i + 1 - 0.5_wp ) * dx 702 surfaces%points(2,surfaces%npoints) = ( j + 1 - 0.5_wp ) * dy 703 surfaces%points(3,surfaces%npoints) = zw(k) 704 ENDIF 705 IF ( point_index(k,j+1,i) < 0 ) THEN 706 surfaces%npoints = surfaces%npoints + 1 707 point_index(k,j+1,i) = point_index_count 708 point_index_count = point_index_count + 1 709 surfaces%points(1,surfaces%npoints) = ( i - 0.5_wp ) * dx 710 surfaces%points(2,surfaces%npoints) = ( j + 1 - 0.5_wp ) * dy 711 surfaces%points(3,surfaces%npoints) = zw(k) 712 ENDIF 713 714 npg = npg + 1 715 surfaces%polygons(1,npg) = 4 716 surfaces%polygons(2,npg) = point_index(k,j,i) 717 surfaces%polygons(3,npg) = point_index(k,j,i+1) 718 surfaces%polygons(4,npg) = point_index(k,j+1,i+1) 719 surfaces%polygons(5,npg) = point_index(k,j+1,i) 720 ENDDO 721 ENDDO 722 DO m = 1, surf_lsm_h%ns 723 i = surf_lsm_h%i(m) + surf_lsm_h%ioff 724 j = surf_lsm_h%j(m) + surf_lsm_h%joff 725 k = surf_lsm_h%k(m) + surf_lsm_h%koff 726 IF ( point_index(k,j,i) < 0 ) THEN 727 surfaces%npoints = surfaces%npoints + 1 728 point_index(k,j,i) = point_index_count 729 point_index_count = point_index_count + 1 730 surfaces%points(1,surfaces%npoints) = ( i - 0.5_wp ) * dx 731 surfaces%points(2,surfaces%npoints) = ( j - 0.5_wp ) * dy 732 surfaces%points(3,surfaces%npoints) = zw(k) 733 ENDIF 734 IF ( point_index(k,j,i+1) < 0 ) THEN 735 surfaces%npoints = surfaces%npoints + 1 736 point_index(k,j,i+1) = point_index_count 737 point_index_count = point_index_count + 1 738 surfaces%points(1,surfaces%npoints) = ( i + 1 - 0.5_wp ) * dx 739 surfaces%points(2,surfaces%npoints) = ( j - 0.5_wp ) * dy 740 surfaces%points(3,surfaces%npoints) = zw(k) 741 ENDIF 742 IF ( point_index(k,j+1,i+1) < 0 ) THEN 743 surfaces%npoints = surfaces%npoints + 1 744 point_index(k,j+1,i+1) = point_index_count 745 point_index_count = point_index_count + 1 746 surfaces%points(1,surfaces%npoints) = ( i + 1 - 0.5_wp ) * dx 747 surfaces%points(2,surfaces%npoints) = ( j + 1 - 0.5_wp ) * dy 748 surfaces%points(3,surfaces%npoints) = zw(k) 749 ENDIF 750 IF ( point_index(k,j+1,i) < 0 ) THEN 751 surfaces%npoints = surfaces%npoints + 1 752 point_index(k,j+1,i) = point_index_count 753 point_index_count = point_index_count + 1 754 surfaces%points(1,surfaces%npoints) = ( i - 0.5_wp ) * dx 755 surfaces%points(2,surfaces%npoints) = ( j + 1 - 0.5_wp ) * dy 756 surfaces%points(3,surfaces%npoints) = zw(k) 757 ENDIF 758 759 npg = npg + 1 760 surfaces%polygons(1,npg) = 4 761 surfaces%polygons(2,npg) = point_index(k,j,i) 762 surfaces%polygons(3,npg) = point_index(k,j,i+1) 763 surfaces%polygons(4,npg) = point_index(k,j+1,i+1) 764 surfaces%polygons(5,npg) = point_index(k,j+1,i) 765 ENDDO 766 767 DO m = 1, surf_usm_h%ns 768 i = surf_usm_h%i(m) + surf_usm_h%ioff 769 j = surf_usm_h%j(m) + surf_usm_h%joff 770 k = surf_usm_h%k(m) + surf_usm_h%koff 771 772 IF ( point_index(k,j,i) < 0 ) THEN 773 surfaces%npoints = surfaces%npoints + 1 774 point_index(k,j,i) = point_index_count 775 point_index_count = point_index_count + 1 776 surfaces%points(1,surfaces%npoints) = ( i - 0.5_wp ) * dx 777 surfaces%points(2,surfaces%npoints) = ( j - 0.5_wp ) * dy 778 surfaces%points(3,surfaces%npoints) = zw(k) 779 ENDIF 780 IF ( point_index(k,j,i+1) < 0 ) THEN 781 surfaces%npoints = surfaces%npoints + 1 782 point_index(k,j,i+1) = point_index_count 783 point_index_count = point_index_count + 1 784 surfaces%points(1,surfaces%npoints) = ( i + 1 - 0.5_wp ) * dx 785 surfaces%points(2,surfaces%npoints) = ( j - 0.5_wp ) * dy 786 surfaces%points(3,surfaces%npoints) = zw(k) 787 ENDIF 788 IF ( point_index(k,j+1,i+1) < 0 ) THEN 789 surfaces%npoints = surfaces%npoints + 1 790 point_index(k,j+1,i+1) = point_index_count 791 point_index_count = point_index_count + 1 792 surfaces%points(1,surfaces%npoints) = ( i + 1 - 0.5_wp ) * dx 793 surfaces%points(2,surfaces%npoints) = ( j + 1 - 0.5_wp ) * dy 794 surfaces%points(3,surfaces%npoints) = zw(k) 795 ENDIF 796 IF ( point_index(k,j+1,i) < 0 ) THEN 797 surfaces%npoints = surfaces%npoints + 1 798 point_index(k,j+1,i) = point_index_count 799 point_index_count = point_index_count + 1 800 surfaces%points(1,surfaces%npoints) = ( i - 0.5_wp ) * dx 801 surfaces%points(2,surfaces%npoints) = ( j + 1 - 0.5_wp ) * dy 802 surfaces%points(3,surfaces%npoints) = zw(k) 803 ENDIF 804 805 npg = npg + 1 806 surfaces%polygons(1,npg) = 4 807 surfaces%polygons(2,npg) = point_index(k,j,i) 808 surfaces%polygons(3,npg) = point_index(k,j,i+1) 809 surfaces%polygons(4,npg) = point_index(k,j+1,i+1) 810 surfaces%polygons(5,npg) = point_index(k,j+1,i) 811 ENDDO 812 813 DO l = 0, 3 814 DO m = 1, surf_def_v(l)%ns 815 ! 816 !-- Determine the indices of the respective grid cell inside the topography. 817 !-- NOTE, j-index for north-facing surfaces ( l==0 ) is identical to the reference j-index 818 !-- outside the grid box. Equivalent for east-facing surfaces and i-index. 819 i = surf_def_v(l)%i(m) + MERGE( surf_def_v(l)%ioff, 0, l == 3 ) 820 j = surf_def_v(l)%j(m) + MERGE( surf_def_v(l)%joff, 0, l == 1 ) 821 k = surf_def_v(l)%k(m) + surf_def_v(l)%koff 822 ! 823 !-- Lower left /front vertex 824 IF ( point_index(k,j,i) < 0 ) THEN 825 surfaces%npoints = surfaces%npoints + 1 826 point_index(k,j,i) = point_index_count 827 point_index_count = point_index_count + 1 828 surfaces%points(1,surfaces%npoints) = ( i - 0.5_wp ) * dx 829 surfaces%points(2,surfaces%npoints) = ( j - 0.5_wp ) * dy 830 surfaces%points(3,surfaces%npoints) = zw(k-1) 831 ENDIF 832 ! 833 !-- Upper / lower right index for north- and south-facing surfaces 834 IF ( l == 0 .OR. l == 1 ) THEN 835 IF ( point_index(k,j,i+1) < 0 ) THEN 836 surfaces%npoints = surfaces%npoints + 1 837 point_index(k,j,i+1) = point_index_count 838 point_index_count = point_index_count + 1 839 surfaces%points(1,surfaces%npoints) = ( i + 1 - 0.5_wp ) * dx 840 surfaces%points(2,surfaces%npoints) = ( j - 0.5_wp ) * dy 841 surfaces%points(3,surfaces%npoints) = zw(k-1) 842 ENDIF 843 IF ( point_index(k+1,j,i+1) < 0 ) THEN 844 surfaces%npoints = surfaces%npoints + 1 845 point_index(k+1,j,i+1) = point_index_count 846 point_index_count = point_index_count + 1 847 surfaces%points(1,surfaces%npoints) = ( i + 1 - 0.5_wp ) * dx 848 surfaces%points(2,surfaces%npoints) = ( j - 0.5_wp ) * dy 849 surfaces%points(3,surfaces%npoints) = zw(k) 850 ENDIF 851 ! 852 !-- Upper / lower front index for east- and west-facing surfaces 853 ELSEIF ( l == 2 .OR. l == 3 ) THEN 854 IF ( point_index(k,j+1,i) < 0 ) THEN 855 surfaces%npoints = surfaces%npoints + 1 856 point_index(k,j+1,i) = point_index_count 857 point_index_count = point_index_count + 1 858 surfaces%points(1,surfaces%npoints) = ( i - 0.5_wp ) * dx 859 surfaces%points(2,surfaces%npoints) = ( j + 1 - 0.5_wp ) * dy 860 surfaces%points(3,surfaces%npoints) = zw(k-1) 861 ENDIF 862 IF ( point_index(k+1,j+1,i) < 0 ) THEN 863 surfaces%npoints = surfaces%npoints + 1 864 point_index(k+1,j+1,i) = point_index_count 865 point_index_count = point_index_count + 1 866 surfaces%points(1,surfaces%npoints) = ( i - 0.5_wp ) * dx 867 surfaces%points(2,surfaces%npoints) = ( j + 1 - 0.5_wp ) * dy 868 surfaces%points(3,surfaces%npoints) = zw(k) 869 ENDIF 870 ENDIF 871 ! 872 !-- Upper left / front vertex 873 IF ( point_index(k+1,j,i) < 0 ) THEN 874 surfaces%npoints = surfaces%npoints + 1 875 point_index(k+1,j,i) = point_index_count 876 point_index_count = point_index_count + 1 877 surfaces%points(1,surfaces%npoints) = ( i - 0.5_wp ) * dx 878 surfaces%points(2,surfaces%npoints) = ( j - 0.5_wp ) * dy 879 surfaces%points(3,surfaces%npoints) = zw(k) 880 ENDIF 881 882 npg = npg + 1 883 IF ( l == 0 .OR. l == 1 ) THEN 884 surfaces%polygons(1,npg) = 4 885 surfaces%polygons(2,npg) = point_index(k,j,i) 886 surfaces%polygons(3,npg) = point_index(k,j,i+1) 887 surfaces%polygons(4,npg) = point_index(k+1,j,i+1) 888 surfaces%polygons(5,npg) = point_index(k+1,j,i) 889 ELSE 890 surfaces%polygons(1,npg) = 4 891 surfaces%polygons(2,npg) = point_index(k,j,i) 892 surfaces%polygons(3,npg) = point_index(k,j+1,i) 893 surfaces%polygons(4,npg) = point_index(k+1,j+1,i) 894 surfaces%polygons(5,npg) = point_index(k+1,j,i) 895 ENDIF 896 897 ENDDO 898 899 DO m = 1, surf_lsm_v(l)%ns 900 i = surf_lsm_v(l)%i(m) + MERGE( surf_lsm_v(l)%ioff, 0, l == 3 ) 901 j = surf_lsm_v(l)%j(m) + MERGE( surf_lsm_v(l)%joff, 0, l == 1 ) 902 k = surf_lsm_v(l)%k(m) + surf_lsm_v(l)%koff 903 ! 904 !-- Lower left /front vertex 905 IF ( point_index(k,j,i) < 0 ) THEN 906 surfaces%npoints = surfaces%npoints + 1 907 point_index(k,j,i) = point_index_count 908 point_index_count = point_index_count + 1 909 surfaces%points(1,surfaces%npoints) = ( i - 0.5_wp ) * dx 910 surfaces%points(2,surfaces%npoints) = ( j - 0.5_wp ) * dy 911 surfaces%points(3,surfaces%npoints) = zw(k-1) 912 ENDIF 913 ! 914 !-- Upper / lower right index for north- and south-facing surfaces 915 IF ( l == 0 .OR. l == 1 ) THEN 916 IF ( point_index(k,j,i+1) < 0 ) THEN 917 surfaces%npoints = surfaces%npoints + 1 918 point_index(k,j,i+1) = point_index_count 919 point_index_count = point_index_count + 1 920 surfaces%points(1,surfaces%npoints) = ( i + 1 - 0.5_wp ) * dx 921 surfaces%points(2,surfaces%npoints) = ( j - 0.5_wp ) * dy 922 surfaces%points(3,surfaces%npoints) = zw(k-1) 923 ENDIF 924 IF ( point_index(k+1,j,i+1) < 0 ) THEN 925 surfaces%npoints = surfaces%npoints + 1 926 point_index(k+1,j,i+1) = point_index_count 927 point_index_count = point_index_count + 1 928 surfaces%points(1,surfaces%npoints) = ( i + 1 - 0.5_wp ) * dx 929 surfaces%points(2,surfaces%npoints) = ( j - 0.5_wp ) * dy 930 surfaces%points(3,surfaces%npoints) = zw(k) 931 ENDIF 932 ! 933 !-- Upper / lower front index for east- and west-facing surfaces 934 ELSEIF ( l == 2 .OR. l == 3 ) THEN 935 IF ( point_index(k,j+1,i) < 0 ) THEN 936 surfaces%npoints = surfaces%npoints + 1 937 point_index(k,j+1,i) = point_index_count 938 point_index_count = point_index_count + 1 939 surfaces%points(1,surfaces%npoints) = ( i - 0.5_wp ) * dx 940 surfaces%points(2,surfaces%npoints) = ( j + 1 - 0.5_wp ) * dy 941 surfaces%points(3,surfaces%npoints) = zw(k-1) 942 ENDIF 943 IF ( point_index(k+1,j+1,i) < 0 ) THEN 944 surfaces%npoints = surfaces%npoints + 1 945 point_index(k+1,j+1,i) = point_index_count 946 point_index_count = point_index_count + 1 947 surfaces%points(1,surfaces%npoints) = ( i - 0.5_wp ) * dx 948 surfaces%points(2,surfaces%npoints) = ( j + 1 - 0.5_wp ) * dy 949 surfaces%points(3,surfaces%npoints) = zw(k) 950 ENDIF 951 ENDIF 952 ! 953 !-- Upper left / front vertex 954 IF ( point_index(k+1,j,i) < 0 ) THEN 955 surfaces%npoints = surfaces%npoints + 1 956 point_index(k+1,j,i) = point_index_count 957 point_index_count = point_index_count + 1 958 surfaces%points(1,surfaces%npoints) = ( i - 0.5_wp ) * dx 959 surfaces%points(2,surfaces%npoints) = ( j - 0.5_wp ) * dy 960 surfaces%points(3,surfaces%npoints) = zw(k) 961 ENDIF 962 963 npg = npg + 1 964 IF ( l == 0 .OR. l == 1 ) THEN 965 surfaces%polygons(1,npg) = 4 966 surfaces%polygons(2,npg) = point_index(k,j,i) 967 surfaces%polygons(3,npg) = point_index(k,j,i+1) 968 surfaces%polygons(4,npg) = point_index(k+1,j,i+1) 969 surfaces%polygons(5,npg) = point_index(k+1,j,i) 970 ELSE 971 surfaces%polygons(1,npg) = 4 972 surfaces%polygons(2,npg) = point_index(k,j,i) 973 surfaces%polygons(3,npg) = point_index(k,j+1,i) 974 surfaces%polygons(4,npg) = point_index(k+1,j+1,i) 975 surfaces%polygons(5,npg) = point_index(k+1,j,i) 976 ENDIF 977 ENDDO 978 DO m = 1, surf_usm_v(l)%ns 979 i = surf_usm_v(l)%i(m) + MERGE( surf_usm_v(l)%ioff, 0, l == 3 ) 980 j = surf_usm_v(l)%j(m) + MERGE( surf_usm_v(l)%joff, 0, l == 1 ) 981 k = surf_usm_v(l)%k(m) + surf_usm_v(l)%koff 982 ! 983 !-- Lower left /front vertex 984 IF ( point_index(k,j,i) < 0 ) THEN 985 surfaces%npoints = surfaces%npoints + 1 986 point_index(k,j,i) = point_index_count 987 point_index_count = point_index_count + 1 988 surfaces%points(1,surfaces%npoints) = ( i - 0.5_wp ) * dx 989 surfaces%points(2,surfaces%npoints) = ( j - 0.5_wp ) * dy 990 surfaces%points(3,surfaces%npoints) = zw(k-1) 991 ENDIF 992 ! 993 !-- Upper / lower right index for north- and south-facing surfaces 994 IF ( l == 0 .OR. l == 1 ) THEN 995 IF ( point_index(k,j,i+1) < 0 ) THEN 996 surfaces%npoints = surfaces%npoints + 1 997 point_index(k,j,i+1) = point_index_count 998 point_index_count = point_index_count + 1 999 surfaces%points(1,surfaces%npoints) = ( i + 1 - 0.5_wp ) * dx 1000 surfaces%points(2,surfaces%npoints) = ( j - 0.5_wp ) * dy 1001 surfaces%points(3,surfaces%npoints) = zw(k-1) 1002 ENDIF 1003 IF ( point_index(k+1,j,i+1) < 0 ) THEN 1004 surfaces%npoints = surfaces%npoints + 1 1005 point_index(k+1,j,i+1) = point_index_count 1006 point_index_count = point_index_count + 1 1007 surfaces%points(1,surfaces%npoints) = ( i + 1 - 0.5_wp ) * dx 1008 surfaces%points(2,surfaces%npoints) = ( j - 0.5_wp ) * dy 1009 surfaces%points(3,surfaces%npoints) = zw(k) 1010 ENDIF 1011 ! 1012 !-- Upper / lower front index for east- and west-facing surfaces 1013 ELSEIF ( l == 2 .OR. l == 3 ) THEN 1014 IF ( point_index(k,j+1,i) < 0 ) THEN 1015 surfaces%npoints = surfaces%npoints + 1 1016 point_index(k,j+1,i) = point_index_count 1017 point_index_count = point_index_count + 1 1018 surfaces%points(1,surfaces%npoints) = ( i - 0.5_wp ) * dx 1019 surfaces%points(2,surfaces%npoints) = ( j + 1 - 0.5_wp ) * dy 1020 surfaces%points(3,surfaces%npoints) = zw(k-1) 1021 ENDIF 1022 IF ( point_index(k+1,j+1,i) < 0 ) THEN 1023 surfaces%npoints = surfaces%npoints + 1 1024 point_index(k+1,j+1,i) = point_index_count 1025 point_index_count = point_index_count + 1 1026 surfaces%points(1,surfaces%npoints) = ( i - 0.5_wp ) * dx 1027 surfaces%points(2,surfaces%npoints) = ( j + 1 - 0.5_wp ) * dy 1028 surfaces%points(3,surfaces%npoints) = zw(k) 1029 ENDIF 1030 ENDIF 1031 ! 1032 !-- Upper left / front vertex 1033 IF ( point_index(k+1,j,i) < 0 ) THEN 1034 surfaces%npoints = surfaces%npoints + 1 1035 point_index(k+1,j,i) = point_index_count 1036 point_index_count = point_index_count + 1 1037 surfaces%points(1,surfaces%npoints) = ( i - 0.5_wp ) * dx 1038 surfaces%points(2,surfaces%npoints) = ( j - 0.5_wp ) * dy 1039 surfaces%points(3,surfaces%npoints) = zw(k) 1040 ENDIF 1041 1042 npg = npg + 1 1043 IF ( l == 0 .OR. l == 1 ) THEN 1044 surfaces%polygons(1,npg) = 4 1045 surfaces%polygons(2,npg) = point_index(k,j,i) 1046 surfaces%polygons(3,npg) = point_index(k,j,i+1) 1047 surfaces%polygons(4,npg) = point_index(k+1,j,i+1) 1048 surfaces%polygons(5,npg) = point_index(k+1,j,i) 1049 ELSE 1050 surfaces%polygons(1,npg) = 4 1051 surfaces%polygons(2,npg) = point_index(k,j,i) 1052 surfaces%polygons(3,npg) = point_index(k,j+1,i) 1053 surfaces%polygons(4,npg) = point_index(k+1,j+1,i) 1054 surfaces%polygons(5,npg) = point_index(k+1,j,i) 1055 ENDIF 1056 ENDDO 1057 1058 ENDDO 1059 ! 1060 !-- Deallocate temporary dummy variable 1061 DEALLOCATE ( point_index ) 1062 ! 1063 !-- Sum-up total number of vertices on domain. This will be needed for post-processing. 1064 surfaces%npoints_total = 0 1043 1065 #if defined( __parallel ) 1044 CALL MPI_ALLREDUCE( surfaces%npoints, surfaces%npoints_total, 1, &1045 MPI_INTEGER, MPI_SUM,comm2d, ierr )1066 CALL MPI_ALLREDUCE( surfaces%npoints, surfaces%npoints_total, 1, MPI_INTEGER, MPI_SUM, & 1067 comm2d, ierr ) 1046 1068 #else 1047 surfaces%npoints_total = surfaces%npoints 1069 surfaces%npoints_total = surfaces%npoints 1070 #endif 1071 ENDIF 1072 ! 1073 !-- If output to netcdf is enabled, set-up the coordinate arrays that unambiguously describe the 1074 !-- position and orientation of each surface element. 1075 IF ( to_netcdf ) THEN 1076 ! 1077 !-- Allocate local coordinate arrays 1078 ALLOCATE( surfaces%s(1:surfaces%ns) ) 1079 ALLOCATE( surfaces%xs(1:surfaces%ns) ) 1080 ALLOCATE( surfaces%ys(1:surfaces%ns) ) 1081 ALLOCATE( surfaces%zs(1:surfaces%ns) ) 1082 ALLOCATE( surfaces%azimuth(1:surfaces%ns) ) 1083 ALLOCATE( surfaces%zenith(1:surfaces%ns) ) 1084 ALLOCATE( surfaces%es_utm(1:surfaces%ns) ) 1085 ALLOCATE( surfaces%ns_utm(1:surfaces%ns) ) 1086 ! 1087 !-- Gather the number of surface on each processor, in order to number the surface elements in 1088 !-- ascending order with respect to the total number of surfaces in the domain. 1089 #if defined( __parallel ) 1090 CALL MPI_ALLGATHER( surfaces%ns, 1, MPI_INTEGER, num_surfaces_on_pe, 1, MPI_INTEGER, & 1091 comm2d, ierr ) 1092 #else 1093 num_surfaces_on_pe = surfaces%ns 1094 #endif 1095 ! 1096 !-- First, however, determine the offset where couting of the surfaces should start (the sum of 1097 !-- surfaces on all PE's with lower MPI rank). 1098 i = 0 1099 start_count = 1 1100 DO WHILE ( i < myid .AND. i <= SIZE( num_surfaces_on_pe ) ) 1101 start_count = start_count + num_surfaces_on_pe(i) 1102 i = i + 1 1103 ENDDO 1104 ! 1105 !-- Set coordinate arrays. For horizontal surfaces, azimuth angles are not defined (fill value). 1106 !-- Zenith angle is 0 (180) for upward (downward)-facing surfaces. 1107 i = start_count 1108 mm = 1 1109 DO m = 1, surf_def_h(0)%ns 1110 surfaces%s(mm) = i 1111 surfaces%xs(mm) = ( surf_def_h(0)%i(m) + 0.5_wp ) * dx 1112 surfaces%ys(mm) = ( surf_def_h(0)%j(m) + 0.5_wp ) * dy 1113 surfaces%zs(mm) = zw(surf_def_h(0)%k(m)+surf_def_h(0)%koff) 1114 surfaces%azimuth(mm) = surfaces%fillvalue 1115 surfaces%zenith(mm) = 0.0 1116 i = i + 1 1117 mm = mm + 1 1118 ENDDO 1119 DO m = 1, surf_lsm_h%ns 1120 surfaces%s(mm) = i 1121 surfaces%xs(mm) = ( surf_lsm_h%i(m) + 0.5_wp ) * dx 1122 surfaces%ys(mm) = ( surf_lsm_h%j(m) + 0.5_wp ) * dy 1123 surfaces%zs(mm) = zw(surf_lsm_h%k(m)+surf_lsm_h%koff) 1124 surfaces%azimuth(mm) = surfaces%fillvalue 1125 surfaces%zenith(mm) = 0.0 1126 i = i + 1 1127 mm = mm + 1 1128 ENDDO 1129 DO m = 1, surf_usm_h%ns 1130 surfaces%s(mm) = i 1131 surfaces%xs(mm) = ( surf_usm_h%i(m) + 0.5_wp ) * dx 1132 surfaces%ys(mm) = ( surf_usm_h%j(m) + 0.5_wp ) * dy 1133 surfaces%zs(mm) = zw(surf_usm_h%k(m)+surf_usm_h%koff) 1134 surfaces%azimuth(mm) = surfaces%fillvalue 1135 surfaces%zenith(mm) = 0.0 1136 i = i + 1 1137 mm = mm + 1 1138 ENDDO 1139 DO m = 1, surf_def_h(1)%ns 1140 surfaces%s(mm) = i 1141 surfaces%xs(mm) = ( surf_def_h(1)%i(m) + 0.5_wp ) * dx 1142 surfaces%ys(mm) = ( surf_def_h(1)%j(m) + 0.5_wp ) * dy 1143 surfaces%zs(mm) = zw(surf_def_h(1)%k(m)+surf_def_h(1)%koff) 1144 surfaces%azimuth(mm) = surfaces%fillvalue 1145 surfaces%zenith(mm) = 180.0 1146 i = i + 1 1147 mm = mm + 1 1148 ENDDO 1149 ! 1150 !-- For vertical surfaces, zenith angles are not defined (fill value). 1151 !-- Azimuth angle: northward (0), eastward (90), southward (180), westward (270). 1152 !-- Note, for vertical surfaces, zenith angles are 90.0_wp. 1153 DO l = 0, 3 1154 IF ( l == 0 ) THEN 1155 az = 0.0_wp 1156 off_x = 0.5_wp 1157 off_y = 0.0_wp 1158 ELSEIF ( l == 1 ) THEN 1159 az = 180.0_wp 1160 off_x = 0.5_wp 1161 off_y = 1.0_wp 1162 ELSEIF ( l == 2 ) THEN 1163 az = 90.0_wp 1164 off_x = 0.0_wp 1165 off_y = 0.5_wp 1166 ELSEIF ( l == 3 ) THEN 1167 az = 270.0_wp 1168 off_x = 1.0_wp 1169 off_y = 0.5_wp 1170 ENDIF 1171 1172 DO m = 1, surf_def_v(l)%ns 1173 surfaces%s(mm) = i 1174 surfaces%xs(mm) = ( surf_def_v(l)%i(m) + off_x ) * dx 1175 surfaces%ys(mm) = ( surf_def_v(l)%j(m) + off_y ) * dy 1176 surfaces%zs(mm) = zu(surf_def_v(l)%k(m)) 1177 surfaces%azimuth(mm) = az 1178 surfaces%zenith(mm) = 90.0_wp 1179 i = i + 1 1180 mm = mm + 1 1181 ENDDO 1182 DO m = 1, surf_lsm_v(l)%ns 1183 surfaces%s(mm) = i 1184 surfaces%xs(mm) = ( surf_lsm_v(l)%i(m) + off_x ) * dx 1185 surfaces%ys(mm) = ( surf_lsm_v(l)%j(m) + off_y ) * dy 1186 surfaces%zs(mm) = zu(surf_lsm_v(l)%k(m)) 1187 surfaces%azimuth(mm) = az 1188 surfaces%zenith(mm) = 90.0_wp 1189 i = i + 1 1190 mm = mm + 1 1191 ENDDO 1192 DO m = 1, surf_usm_v(l)%ns 1193 surfaces%s(mm) = i 1194 surfaces%xs(mm) = ( surf_usm_v(l)%i(m) + off_x ) * dx 1195 surfaces%ys(mm) = ( surf_usm_v(l)%j(m) + off_y ) * dy 1196 surfaces%zs(mm) = zu(surf_usm_v(l)%k(m)) 1197 surfaces%azimuth(mm) = az 1198 surfaces%zenith(mm) = 90.0_wp 1199 i = i + 1 1200 mm = mm + 1 1201 ENDDO 1202 ENDDO 1203 ! 1204 !-- Finally, define UTM coordinates, which are the x/y-coordinates plus the origin (lower-left 1205 !-- coordinate of the model domain). 1206 surfaces%es_utm = surfaces%xs + init_model%origin_x 1207 surfaces%ns_utm = surfaces%ys + init_model%origin_y 1208 ! 1209 !-- Initialize NetCDF data output. Please note, local start position for the surface elements in 1210 !-- the NetCDF file is surfaces%s(1), while the number of surfaces on the subdomain is given by 1211 !-- surfaces%ns. 1212 #if defined( __netcdf4_parallel ) 1213 1214 ! 1215 !-- Calculate number of time steps to be output 1216 ntdim_surf(0) = dosurf_time_count(0) + CEILING( ( end_time - MAX( & 1217 MERGE( skip_time_dosurf, skip_time_dosurf + spinup_time, & 1218 data_output_during_spinup ), simulated_time_at_begin ) & 1219 ) / dt_dosurf ) 1220 1221 ntdim_surf(1) = dosurf_time_count(1) + CEILING( ( end_time - MAX( & 1222 MERGE( skip_time_dosurf_av, skip_time_dosurf_av + spinup_time, & 1223 data_output_during_spinup ), simulated_time_at_begin ) & 1224 ) / dt_dosurf_av ) 1225 1226 ! 1227 !-- Create NetCDF4 files for parallel writing 1228 DO av = 0, 1 1229 ! 1230 !-- If there is no instantaneous data (av=0) or averaged data (av=1) requested, do not create 1231 !-- the corresponding NetCDF file 1232 IF ( dosurf_no(av) == 0 ) CYCLE 1233 1234 IF ( av == 0 ) THEN 1235 filename = 'SURFACE_DATA_NETCDF' // TRIM( coupling_char ) 1236 ELSE 1237 filename = 'SURFACE_DATA_AV_NETCDF' // TRIM( coupling_char ) 1238 ENDIF 1239 ! 1240 !-- Open file using netCDF4/HDF5 format, parallel 1241 nc_stat = NF90_CREATE( TRIM(filename), & 1242 IOR( NF90_NOCLOBBER, IOR( NF90_NETCDF4, NF90_MPIIO ) ), & 1243 id_set_surf(av), COMM = comm2d, INFO = MPI_INFO_NULL ) 1244 CALL netcdf_handle_error( 'surface_data_output_mod', 5550 ) 1245 1246 !- Write some global attributes 1247 IF ( av == 0 ) THEN 1248 CALL netcdf_create_global_atts( id_set_surf(av), 'surface-data', & 1249 TRIM( run_description_header ), 5551 ) 1250 time_average_text = ' ' 1251 ELSE 1252 CALL netcdf_create_global_atts( id_set_surf(av), 'surface-data_av', & 1253 TRIM( run_description_header ), 5552 ) 1254 WRITE ( time_average_text,'(F7.1,'' s avg'')' ) averaging_interval_surf 1255 nc_stat = NF90_PUT_ATT( id_set_surf(av), NF90_GLOBAL, 'time_avg', & 1256 TRIM( time_average_text ) ) 1257 CALL netcdf_handle_error( 'surface_data_output_mod', 5553 ) 1258 ENDIF 1259 1260 1261 ! 1262 !-- Define time coordinate for surface data. 1263 !-- For parallel output the time dimension has to be limited (ntdim_surf), otherwise the 1264 !-- performance drops significantly. 1265 CALL netcdf_create_dim( id_set_surf(av), 'time', ntdim_surf(av), id_dim_time_surf(av), & 1266 5554 ) 1267 1268 CALL netcdf_create_var( id_set_surf(av), (/ id_dim_time_surf(av) /), & 1269 'time', NF90_DOUBLE, id_var_time_surf(av), & 1270 'seconds since '// TRIM(init_model%origin_time), & 1271 'time', 5555, 5555, 5555 ) 1272 1273 CALL netcdf_create_att( id_set_surf(av), id_var_time_surf(av), 'standard_name', 'time', & 1274 5556) 1275 1276 CALL netcdf_create_att( id_set_surf(av), id_var_time_surf(av), 'axis', 'T', 5557) 1277 ! 1278 !-- Define spatial dimensions and coordinates: 1279 !-- Define index of surface element 1280 CALL netcdf_create_dim( id_set_surf(av), 's', surfaces%ns_total, id_dim_s_surf(av), & 1281 5558 ) 1282 CALL netcdf_create_var( id_set_surf(av), (/ id_dim_s_surf(av) /), 's', NF90_DOUBLE, & 1283 id_var_s_surf(av), '1', 'number of surface element', 5559, & 1284 5559, 5559 ) 1285 ! 1286 !-- Define x coordinate 1287 CALL netcdf_create_var( id_set_surf(av), (/ id_dim_s_surf(av) /), 'xs', NF90_DOUBLE, & 1288 id_var_xs_surf(av), 'meters', & 1289 'distance to origin in x-direction', 5561, 5561, 5561 ) 1290 ! 1291 !-- Define y coordinate 1292 CALL netcdf_create_var( id_set_surf(av), (/ id_dim_s_surf(av) /), 'ys', NF90_DOUBLE, & 1293 id_var_ys_surf(av), 'meters', & 1294 'distance to origin in y-direction', 5562, 5562, 5562 ) 1295 ! 1296 !-- Define z coordinate 1297 CALL netcdf_create_var( id_set_surf(av), (/ id_dim_s_surf(av) /), 'zs', NF90_DOUBLE, & 1298 id_var_zs_surf(av), 'meters', 'height', 5560, 5560, 5560 ) 1299 CALL netcdf_create_att( id_set_surf(av), id_var_zs_surf(av), 'standard_name', 'height', & 1300 5583 ) 1301 1302 ! 1303 !-- Define UTM coordinates 1304 CALL netcdf_create_var( id_set_surf(av), (/ id_dim_s_surf(av) /), 'Es_UTM', & 1305 NF90_DOUBLE, id_var_etum_surf(av), 'meters', '', 5563, 5563, & 1306 5563 ) 1307 CALL netcdf_create_var( id_set_surf(av), (/ id_dim_s_surf(av) /), 'Ns_UTM', & 1308 NF90_DOUBLE, id_var_nutm_surf(av), 'meters', '', 5564, 5564, & 1309 5564 ) 1310 1311 ! 1312 !-- Define angles 1313 CALL netcdf_create_var( id_set_surf(av), (/ id_dim_s_surf(av) /), 'azimuth', & 1314 NF90_DOUBLE, id_var_azimuth_surf(av), 'degree', & 1315 'azimuth angle', 5577, 5578, 5579, fill = .TRUE. ) 1316 CALL netcdf_create_att( id_set_surf(av), id_var_azimuth_surf(av), 'standard_name', & 1317 'surface_azimuth_angle', 5584 ) 1318 1319 CALL netcdf_create_var( id_set_surf(av), (/ id_dim_s_surf(av) /), 'zenith', & 1320 NF90_DOUBLE, id_var_zenith_surf(av), 'degree', '', 5580, 5581, & 1321 5582, fill = .TRUE. ) 1322 ! 1323 !-- Define the variables 1324 var_list = ';' 1325 i = 1 1326 1327 DO WHILE ( dosurf(av,i)(1:1) /= ' ' ) 1328 1329 CALL netcdf_create_var( id_set_surf(av), & 1330 (/ id_dim_s_surf(av), id_dim_time_surf(av) /), dosurf(av,i), & 1331 NF90_REAL4, id_var_dosurf(av,i), dosurf_unit(av,i), & 1332 dosurf(av,i), 5565, 5565, 5565, .TRUE. ) 1333 ! 1334 !-- Set no fill for every variable to increase performance. 1335 nc_stat = NF90_DEF_VAR_FILL( id_set_surf(av), id_var_dosurf(av,i), NF90_NOFILL, 0 ) 1336 CALL netcdf_handle_error( 'surface_data_output_init', 5566 ) 1337 ! 1338 !-- Set collective io operations for parallel io 1339 nc_stat = NF90_VAR_PAR_ACCESS( id_set_surf(av), id_var_dosurf(av,i), NF90_COLLECTIVE ) 1340 CALL netcdf_handle_error( 'surface_data_output_init', 5567 ) 1341 var_list = TRIM( var_list ) // TRIM( dosurf(av,i) ) // ';' 1342 1343 i = i + 1 1344 1345 ENDDO 1346 ! 1347 !-- Write the list of variables as global attribute (this is used by restart runs and by 1348 !-- combine_plot_fields) 1349 nc_stat = NF90_PUT_ATT( id_set_surf(av), NF90_GLOBAL, 'VAR_LIST', var_list ) 1350 CALL netcdf_handle_error( 'surface_data_output_init', 5568 ) 1351 1352 ! 1353 !-- Set general no fill, otherwise the performance drops significantly for parallel output. 1354 nc_stat = NF90_SET_FILL( id_set_surf(av), NF90_NOFILL, oldmode ) 1355 CALL netcdf_handle_error( 'surface_data_output_init', 5569 ) 1356 1357 ! 1358 !-- Leave netCDF define mode 1359 nc_stat = NF90_ENDDEF( id_set_surf(av) ) 1360 CALL netcdf_handle_error( 'surface_data_output_init', 5570 ) 1361 1362 ! 1363 !-- These data are only written by PE0 for parallel output to increase the performance. 1364 IF ( myid == 0 ) THEN 1365 ! 1366 !-- Write data for surface indices 1367 ALLOCATE( netcdf_data_1d(1:surfaces%ns_total) ) 1368 1369 DO i = 1, surfaces%ns_total 1370 netcdf_data_1d(i) = i 1371 ENDDO 1372 1373 nc_stat = NF90_PUT_VAR( id_set_surf(av), id_var_s_surf(av), netcdf_data_1d, & 1374 start = (/ 1 /), count = (/ surfaces%ns_total /) ) 1375 CALL netcdf_handle_error( 'surface_data_output_init', 5571 ) 1376 1377 DEALLOCATE( netcdf_data_1d ) 1378 1379 ENDIF 1380 1381 ! 1382 !-- Write surface positions to file 1383 nc_stat = NF90_PUT_VAR( id_set_surf(av), id_var_xs_surf(av), & 1384 surfaces%xs, start = (/ surfaces%s(1) /), & 1385 count = (/ surfaces%ns /) ) 1386 CALL netcdf_handle_error( 'surface_data_output_init', 5572 ) 1387 1388 nc_stat = NF90_PUT_VAR( id_set_surf(av), id_var_ys_surf(av), surfaces%ys, & 1389 start = (/ surfaces%s(1) /), count = (/ surfaces%ns /) ) 1390 CALL netcdf_handle_error( 'surface_data_output_init', 5573 ) 1391 1392 nc_stat = NF90_PUT_VAR( id_set_surf(av), id_var_zs_surf(av), surfaces%zs, & 1393 start = (/ surfaces%s(1) /), count = (/ surfaces%ns /) ) 1394 CALL netcdf_handle_error( 'surface_data_output_init', 5574 ) 1395 1396 nc_stat = NF90_PUT_VAR( id_set_surf(av), id_var_etum_surf(av), surfaces%es_utm, & 1397 start = (/ surfaces%s(1) /), count = (/ surfaces%ns /) ) 1398 CALL netcdf_handle_error( 'surface_data_output_init', 5575 ) 1399 1400 nc_stat = NF90_PUT_VAR( id_set_surf(av), id_var_nutm_surf(av), surfaces%ns_utm, & 1401 start = (/ surfaces%s(1) /), count = (/ surfaces%ns /) ) 1402 CALL netcdf_handle_error( 'surface_data_output_init', 5576 ) 1403 1404 nc_stat = NF90_PUT_VAR( id_set_surf(av), id_var_azimuth_surf(av), surfaces%azimuth, & 1405 start = (/ surfaces%s(1) /), count = (/ surfaces%ns /) ) 1406 CALL netcdf_handle_error( 'surface_data_output_init', 5585 ) 1407 1408 nc_stat = NF90_PUT_VAR( id_set_surf(av), id_var_zenith_surf(av), surfaces%zenith, & 1409 start = (/ surfaces%s(1) /), count = (/ surfaces%ns /) ) 1410 CALL netcdf_handle_error( 'surface_data_output_init', 5586 ) 1411 1412 ENDDO 1413 #endif 1414 1415 ENDIF 1416 1417 END SUBROUTINE surface_data_output_init 1418 1419 !--------------------------------------------------------------------------------------------------! 1420 ! Description: 1421 ! ------------ 1422 !> Routine for controlling the data output. Surface data is collected from different types of 1423 !> surfaces (default, natural, urban) and different orientation and written to one 1D-output array. 1424 !> Further, NetCDF routines are called to write the surface data in the respective NetCDF files. 1425 !--------------------------------------------------------------------------------------------------! 1426 SUBROUTINE surface_data_output( av ) 1427 1428 USE control_parameters, & 1429 ONLY: io_blocks, & 1430 io_group, & 1431 time_since_reference_point 1432 1433 #if defined( __parallel ) 1434 USE pegrid, & 1435 ONLY: comm2d, & 1436 ierr 1437 #endif 1438 1439 1440 IMPLICIT NONE 1441 1442 CHARACTER(LEN=100) :: trimvar = ' ' !< dummy for single output variable 1443 1444 INTEGER(iwp) :: av !< id indicating average or non-average data output 1445 INTEGER(iwp) :: i !< loop index 1446 INTEGER(iwp) :: l !< running index for surface orientation 1447 INTEGER(iwp) :: m !< running index for surface elements 1448 INTEGER(iwp) :: n_out !< counter variables for surface output 1449 1450 ! 1451 !-- Return, if nothing to output 1452 IF ( dosurf_no(av) == 0 ) RETURN 1453 ! 1454 !-- In case of VTK output, check if binary files are open and write coordinates. 1455 IF ( to_vtk ) THEN 1456 1457 CALL check_open( 25 + av ) 1458 1459 IF ( .NOT. first_output(av) ) THEN 1460 DO i = 0, io_blocks - 1 1461 IF ( i == io_group ) THEN 1462 WRITE ( 25 + av ) surfaces%npoints 1463 WRITE ( 25 + av ) surfaces%npoints_total 1464 WRITE ( 25 + av ) surfaces%ns 1465 WRITE ( 25 + av ) surfaces%ns_total 1466 WRITE ( 25 + av ) surfaces%points 1467 WRITE ( 25 + av ) surfaces%polygons 1468 ENDIF 1469 #if defined( __parallel ) 1470 CALL MPI_BARRIER( comm2d, ierr ) 1471 #endif 1472 first_output(av) = .TRUE. 1473 ENDDO 1474 ENDIF 1475 ENDIF 1476 ! 1477 !-- In case of NetCDF output, check if enough time steps are available in file and update time axis. 1478 IF ( to_netcdf ) THEN 1479 #if defined( __netcdf4_parallel ) 1480 IF ( dosurf_time_count(av) + 1 > ntdim_surf(av) ) THEN 1481 WRITE ( message_string, * ) 'Output of surface data is not given at t=', & 1482 time_since_reference_point, 's because the maximum ', & 1483 'number of output time levels is exceeded.' 1484 CALL message( 'surface_data_output', 'PA0539', 0, 1, 0, 6, 0 ) 1485 1486 RETURN 1487 1488 ENDIF 1489 ! 1490 !-- Update the netCDF time axis 1491 !-- In case of parallel output, this is only done by PE0 to increase the performance. 1492 dosurf_time_count(av) = dosurf_time_count(av) + 1 1493 IF ( myid == 0 ) THEN 1494 nc_stat = NF90_PUT_VAR( id_set_surf(av), id_var_time_surf(av), & 1495 (/ time_since_reference_point /), & 1496 start = (/ dosurf_time_count(av) /), count = (/ 1 /) ) 1497 CALL netcdf_handle_error( 'surface_data_output', 6666 ) 1498 ENDIF 1499 #endif 1500 ENDIF 1501 1502 ! 1503 !-- Cycle through output quantities and write them to file. 1504 n_out = 0 1505 DO WHILE ( dosurf(av,n_out+1)(1:1) /= ' ' ) 1506 1507 n_out = n_out + 1 1508 trimvar = TRIM( dosurf(av,n_out) ) 1509 ! 1510 !-- Set the output array to the _FillValue in case it is not defined for each type of surface. 1511 surfaces%var_out = surfaces%fillvalue 1512 SELECT CASE ( trimvar ) 1513 1514 CASE ( 'us' ) 1515 ! 1516 !-- Output of instantaneous data 1517 IF ( av == 0 ) THEN 1518 CALL surface_data_output_collect( surf_def_h(0)%us, surf_def_h(1)%us, & 1519 surf_lsm_h%us, surf_usm_h%us, surf_def_v(0)%us, & 1520 surf_lsm_v(0)%us, surf_usm_v(0)%us, & 1521 surf_def_v(1)%us, surf_lsm_v(1)%us, & 1522 surf_usm_v(1)%us, surf_def_v(2)%us, & 1523 surf_lsm_v(2)%us, surf_usm_v(2)%us, & 1524 surf_def_v(3)%us, surf_lsm_v(3)%us, & 1525 surf_usm_v(3)%us ) 1526 ELSE 1527 ! 1528 !-- Output of averaged data 1529 surfaces%var_out(:) = surfaces%var_av(:,n_out) / REAL( average_count_surf, KIND=wp ) 1530 surfaces%var_av(:,n_out) = 0.0_wp 1531 1532 ENDIF 1533 1534 CASE ( 'ts' ) 1535 ! 1536 !-- Output of instantaneous data 1537 IF ( av == 0 ) THEN 1538 CALL surface_data_output_collect( surf_def_h(0)%ts, surf_def_h(1)%ts, & 1539 surf_lsm_h%ts, surf_usm_h%ts, surf_def_v(0)%ts, & 1540 surf_lsm_v(0)%ts, surf_usm_v(0)%ts, & 1541 surf_def_v(1)%ts, surf_lsm_v(1)%ts, & 1542 surf_usm_v(1)%ts, surf_def_v(2)%ts, & 1543 surf_lsm_v(2)%ts, surf_usm_v(2)%ts, & 1544 surf_def_v(3)%ts, surf_lsm_v(3)%ts, & 1545 surf_usm_v(3)%ts ) 1546 ELSE 1547 ! 1548 !-- Output of averaged data 1549 surfaces%var_out(:) = surfaces%var_av(:,n_out) / REAL( average_count_surf, KIND=wp ) 1550 surfaces%var_av(:,n_out) = 0.0_wp 1551 1552 ENDIF 1553 1554 CASE ( 'qs' ) 1555 ! 1556 !-- Output of instantaneous data 1557 IF ( av == 0 ) THEN 1558 CALL surface_data_output_collect( surf_def_h(0)%qs, surf_def_h(1)%qs, & 1559 surf_lsm_h%qs, surf_usm_h%qs, surf_def_v(0)%qs, & 1560 surf_lsm_v(0)%qs, surf_usm_v(0)%qs, & 1561 surf_def_v(1)%qs, surf_lsm_v(1)%qs, & 1562 surf_usm_v(1)%qs, surf_def_v(2)%qs, & 1563 surf_lsm_v(2)%qs, surf_usm_v(2)%qs, & 1564 surf_def_v(3)%qs, surf_lsm_v(3)%qs, & 1565 surf_usm_v(3)%qs ) 1566 ELSE 1567 ! 1568 !-- Output of averaged data 1569 surfaces%var_out(:) = surfaces%var_av(:,n_out) / REAL( average_count_surf, KIND=wp ) 1570 surfaces%var_av(:,n_out) = 0.0_wp 1571 1572 ENDIF 1573 1574 CASE ( 'ss' ) 1575 ! 1576 !-- Output of instantaneous data 1577 IF ( av == 0 ) THEN 1578 CALL surface_data_output_collect( surf_def_h(0)%ss, surf_def_h(1)%ss, & 1579 surf_lsm_h%ss, surf_usm_h%ss, surf_def_v(0)%ss, & 1580 surf_lsm_v(0)%ss, surf_usm_v(0)%ss, & 1581 surf_def_v(1)%ss, surf_lsm_v(1)%ss, & 1582 surf_usm_v(1)%ss, surf_def_v(2)%ss, & 1583 surf_lsm_v(2)%ss, surf_usm_v(2)%ss, & 1584 surf_def_v(3)%ss, surf_lsm_v(3)%ss, & 1585 surf_usm_v(3)%ss ) 1586 ELSE 1587 ! 1588 !-- Output of averaged data 1589 surfaces%var_out(:) = surfaces%var_av(:,n_out) / REAL( average_count_surf, KIND=wp ) 1590 surfaces%var_av(:,n_out) = 0.0_wp 1591 1592 ENDIF 1593 1594 CASE ( 'qcs' ) 1595 ! 1596 !-- Output of instantaneous data 1597 IF ( av == 0 ) THEN 1598 CALL surface_data_output_collect( surf_def_h(0)%qcs, surf_def_h(1)%qcs, & 1599 surf_lsm_h%qcs, surf_usm_h%qcs, & 1600 surf_def_v(0)%qcs, surf_lsm_v(0)%qcs, & 1601 surf_usm_v(0)%qcs, surf_def_v(1)%qcs, & 1602 surf_lsm_v(1)%qcs, surf_usm_v(1)%qcs, & 1603 surf_def_v(2)%qcs, surf_lsm_v(2)%qcs, & 1604 surf_usm_v(2)%qcs, surf_def_v(3)%qcs, & 1605 surf_lsm_v(3)%qcs, surf_usm_v(3)%qcs ) 1606 ELSE 1607 ! 1608 !-- Output of averaged data 1609 surfaces%var_out(:) = surfaces%var_av(:,n_out) / REAL( average_count_surf, KIND=wp ) 1610 surfaces%var_av(:,n_out) = 0.0_wp 1611 1612 ENDIF 1613 1614 CASE ( 'ncs' ) 1615 ! 1616 !-- Output of instantaneous data 1617 IF ( av == 0 ) THEN 1618 CALL surface_data_output_collect( surf_def_h(0)%ncs, surf_def_h(1)%ncs, & 1619 surf_lsm_h%ncs, surf_usm_h%ncs, & 1620 surf_def_v(0)%ncs, surf_lsm_v(0)%ncs, & 1621 surf_usm_v(0)%ncs, surf_def_v(1)%ncs, & 1622 surf_lsm_v(1)%ncs, surf_usm_v(1)%ncs, & 1623 surf_def_v(2)%ncs, surf_lsm_v(2)%ncs, & 1624 surf_usm_v(2)%ncs, surf_def_v(3)%ncs, & 1625 surf_lsm_v(3)%ncs, surf_usm_v(3)%ncs ) 1626 ELSE 1627 ! 1628 !-- Output of averaged data 1629 surfaces%var_out(:) = surfaces%var_av(:,n_out) / REAL( average_count_surf, KIND=wp ) 1630 surfaces%var_av(:,n_out) = 0.0_wp 1631 1632 ENDIF 1633 1634 CASE ( 'qis' ) 1635 ! 1636 !-- Output of instantaneous data 1637 IF ( av == 0 ) THEN 1638 CALL surface_data_output_collect( surf_def_h(0)%qis, surf_def_h(1)%qis, & 1639 surf_lsm_h%qis, surf_usm_h%qis, & 1640 surf_def_v(0)%qis, surf_lsm_v(0)%qis, & 1641 surf_usm_v(0)%qis, surf_def_v(1)%qis, & 1642 surf_lsm_v(1)%qis, surf_usm_v(1)%qis, & 1643 surf_def_v(2)%qis, surf_lsm_v(2)%qis, & 1644 surf_usm_v(2)%qis, surf_def_v(3)%qis, & 1645 surf_lsm_v(3)%qis, surf_usm_v(3)%qis ) 1646 ELSE 1647 ! 1648 !-- Output of averaged data 1649 surfaces%var_out(:) = surfaces%var_av(:,n_out) / REAL( average_count_surf, KIND=wp ) 1650 surfaces%var_av(:,n_out) = 0.0_wp 1651 1652 ENDIF 1653 1654 CASE ( 'nis' ) 1655 ! 1656 !-- Output of instantaneous data 1657 IF ( av == 0 ) THEN 1658 CALL surface_data_output_collect( surf_def_h(0)%nis, surf_def_h(1)%nis, & 1659 surf_lsm_h%nis, surf_usm_h%nis, & 1660 surf_def_v(0)%nis, surf_lsm_v(0)%nis, & 1661 surf_usm_v(0)%nis, surf_def_v(1)%nis, & 1662 surf_lsm_v(1)%nis, surf_usm_v(1)%nis, & 1663 surf_def_v(2)%nis, surf_lsm_v(2)%nis, & 1664 surf_usm_v(2)%nis, surf_def_v(3)%nis, & 1665 surf_lsm_v(3)%nis, surf_usm_v(3)%nis ) 1666 ELSE 1667 ! 1668 !-- Output of averaged data 1669 surfaces%var_out(:) = surfaces%var_av(:,n_out) / REAL( average_count_surf, KIND=wp ) 1670 surfaces%var_av(:,n_out) = 0.0_wp 1671 1672 ENDIF 1673 1674 CASE ( 'qrs' ) 1675 ! 1676 !-- Output of instantaneous data 1677 IF ( av == 0 ) THEN 1678 CALL surface_data_output_collect( surf_def_h(0)%qrs, surf_def_h(1)%qrs, & 1679 surf_lsm_h%qrs, surf_usm_h%qrs, & 1680 surf_def_v(0)%qrs, surf_lsm_v(0)%qrs, & 1681 surf_usm_v(0)%qrs, surf_def_v(1)%qrs, & 1682 surf_lsm_v(1)%qrs, surf_usm_v(1)%qrs, & 1683 surf_def_v(2)%qrs, surf_lsm_v(2)%qrs, & 1684 surf_usm_v(2)%qrs, surf_def_v(3)%qrs, & 1685 surf_lsm_v(3)%qrs, surf_usm_v(3)%qrs ) 1686 ELSE 1687 ! 1688 !-- Output of averaged data 1689 surfaces%var_out(:) = surfaces%var_av(:,n_out) / REAL( average_count_surf, KIND=wp ) 1690 surfaces%var_av(:,n_out) = 0.0_wp 1691 1692 ENDIF 1693 1694 CASE ( 'nrs' ) 1695 ! 1696 !-- Output of instantaneous data 1697 IF ( av == 0 ) THEN 1698 CALL surface_data_output_collect( surf_def_h(0)%nrs, surf_def_h(1)%nrs, & 1699 surf_lsm_h%nrs, surf_usm_h%nrs, & 1700 surf_def_v(0)%nrs, surf_lsm_v(0)%nrs, & 1701 surf_usm_v(0)%nrs, surf_def_v(1)%nrs, & 1702 surf_lsm_v(1)%nrs, surf_usm_v(1)%nrs, & 1703 surf_def_v(2)%nrs, surf_lsm_v(2)%nrs, & 1704 surf_usm_v(2)%nrs, surf_def_v(3)%nrs, & 1705 surf_lsm_v(3)%nrs, surf_usm_v(3)%nrs ) 1706 ELSE 1707 ! 1708 !-- Output of averaged data 1709 surfaces%var_out(:) = surfaces%var_av(:,n_out) / REAL( average_count_surf, KIND=wp ) 1710 surfaces%var_av(:,n_out) = 0.0_wp 1711 1712 ENDIF 1713 1714 CASE ( 'ol' ) 1715 ! 1716 !-- Output of instantaneous data 1717 IF ( av == 0 ) THEN 1718 CALL surface_data_output_collect( surf_def_h(0)%ol, surf_def_h(1)%ol, & 1719 surf_lsm_h%ol, surf_usm_h%ol, surf_def_v(0)%ol, & 1720 surf_lsm_v(0)%ol, surf_usm_v(0)%ol, & 1721 surf_def_v(1)%ol, surf_lsm_v(1)%ol, & 1722 surf_usm_v(1)%ol, surf_def_v(2)%ol, & 1723 surf_lsm_v(2)%ol, surf_usm_v(2)%ol, & 1724 surf_def_v(3)%ol, surf_lsm_v(3)%ol, & 1725 surf_usm_v(3)%ol ) 1726 ELSE 1727 ! 1728 !-- Output of averaged data 1729 surfaces%var_out(:) = surfaces%var_av(:,n_out) / REAL( average_count_surf, KIND=wp ) 1730 surfaces%var_av(:,n_out) = 0.0_wp 1731 1732 ENDIF 1733 1734 CASE ( 'z0' ) 1735 ! 1736 !-- Output of instantaneous data 1737 IF ( av == 0 ) THEN 1738 CALL surface_data_output_collect( surf_def_h(0)%z0, surf_def_h(1)%z0, & 1739 surf_lsm_h%z0, surf_usm_h%z0, surf_def_v(0)%z0, & 1740 surf_lsm_v(0)%z0, surf_usm_v(0)%z0, & 1741 surf_def_v(1)%z0, surf_lsm_v(1)%z0, & 1742 surf_usm_v(1)%z0, surf_def_v(2)%z0, & 1743 surf_lsm_v(2)%z0, surf_usm_v(2)%z0, & 1744 surf_def_v(3)%z0, surf_lsm_v(3)%z0, & 1745 surf_usm_v(3)%z0 ) 1746 ELSE 1747 ! 1748 !-- Output of averaged data 1749 surfaces%var_out(:) = surfaces%var_av(:,n_out) / REAL( average_count_surf, KIND=wp ) 1750 surfaces%var_av(:,n_out) = 0.0_wp 1751 1752 ENDIF 1753 1754 CASE ( 'z0h' ) 1755 ! 1756 !-- Output of instantaneous data 1757 IF ( av == 0 ) THEN 1758 CALL surface_data_output_collect( surf_def_h(0)%z0h, surf_def_h(1)%z0h, & 1759 surf_lsm_h%z0h, surf_usm_h%z0h, & 1760 surf_def_v(0)%z0h, surf_lsm_v(0)%z0h, & 1761 surf_usm_v(0)%z0h, surf_def_v(1)%z0h, & 1762 surf_lsm_v(1)%z0h, surf_usm_v(1)%z0h, & 1763 surf_def_v(2)%z0h, surf_lsm_v(2)%z0h, & 1764 surf_usm_v(2)%z0h, surf_def_v(3)%z0h, & 1765 surf_lsm_v(3)%z0h, surf_usm_v(3)%z0h ) 1766 ELSE 1767 ! 1768 !-- Output of averaged data 1769 surfaces%var_out(:) = surfaces%var_av(:,n_out) / REAL( average_count_surf, KIND=wp ) 1770 surfaces%var_av(:,n_out) = 0.0_wp 1771 1772 ENDIF 1773 1774 CASE ( 'z0q' ) 1775 ! 1776 !-- Output of instantaneous data 1777 IF ( av == 0 ) THEN 1778 CALL surface_data_output_collect( surf_def_h(0)%z0q, surf_def_h(1)%z0q, & 1779 surf_lsm_h%z0q, surf_usm_h%z0q, & 1780 surf_def_v(0)%z0q, surf_lsm_v(0)%z0q, & 1781 surf_usm_v(0)%z0q, surf_def_v(1)%z0q, & 1782 surf_lsm_v(1)%z0q, surf_usm_v(1)%z0q, & 1783 surf_def_v(2)%z0q, surf_lsm_v(2)%z0q, & 1784 surf_usm_v(2)%z0q, surf_def_v(3)%z0q, & 1785 surf_lsm_v(3)%z0q, surf_usm_v(3)%z0q ) 1786 ELSE 1787 ! 1788 !-- Output of averaged data 1789 surfaces%var_out(:) = surfaces%var_av(:,n_out) / REAL( average_count_surf, KIND=wp ) 1790 surfaces%var_av(:,n_out) = 0.0_wp 1791 1792 ENDIF 1793 1794 CASE ( 'theta1' ) 1795 ! 1796 !-- Output of instantaneous data 1797 IF ( av == 0 ) THEN 1798 CALL surface_data_output_collect( surf_def_h(0)%pt1, surf_def_h(1)%pt1, & 1799 surf_lsm_h%pt1, surf_usm_h%pt1, & 1800 surf_def_v(0)%pt1, surf_lsm_v(0)%pt1, & 1801 surf_usm_v(0)%pt1, surf_def_v(1)%pt1, & 1802 surf_lsm_v(1)%pt1, surf_usm_v(1)%pt1, & 1803 surf_def_v(2)%pt1, surf_lsm_v(2)%pt1, & 1804 surf_usm_v(2)%pt1, surf_def_v(3)%pt1, & 1805 surf_lsm_v(3)%pt1, surf_usm_v(3)%pt1 ) 1806 ELSE 1807 ! 1808 !-- Output of averaged data 1809 surfaces%var_out(:) = surfaces%var_av(:,n_out) / REAL( average_count_surf, KIND=wp ) 1810 surfaces%var_av(:,n_out) = 0.0_wp 1811 1812 ENDIF 1813 1814 CASE ( 'qv1' ) 1815 ! 1816 !-- Output of instantaneous data 1817 IF ( av == 0 ) THEN 1818 CALL surface_data_output_collect( surf_def_h(0)%qv1, surf_def_h(1)%qv1, & 1819 surf_lsm_h%qv1, surf_usm_h%qv1, & 1820 surf_def_v(0)%qv1, surf_lsm_v(0)%qv1, & 1821 surf_usm_v(0)%qv1, surf_def_v(1)%qv1, & 1822 surf_lsm_v(1)%qv1, surf_usm_v(1)%qv1, & 1823 surf_def_v(2)%qv1, surf_lsm_v(2)%qv1, & 1824 surf_usm_v(2)%qv1, surf_def_v(3)%qv1, & 1825 surf_lsm_v(3)%qv1, surf_usm_v(3)%qv1 ) 1826 ELSE 1827 ! 1828 !-- Output of averaged data 1829 surfaces%var_out(:) = surfaces%var_av(:,n_out) / REAL( average_count_surf, KIND=wp ) 1830 surfaces%var_av(:,n_out) = 0.0_wp 1831 1832 ENDIF 1833 1834 CASE ( 'thetav1' ) 1835 ! 1836 !-- Output of instantaneous data 1837 IF ( av == 0 ) THEN 1838 CALL surface_data_output_collect( surf_def_h(0)%vpt1, surf_def_h(1)%vpt1, & 1839 surf_lsm_h%vpt1, surf_usm_h%vpt1, & 1840 surf_def_v(0)%vpt1, surf_lsm_v(0)%vpt1, & 1841 surf_usm_v(0)%vpt1, surf_def_v(1)%vpt1, & 1842 surf_lsm_v(1)%vpt1, surf_usm_v(1)%vpt1, & 1843 surf_def_v(2)%vpt1, surf_lsm_v(2)%vpt1, & 1844 surf_usm_v(2)%vpt1, surf_def_v(3)%vpt1, & 1845 surf_lsm_v(3)%vpt1, surf_usm_v(3)%vpt1 ) 1846 ELSE 1847 ! 1848 !-- Output of averaged data 1849 surfaces%var_out(:) = surfaces%var_av(:,n_out) / REAL( average_count_surf, KIND=wp ) 1850 surfaces%var_av(:,n_out) = 0.0_wp 1851 1852 ENDIF 1853 1854 CASE ( 'usws' ) 1855 ! 1856 !-- Output of instantaneous data 1857 IF ( av == 0 ) THEN 1858 CALL surface_data_output_collect( surf_def_h(0)%usws, surf_def_h(1)%usws, & 1859 surf_lsm_h%usws, surf_usm_h%usws, & 1860 surf_def_v(0)%usws, surf_lsm_v(0)%usws, & 1861 surf_usm_v(0)%usws, surf_def_v(1)%usws, & 1862 surf_lsm_v(1)%usws, surf_usm_v(1)%usws, & 1863 surf_def_v(2)%usws, surf_lsm_v(2)%usws, & 1864 surf_usm_v(2)%usws, surf_def_v(3)%usws, & 1865 surf_lsm_v(3)%usws, surf_usm_v(3)%usws, & 1866 momentumflux_output_conversion ) 1867 ELSE 1868 ! 1869 !-- Output of averaged data 1870 surfaces%var_out(:) = surfaces%var_av(:,n_out) / REAL( average_count_surf, KIND=wp ) 1871 surfaces%var_av(:,n_out) = 0.0_wp 1872 1873 ENDIF 1874 1875 CASE ( 'vsws' ) 1876 ! 1877 !-- Output of instantaneous data 1878 IF ( av == 0 ) THEN 1879 CALL surface_data_output_collect( surf_def_h(0)%vsws, surf_def_h(1)%vsws, & 1880 surf_lsm_h%vsws, surf_usm_h%vsws, & 1881 surf_def_v(0)%vsws, surf_lsm_v(0)%vsws, & 1882 surf_usm_v(0)%vsws, surf_def_v(1)%vsws, & 1883 surf_lsm_v(1)%vsws, surf_usm_v(1)%vsws, & 1884 surf_def_v(2)%vsws, surf_lsm_v(2)%vsws, & 1885 surf_usm_v(2)%vsws, surf_def_v(3)%vsws, & 1886 surf_lsm_v(3)%vsws, surf_usm_v(3)%vsws, & 1887 momentumflux_output_conversion ) 1888 ELSE 1889 ! 1890 !-- Output of averaged data 1891 surfaces%var_out(:) = surfaces%var_av(:,n_out) / REAL( average_count_surf, KIND=wp ) 1892 surfaces%var_av(:,n_out) = 0.0_wp 1893 1894 ENDIF 1895 1896 CASE ( 'shf' ) 1897 ! 1898 !-- Output of instantaneous data 1899 IF ( av == 0 ) THEN 1900 CALL surface_data_output_collect( surf_def_h(0)%shf, surf_def_h(1)%shf, & 1901 surf_lsm_h%shf, surf_usm_h%shf, & 1902 surf_def_v(0)%shf, surf_lsm_v(0)%shf, & 1903 surf_usm_v(0)%shf, surf_def_v(1)%shf, & 1904 surf_lsm_v(1)%shf, surf_usm_v(1)%shf, & 1905 surf_def_v(2)%shf, surf_lsm_v(2)%shf, & 1906 surf_usm_v(2)%shf, surf_def_v(3)%shf, & 1907 surf_lsm_v(3)%shf, surf_usm_v(3)%shf, & 1908 heatflux_output_conversion ) 1909 ELSE 1910 ! 1911 !-- Output of averaged data 1912 surfaces%var_out(:) = surfaces%var_av(:,n_out) / REAL( average_count_surf, KIND=wp ) 1913 surfaces%var_av(:,n_out) = 0.0_wp 1914 ENDIF 1915 1916 CASE ( 'qsws' ) 1917 ! 1918 !-- Output of instantaneous data 1919 IF ( av == 0 ) THEN 1920 CALL surface_data_output_collect( surf_def_h(0)%qsws, surf_def_h(1)%qsws, & 1921 surf_lsm_h%qsws, surf_usm_h%qsws, & 1922 surf_def_v(0)%qsws, surf_lsm_v(0)%qsws, & 1923 surf_usm_v(0)%qsws, surf_def_v(1)%qsws, & 1924 surf_lsm_v(1)%qsws, surf_usm_v(1)%qsws, & 1925 surf_def_v(2)%qsws, surf_lsm_v(2)%qsws, & 1926 surf_usm_v(2)%qsws, surf_def_v(3)%qsws, & 1927 surf_lsm_v(3)%qsws, surf_usm_v(3)%qsws, & 1928 waterflux_output_conversion ) 1929 ELSE 1930 ! 1931 !-- Output of averaged data 1932 surfaces%var_out(:) = surfaces%var_av(:,n_out) / REAL( average_count_surf, KIND=wp ) 1933 surfaces%var_av(:,n_out) = 0.0_wp 1934 1935 ENDIF 1936 1937 CASE ( 'ssws' ) 1938 ! 1939 !-- Output of instantaneous data 1940 IF ( av == 0 ) THEN 1941 CALL surface_data_output_collect( surf_def_h(0)%ssws, surf_def_h(1)%ssws, & 1942 surf_lsm_h%ssws, surf_usm_h%ssws, & 1943 surf_def_v(0)%ssws, surf_lsm_v(0)%ssws, & 1944 surf_usm_v(0)%ssws, surf_def_v(1)%ssws, & 1945 surf_lsm_v(1)%ssws, surf_usm_v(1)%ssws, & 1946 surf_def_v(2)%ssws, surf_lsm_v(2)%ssws, & 1947 surf_usm_v(2)%ssws, surf_def_v(3)%ssws, & 1948 surf_lsm_v(3)%ssws, surf_usm_v(3)%ssws ) 1949 ELSE 1950 ! 1951 !-- Output of averaged data 1952 surfaces%var_out(:) = surfaces%var_av(:,n_out) / REAL( average_count_surf, KIND=wp ) 1953 surfaces%var_av(:,n_out) = 0.0_wp 1954 1955 ENDIF 1956 1957 CASE ( 'qcsws' ) 1958 ! 1959 !-- Output of instantaneous data 1960 IF ( av == 0 ) THEN 1961 CALL surface_data_output_collect( surf_def_h(0)%qcsws, surf_def_h(1)%qcsws, & 1962 surf_lsm_h%qcsws, surf_usm_h%qcsws, & 1963 surf_def_v(0)%qcsws, surf_lsm_v(0)%qcsws, & 1964 surf_usm_v(0)%qcsws, surf_def_v(1)%qcsws, & 1965 surf_lsm_v(1)%qcsws, surf_usm_v(1)%qcsws, & 1966 surf_def_v(2)%qcsws, surf_lsm_v(2)%qcsws, & 1967 surf_usm_v(2)%qcsws, surf_def_v(3)%qcsws, & 1968 surf_lsm_v(3)%qcsws, surf_usm_v(3)%qcsws ) 1969 ELSE 1970 ! 1971 !-- Output of averaged data 1972 surfaces%var_out(:) = surfaces%var_av(:,n_out) / REAL( average_count_surf, KIND=wp ) 1973 surfaces%var_av(:,n_out) = 0.0_wp 1974 1975 ENDIF 1976 1977 CASE ( 'ncsws' ) 1978 ! 1979 !-- Output of instantaneous data 1980 IF ( av == 0 ) THEN 1981 CALL surface_data_output_collect( surf_def_h(0)%ncsws, surf_def_h(1)%ncsws, & 1982 surf_lsm_h%ncsws, surf_usm_h%ncsws, & 1983 surf_def_v(0)%ncsws, surf_lsm_v(0)%ncsws, & 1984 surf_usm_v(0)%ncsws, surf_def_v(1)%ncsws, & 1985 surf_lsm_v(1)%ncsws, surf_usm_v(1)%ncsws, & 1986 surf_def_v(2)%ncsws, surf_lsm_v(2)%ncsws, & 1987 surf_usm_v(2)%ncsws, surf_def_v(3)%ncsws, & 1988 surf_lsm_v(3)%ncsws, surf_usm_v(3)%ncsws ) 1989 ELSE 1990 ! 1991 !-- Output of averaged data 1992 surfaces%var_out(:) = surfaces%var_av(:,n_out) / REAL( average_count_surf, KIND=wp ) 1993 surfaces%var_av(:,n_out) = 0.0_wp 1994 1995 ENDIF 1996 1997 1998 CASE ( 'qisws' ) 1999 ! 2000 !-- Output of instantaneous data 2001 IF ( av == 0 ) THEN 2002 CALL surface_data_output_collect( surf_def_h(0)%qisws, surf_def_h(1)%qisws, & 2003 surf_lsm_h%qisws, surf_usm_h%qisws, & 2004 surf_def_v(0)%qisws, surf_lsm_v(0)%qisws, & 2005 surf_usm_v(0)%qisws, surf_def_v(1)%qisws, & 2006 surf_lsm_v(1)%qisws, surf_usm_v(1)%qisws, & 2007 surf_def_v(2)%qisws, surf_lsm_v(2)%qisws, & 2008 surf_usm_v(2)%qisws, surf_def_v(3)%qisws, & 2009 surf_lsm_v(3)%qisws, surf_usm_v(3)%qisws ) 2010 ELSE 2011 ! 2012 !-- Output of averaged data 2013 surfaces%var_out(:) = surfaces%var_av(:,n_out) / REAL( average_count_surf, KIND=wp ) 2014 surfaces%var_av(:,n_out) = 0.0_wp 2015 2016 ENDIF 2017 2018 CASE ( 'nisws' ) 2019 ! 2020 !-- Output of instantaneous data 2021 IF ( av == 0 ) THEN 2022 CALL surface_data_output_collect( surf_def_h(0)%nisws, surf_def_h(1)%nisws, & 2023 surf_lsm_h%nisws, surf_usm_h%nisws, & 2024 surf_def_v(0)%nisws, surf_lsm_v(0)%nisws, & 2025 surf_usm_v(0)%nisws, surf_def_v(1)%nisws, & 2026 surf_lsm_v(1)%nisws, surf_usm_v(1)%nisws, & 2027 surf_def_v(2)%nisws, surf_lsm_v(2)%nisws, & 2028 surf_usm_v(2)%nisws, surf_def_v(3)%nisws, & 2029 surf_lsm_v(3)%nisws, surf_usm_v(3)%nisws ) 2030 ELSE 2031 ! 2032 !-- Output of averaged data 2033 surfaces%var_out(:) = surfaces%var_av(:,n_out) / REAL( average_count_surf, KIND=wp ) 2034 surfaces%var_av(:,n_out) = 0.0_wp 2035 2036 ENDIF 2037 2038 CASE ( 'qrsws' ) 2039 ! 2040 !-- Output of instantaneous data 2041 IF ( av == 0 ) THEN 2042 CALL surface_data_output_collect( surf_def_h(0)%qrsws, surf_def_h(1)%qrsws, & 2043 surf_lsm_h%qrsws, surf_usm_h%qrsws, & 2044 surf_def_v(0)%qrsws, surf_lsm_v(0)%qrsws, & 2045 surf_usm_v(0)%qrsws, surf_def_v(1)%qrsws, & 2046 surf_lsm_v(1)%qrsws, surf_usm_v(1)%qrsws, & 2047 surf_def_v(2)%qrsws, surf_lsm_v(2)%qrsws, & 2048 surf_usm_v(2)%qrsws, surf_def_v(3)%qrsws, & 2049 surf_lsm_v(3)%qrsws, surf_usm_v(3)%qrsws ) 2050 ELSE 2051 ! 2052 !-- Output of averaged data 2053 surfaces%var_out(:) = surfaces%var_av(:,n_out) / REAL( average_count_surf, KIND=wp ) 2054 surfaces%var_av(:,n_out) = 0.0_wp 2055 2056 ENDIF 2057 2058 CASE ( 'nrsws' ) 2059 ! 2060 !-- Output of instantaneous data 2061 IF ( av == 0 ) THEN 2062 CALL surface_data_output_collect( surf_def_h(0)%nrsws, surf_def_h(1)%nrsws, & 2063 surf_lsm_h%nrsws, surf_usm_h%nrsws, & 2064 surf_def_v(0)%nrsws, surf_lsm_v(0)%nrsws, & 2065 surf_usm_v(0)%nrsws, surf_def_v(1)%nrsws, & 2066 surf_lsm_v(1)%nrsws, surf_usm_v(1)%nrsws, & 2067 surf_def_v(2)%nrsws, surf_lsm_v(2)%nrsws, & 2068 surf_usm_v(2)%nrsws, surf_def_v(3)%nrsws, & 2069 surf_lsm_v(3)%nrsws, surf_usm_v(3)%nrsws ) 2070 ELSE 2071 ! 2072 !-- Output of averaged data 2073 surfaces%var_out(:) = surfaces%var_av(:,n_out) / REAL( average_count_surf, KIND=wp ) 2074 surfaces%var_av(:,n_out) = 0.0_wp 2075 2076 ENDIF 2077 2078 CASE ( 'sasws' ) 2079 ! 2080 !-- Output of instantaneous data 2081 IF ( av == 0 ) THEN 2082 CALL surface_data_output_collect( surf_def_h(0)%sasws, surf_def_h(1)%sasws, & 2083 surf_lsm_h%sasws, surf_usm_h%sasws, & 2084 surf_def_v(0)%sasws, surf_lsm_v(0)%sasws, & 2085 surf_usm_v(0)%sasws, surf_def_v(1)%sasws, & 2086 surf_lsm_v(1)%sasws, surf_usm_v(1)%sasws, & 2087 surf_def_v(2)%sasws, surf_lsm_v(2)%sasws, & 2088 surf_usm_v(2)%sasws, surf_def_v(3)%sasws, & 2089 surf_lsm_v(3)%sasws, surf_usm_v(3)%sasws ) 2090 ELSE 2091 ! 2092 !-- Output of averaged data 2093 surfaces%var_out(:) = surfaces%var_av(:,n_out) / REAL( average_count_surf, KIND=wp ) 2094 surfaces%var_av(:,n_out) = 0.0_wp 2095 2096 ENDIF 2097 2098 CASE ( 'q_surface' ) 2099 ! 2100 !-- Output of instantaneous data 2101 IF ( av == 0 ) THEN 2102 CALL surface_data_output_collect( surf_def_h(0)%q_surface, surf_def_h(1)%q_surface,& 2103 surf_lsm_h%q_surface, surf_usm_h%q_surface, & 2104 surf_def_v(0)%q_surface, surf_lsm_v(0)%q_surface,& 2105 surf_usm_v(0)%q_surface, surf_def_v(1)%q_surface,& 2106 surf_lsm_v(1)%q_surface, surf_usm_v(1)%q_surface,& 2107 surf_def_v(2)%q_surface, surf_lsm_v(2)%q_surface,& 2108 surf_usm_v(2)%q_surface, surf_def_v(3)%q_surface,& 2109 surf_lsm_v(3)%q_surface, surf_usm_v(3)%q_surface ) 2110 ELSE 2111 ! 2112 !-- Output of averaged data 2113 surfaces%var_out(:) = surfaces%var_av(:,n_out) / REAL( average_count_surf, KIND=wp ) 2114 surfaces%var_av(:,n_out) = 0.0_wp 2115 2116 ENDIF 2117 2118 CASE ( 'theta_surface' ) 2119 ! 2120 !-- Output of instantaneous data 2121 IF ( av == 0 ) THEN 2122 CALL surface_data_output_collect( surf_def_h(0)%pt_surface, & 2123 surf_def_h(1)%pt_surface, & 2124 surf_lsm_h%pt_surface, surf_usm_h%pt_surface, & 2125 surf_def_v(0)%pt_surface, & 2126 surf_lsm_v(0)%pt_surface, & 2127 surf_usm_v(0)%pt_surface, & 2128 surf_def_v(1)%pt_surface, & 2129 surf_lsm_v(1)%pt_surface, & 2130 surf_usm_v(1)%pt_surface, & 2131 surf_def_v(2)%pt_surface, & 2132 surf_lsm_v(2)%pt_surface, & 2133 surf_usm_v(2)%pt_surface, & 2134 surf_def_v(3)%pt_surface, & 2135 surf_lsm_v(3)%pt_surface, & 2136 surf_usm_v(3)%pt_surface ) 2137 ELSE 2138 ! 2139 !-- Output of averaged data 2140 surfaces%var_out(:) = surfaces%var_av(:,n_out) / REAL( average_count_surf, KIND=wp ) 2141 surfaces%var_av(:,n_out) = 0.0_wp 2142 2143 ENDIF 2144 2145 CASE ( 'thetav_surface' ) 2146 ! 2147 !-- Output of instantaneous data 2148 IF ( av == 0 ) THEN 2149 CALL surface_data_output_collect( surf_def_h(0)%vpt_surface, & 2150 surf_def_h(1)%vpt_surface, & 2151 surf_lsm_h%vpt_surface, surf_usm_h%vpt_surface, & 2152 surf_def_v(0)%vpt_surface, & 2153 surf_lsm_v(0)%vpt_surface, & 2154 surf_usm_v(0)%vpt_surface, & 2155 surf_def_v(1)%vpt_surface, & 2156 surf_lsm_v(1)%vpt_surface, & 2157 surf_usm_v(1)%vpt_surface, & 2158 surf_def_v(2)%vpt_surface, & 2159 surf_lsm_v(2)%vpt_surface, & 2160 surf_usm_v(2)%vpt_surface, & 2161 surf_def_v(3)%vpt_surface, & 2162 surf_lsm_v(3)%vpt_surface, & 2163 surf_usm_v(3)%vpt_surface) 2164 ELSE 2165 ! 2166 !-- Output of averaged data 2167 surfaces%var_out(:) = surfaces%var_av(:,n_out) / REAL( average_count_surf, KIND=wp ) 2168 surfaces%var_av(:,n_out) = 0.0_wp 2169 2170 ENDIF 2171 2172 CASE ( 'rad_net' ) 2173 ! 2174 !-- Output of instantaneous data 2175 IF ( av == 0 ) THEN 2176 CALL surface_data_output_collect( surf_def_h(0)%rad_net, surf_def_h(1)%rad_net, & 2177 surf_lsm_h%rad_net, surf_usm_h%rad_net, & 2178 surf_def_v(0)%rad_net, surf_lsm_v(0)%rad_net, & 2179 surf_usm_v(0)%rad_net, surf_def_v(1)%rad_net, & 2180 surf_lsm_v(1)%rad_net, surf_usm_v(1)%rad_net, & 2181 surf_def_v(2)%rad_net, surf_lsm_v(2)%rad_net, & 2182 surf_usm_v(2)%rad_net, surf_def_v(3)%rad_net, & 2183 surf_lsm_v(3)%rad_net, surf_usm_v(3)%rad_net ) 2184 ELSE 2185 ! 2186 !-- Output of averaged data 2187 surfaces%var_out(:) = surfaces%var_av(:,n_out) / REAL( average_count_surf, KIND=wp ) 2188 surfaces%var_av(:,n_out) = 0.0_wp 2189 2190 ENDIF 2191 2192 CASE ( 'rad_lw_in' ) 2193 ! 2194 !-- Output of instantaneous data 2195 IF ( av == 0 ) THEN 2196 CALL surface_data_output_collect( surf_def_h(0)%rad_lw_in, & 2197 surf_def_h(1)%rad_lw_in, surf_lsm_h%rad_lw_in, & 2198 surf_usm_h%rad_lw_in, surf_def_v(0)%rad_lw_in, & 2199 surf_lsm_v(0)%rad_lw_in, & 2200 surf_usm_v(0)%rad_lw_in, & 2201 surf_def_v(1)%rad_lw_in, & 2202 surf_lsm_v(1)%rad_lw_in, & 2203 surf_usm_v(1)%rad_lw_in, & 2204 surf_def_v(2)%rad_lw_in, & 2205 surf_lsm_v(2)%rad_lw_in, & 2206 surf_usm_v(2)%rad_lw_in, & 2207 surf_def_v(3)%rad_lw_in, & 2208 surf_lsm_v(3)%rad_lw_in, & 2209 surf_usm_v(3)%rad_lw_in ) 2210 ELSE 2211 ! 2212 !-- Output of averaged data 2213 surfaces%var_out(:) = surfaces%var_av(:,n_out) / REAL( average_count_surf, KIND=wp ) 2214 surfaces%var_av(:,n_out) = 0.0_wp 2215 2216 ENDIF 2217 2218 CASE ( 'rad_lw_out' ) 2219 ! 2220 !-- Output of instantaneous data 2221 IF ( av == 0 ) THEN 2222 CALL surface_data_output_collect( surf_def_h(0)%rad_lw_out, & 2223 surf_def_h(1)%rad_lw_out, surf_lsm_h%rad_lw_out, & 2224 surf_usm_h%rad_lw_out, surf_def_v(0)%rad_lw_out, & 2225 surf_lsm_v(0)%rad_lw_out, & 2226 surf_usm_v(0)%rad_lw_out, & 2227 surf_def_v(1)%rad_lw_out, & 2228 surf_lsm_v(1)%rad_lw_out, & 2229 surf_usm_v(1)%rad_lw_out, & 2230 surf_def_v(2)%rad_lw_out, & 2231 surf_lsm_v(2)%rad_lw_out, & 2232 surf_usm_v(2)%rad_lw_out, & 2233 surf_def_v(3)%rad_lw_out, & 2234 surf_lsm_v(3)%rad_lw_out, & 2235 surf_usm_v(3)%rad_lw_out ) 2236 ELSE 2237 ! 2238 !-- Output of averaged data 2239 surfaces%var_out(:) = surfaces%var_av(:,n_out) / REAL( average_count_surf, KIND=wp ) 2240 surfaces%var_av(:,n_out) = 0.0_wp 2241 2242 ENDIF 2243 2244 CASE ( 'rad_sw_in' ) 2245 ! 2246 !-- Output of instantaneous data 2247 IF ( av == 0 ) THEN 2248 CALL surface_data_output_collect( surf_def_h(0)%rad_sw_in, & 2249 surf_def_h(1)%rad_sw_in, surf_lsm_h%rad_sw_in, & 2250 surf_usm_h%rad_sw_in, surf_def_v(0)%rad_sw_in, & 2251 surf_lsm_v(0)%rad_sw_in, & 2252 surf_usm_v(0)%rad_sw_in, & 2253 surf_def_v(1)%rad_sw_in, & 2254 surf_lsm_v(1)%rad_sw_in, & 2255 surf_usm_v(1)%rad_sw_in, & 2256 surf_def_v(2)%rad_sw_in, & 2257 surf_lsm_v(2)%rad_sw_in, & 2258 surf_usm_v(2)%rad_sw_in, & 2259 surf_def_v(3)%rad_sw_in, & 2260 surf_lsm_v(3)%rad_sw_in, & 2261 surf_usm_v(3)%rad_sw_in ) 2262 ELSE 2263 ! 2264 !-- Output of averaged data 2265 surfaces%var_out(:) = surfaces%var_av(:,n_out) / REAL( average_count_surf, KIND=wp ) 2266 surfaces%var_av(:,n_out) = 0.0_wp 2267 2268 ENDIF 2269 2270 CASE ( 'rad_sw_out' ) 2271 ! 2272 !-- Output of instantaneous data 2273 IF ( av == 0 ) THEN 2274 CALL surface_data_output_collect( surf_def_h(0)%rad_sw_out, & 2275 surf_def_h(1)%rad_sw_out, surf_lsm_h%rad_sw_out, & 2276 surf_usm_h%rad_sw_out, surf_def_v(0)%rad_sw_out, & 2277 surf_lsm_v(0)%rad_sw_out, & 2278 surf_usm_v(0)%rad_sw_out, & 2279 surf_def_v(1)%rad_sw_out, & 2280 surf_lsm_v(1)%rad_sw_out, & 2281 surf_usm_v(1)%rad_sw_out, & 2282 surf_def_v(2)%rad_sw_out, & 2283 surf_lsm_v(2)%rad_sw_out, & 2284 surf_usm_v(2)%rad_sw_out, & 2285 surf_def_v(3)%rad_sw_out, & 2286 surf_lsm_v(3)%rad_sw_out, & 2287 surf_usm_v(3)%rad_sw_out ) 2288 ELSE 2289 ! 2290 !-- Output of averaged data 2291 surfaces%var_out(:) = surfaces%var_av(:,n_out) / REAL( average_count_surf, KIND=wp ) 2292 surfaces%var_av(:,n_out) = 0.0_wp 2293 2294 ENDIF 2295 2296 CASE ( 'ghf' ) 2297 ! 2298 !-- Output of instantaneous data 2299 IF ( av == 0 ) THEN 2300 ! 2301 !-- Sum up ground / wall heat flux. Note, for urban surfaces the wall heat flux is 2302 !-- aggregated from the different green, window and wall tiles. 2303 DO m = 1, surf_usm_h%ns 2304 surf_usm_h%ghf(m) = surf_usm_h%frac(m,ind_veg_wall) * surf_usm_h%wghf_eb(m) + & 2305 surf_usm_h%frac(m,ind_pav_green) * & 2306 surf_usm_h%wghf_eb_green(m) + & 2307 surf_usm_h%frac(m,ind_wat_win) * & 2308 surf_usm_h%wghf_eb_window(m) 2309 ENDDO 2310 DO l = 0, 3 2311 DO m = 1, surf_usm_v(l)%ns 2312 surf_usm_v(l)%ghf(m) = surf_usm_v(l)%frac(m,ind_veg_wall) * & 2313 surf_usm_v(l)%wghf_eb(m) + & 2314 surf_usm_v(l)%frac(m,ind_pav_green) * & 2315 surf_usm_v(l)%wghf_eb_green(m) + & 2316 surf_usm_v(l)%frac(m,ind_wat_win) * & 2317 surf_usm_v(l)%wghf_eb_window(m) 2318 ENDDO 2319 ENDDO 2320 2321 CALL surface_data_output_collect( surf_def_h(0)%ghf, surf_def_h(1)%ghf, & 2322 surf_lsm_h%ghf, surf_usm_h%ghf, & 2323 surf_def_v(0)%ghf, surf_lsm_v(0)%ghf, & 2324 surf_usm_v(0)%ghf, surf_def_v(1)%ghf, & 2325 surf_lsm_v(1)%ghf, surf_usm_v(1)%ghf, & 2326 surf_def_v(2)%ghf, surf_lsm_v(2)%ghf, & 2327 surf_usm_v(2)%ghf, surf_def_v(3)%ghf, & 2328 surf_lsm_v(3)%ghf, surf_usm_v(3)%ghf ) 2329 ELSE 2330 ! 2331 !-- Output of averaged data 2332 surfaces%var_out(:) = surfaces%var_av(:,n_out) / REAL( average_count_surf, KIND=wp ) 2333 surfaces%var_av(:,n_out) = 0.0_wp 2334 2335 ENDIF 2336 2337 CASE ( 'r_a' ) 2338 ! 2339 !-- Output of instantaneous data 2340 IF ( av == 0 ) THEN 2341 CALL surface_data_output_collect( surf_def_h(0)%r_a, surf_def_h(1)%r_a, & 2342 surf_lsm_h%r_a, surf_usm_h%r_a, & 2343 surf_def_v(0)%r_a, surf_lsm_v(0)%r_a, & 2344 surf_usm_v(0)%r_a, surf_def_v(1)%r_a, & 2345 surf_lsm_v(1)%r_a, surf_usm_v(1)%r_a, & 2346 surf_def_v(2)%r_a, surf_lsm_v(2)%r_a, & 2347 surf_usm_v(2)%r_a, surf_def_v(3)%r_a, & 2348 surf_lsm_v(3)%r_a, surf_usm_v(3)%r_a ) 2349 ELSE 2350 ! 2351 !-- Output of averaged data 2352 surfaces%var_out(:) = surfaces%var_av(:,n_out) / REAL( average_count_surf, KIND=wp ) 2353 surfaces%var_av(:,n_out) = 0.0_wp 2354 2355 ENDIF 2356 2357 CASE ( 'r_soil' ) 2358 ! 2359 !-- Output of instantaneous data 2360 IF ( av == 0 ) THEN 2361 CALL surface_data_output_collect( surf_def_h(0)%r_soil, surf_def_h(1)%r_soil, & 2362 surf_lsm_h%r_soil, surf_usm_h%r_soil, & 2363 surf_def_v(0)%r_soil, surf_lsm_v(0)%r_soil, & 2364 surf_usm_v(0)%r_soil, surf_def_v(1)%r_soil, & 2365 surf_lsm_v(1)%r_soil, surf_usm_v(1)%r_soil, & 2366 surf_def_v(2)%r_soil, surf_lsm_v(2)%r_soil, & 2367 surf_usm_v(2)%r_soil, surf_def_v(3)%r_soil, & 2368 surf_lsm_v(3)%r_soil, surf_usm_v(3)%r_soil ) 2369 ELSE 2370 ! 2371 !-- Output of averaged data 2372 surfaces%var_out(:) = surfaces%var_av(:,n_out) / REAL( average_count_surf, KIND=wp ) 2373 surfaces%var_av(:,n_out) = 0.0_wp 2374 2375 ENDIF 2376 2377 CASE ( 'r_canopy' ) 2378 ! 2379 !-- Output of instantaneous data 2380 IF ( av == 0 ) THEN 2381 CALL surface_data_output_collect( surf_def_h(0)%r_canopy, surf_def_h(1)%r_canopy, & 2382 surf_lsm_h%r_canopy, surf_usm_h%r_canopy, & 2383 surf_def_v(0)%r_canopy, surf_lsm_v(0)%r_canopy, & 2384 surf_usm_v(0)%r_canopy, surf_def_v(1)%r_canopy, & 2385 surf_lsm_v(1)%r_canopy, surf_usm_v(1)%r_canopy, & 2386 surf_def_v(2)%r_canopy, surf_lsm_v(2)%r_canopy, & 2387 surf_usm_v(2)%r_canopy, surf_def_v(3)%r_canopy, & 2388 surf_lsm_v(3)%r_canopy, surf_usm_v(3)%r_canopy ) 2389 ELSE 2390 ! 2391 !-- Output of averaged data 2392 surfaces%var_out(:) = surfaces%var_av(:,n_out) / REAL( average_count_surf, KIND=wp ) 2393 surfaces%var_av(:,n_out) = 0.0_wp 2394 2395 ENDIF 2396 2397 CASE ( 'r_s' ) 2398 ! 2399 !-- Output of instantaneous data 2400 IF ( av == 0 ) THEN 2401 CALL surface_data_output_collect( surf_def_h(0)%r_s, surf_def_h(1)%r_s, & 2402 surf_lsm_h%r_s, surf_usm_h%r_s, & 2403 surf_def_v(0)%r_s, surf_lsm_v(0)%r_s, & 2404 surf_usm_v(0)%r_s, surf_def_v(1)%r_s, & 2405 surf_lsm_v(1)%r_s, surf_usm_v(1)%r_s, & 2406 surf_def_v(2)%r_s, surf_lsm_v(2)%r_s, & 2407 surf_usm_v(2)%r_s, surf_def_v(3)%r_s, & 2408 surf_lsm_v(3)%r_s, surf_usm_v(3)%r_s ) 2409 ELSE 2410 ! 2411 !-- Output of averaged data 2412 surfaces%var_out(:) = surfaces%var_av(:,n_out) / REAL( average_count_surf, KIND=wp ) 2413 surfaces%var_av(:,n_out) = 0.0_wp 2414 2415 ENDIF 2416 2417 CASE ( 'rad_sw_dir' ) 2418 ! 2419 !-- Output of instantaneous data 2420 IF ( av == 0 ) THEN 2421 CALL surface_data_output_collect( surf_def_h(0)%rad_sw_dir, & 2422 surf_def_h(1)%rad_sw_dir, surf_lsm_h%rad_sw_dir, & 2423 surf_usm_h%rad_sw_dir, surf_def_v(0)%rad_sw_dir, & 2424 surf_lsm_v(0)%rad_sw_dir, & 2425 surf_usm_v(0)%rad_sw_dir, & 2426 surf_def_v(1)%rad_sw_dir, & 2427 surf_lsm_v(1)%rad_sw_dir, & 2428 surf_usm_v(1)%rad_sw_dir, & 2429 surf_def_v(2)%rad_sw_dir, & 2430 surf_lsm_v(2)%rad_sw_dir, & 2431 surf_usm_v(2)%rad_sw_dir, & 2432 surf_def_v(3)%rad_sw_dir, & 2433 surf_lsm_v(3)%rad_sw_dir, & 2434 surf_usm_v(3)%rad_sw_dir ) 2435 ELSE 2436 ! 2437 !-- Output of averaged data 2438 surfaces%var_out(:) = surfaces%var_av(:,n_out) / REAL( average_count_surf, KIND=wp ) 2439 surfaces%var_av(:,n_out) = 0.0_wp 2440 2441 ENDIF 2442 2443 CASE ( 'rad_sw_dif' ) 2444 ! 2445 !-- Output of instantaneous data 2446 IF ( av == 0 ) THEN 2447 CALL surface_data_output_collect( surf_def_h(0)%rad_sw_dif, & 2448 surf_def_h(1)%rad_sw_dif, surf_lsm_h%rad_sw_dif, & 2449 surf_usm_h%rad_sw_dif, surf_def_v(0)%rad_sw_dif, & 2450 surf_lsm_v(0)%rad_sw_dif, & 2451 surf_usm_v(0)%rad_sw_dif, & 2452 surf_def_v(1)%rad_sw_dif, & 2453 surf_lsm_v(1)%rad_sw_dif, & 2454 surf_usm_v(1)%rad_sw_dif, & 2455 surf_def_v(2)%rad_sw_dif, & 2456 surf_lsm_v(2)%rad_sw_dif, & 2457 surf_usm_v(2)%rad_sw_dif, & 2458 surf_def_v(3)%rad_sw_dif, & 2459 surf_lsm_v(3)%rad_sw_dif, & 2460 surf_usm_v(3)%rad_sw_dif ) 2461 ELSE 2462 ! 2463 !-- Output of averaged data 2464 surfaces%var_out(:) = surfaces%var_av(:,n_out) / REAL( average_count_surf, KIND=wp ) 2465 surfaces%var_av(:,n_out) = 0.0_wp 2466 2467 ENDIF 2468 2469 CASE ( 'rad_sw_ref' ) 2470 ! 2471 !-- Output of instantaneous data 2472 IF ( av == 0 ) THEN 2473 CALL surface_data_output_collect( surf_def_h(0)%rad_sw_ref, & 2474 surf_def_h(1)%rad_sw_ref, surf_lsm_h%rad_sw_ref, & 2475 surf_usm_h%rad_sw_ref, surf_def_v(0)%rad_sw_ref, & 2476 surf_lsm_v(0)%rad_sw_ref, & 2477 surf_usm_v(0)%rad_sw_ref, & 2478 surf_def_v(1)%rad_sw_ref, & 2479 surf_lsm_v(1)%rad_sw_ref, & 2480 surf_usm_v(1)%rad_sw_ref, & 2481 surf_def_v(2)%rad_sw_ref, & 2482 surf_lsm_v(2)%rad_sw_ref, & 2483 surf_usm_v(2)%rad_sw_ref, & 2484 surf_def_v(3)%rad_sw_ref, & 2485 surf_lsm_v(3)%rad_sw_ref, & 2486 surf_usm_v(3)%rad_sw_ref ) 2487 ELSE 2488 ! 2489 !-- Output of averaged data 2490 surfaces%var_out(:) = surfaces%var_av(:,n_out) / REAL( average_count_surf, KIND=wp ) 2491 surfaces%var_av(:,n_out) = 0.0_wp 2492 2493 ENDIF 2494 2495 CASE ( 'rad_sw_res' ) 2496 ! 2497 !-- Output of instantaneous data 2498 IF ( av == 0 ) THEN 2499 CALL surface_data_output_collect( surf_def_h(0)%rad_sw_res, & 2500 surf_def_h(1)%rad_sw_res, surf_lsm_h%rad_sw_res, & 2501 surf_usm_h%rad_sw_res, surf_def_v(0)%rad_sw_res, & 2502 surf_lsm_v(0)%rad_sw_res, & 2503 surf_usm_v(0)%rad_sw_res, & 2504 surf_def_v(1)%rad_sw_res, & 2505 surf_lsm_v(1)%rad_sw_res, & 2506 surf_usm_v(1)%rad_sw_res, & 2507 surf_def_v(2)%rad_sw_res, & 2508 surf_lsm_v(2)%rad_sw_res, & 2509 surf_usm_v(2)%rad_sw_res, & 2510 surf_def_v(3)%rad_sw_res, & 2511 surf_lsm_v(3)%rad_sw_res, & 2512 surf_usm_v(3)%rad_sw_res ) 2513 ELSE 2514 ! 2515 !-- Output of averaged data 2516 surfaces%var_out(:) = surfaces%var_av(:,n_out) / REAL( average_count_surf, KIND=wp ) 2517 surfaces%var_av(:,n_out) = 0.0_wp 2518 2519 ENDIF 2520 2521 CASE ( 'rad_lw_dif' ) 2522 ! 2523 !-- Output of instantaneous data 2524 IF ( av == 0 ) THEN 2525 CALL surface_data_output_collect( surf_def_h(0)%rad_lw_dif, & 2526 surf_def_h(1)%rad_lw_dif, surf_lsm_h%rad_lw_dif, & 2527 surf_usm_h%rad_lw_dif, surf_def_v(0)%rad_lw_dif, & 2528 surf_lsm_v(0)%rad_lw_dif, & 2529 surf_usm_v(0)%rad_lw_dif, & 2530 surf_def_v(1)%rad_lw_dif, & 2531 surf_lsm_v(1)%rad_lw_dif, & 2532 surf_usm_v(1)%rad_lw_dif, & 2533 surf_def_v(2)%rad_lw_dif, & 2534 surf_lsm_v(2)%rad_lw_dif, & 2535 surf_usm_v(2)%rad_lw_dif, & 2536 surf_def_v(3)%rad_lw_dif, & 2537 surf_lsm_v(3)%rad_lw_dif, & 2538 surf_usm_v(3)%rad_lw_dif ) 2539 ELSE 2540 ! 2541 !-- Output of averaged data 2542 surfaces%var_out(:) = surfaces%var_av(:,n_out) / REAL( average_count_surf, KIND=wp ) 2543 surfaces%var_av(:,n_out) = 0.0_wp 2544 2545 ENDIF 2546 2547 CASE ( 'rad_lw_ref' ) 2548 ! 2549 !-- Output of instantaneous data 2550 IF ( av == 0 ) THEN 2551 CALL surface_data_output_collect( surf_def_h(0)%rad_lw_ref, & 2552 surf_def_h(1)%rad_lw_ref, surf_lsm_h%rad_lw_ref, & 2553 surf_usm_h%rad_lw_ref, surf_def_v(0)%rad_lw_ref, & 2554 surf_lsm_v(0)%rad_lw_ref, & 2555 surf_usm_v(0)%rad_lw_ref, & 2556 surf_def_v(1)%rad_lw_ref, & 2557 surf_lsm_v(1)%rad_lw_ref, & 2558 surf_usm_v(1)%rad_lw_ref, & 2559 surf_def_v(2)%rad_lw_ref, & 2560 surf_lsm_v(2)%rad_lw_ref, & 2561 surf_usm_v(2)%rad_lw_ref, & 2562 surf_def_v(3)%rad_lw_ref, & 2563 surf_lsm_v(3)%rad_lw_ref, & 2564 surf_usm_v(3)%rad_lw_ref ) 2565 ELSE 2566 ! 2567 !-- Output of averaged data 2568 surfaces%var_out(:) = surfaces%var_av(:,n_out) / REAL( average_count_surf, KIND=wp ) 2569 surfaces%var_av(:,n_out) = 0.0_wp 2570 2571 ENDIF 2572 2573 CASE ( 'rad_lw_res' ) 2574 ! 2575 !-- Output of instantaneous data 2576 IF ( av == 0 ) THEN 2577 CALL surface_data_output_collect( surf_def_h(0)%rad_lw_res, & 2578 surf_def_h(1)%rad_lw_res, surf_lsm_h%rad_lw_res, & 2579 surf_usm_h%rad_lw_res, surf_def_v(0)%rad_lw_res, & 2580 surf_lsm_v(0)%rad_lw_res, & 2581 surf_usm_v(0)%rad_lw_res, & 2582 surf_def_v(1)%rad_lw_res, & 2583 surf_lsm_v(1)%rad_lw_res, & 2584 surf_usm_v(1)%rad_lw_res, & 2585 surf_def_v(2)%rad_lw_res, & 2586 surf_lsm_v(2)%rad_lw_res, & 2587 surf_usm_v(2)%rad_lw_res, & 2588 surf_def_v(3)%rad_lw_res, & 2589 surf_lsm_v(3)%rad_lw_res, & 2590 surf_usm_v(3)%rad_lw_res ) 2591 ELSE 2592 ! 2593 !-- Output of averaged data 2594 surfaces%var_out(:) = surfaces%var_av(:,n_out) / REAL( average_count_surf, KIND=wp ) 2595 surfaces%var_av(:,n_out) = 0.0_wp 2596 2597 ENDIF 2598 2599 CASE ( 'uvw1' ) 2600 ! 2601 !-- Output of instantaneous data 2602 IF ( av == 0 ) THEN 2603 CALL surface_data_output_collect( surf_def_h(0)%uvw_abs, & 2604 surf_def_h(1)%uvw_abs, surf_lsm_h%uvw_abs, & 2605 surf_usm_h%uvw_abs, surf_def_v(0)%uvw_abs, & 2606 surf_lsm_v(0)%uvw_abs, & 2607 surf_usm_v(0)%uvw_abs, & 2608 surf_def_v(1)%uvw_abs, & 2609 surf_lsm_v(1)%uvw_abs, & 2610 surf_usm_v(1)%uvw_abs, & 2611 surf_def_v(2)%uvw_abs, & 2612 surf_lsm_v(2)%uvw_abs, & 2613 surf_usm_v(2)%uvw_abs, & 2614 surf_def_v(3)%uvw_abs, & 2615 surf_lsm_v(3)%uvw_abs, & 2616 surf_usm_v(3)%uvw_abs ) 2617 ELSE 2618 ! 2619 !-- Output of averaged data 2620 surfaces%var_out(:) = surfaces%var_av(:,n_out) / REAL( average_count_surf, KIND=wp ) 2621 surfaces%var_av(:,n_out) = 0.0_wp 2622 2623 ENDIF 2624 ! 2625 !-- Waste heat from indoor model 2626 CASE ( 'waste_heat' ) 2627 ! 2628 !-- Output of instantaneous data 2629 IF ( av == 0 ) THEN 2630 CALL surface_data_output_collect( surf_def_h(0)%waste_heat, & 2631 surf_def_h(1)%waste_heat, surf_lsm_h%waste_heat, & 2632 surf_usm_h%waste_heat, surf_def_v(0)%waste_heat, & 2633 surf_lsm_v(0)%waste_heat, & 2634 surf_usm_v(0)%waste_heat, & 2635 surf_def_v(1)%waste_heat, & 2636 surf_lsm_v(1)%waste_heat, & 2637 surf_usm_v(1)%waste_heat, & 2638 surf_def_v(2)%waste_heat, & 2639 surf_lsm_v(2)%waste_heat, & 2640 surf_usm_v(2)%waste_heat, & 2641 surf_def_v(3)%waste_heat, & 2642 surf_lsm_v(3)%waste_heat, & 2643 surf_usm_v(3)%waste_heat ) 2644 ELSE 2645 ! 2646 !-- Output of averaged data 2647 surfaces%var_out(:) = surfaces%var_av(:,n_out) / REAL( average_count_surf, KIND=wp ) 2648 surfaces%var_av(:,n_out) = 0.0_wp 2649 2650 ENDIF 2651 ! 2652 !-- Innermost building wall flux from indoor model 2653 CASE ( 'im_hf' ) 2654 ! 2655 !-- Output of instantaneous data 2656 IF ( av == 0 ) THEN 2657 CALL surface_data_output_collect( surf_def_h(0)%iwghf_eb, surf_def_h(1)%iwghf_eb, & 2658 surf_lsm_h%iwghf_eb, surf_usm_h%iwghf_eb, & 2659 surf_def_v(0)%iwghf_eb, surf_lsm_v(0)%iwghf_eb, & 2660 surf_usm_v(0)%iwghf_eb, surf_def_v(1)%iwghf_eb, & 2661 surf_lsm_v(1)%iwghf_eb, surf_usm_v(1)%iwghf_eb, & 2662 surf_def_v(2)%iwghf_eb, surf_lsm_v(2)%iwghf_eb, & 2663 surf_usm_v(2)%iwghf_eb, surf_def_v(3)%iwghf_eb, & 2664 surf_lsm_v(3)%iwghf_eb, surf_usm_v(3)%iwghf_eb ) 2665 ELSE 2666 ! 2667 !-- Output of averaged data 2668 surfaces%var_out(:) = surfaces%var_av(:,n_out) / REAL( average_count_surf, KIND=wp ) 2669 surfaces%var_av(:,n_out) = 0.0_wp 2670 2671 ENDIF 2672 ! 2673 !-- Surface albedo (tile approach) 2674 CASE ( 'albedo' ) 2675 ! 2676 !-- Output of instantaneous data 2677 IF ( av == 0 ) THEN 2678 CALL surface_data_output_collect( surf_def_h(0)%albedo, surf_def_h(1)%albedo, & 2679 surf_lsm_h%albedo, surf_usm_h%albedo, & 2680 surf_def_v(0)%albedo, surf_lsm_v(0)%albedo, & 2681 surf_usm_v(0)%albedo, surf_def_v(1)%albedo, & 2682 surf_lsm_v(1)%albedo, surf_usm_v(1)%albedo, & 2683 surf_def_v(2)%albedo, surf_lsm_v(2)%albedo, & 2684 surf_usm_v(2)%albedo, surf_def_v(3)%albedo, & 2685 surf_lsm_v(3)%albedo, surf_usm_v(3)%albedo ) 2686 ELSE 2687 ! 2688 !-- Output of averaged data 2689 surfaces%var_out(:) = surfaces%var_av(:,n_out) / REAL( average_count_surf, KIND=wp ) 2690 surfaces%var_av(:,n_out) = 0.0_wp 2691 2692 ENDIF 2693 ! 2694 !-- Surface emissivity (tile approach) 2695 CASE ( 'emissivity' ) 2696 ! 2697 !-- Output of instantaneous data 2698 IF ( av == 0 ) THEN 2699 CALL surface_data_output_collect( surf_def_h(0)%emissivity, & 2700 surf_def_h(1)%emissivity, surf_lsm_h%emissivity, & 2701 surf_usm_h%emissivity, surf_def_v(0)%emissivity, & 2702 surf_lsm_v(0)%emissivity, & 2703 surf_usm_v(0)%emissivity, & 2704 surf_def_v(1)%emissivity, & 2705 surf_lsm_v(1)%emissivity, & 2706 surf_usm_v(1)%emissivity, & 2707 surf_def_v(2)%emissivity, & 2708 surf_lsm_v(2)%emissivity, & 2709 surf_usm_v(2)%emissivity, & 2710 surf_def_v(3)%emissivity, & 2711 surf_lsm_v(3)%emissivity, & 2712 surf_usm_v(3)%emissivity ) 2713 ELSE 2714 ! 2715 !-- Output of averaged data 2716 surfaces%var_out(:) = surfaces%var_av(:,n_out) / REAL( average_count_surf, KIND=wp ) 2717 surfaces%var_av(:,n_out) = 0.0_wp 2718 2719 ENDIF 2720 ! 2721 !-- Add further variables: 2722 !-- 'css', 'cssws', 'qsws_liq', 'qsws_soil', 'qsws_veg' 2723 2724 END SELECT 2725 ! 2726 !-- Write to binary file: 2727 !-- - surfaces%points ( 3, 1-npoints ) 2728 !-- - surfaces%polygons ( 5, 1-ns ) 2729 !-- - surfaces%var_out ( 1-ns, time ) 2730 !-- - Dimension: 1-nsurfaces, 1-npoints - can be ordered consecutively 2731 !-- - Distinguish between average and non-average data 2732 IF ( to_vtk ) THEN 2733 DO i = 0, io_blocks - 1 2734 IF ( i == io_group ) THEN 2735 WRITE ( 25 + av ) LEN_TRIM( 'time' ) 2736 WRITE ( 25 + av ) 'time' 2737 WRITE ( 25 + av ) time_since_reference_point 2738 WRITE ( 25 + av ) LEN_TRIM( trimvar ) 2739 WRITE ( 25 + av ) TRIM( trimvar ) 2740 WRITE ( 25 + av ) surfaces%var_out 2741 ENDIF 2742 #if defined( __parallel ) 2743 CALL MPI_BARRIER( comm2d, ierr ) 2744 #endif 2745 ENDDO 2746 ENDIF 2747 2748 IF ( to_netcdf ) THEN 2749 #if defined( __netcdf4_parallel ) 2750 ! 2751 !-- Write output array to file 2752 nc_stat = NF90_PUT_VAR( id_set_surf(av), id_var_dosurf(av,n_out), surfaces%var_out, & 2753 start = (/ surfaces%s(1), dosurf_time_count(av) /), & 2754 count = (/ surfaces%ns, 1 /) ) 2755 CALL netcdf_handle_error( 'surface_data_output', 6667 ) 1048 2756 #endif 1049 2757 ENDIF 1050 ! 1051 !-- If output to netcdf is enabled, set-up the coordinate arrays that 1052 !-- unambiguously describe the position and orientation of each surface 1053 !-- element. 1054 IF ( to_netcdf ) THEN 1055 ! 1056 !-- Allocate local coordinate arrays 1057 ALLOCATE( surfaces%s(1:surfaces%ns) ) 1058 ALLOCATE( surfaces%xs(1:surfaces%ns) ) 1059 ALLOCATE( surfaces%ys(1:surfaces%ns) ) 1060 ALLOCATE( surfaces%zs(1:surfaces%ns) ) 1061 ALLOCATE( surfaces%azimuth(1:surfaces%ns) ) 1062 ALLOCATE( surfaces%zenith(1:surfaces%ns) ) 1063 ALLOCATE( surfaces%es_utm(1:surfaces%ns) ) 1064 ALLOCATE( surfaces%ns_utm(1:surfaces%ns) ) 1065 ! 1066 !-- Gather the number of surface on each processor, in order to number 1067 !-- the surface elements in ascending order with respect to the total 1068 !-- number of surfaces in the domain. 1069 #if defined( __parallel ) 1070 CALL MPI_ALLGATHER( surfaces%ns, 1, MPI_INTEGER, & 1071 num_surfaces_on_pe, 1, MPI_INTEGER, comm2d, ierr ) 1072 #else 1073 num_surfaces_on_pe = surfaces%ns 1074 #endif 1075 ! 1076 !-- First, however, determine the offset where couting of the surfaces 1077 !-- should start (the sum of surfaces on all PE's with lower MPI rank). 1078 i = 0 1079 start_count = 1 1080 DO WHILE ( i < myid .AND. i <= SIZE( num_surfaces_on_pe ) ) 1081 start_count = start_count + num_surfaces_on_pe(i) 1082 i = i + 1 1083 ENDDO 1084 ! 1085 !-- Set coordinate arrays. For horizontal surfaces, azimuth 1086 !-- angles are not defined (fill value). Zenith angle is 0 (180) for 1087 !-- upward (downward)-facing surfaces. 1088 i = start_count 1089 mm = 1 1090 DO m = 1, surf_def_h(0)%ns 1091 surfaces%s(mm) = i 1092 surfaces%xs(mm) = ( surf_def_h(0)%i(m) + 0.5_wp ) * dx 1093 surfaces%ys(mm) = ( surf_def_h(0)%j(m) + 0.5_wp ) * dy 1094 surfaces%zs(mm) = zw(surf_def_h(0)%k(m)+surf_def_h(0)%koff) 1095 surfaces%azimuth(mm) = surfaces%fillvalue 1096 surfaces%zenith(mm) = 0.0 1097 i = i + 1 1098 mm = mm + 1 1099 ENDDO 1100 DO m = 1, surf_lsm_h%ns 1101 surfaces%s(mm) = i 1102 surfaces%xs(mm) = ( surf_lsm_h%i(m) + 0.5_wp ) * dx 1103 surfaces%ys(mm) = ( surf_lsm_h%j(m) + 0.5_wp ) * dy 1104 surfaces%zs(mm) = zw(surf_lsm_h%k(m)+surf_lsm_h%koff) 1105 surfaces%azimuth(mm) = surfaces%fillvalue 1106 surfaces%zenith(mm) = 0.0 1107 i = i + 1 1108 mm = mm + 1 1109 ENDDO 1110 DO m = 1, surf_usm_h%ns 1111 surfaces%s(mm) = i 1112 surfaces%xs(mm) = ( surf_usm_h%i(m) + 0.5_wp ) * dx 1113 surfaces%ys(mm) = ( surf_usm_h%j(m) + 0.5_wp ) * dy 1114 surfaces%zs(mm) = zw(surf_usm_h%k(m)+surf_usm_h%koff) 1115 surfaces%azimuth(mm) = surfaces%fillvalue 1116 surfaces%zenith(mm) = 0.0 1117 i = i + 1 1118 mm = mm + 1 1119 ENDDO 1120 DO m = 1, surf_def_h(1)%ns 1121 surfaces%s(mm) = i 1122 surfaces%xs(mm) = ( surf_def_h(1)%i(m) + 0.5_wp ) * dx 1123 surfaces%ys(mm) = ( surf_def_h(1)%j(m) + 0.5_wp ) * dy 1124 surfaces%zs(mm) = zw(surf_def_h(1)%k(m)+surf_def_h(1)%koff) 1125 surfaces%azimuth(mm) = surfaces%fillvalue 1126 surfaces%zenith(mm) = 180.0 1127 i = i + 1 1128 mm = mm + 1 1129 ENDDO 1130 ! 1131 !-- For vertical surfaces, zenith angles are not defined (fill value). 1132 !-- Azimuth angle: northward (0), eastward (90), southward (180), 1133 !-- westward (270). 1134 !-- Note, for vertical surfaces, zenith angles are 90.0_wp. 1135 DO l = 0, 3 1136 IF ( l == 0 ) THEN 1137 az = 0.0_wp 1138 off_x = 0.5_wp 1139 off_y = 0.0_wp 1140 ELSEIF ( l == 1 ) THEN 1141 az = 180.0_wp 1142 off_x = 0.5_wp 1143 off_y = 1.0_wp 1144 ELSEIF ( l == 2 ) THEN 1145 az = 90.0_wp 1146 off_x = 0.0_wp 1147 off_y = 0.5_wp 1148 ELSEIF ( l == 3 ) THEN 1149 az = 270.0_wp 1150 off_x = 1.0_wp 1151 off_y = 0.5_wp 1152 ENDIF 1153 1154 DO m = 1, surf_def_v(l)%ns 1155 surfaces%s(mm) = i 1156 surfaces%xs(mm) = ( surf_def_v(l)%i(m) + off_x ) * dx 1157 surfaces%ys(mm) = ( surf_def_v(l)%j(m) + off_y ) * dy 1158 surfaces%zs(mm) = zu(surf_def_v(l)%k(m)) 1159 surfaces%azimuth(mm) = az 1160 surfaces%zenith(mm) = 90.0_wp 1161 i = i + 1 1162 mm = mm + 1 1163 ENDDO 1164 DO m = 1, surf_lsm_v(l)%ns 1165 surfaces%s(mm) = i 1166 surfaces%xs(mm) = ( surf_lsm_v(l)%i(m) + off_x ) * dx 1167 surfaces%ys(mm) = ( surf_lsm_v(l)%j(m) + off_y ) * dy 1168 surfaces%zs(mm) = zu(surf_lsm_v(l)%k(m)) 1169 surfaces%azimuth(mm) = az 1170 surfaces%zenith(mm) = 90.0_wp 1171 i = i + 1 1172 mm = mm + 1 1173 ENDDO 1174 DO m = 1, surf_usm_v(l)%ns 1175 surfaces%s(mm) = i 1176 surfaces%xs(mm) = ( surf_usm_v(l)%i(m) + off_x ) * dx 1177 surfaces%ys(mm) = ( surf_usm_v(l)%j(m) + off_y ) * dy 1178 surfaces%zs(mm) = zu(surf_usm_v(l)%k(m)) 1179 surfaces%azimuth(mm) = az 1180 surfaces%zenith(mm) = 90.0_wp 1181 i = i + 1 1182 mm = mm + 1 1183 ENDDO 1184 ENDDO 1185 ! 1186 !-- Finally, define UTM coordinates, which are the x/y-coordinates 1187 !-- plus the origin (lower-left coordinate of the model domain). 1188 surfaces%es_utm = surfaces%xs + init_model%origin_x 1189 surfaces%ns_utm = surfaces%ys + init_model%origin_y 1190 ! 1191 !-- Initialize NetCDF data output. Please note, local start position for 1192 !-- the surface elements in the NetCDF file is surfaces%s(1), while 1193 !-- the number of surfaces on the subdomain is given by surfaces%ns. 1194 #if defined( __netcdf4_parallel ) 1195 1196 ! 1197 !-- Calculate number of time steps to be output 1198 ntdim_surf(0) = dosurf_time_count(0) + CEILING( & 1199 ( end_time - MAX( & 1200 MERGE( skip_time_dosurf, & 1201 skip_time_dosurf + spinup_time, & 1202 data_output_during_spinup ), & 1203 simulated_time_at_begin ) & 1204 ) / dt_dosurf ) 1205 1206 ntdim_surf(1) = dosurf_time_count(1) + CEILING( & 1207 ( end_time - MAX( & 1208 MERGE( skip_time_dosurf_av, & 1209 skip_time_dosurf_av + spinup_time, & 1210 data_output_during_spinup ), & 1211 simulated_time_at_begin ) & 1212 ) / dt_dosurf_av ) 1213 1214 ! 1215 !-- Create NetCDF4 files for parallel writing 1216 DO av = 0, 1 1217 ! 1218 !-- If there is no instantaneous data (av=0) or averaged data (av=1) 1219 !-- requested, do not create the corresponding NetCDF file 1220 IF ( dosurf_no(av) == 0 ) CYCLE 1221 1222 IF ( av == 0 ) THEN 1223 filename = 'SURFACE_DATA_NETCDF' // TRIM( coupling_char ) 1224 ELSE 1225 filename = 'SURFACE_DATA_AV_NETCDF' // TRIM( coupling_char ) 1226 ENDIF 1227 ! 1228 !-- Open file using netCDF4/HDF5 format, parallel 1229 nc_stat = NF90_CREATE( TRIM(filename), & 1230 IOR( NF90_NOCLOBBER, & 1231 IOR( NF90_NETCDF4, NF90_MPIIO ) ), & 1232 id_set_surf(av), & 1233 COMM = comm2d, INFO = MPI_INFO_NULL ) 1234 CALL netcdf_handle_error( 'surface_data_output_mod', 5550 ) 1235 1236 !- Write some global attributes 1237 IF ( av == 0 ) THEN 1238 CALL netcdf_create_global_atts( id_set_surf(av), & 1239 'surface-data', & 1240 TRIM( run_description_header ),& 1241 5551 ) 1242 time_average_text = ' ' 1243 ELSE 1244 CALL netcdf_create_global_atts( id_set_surf(av), & 1245 'surface-data_av', & 1246 TRIM( run_description_header ),& 1247 5552 ) 1248 WRITE ( time_average_text,'(F7.1,'' s avg'')' ) & 1249 averaging_interval_surf 1250 nc_stat = NF90_PUT_ATT( id_set_surf(av), NF90_GLOBAL, & 1251 'time_avg', & 1252 TRIM( time_average_text ) ) 1253 CALL netcdf_handle_error( 'surface_data_output_mod', 5553 ) 1254 ENDIF 1255 1256 1257 ! 1258 !-- Define time coordinate for surface data. 1259 !-- For parallel output the time dimension has to be limited 1260 !-- (ntdim_surf), otherwise the performance drops significantly. 1261 CALL netcdf_create_dim( id_set_surf(av), 'time', ntdim_surf(av), & 1262 id_dim_time_surf(av), 5554 ) 1263 1264 CALL netcdf_create_var( id_set_surf(av), & 1265 (/ id_dim_time_surf(av) /), & 1266 'time', NF90_DOUBLE, & 1267 id_var_time_surf(av), & 1268 'seconds since '// & 1269 TRIM(init_model%origin_time), & 1270 'time', 5555, 5555, 5555 ) 1271 1272 CALL netcdf_create_att( id_set_surf(av), id_var_time_surf(av), & 1273 'standard_name', 'time', 5556) 1274 1275 CALL netcdf_create_att( id_set_surf(av), id_var_time_surf(av), & 1276 'axis', 'T', 5557) 1277 ! 1278 !-- Define spatial dimensions and coordinates: 1279 !-- Define index of surface element 1280 CALL netcdf_create_dim( id_set_surf(av), 's', surfaces%ns_total, & 1281 id_dim_s_surf(av), 5558 ) 1282 CALL netcdf_create_var( id_set_surf(av), (/ id_dim_s_surf(av) /), & 1283 's', NF90_DOUBLE, id_var_s_surf(av), & 1284 '1', 'number of surface element', & 1285 5559, 5559, 5559 ) 1286 ! 1287 !-- Define x coordinate 1288 CALL netcdf_create_var( id_set_surf(av), (/ id_dim_s_surf(av) /), & 1289 'xs', NF90_DOUBLE, id_var_xs_surf(av), & 1290 'meters', & 1291 'distance to origin in x-direction', & 1292 5561, 5561, 5561 ) 1293 ! 1294 !-- Define y coordinate 1295 CALL netcdf_create_var( id_set_surf(av), (/ id_dim_s_surf(av) /), & 1296 'ys', NF90_DOUBLE, id_var_ys_surf(av), & 1297 'meters', & 1298 'distance to origin in y-direction', & 1299 5562, 5562, 5562 ) 1300 ! 1301 !-- Define z coordinate 1302 CALL netcdf_create_var( id_set_surf(av), (/ id_dim_s_surf(av) /), & 1303 'zs', NF90_DOUBLE, id_var_zs_surf(av), & 1304 'meters', 'height', 5560, 5560, 5560 ) 1305 CALL netcdf_create_att( id_set_surf(av), id_var_zs_surf(av), & 1306 'standard_name', 'height', 5583 ) 1307 1308 ! 1309 !-- Define UTM coordinates 1310 CALL netcdf_create_var( id_set_surf(av), (/ id_dim_s_surf(av) /), & 1311 'Es_UTM', NF90_DOUBLE, & 1312 id_var_etum_surf(av), & 1313 'meters', '', 5563, 5563, 5563 ) 1314 CALL netcdf_create_var( id_set_surf(av), (/ id_dim_s_surf(av) /), & 1315 'Ns_UTM', NF90_DOUBLE, & 1316 id_var_nutm_surf(av), & 1317 'meters', '', 5564, 5564, 5564 ) 1318 1319 ! 1320 !-- Define angles 1321 CALL netcdf_create_var( id_set_surf(av), (/ id_dim_s_surf(av) /), & 1322 'azimuth', NF90_DOUBLE, & 1323 id_var_azimuth_surf(av), & 1324 'degree', 'azimuth angle', & 1325 5577, 5578, 5579, & 1326 fill = .TRUE. ) 1327 CALL netcdf_create_att( id_set_surf(av), id_var_azimuth_surf(av), & 1328 'standard_name', 'surface_azimuth_angle', & 1329 5584 ) 1330 1331 CALL netcdf_create_var( id_set_surf(av), (/ id_dim_s_surf(av) /), & 1332 'zenith', NF90_DOUBLE, & 1333 id_var_zenith_surf(av), & 1334 'degree', '', 5580, 5581, 5582, & 1335 fill = .TRUE. ) 1336 ! 1337 !-- Define the variables 1338 var_list = ';' 1339 i = 1 1340 1341 DO WHILE ( dosurf(av,i)(1:1) /= ' ' ) 1342 1343 CALL netcdf_create_var( id_set_surf(av),(/ id_dim_s_surf(av), & 1344 id_dim_time_surf(av) /), dosurf(av,i), & 1345 NF90_REAL4, id_var_dosurf(av,i), & 1346 dosurf_unit(av,i), dosurf(av,i), 5565, & 1347 5565, 5565, .TRUE. ) 1348 ! 1349 !-- Set no fill for every variable to increase performance. 1350 nc_stat = NF90_DEF_VAR_FILL( id_set_surf(av), & 1351 id_var_dosurf(av,i), & 1352 NF90_NOFILL, 0 ) 1353 CALL netcdf_handle_error( 'surface_data_output_init', 5566 ) 1354 ! 1355 !-- Set collective io operations for parallel io 1356 nc_stat = NF90_VAR_PAR_ACCESS( id_set_surf(av), & 1357 id_var_dosurf(av,i), & 1358 NF90_COLLECTIVE ) 1359 CALL netcdf_handle_error( 'surface_data_output_init', 5567 ) 1360 var_list = TRIM( var_list ) // TRIM( dosurf(av,i) ) // ';' 1361 1362 i = i + 1 1363 1364 ENDDO 1365 ! 1366 !-- Write the list of variables as global attribute (this is used by 1367 !-- restart runs and by combine_plot_fields) 1368 nc_stat = NF90_PUT_ATT( id_set_surf(av), NF90_GLOBAL, 'VAR_LIST', & 1369 var_list ) 1370 CALL netcdf_handle_error( 'surface_data_output_init', 5568 ) 1371 1372 ! 1373 !-- Set general no fill, otherwise the performance drops significantly 1374 !-- for parallel output. 1375 nc_stat = NF90_SET_FILL( id_set_surf(av), NF90_NOFILL, oldmode ) 1376 CALL netcdf_handle_error( 'surface_data_output_init', 5569 ) 1377 1378 ! 1379 !-- Leave netCDF define mode 1380 nc_stat = NF90_ENDDEF( id_set_surf(av) ) 1381 CALL netcdf_handle_error( 'surface_data_output_init', 5570 ) 1382 1383 ! 1384 !-- These data are only written by PE0 for parallel output to increase 1385 !-- the performance. 1386 IF ( myid == 0 ) THEN 1387 ! 1388 !-- Write data for surface indices 1389 ALLOCATE( netcdf_data_1d(1:surfaces%ns_total) ) 1390 1391 DO i = 1, surfaces%ns_total 1392 netcdf_data_1d(i) = i 1393 ENDDO 1394 1395 nc_stat = NF90_PUT_VAR( id_set_surf(av), id_var_s_surf(av), & 1396 netcdf_data_1d, start = (/ 1 /), & 1397 count = (/ surfaces%ns_total /) ) 1398 CALL netcdf_handle_error( 'surface_data_output_init', 5571 ) 1399 1400 DEALLOCATE( netcdf_data_1d ) 1401 1402 ENDIF 1403 1404 ! 1405 !-- Write surface positions to file 1406 nc_stat = NF90_PUT_VAR( id_set_surf(av), id_var_xs_surf(av), & 1407 surfaces%xs, start = (/ surfaces%s(1) /), & 1408 count = (/ surfaces%ns /) ) 1409 CALL netcdf_handle_error( 'surface_data_output_init', 5572 ) 1410 1411 nc_stat = NF90_PUT_VAR( id_set_surf(av), id_var_ys_surf(av), & 1412 surfaces%ys, start = (/ surfaces%s(1) /), & 1413 count = (/ surfaces%ns /) ) 1414 CALL netcdf_handle_error( 'surface_data_output_init', 5573 ) 1415 1416 nc_stat = NF90_PUT_VAR( id_set_surf(av), id_var_zs_surf(av), & 1417 surfaces%zs, start = (/ surfaces%s(1) /), & 1418 count = (/ surfaces%ns /) ) 1419 CALL netcdf_handle_error( 'surface_data_output_init', 5574 ) 1420 1421 nc_stat = NF90_PUT_VAR( id_set_surf(av), id_var_etum_surf(av), & 1422 surfaces%es_utm, & 1423 start = (/ surfaces%s(1) /), & 1424 count = (/ surfaces%ns /) ) 1425 CALL netcdf_handle_error( 'surface_data_output_init', 5575 ) 1426 1427 nc_stat = NF90_PUT_VAR( id_set_surf(av), id_var_nutm_surf(av), & 1428 surfaces%ns_utm, & 1429 start = (/ surfaces%s(1) /), & 1430 count = (/ surfaces%ns /) ) 1431 CALL netcdf_handle_error( 'surface_data_output_init', 5576 ) 1432 1433 nc_stat = NF90_PUT_VAR( id_set_surf(av), id_var_azimuth_surf(av), & 1434 surfaces%azimuth, & 1435 start = (/ surfaces%s(1) /), & 1436 count = (/ surfaces%ns /) ) 1437 CALL netcdf_handle_error( 'surface_data_output_init', 5585 ) 1438 1439 nc_stat = NF90_PUT_VAR( id_set_surf(av), id_var_zenith_surf(av), & 1440 surfaces%zenith, & 1441 start = (/ surfaces%s(1) /), & 1442 count = (/ surfaces%ns /) ) 1443 CALL netcdf_handle_error( 'surface_data_output_init', 5586 ) 1444 1445 ENDDO 1446 #endif 1447 1448 ENDIF 1449 1450 END SUBROUTINE surface_data_output_init 1451 1452 !------------------------------------------------------------------------------! 1453 ! Description: 1454 ! ------------ 1455 !> Routine for controlling the data output. Surface data is collected from 1456 !> different types of surfaces (default, natural, urban) and different 1457 !> orientation and written to one 1D-output array. Further, NetCDF routines 1458 !> are called to write the surface data in the respective NetCDF files. 1459 !------------------------------------------------------------------------------! 1460 SUBROUTINE surface_data_output( av ) 1461 1462 USE control_parameters, & 1463 ONLY: io_blocks, io_group, time_since_reference_point 1464 1465 #if defined( __parallel ) 1466 USE pegrid, & 1467 ONLY: comm2d, ierr 1468 #endif 1469 1470 1471 IMPLICIT NONE 1472 1473 CHARACTER(LEN=100) :: trimvar = ' ' !< dummy for single output variable 1474 1475 INTEGER(iwp) :: av !< id indicating average or non-average data output 1476 INTEGER(iwp) :: i !< loop index 1477 INTEGER(iwp) :: l !< running index for surface orientation 1478 INTEGER(iwp) :: m !< running index for surface elements 1479 INTEGER(iwp) :: n_out !< counter variables for surface output 1480 1481 ! 1482 !-- Return, if nothing to output 1483 IF ( dosurf_no(av) == 0 ) RETURN 1484 ! 1485 !-- In case of VTK output, check if binary files are open and write coordinates. 1486 IF ( to_vtk ) THEN 1487 1488 CALL check_open( 25+av ) 1489 1490 IF ( .NOT. first_output(av) ) THEN 1491 DO i = 0, io_blocks-1 1492 IF ( i == io_group ) THEN 1493 WRITE ( 25+av ) surfaces%npoints 1494 WRITE ( 25+av ) surfaces%npoints_total 1495 WRITE ( 25+av ) surfaces%ns 1496 WRITE ( 25+av ) surfaces%ns_total 1497 WRITE ( 25+av ) surfaces%points 1498 WRITE ( 25+av ) surfaces%polygons 1499 ENDIF 1500 #if defined( __parallel ) 1501 CALL MPI_BARRIER( comm2d, ierr ) 1502 #endif 1503 first_output(av) = .TRUE. 1504 ENDDO 1505 ENDIF 1506 ENDIF 1507 ! 1508 !-- In case of NetCDF output, check if enough time steps are available in file 1509 !-- and update time axis. 1510 IF ( to_netcdf ) THEN 1511 #if defined( __netcdf4_parallel ) 1512 IF ( dosurf_time_count(av) + 1 > ntdim_surf(av) ) THEN 1513 WRITE ( message_string, * ) & 1514 'Output of surface data is not given at t=', & 1515 time_since_reference_point, 's because the maximum ', & 1516 'number of output time levels is exceeded.' 1517 CALL message( 'surface_data_output', 'PA0539', 0, 1, 0, 6, 0 ) 1518 1519 RETURN 1520 1521 ENDIF 1522 ! 1523 !-- Update the netCDF time axis 1524 !-- In case of parallel output, this is only done by PE0 to increase the 1525 !-- performance. 1526 dosurf_time_count(av) = dosurf_time_count(av) + 1 1527 IF ( myid == 0 ) THEN 1528 nc_stat = NF90_PUT_VAR( id_set_surf(av), id_var_time_surf(av), & 1529 (/ time_since_reference_point /), & 1530 start = (/ dosurf_time_count(av) /), & 1531 count = (/ 1 /) ) 1532 CALL netcdf_handle_error( 'surface_data_output', 6666 ) 1533 ENDIF 1534 #endif 1535 ENDIF 1536 1537 ! 1538 !-- Cycle through output quantities and write them to file. 1539 n_out = 0 1540 DO WHILE ( dosurf(av,n_out+1)(1:1) /= ' ' ) 1541 1542 n_out = n_out + 1 1543 trimvar = TRIM( dosurf(av,n_out) ) 1544 ! 1545 !-- Set the output array to the _FillValue in case it is not 1546 !-- defined for each type of surface. 1547 surfaces%var_out = surfaces%fillvalue 1548 SELECT CASE ( trimvar ) 1549 1550 CASE ( 'us' ) 1551 ! 1552 !-- Output of instantaneous data 1553 IF ( av == 0 ) THEN 1554 CALL surface_data_output_collect( surf_def_h(0)%us, & 1555 surf_def_h(1)%us, & 1556 surf_lsm_h%us, & 1557 surf_usm_h%us, & 1558 surf_def_v(0)%us, & 1559 surf_lsm_v(0)%us, & 1560 surf_usm_v(0)%us, & 1561 surf_def_v(1)%us, & 1562 surf_lsm_v(1)%us, & 1563 surf_usm_v(1)%us, & 1564 surf_def_v(2)%us, & 1565 surf_lsm_v(2)%us, & 1566 surf_usm_v(2)%us, & 1567 surf_def_v(3)%us, & 1568 surf_lsm_v(3)%us, & 1569 surf_usm_v(3)%us ) 1570 ELSE 1571 ! 1572 !-- Output of averaged data 1573 surfaces%var_out(:) = surfaces%var_av(:,n_out) / & 1574 REAL( average_count_surf, KIND=wp ) 1575 surfaces%var_av(:,n_out) = 0.0_wp 1576 1577 ENDIF 1578 1579 CASE ( 'ts' ) 1580 ! 1581 !-- Output of instantaneous data 1582 IF ( av == 0 ) THEN 1583 CALL surface_data_output_collect( surf_def_h(0)%ts, & 1584 surf_def_h(1)%ts, & 1585 surf_lsm_h%ts, & 1586 surf_usm_h%ts, & 1587 surf_def_v(0)%ts, & 1588 surf_lsm_v(0)%ts, & 1589 surf_usm_v(0)%ts, & 1590 surf_def_v(1)%ts, & 1591 surf_lsm_v(1)%ts, & 1592 surf_usm_v(1)%ts, & 1593 surf_def_v(2)%ts, & 1594 surf_lsm_v(2)%ts, & 1595 surf_usm_v(2)%ts, & 1596 surf_def_v(3)%ts, & 1597 surf_lsm_v(3)%ts, & 1598 surf_usm_v(3)%ts ) 1599 ELSE 1600 ! 1601 !-- Output of averaged data 1602 surfaces%var_out(:) = surfaces%var_av(:,n_out) / & 1603 REAL( average_count_surf, KIND=wp ) 1604 surfaces%var_av(:,n_out) = 0.0_wp 1605 1606 ENDIF 1607 1608 CASE ( 'qs' ) 1609 ! 1610 !-- Output of instantaneous data 1611 IF ( av == 0 ) THEN 1612 CALL surface_data_output_collect( surf_def_h(0)%qs, & 1613 surf_def_h(1)%qs, & 1614 surf_lsm_h%qs, & 1615 surf_usm_h%qs, & 1616 surf_def_v(0)%qs, & 1617 surf_lsm_v(0)%qs, & 1618 surf_usm_v(0)%qs, & 1619 surf_def_v(1)%qs, & 1620 surf_lsm_v(1)%qs, & 1621 surf_usm_v(1)%qs, & 1622 surf_def_v(2)%qs, & 1623 surf_lsm_v(2)%qs, & 1624 surf_usm_v(2)%qs, & 1625 surf_def_v(3)%qs, & 1626 surf_lsm_v(3)%qs, & 1627 surf_usm_v(3)%qs ) 1628 ELSE 1629 ! 1630 !-- Output of averaged data 1631 surfaces%var_out(:) = surfaces%var_av(:,n_out) / & 1632 REAL( average_count_surf, KIND=wp ) 1633 surfaces%var_av(:,n_out) = 0.0_wp 1634 1635 ENDIF 1636 1637 CASE ( 'ss' ) 1638 ! 1639 !-- Output of instantaneous data 1640 IF ( av == 0 ) THEN 1641 CALL surface_data_output_collect( surf_def_h(0)%ss, & 1642 surf_def_h(1)%ss, & 1643 surf_lsm_h%ss, & 1644 surf_usm_h%ss, & 1645 surf_def_v(0)%ss, & 1646 surf_lsm_v(0)%ss, & 1647 surf_usm_v(0)%ss, & 1648 surf_def_v(1)%ss, & 1649 surf_lsm_v(1)%ss, & 1650 surf_usm_v(1)%ss, & 1651 surf_def_v(2)%ss, & 1652 surf_lsm_v(2)%ss, & 1653 surf_usm_v(2)%ss, & 1654 surf_def_v(3)%ss, & 1655 surf_lsm_v(3)%ss, & 1656 surf_usm_v(3)%ss ) 1657 ELSE 1658 ! 1659 !-- Output of averaged data 1660 surfaces%var_out(:) = surfaces%var_av(:,n_out) / & 1661 REAL( average_count_surf, KIND=wp ) 1662 surfaces%var_av(:,n_out) = 0.0_wp 1663 1664 ENDIF 1665 1666 CASE ( 'qcs' ) 1667 ! 1668 !-- Output of instantaneous data 1669 IF ( av == 0 ) THEN 1670 CALL surface_data_output_collect( surf_def_h(0)%qcs, & 1671 surf_def_h(1)%qcs, & 1672 surf_lsm_h%qcs, & 1673 surf_usm_h%qcs, & 1674 surf_def_v(0)%qcs, & 1675 surf_lsm_v(0)%qcs, & 1676 surf_usm_v(0)%qcs, & 1677 surf_def_v(1)%qcs, & 1678 surf_lsm_v(1)%qcs, & 1679 surf_usm_v(1)%qcs, & 1680 surf_def_v(2)%qcs, & 1681 surf_lsm_v(2)%qcs, & 1682 surf_usm_v(2)%qcs, & 1683 surf_def_v(3)%qcs, & 1684 surf_lsm_v(3)%qcs, & 1685 surf_usm_v(3)%qcs ) 1686 ELSE 1687 ! 1688 !-- Output of averaged data 1689 surfaces%var_out(:) = surfaces%var_av(:,n_out) / & 1690 REAL( average_count_surf, KIND=wp ) 1691 surfaces%var_av(:,n_out) = 0.0_wp 1692 1693 ENDIF 1694 1695 CASE ( 'ncs' ) 1696 ! 1697 !-- Output of instantaneous data 1698 IF ( av == 0 ) THEN 1699 CALL surface_data_output_collect( surf_def_h(0)%ncs, & 1700 surf_def_h(1)%ncs, & 1701 surf_lsm_h%ncs, & 1702 surf_usm_h%ncs, & 1703 surf_def_v(0)%ncs, & 1704 surf_lsm_v(0)%ncs, & 1705 surf_usm_v(0)%ncs, & 1706 surf_def_v(1)%ncs, & 1707 surf_lsm_v(1)%ncs, & 1708 surf_usm_v(1)%ncs, & 1709 surf_def_v(2)%ncs, & 1710 surf_lsm_v(2)%ncs, & 1711 surf_usm_v(2)%ncs, & 1712 surf_def_v(3)%ncs, & 1713 surf_lsm_v(3)%ncs, & 1714 surf_usm_v(3)%ncs ) 1715 ELSE 1716 ! 1717 !-- Output of averaged data 1718 surfaces%var_out(:) = surfaces%var_av(:,n_out) / & 1719 REAL( average_count_surf, KIND=wp ) 1720 surfaces%var_av(:,n_out) = 0.0_wp 1721 1722 ENDIF 1723 1724 CASE ( 'qis' ) 1725 ! 1726 !-- Output of instantaneous data 1727 IF ( av == 0 ) THEN 1728 CALL surface_data_output_collect( surf_def_h(0)%qis, & 1729 surf_def_h(1)%qis, & 1730 surf_lsm_h%qis, & 1731 surf_usm_h%qis, & 1732 surf_def_v(0)%qis, & 1733 surf_lsm_v(0)%qis, & 1734 surf_usm_v(0)%qis, & 1735 surf_def_v(1)%qis, & 1736 surf_lsm_v(1)%qis, & 1737 surf_usm_v(1)%qis, & 1738 surf_def_v(2)%qis, & 1739 surf_lsm_v(2)%qis, & 1740 surf_usm_v(2)%qis, & 1741 surf_def_v(3)%qis, & 1742 surf_lsm_v(3)%qis, & 1743 surf_usm_v(3)%qis ) 1744 ELSE 1745 ! 1746 !-- Output of averaged data 1747 surfaces%var_out(:) = surfaces%var_av(:,n_out) / & 1748 REAL( average_count_surf, KIND=wp ) 1749 surfaces%var_av(:,n_out) = 0.0_wp 1750 1751 ENDIF 1752 1753 CASE ( 'nis' ) 1754 ! 1755 !-- Output of instantaneous data 1756 IF ( av == 0 ) THEN 1757 CALL surface_data_output_collect( surf_def_h(0)%nis, & 1758 surf_def_h(1)%nis, & 1759 surf_lsm_h%nis, & 1760 surf_usm_h%nis, & 1761 surf_def_v(0)%nis, & 1762 surf_lsm_v(0)%nis, & 1763 surf_usm_v(0)%nis, & 1764 surf_def_v(1)%nis, & 1765 surf_lsm_v(1)%nis, & 1766 surf_usm_v(1)%nis, & 1767 surf_def_v(2)%nis, & 1768 surf_lsm_v(2)%nis, & 1769 surf_usm_v(2)%nis, & 1770 surf_def_v(3)%nis, & 1771 surf_lsm_v(3)%nis, & 1772 surf_usm_v(3)%nis ) 1773 ELSE 1774 ! 1775 !-- Output of averaged data 1776 surfaces%var_out(:) = surfaces%var_av(:,n_out) / & 1777 REAL( average_count_surf, KIND=wp ) 1778 surfaces%var_av(:,n_out) = 0.0_wp 1779 1780 ENDIF 1781 1782 CASE ( 'qrs' ) 1783 ! 1784 !-- Output of instantaneous data 1785 IF ( av == 0 ) THEN 1786 CALL surface_data_output_collect( surf_def_h(0)%qrs, & 1787 surf_def_h(1)%qrs, & 1788 surf_lsm_h%qrs, & 1789 surf_usm_h%qrs, & 1790 surf_def_v(0)%qrs, & 1791 surf_lsm_v(0)%qrs, & 1792 surf_usm_v(0)%qrs, & 1793 surf_def_v(1)%qrs, & 1794 surf_lsm_v(1)%qrs, & 1795 surf_usm_v(1)%qrs, & 1796 surf_def_v(2)%qrs, & 1797 surf_lsm_v(2)%qrs, & 1798 surf_usm_v(2)%qrs, & 1799 surf_def_v(3)%qrs, & 1800 surf_lsm_v(3)%qrs, & 1801 surf_usm_v(3)%qrs ) 1802 ELSE 1803 ! 1804 !-- Output of averaged data 1805 surfaces%var_out(:) = surfaces%var_av(:,n_out) / & 1806 REAL( average_count_surf, KIND=wp ) 1807 surfaces%var_av(:,n_out) = 0.0_wp 1808 1809 ENDIF 1810 1811 CASE ( 'nrs' ) 1812 ! 1813 !-- Output of instantaneous data 1814 IF ( av == 0 ) THEN 1815 CALL surface_data_output_collect( surf_def_h(0)%nrs, & 1816 surf_def_h(1)%nrs, & 1817 surf_lsm_h%nrs, & 1818 surf_usm_h%nrs, & 1819 surf_def_v(0)%nrs, & 1820 surf_lsm_v(0)%nrs, & 1821 surf_usm_v(0)%nrs, & 1822 surf_def_v(1)%nrs, & 1823 surf_lsm_v(1)%nrs, & 1824 surf_usm_v(1)%nrs, & 1825 surf_def_v(2)%nrs, & 1826 surf_lsm_v(2)%nrs, & 1827 surf_usm_v(2)%nrs, & 1828 surf_def_v(3)%nrs, & 1829 surf_lsm_v(3)%nrs, & 1830 surf_usm_v(3)%nrs ) 1831 ELSE 1832 ! 1833 !-- Output of averaged data 1834 surfaces%var_out(:) = surfaces%var_av(:,n_out) / & 1835 REAL( average_count_surf, KIND=wp ) 1836 surfaces%var_av(:,n_out) = 0.0_wp 1837 1838 ENDIF 1839 1840 CASE ( 'ol' ) 1841 ! 1842 !-- Output of instantaneous data 1843 IF ( av == 0 ) THEN 1844 CALL surface_data_output_collect( surf_def_h(0)%ol, & 1845 surf_def_h(1)%ol, & 1846 surf_lsm_h%ol, & 1847 surf_usm_h%ol, & 1848 surf_def_v(0)%ol, & 1849 surf_lsm_v(0)%ol, & 1850 surf_usm_v(0)%ol, & 1851 surf_def_v(1)%ol, & 1852 surf_lsm_v(1)%ol, & 1853 surf_usm_v(1)%ol, & 1854 surf_def_v(2)%ol, & 1855 surf_lsm_v(2)%ol, & 1856 surf_usm_v(2)%ol, & 1857 surf_def_v(3)%ol, & 1858 surf_lsm_v(3)%ol, & 1859 surf_usm_v(3)%ol ) 1860 ELSE 1861 ! 1862 !-- Output of averaged data 1863 surfaces%var_out(:) = surfaces%var_av(:,n_out) / & 1864 REAL( average_count_surf, KIND=wp ) 1865 surfaces%var_av(:,n_out) = 0.0_wp 1866 1867 ENDIF 1868 1869 CASE ( 'z0' ) 1870 ! 1871 !-- Output of instantaneous data 1872 IF ( av == 0 ) THEN 1873 CALL surface_data_output_collect( surf_def_h(0)%z0, & 1874 surf_def_h(1)%z0, & 1875 surf_lsm_h%z0, & 1876 surf_usm_h%z0, & 1877 surf_def_v(0)%z0, & 1878 surf_lsm_v(0)%z0, & 1879 surf_usm_v(0)%z0, & 1880 surf_def_v(1)%z0, & 1881 surf_lsm_v(1)%z0, & 1882 surf_usm_v(1)%z0, & 1883 surf_def_v(2)%z0, & 1884 surf_lsm_v(2)%z0, & 1885 surf_usm_v(2)%z0, & 1886 surf_def_v(3)%z0, & 1887 surf_lsm_v(3)%z0, & 1888 surf_usm_v(3)%z0 ) 1889 ELSE 1890 ! 1891 !-- Output of averaged data 1892 surfaces%var_out(:) = surfaces%var_av(:,n_out) / & 1893 REAL( average_count_surf, KIND=wp ) 1894 surfaces%var_av(:,n_out) = 0.0_wp 1895 1896 ENDIF 1897 1898 CASE ( 'z0h' ) 1899 ! 1900 !-- Output of instantaneous data 1901 IF ( av == 0 ) THEN 1902 CALL surface_data_output_collect( surf_def_h(0)%z0h, & 1903 surf_def_h(1)%z0h, & 1904 surf_lsm_h%z0h, & 1905 surf_usm_h%z0h, & 1906 surf_def_v(0)%z0h, & 1907 surf_lsm_v(0)%z0h, & 1908 surf_usm_v(0)%z0h, & 1909 surf_def_v(1)%z0h, & 1910 surf_lsm_v(1)%z0h, & 1911 surf_usm_v(1)%z0h, & 1912 surf_def_v(2)%z0h, & 1913 surf_lsm_v(2)%z0h, & 1914 surf_usm_v(2)%z0h, & 1915 surf_def_v(3)%z0h, & 1916 surf_lsm_v(3)%z0h, & 1917 surf_usm_v(3)%z0h ) 1918 ELSE 1919 ! 1920 !-- Output of averaged data 1921 surfaces%var_out(:) = surfaces%var_av(:,n_out) / & 1922 REAL( average_count_surf, KIND=wp ) 1923 surfaces%var_av(:,n_out) = 0.0_wp 1924 1925 ENDIF 1926 1927 CASE ( 'z0q' ) 1928 ! 1929 !-- Output of instantaneous data 1930 IF ( av == 0 ) THEN 1931 CALL surface_data_output_collect( surf_def_h(0)%z0q, & 1932 surf_def_h(1)%z0q, & 1933 surf_lsm_h%z0q, & 1934 surf_usm_h%z0q, & 1935 surf_def_v(0)%z0q, & 1936 surf_lsm_v(0)%z0q, & 1937 surf_usm_v(0)%z0q, & 1938 surf_def_v(1)%z0q, & 1939 surf_lsm_v(1)%z0q, & 1940 surf_usm_v(1)%z0q, & 1941 surf_def_v(2)%z0q, & 1942 surf_lsm_v(2)%z0q, & 1943 surf_usm_v(2)%z0q, & 1944 surf_def_v(3)%z0q, & 1945 surf_lsm_v(3)%z0q, & 1946 surf_usm_v(3)%z0q ) 1947 ELSE 1948 ! 1949 !-- Output of averaged data 1950 surfaces%var_out(:) = surfaces%var_av(:,n_out) / & 1951 REAL( average_count_surf, KIND=wp ) 1952 surfaces%var_av(:,n_out) = 0.0_wp 1953 1954 ENDIF 1955 1956 CASE ( 'theta1' ) 1957 ! 1958 !-- Output of instantaneous data 1959 IF ( av == 0 ) THEN 1960 CALL surface_data_output_collect( surf_def_h(0)%pt1, & 1961 surf_def_h(1)%pt1, & 1962 surf_lsm_h%pt1, & 1963 surf_usm_h%pt1, & 1964 surf_def_v(0)%pt1, & 1965 surf_lsm_v(0)%pt1, & 1966 surf_usm_v(0)%pt1, & 1967 surf_def_v(1)%pt1, & 1968 surf_lsm_v(1)%pt1, & 1969 surf_usm_v(1)%pt1, & 1970 surf_def_v(2)%pt1, & 1971 surf_lsm_v(2)%pt1, & 1972 surf_usm_v(2)%pt1, & 1973 surf_def_v(3)%pt1, & 1974 surf_lsm_v(3)%pt1, & 1975 surf_usm_v(3)%pt1 ) 1976 ELSE 1977 ! 1978 !-- Output of averaged data 1979 surfaces%var_out(:) = surfaces%var_av(:,n_out) / & 1980 REAL( average_count_surf, KIND=wp ) 1981 surfaces%var_av(:,n_out) = 0.0_wp 1982 1983 ENDIF 1984 1985 CASE ( 'qv1' ) 1986 ! 1987 !-- Output of instantaneous data 1988 IF ( av == 0 ) THEN 1989 CALL surface_data_output_collect( surf_def_h(0)%qv1, & 1990 surf_def_h(1)%qv1, & 1991 surf_lsm_h%qv1, & 1992 surf_usm_h%qv1, & 1993 surf_def_v(0)%qv1, & 1994 surf_lsm_v(0)%qv1, & 1995 surf_usm_v(0)%qv1, & 1996 surf_def_v(1)%qv1, & 1997 surf_lsm_v(1)%qv1, & 1998 surf_usm_v(1)%qv1, & 1999 surf_def_v(2)%qv1, & 2000 surf_lsm_v(2)%qv1, & 2001 surf_usm_v(2)%qv1, & 2002 surf_def_v(3)%qv1, & 2003 surf_lsm_v(3)%qv1, & 2004 surf_usm_v(3)%qv1 ) 2005 ELSE 2006 ! 2007 !-- Output of averaged data 2008 surfaces%var_out(:) = surfaces%var_av(:,n_out) / & 2009 REAL( average_count_surf, KIND=wp ) 2010 surfaces%var_av(:,n_out) = 0.0_wp 2011 2012 ENDIF 2013 2014 CASE ( 'thetav1' ) 2015 ! 2016 !-- Output of instantaneous data 2017 IF ( av == 0 ) THEN 2018 CALL surface_data_output_collect( surf_def_h(0)%vpt1, & 2019 surf_def_h(1)%vpt1, & 2020 surf_lsm_h%vpt1, & 2021 surf_usm_h%vpt1, & 2022 surf_def_v(0)%vpt1, & 2023 surf_lsm_v(0)%vpt1, & 2024 surf_usm_v(0)%vpt1, & 2025 surf_def_v(1)%vpt1, & 2026 surf_lsm_v(1)%vpt1, & 2027 surf_usm_v(1)%vpt1, & 2028 surf_def_v(2)%vpt1, & 2029 surf_lsm_v(2)%vpt1, & 2030 surf_usm_v(2)%vpt1, & 2031 surf_def_v(3)%vpt1, & 2032 surf_lsm_v(3)%vpt1, & 2033 surf_usm_v(3)%vpt1 ) 2034 ELSE 2035 ! 2036 !-- Output of averaged data 2037 surfaces%var_out(:) = surfaces%var_av(:,n_out) / & 2038 REAL( average_count_surf, KIND=wp ) 2039 surfaces%var_av(:,n_out) = 0.0_wp 2040 2041 ENDIF 2042 2043 CASE ( 'usws' ) 2044 ! 2045 !-- Output of instantaneous data 2046 IF ( av == 0 ) THEN 2047 CALL surface_data_output_collect( surf_def_h(0)%usws, & 2048 surf_def_h(1)%usws, & 2049 surf_lsm_h%usws, & 2050 surf_usm_h%usws, & 2051 surf_def_v(0)%usws, & 2052 surf_lsm_v(0)%usws, & 2053 surf_usm_v(0)%usws, & 2054 surf_def_v(1)%usws, & 2055 surf_lsm_v(1)%usws, & 2056 surf_usm_v(1)%usws, & 2057 surf_def_v(2)%usws, & 2058 surf_lsm_v(2)%usws, & 2059 surf_usm_v(2)%usws, & 2060 surf_def_v(3)%usws, & 2061 surf_lsm_v(3)%usws, & 2062 surf_usm_v(3)%usws, & 2063 momentumflux_output_conversion ) 2064 ELSE 2065 ! 2066 !-- Output of averaged data 2067 surfaces%var_out(:) = surfaces%var_av(:,n_out) / & 2068 REAL( average_count_surf, KIND=wp ) 2069 surfaces%var_av(:,n_out) = 0.0_wp 2070 2071 ENDIF 2072 2073 CASE ( 'vsws' ) 2074 ! 2075 !-- Output of instantaneous data 2076 IF ( av == 0 ) THEN 2077 CALL surface_data_output_collect( surf_def_h(0)%vsws, & 2078 surf_def_h(1)%vsws, & 2079 surf_lsm_h%vsws, & 2080 surf_usm_h%vsws, & 2081 surf_def_v(0)%vsws, & 2082 surf_lsm_v(0)%vsws, & 2083 surf_usm_v(0)%vsws, & 2084 surf_def_v(1)%vsws, & 2085 surf_lsm_v(1)%vsws, & 2086 surf_usm_v(1)%vsws, & 2087 surf_def_v(2)%vsws, & 2088 surf_lsm_v(2)%vsws, & 2089 surf_usm_v(2)%vsws, & 2090 surf_def_v(3)%vsws, & 2091 surf_lsm_v(3)%vsws, & 2092 surf_usm_v(3)%vsws, & 2093 momentumflux_output_conversion ) 2094 ELSE 2095 ! 2096 !-- Output of averaged data 2097 surfaces%var_out(:) = surfaces%var_av(:,n_out) / & 2098 REAL( average_count_surf, KIND=wp ) 2099 surfaces%var_av(:,n_out) = 0.0_wp 2100 2101 ENDIF 2102 2103 CASE ( 'shf' ) 2104 ! 2105 !-- Output of instantaneous data 2106 IF ( av == 0 ) THEN 2107 CALL surface_data_output_collect( surf_def_h(0)%shf, & 2108 surf_def_h(1)%shf, & 2109 surf_lsm_h%shf, & 2110 surf_usm_h%shf, & 2111 surf_def_v(0)%shf, & 2112 surf_lsm_v(0)%shf, & 2113 surf_usm_v(0)%shf, & 2114 surf_def_v(1)%shf, & 2115 surf_lsm_v(1)%shf, & 2116 surf_usm_v(1)%shf, & 2117 surf_def_v(2)%shf, & 2118 surf_lsm_v(2)%shf, & 2119 surf_usm_v(2)%shf, & 2120 surf_def_v(3)%shf, & 2121 surf_lsm_v(3)%shf, & 2122 surf_usm_v(3)%shf, & 2123 heatflux_output_conversion ) 2124 ELSE 2125 ! 2126 !-- Output of averaged data 2127 surfaces%var_out(:) = surfaces%var_av(:,n_out) / & 2128 REAL( average_count_surf, KIND=wp ) 2129 surfaces%var_av(:,n_out) = 0.0_wp 2130 ENDIF 2131 2132 CASE ( 'qsws' ) 2133 ! 2134 !-- Output of instantaneous data 2135 IF ( av == 0 ) THEN 2136 CALL surface_data_output_collect( surf_def_h(0)%qsws, & 2137 surf_def_h(1)%qsws, & 2138 surf_lsm_h%qsws, & 2139 surf_usm_h%qsws, & 2140 surf_def_v(0)%qsws, & 2141 surf_lsm_v(0)%qsws, & 2142 surf_usm_v(0)%qsws, & 2143 surf_def_v(1)%qsws, & 2144 surf_lsm_v(1)%qsws, & 2145 surf_usm_v(1)%qsws, & 2146 surf_def_v(2)%qsws, & 2147 surf_lsm_v(2)%qsws, & 2148 surf_usm_v(2)%qsws, & 2149 surf_def_v(3)%qsws, & 2150 surf_lsm_v(3)%qsws, & 2151 surf_usm_v(3)%qsws, & 2152 waterflux_output_conversion ) 2153 ELSE 2154 ! 2155 !-- Output of averaged data 2156 surfaces%var_out(:) = surfaces%var_av(:,n_out) / & 2157 REAL( average_count_surf, KIND=wp ) 2158 surfaces%var_av(:,n_out) = 0.0_wp 2159 2160 ENDIF 2161 2162 CASE ( 'ssws' ) 2163 ! 2164 !-- Output of instantaneous data 2165 IF ( av == 0 ) THEN 2166 CALL surface_data_output_collect( surf_def_h(0)%ssws, & 2167 surf_def_h(1)%ssws, & 2168 surf_lsm_h%ssws, & 2169 surf_usm_h%ssws, & 2170 surf_def_v(0)%ssws, & 2171 surf_lsm_v(0)%ssws, & 2172 surf_usm_v(0)%ssws, & 2173 surf_def_v(1)%ssws, & 2174 surf_lsm_v(1)%ssws, & 2175 surf_usm_v(1)%ssws, & 2176 surf_def_v(2)%ssws, & 2177 surf_lsm_v(2)%ssws, & 2178 surf_usm_v(2)%ssws, & 2179 surf_def_v(3)%ssws, & 2180 surf_lsm_v(3)%ssws, & 2181 surf_usm_v(3)%ssws ) 2182 ELSE 2183 ! 2184 !-- Output of averaged data 2185 surfaces%var_out(:) = surfaces%var_av(:,n_out) / & 2186 REAL( average_count_surf, KIND=wp ) 2187 surfaces%var_av(:,n_out) = 0.0_wp 2188 2189 ENDIF 2190 2191 CASE ( 'qcsws' ) 2192 ! 2193 !-- Output of instantaneous data 2194 IF ( av == 0 ) THEN 2195 CALL surface_data_output_collect( surf_def_h(0)%qcsws, & 2196 surf_def_h(1)%qcsws, & 2197 surf_lsm_h%qcsws, & 2198 surf_usm_h%qcsws, & 2199 surf_def_v(0)%qcsws, & 2200 surf_lsm_v(0)%qcsws, & 2201 surf_usm_v(0)%qcsws, & 2202 surf_def_v(1)%qcsws, & 2203 surf_lsm_v(1)%qcsws, & 2204 surf_usm_v(1)%qcsws, & 2205 surf_def_v(2)%qcsws, & 2206 surf_lsm_v(2)%qcsws, & 2207 surf_usm_v(2)%qcsws, & 2208 surf_def_v(3)%qcsws, & 2209 surf_lsm_v(3)%qcsws, & 2210 surf_usm_v(3)%qcsws ) 2211 ELSE 2212 ! 2213 !-- Output of averaged data 2214 surfaces%var_out(:) = surfaces%var_av(:,n_out) / & 2215 REAL( average_count_surf, KIND=wp ) 2216 surfaces%var_av(:,n_out) = 0.0_wp 2217 2218 ENDIF 2219 2220 CASE ( 'ncsws' ) 2221 ! 2222 !-- Output of instantaneous data 2223 IF ( av == 0 ) THEN 2224 CALL surface_data_output_collect( surf_def_h(0)%ncsws, & 2225 surf_def_h(1)%ncsws, & 2226 surf_lsm_h%ncsws, & 2227 surf_usm_h%ncsws, & 2228 surf_def_v(0)%ncsws, & 2229 surf_lsm_v(0)%ncsws, & 2230 surf_usm_v(0)%ncsws, & 2231 surf_def_v(1)%ncsws, & 2232 surf_lsm_v(1)%ncsws, & 2233 surf_usm_v(1)%ncsws, & 2234 surf_def_v(2)%ncsws, & 2235 surf_lsm_v(2)%ncsws, & 2236 surf_usm_v(2)%ncsws, & 2237 surf_def_v(3)%ncsws, & 2238 surf_lsm_v(3)%ncsws, & 2239 surf_usm_v(3)%ncsws ) 2240 ELSE 2241 ! 2242 !-- Output of averaged data 2243 surfaces%var_out(:) = surfaces%var_av(:,n_out) / & 2244 REAL( average_count_surf, KIND=wp ) 2245 surfaces%var_av(:,n_out) = 0.0_wp 2246 2247 ENDIF 2248 2249 2250 CASE ( 'qisws' ) 2251 ! 2252 !-- Output of instantaneous data 2253 IF ( av == 0 ) THEN 2254 CALL surface_data_output_collect( surf_def_h(0)%qisws, & 2255 surf_def_h(1)%qisws, & 2256 surf_lsm_h%qisws, & 2257 surf_usm_h%qisws, & 2258 surf_def_v(0)%qisws, & 2259 surf_lsm_v(0)%qisws, & 2260 surf_usm_v(0)%qisws, & 2261 surf_def_v(1)%qisws, & 2262 surf_lsm_v(1)%qisws, & 2263 surf_usm_v(1)%qisws, & 2264 surf_def_v(2)%qisws, & 2265 surf_lsm_v(2)%qisws, & 2266 surf_usm_v(2)%qisws, & 2267 surf_def_v(3)%qisws, & 2268 surf_lsm_v(3)%qisws, & 2269 surf_usm_v(3)%qisws ) 2270 ELSE 2271 ! 2272 !-- Output of averaged data 2273 surfaces%var_out(:) = surfaces%var_av(:,n_out) / & 2274 REAL( average_count_surf, KIND=wp ) 2275 surfaces%var_av(:,n_out) = 0.0_wp 2276 2277 ENDIF 2278 2279 CASE ( 'nisws' ) 2280 ! 2281 !-- Output of instantaneous data 2282 IF ( av == 0 ) THEN 2283 CALL surface_data_output_collect( surf_def_h(0)%nisws, & 2284 surf_def_h(1)%nisws, & 2285 surf_lsm_h%nisws, & 2286 surf_usm_h%nisws, & 2287 surf_def_v(0)%nisws, & 2288 surf_lsm_v(0)%nisws, & 2289 surf_usm_v(0)%nisws, & 2290 surf_def_v(1)%nisws, & 2291 surf_lsm_v(1)%nisws, & 2292 surf_usm_v(1)%nisws, & 2293 surf_def_v(2)%nisws, & 2294 surf_lsm_v(2)%nisws, & 2295 surf_usm_v(2)%nisws, & 2296 surf_def_v(3)%nisws, & 2297 surf_lsm_v(3)%nisws, & 2298 surf_usm_v(3)%nisws ) 2299 ELSE 2300 ! 2301 !-- Output of averaged data 2302 surfaces%var_out(:) = surfaces%var_av(:,n_out) / & 2303 REAL( average_count_surf, KIND=wp ) 2304 surfaces%var_av(:,n_out) = 0.0_wp 2305 2306 ENDIF 2307 2308 CASE ( 'qrsws' ) 2309 ! 2310 !-- Output of instantaneous data 2311 IF ( av == 0 ) THEN 2312 CALL surface_data_output_collect( surf_def_h(0)%qrsws, & 2313 surf_def_h(1)%qrsws, & 2314 surf_lsm_h%qrsws, & 2315 surf_usm_h%qrsws, & 2316 surf_def_v(0)%qrsws, & 2317 surf_lsm_v(0)%qrsws, & 2318 surf_usm_v(0)%qrsws, & 2319 surf_def_v(1)%qrsws, & 2320 surf_lsm_v(1)%qrsws, & 2321 surf_usm_v(1)%qrsws, & 2322 surf_def_v(2)%qrsws, & 2323 surf_lsm_v(2)%qrsws, & 2324 surf_usm_v(2)%qrsws, & 2325 surf_def_v(3)%qrsws, & 2326 surf_lsm_v(3)%qrsws, & 2327 surf_usm_v(3)%qrsws ) 2328 ELSE 2329 ! 2330 !-- Output of averaged data 2331 surfaces%var_out(:) = surfaces%var_av(:,n_out) / & 2332 REAL( average_count_surf, KIND=wp ) 2333 surfaces%var_av(:,n_out) = 0.0_wp 2334 2335 ENDIF 2336 2337 CASE ( 'nrsws' ) 2338 ! 2339 !-- Output of instantaneous data 2340 IF ( av == 0 ) THEN 2341 CALL surface_data_output_collect( surf_def_h(0)%nrsws, & 2342 surf_def_h(1)%nrsws, & 2343 surf_lsm_h%nrsws, & 2344 surf_usm_h%nrsws, & 2345 surf_def_v(0)%nrsws, & 2346 surf_lsm_v(0)%nrsws, & 2347 surf_usm_v(0)%nrsws, & 2348 surf_def_v(1)%nrsws, & 2349 surf_lsm_v(1)%nrsws, & 2350 surf_usm_v(1)%nrsws, & 2351 surf_def_v(2)%nrsws, & 2352 surf_lsm_v(2)%nrsws, & 2353 surf_usm_v(2)%nrsws, & 2354 surf_def_v(3)%nrsws, & 2355 surf_lsm_v(3)%nrsws, & 2356 surf_usm_v(3)%nrsws ) 2357 ELSE 2358 ! 2359 !-- Output of averaged data 2360 surfaces%var_out(:) = surfaces%var_av(:,n_out) / & 2361 REAL( average_count_surf, KIND=wp ) 2362 surfaces%var_av(:,n_out) = 0.0_wp 2363 2364 ENDIF 2365 2366 CASE ( 'sasws' ) 2367 ! 2368 !-- Output of instantaneous data 2369 IF ( av == 0 ) THEN 2370 CALL surface_data_output_collect( surf_def_h(0)%sasws, & 2371 surf_def_h(1)%sasws, & 2372 surf_lsm_h%sasws, & 2373 surf_usm_h%sasws, & 2374 surf_def_v(0)%sasws, & 2375 surf_lsm_v(0)%sasws, & 2376 surf_usm_v(0)%sasws, & 2377 surf_def_v(1)%sasws, & 2378 surf_lsm_v(1)%sasws, & 2379 surf_usm_v(1)%sasws, & 2380 surf_def_v(2)%sasws, & 2381 surf_lsm_v(2)%sasws, & 2382 surf_usm_v(2)%sasws, & 2383 surf_def_v(3)%sasws, & 2384 surf_lsm_v(3)%sasws, & 2385 surf_usm_v(3)%sasws ) 2386 ELSE 2387 ! 2388 !-- Output of averaged data 2389 surfaces%var_out(:) = surfaces%var_av(:,n_out) / & 2390 REAL( average_count_surf, KIND=wp ) 2391 surfaces%var_av(:,n_out) = 0.0_wp 2392 2393 ENDIF 2394 2395 CASE ( 'q_surface' ) 2396 ! 2397 !-- Output of instantaneous data 2398 IF ( av == 0 ) THEN 2399 CALL surface_data_output_collect( surf_def_h(0)%q_surface, & 2400 surf_def_h(1)%q_surface, & 2401 surf_lsm_h%q_surface, & 2402 surf_usm_h%q_surface, & 2403 surf_def_v(0)%q_surface, & 2404 surf_lsm_v(0)%q_surface, & 2405 surf_usm_v(0)%q_surface, & 2406 surf_def_v(1)%q_surface, & 2407 surf_lsm_v(1)%q_surface, & 2408 surf_usm_v(1)%q_surface, & 2409 surf_def_v(2)%q_surface, & 2410 surf_lsm_v(2)%q_surface, & 2411 surf_usm_v(2)%q_surface, & 2412 surf_def_v(3)%q_surface, & 2413 surf_lsm_v(3)%q_surface, & 2414 surf_usm_v(3)%q_surface ) 2415 ELSE 2416 ! 2417 !-- Output of averaged data 2418 surfaces%var_out(:) = surfaces%var_av(:,n_out) / & 2419 REAL( average_count_surf, KIND=wp ) 2420 surfaces%var_av(:,n_out) = 0.0_wp 2421 2422 ENDIF 2423 2424 CASE ( 'theta_surface' ) 2425 ! 2426 !-- Output of instantaneous data 2427 IF ( av == 0 ) THEN 2428 CALL surface_data_output_collect( surf_def_h(0)%pt_surface, & 2429 surf_def_h(1)%pt_surface, & 2430 surf_lsm_h%pt_surface, & 2431 surf_usm_h%pt_surface, & 2432 surf_def_v(0)%pt_surface, & 2433 surf_lsm_v(0)%pt_surface, & 2434 surf_usm_v(0)%pt_surface, & 2435 surf_def_v(1)%pt_surface, & 2436 surf_lsm_v(1)%pt_surface, & 2437 surf_usm_v(1)%pt_surface, & 2438 surf_def_v(2)%pt_surface, & 2439 surf_lsm_v(2)%pt_surface, & 2440 surf_usm_v(2)%pt_surface, & 2441 surf_def_v(3)%pt_surface, & 2442 surf_lsm_v(3)%pt_surface, & 2443 surf_usm_v(3)%pt_surface ) 2444 ELSE 2445 ! 2446 !-- Output of averaged data 2447 surfaces%var_out(:) = surfaces%var_av(:,n_out) / & 2448 REAL( average_count_surf, KIND=wp ) 2449 surfaces%var_av(:,n_out) = 0.0_wp 2450 2451 ENDIF 2452 2453 CASE ( 'thetav_surface' ) 2454 ! 2455 !-- Output of instantaneous data 2456 IF ( av == 0 ) THEN 2457 CALL surface_data_output_collect( surf_def_h(0)%vpt_surface, & 2458 surf_def_h(1)%vpt_surface, & 2459 surf_lsm_h%vpt_surface, & 2460 surf_usm_h%vpt_surface, & 2461 surf_def_v(0)%vpt_surface, & 2462 surf_lsm_v(0)%vpt_surface, & 2463 surf_usm_v(0)%vpt_surface, & 2464 surf_def_v(1)%vpt_surface, & 2465 surf_lsm_v(1)%vpt_surface, & 2466 surf_usm_v(1)%vpt_surface, & 2467 surf_def_v(2)%vpt_surface, & 2468 surf_lsm_v(2)%vpt_surface, & 2469 surf_usm_v(2)%vpt_surface, & 2470 surf_def_v(3)%vpt_surface, & 2471 surf_lsm_v(3)%vpt_surface, & 2472 surf_usm_v(3)%vpt_surface) 2473 ELSE 2474 ! 2475 !-- Output of averaged data 2476 surfaces%var_out(:) = surfaces%var_av(:,n_out) / & 2477 REAL( average_count_surf, KIND=wp ) 2478 surfaces%var_av(:,n_out) = 0.0_wp 2479 2480 ENDIF 2481 2482 CASE ( 'rad_net' ) 2483 ! 2484 !-- Output of instantaneous data 2485 IF ( av == 0 ) THEN 2486 CALL surface_data_output_collect( surf_def_h(0)%rad_net, & 2487 surf_def_h(1)%rad_net, & 2488 surf_lsm_h%rad_net, & 2489 surf_usm_h%rad_net, & 2490 surf_def_v(0)%rad_net, & 2491 surf_lsm_v(0)%rad_net, & 2492 surf_usm_v(0)%rad_net, & 2493 surf_def_v(1)%rad_net, & 2494 surf_lsm_v(1)%rad_net, & 2495 surf_usm_v(1)%rad_net, & 2496 surf_def_v(2)%rad_net, & 2497 surf_lsm_v(2)%rad_net, & 2498 surf_usm_v(2)%rad_net, & 2499 surf_def_v(3)%rad_net, & 2500 surf_lsm_v(3)%rad_net, & 2501 surf_usm_v(3)%rad_net ) 2502 ELSE 2503 ! 2504 !-- Output of averaged data 2505 surfaces%var_out(:) = surfaces%var_av(:,n_out) / & 2506 REAL( average_count_surf, KIND=wp ) 2507 surfaces%var_av(:,n_out) = 0.0_wp 2508 2509 ENDIF 2510 2511 CASE ( 'rad_lw_in' ) 2512 ! 2513 !-- Output of instantaneous data 2514 IF ( av == 0 ) THEN 2515 CALL surface_data_output_collect( surf_def_h(0)%rad_lw_in, & 2516 surf_def_h(1)%rad_lw_in, & 2517 surf_lsm_h%rad_lw_in, & 2518 surf_usm_h%rad_lw_in, & 2519 surf_def_v(0)%rad_lw_in, & 2520 surf_lsm_v(0)%rad_lw_in, & 2521 surf_usm_v(0)%rad_lw_in, & 2522 surf_def_v(1)%rad_lw_in, & 2523 surf_lsm_v(1)%rad_lw_in, & 2524 surf_usm_v(1)%rad_lw_in, & 2525 surf_def_v(2)%rad_lw_in, & 2526 surf_lsm_v(2)%rad_lw_in, & 2527 surf_usm_v(2)%rad_lw_in, & 2528 surf_def_v(3)%rad_lw_in, & 2529 surf_lsm_v(3)%rad_lw_in, & 2530 surf_usm_v(3)%rad_lw_in ) 2531 ELSE 2532 ! 2533 !-- Output of averaged data 2534 surfaces%var_out(:) = surfaces%var_av(:,n_out) / & 2535 REAL( average_count_surf, KIND=wp ) 2536 surfaces%var_av(:,n_out) = 0.0_wp 2537 2538 ENDIF 2539 2540 CASE ( 'rad_lw_out' ) 2541 ! 2542 !-- Output of instantaneous data 2543 IF ( av == 0 ) THEN 2544 CALL surface_data_output_collect( surf_def_h(0)%rad_lw_out, & 2545 surf_def_h(1)%rad_lw_out, & 2546 surf_lsm_h%rad_lw_out, & 2547 surf_usm_h%rad_lw_out, & 2548 surf_def_v(0)%rad_lw_out, & 2549 surf_lsm_v(0)%rad_lw_out, & 2550 surf_usm_v(0)%rad_lw_out, & 2551 surf_def_v(1)%rad_lw_out, & 2552 surf_lsm_v(1)%rad_lw_out, & 2553 surf_usm_v(1)%rad_lw_out, & 2554 surf_def_v(2)%rad_lw_out, & 2555 surf_lsm_v(2)%rad_lw_out, & 2556 surf_usm_v(2)%rad_lw_out, & 2557 surf_def_v(3)%rad_lw_out, & 2558 surf_lsm_v(3)%rad_lw_out, & 2559 surf_usm_v(3)%rad_lw_out ) 2560 ELSE 2561 ! 2562 !-- Output of averaged data 2563 surfaces%var_out(:) = surfaces%var_av(:,n_out) / & 2564 REAL( average_count_surf, KIND=wp ) 2565 surfaces%var_av(:,n_out) = 0.0_wp 2566 2567 ENDIF 2568 2569 CASE ( 'rad_sw_in' ) 2570 ! 2571 !-- Output of instantaneous data 2572 IF ( av == 0 ) THEN 2573 CALL surface_data_output_collect( surf_def_h(0)%rad_sw_in, & 2574 surf_def_h(1)%rad_sw_in, & 2575 surf_lsm_h%rad_sw_in, & 2576 surf_usm_h%rad_sw_in, & 2577 surf_def_v(0)%rad_sw_in, & 2578 surf_lsm_v(0)%rad_sw_in, & 2579 surf_usm_v(0)%rad_sw_in, & 2580 surf_def_v(1)%rad_sw_in, & 2581 surf_lsm_v(1)%rad_sw_in, & 2582 surf_usm_v(1)%rad_sw_in, & 2583 surf_def_v(2)%rad_sw_in, & 2584 surf_lsm_v(2)%rad_sw_in, & 2585 surf_usm_v(2)%rad_sw_in, & 2586 surf_def_v(3)%rad_sw_in, & 2587 surf_lsm_v(3)%rad_sw_in, & 2588 surf_usm_v(3)%rad_sw_in ) 2589 ELSE 2590 ! 2591 !-- Output of averaged data 2592 surfaces%var_out(:) = surfaces%var_av(:,n_out) / & 2593 REAL( average_count_surf, KIND=wp ) 2594 surfaces%var_av(:,n_out) = 0.0_wp 2595 2596 ENDIF 2597 2598 CASE ( 'rad_sw_out' ) 2599 ! 2600 !-- Output of instantaneous data 2601 IF ( av == 0 ) THEN 2602 CALL surface_data_output_collect( surf_def_h(0)%rad_sw_out, & 2603 surf_def_h(1)%rad_sw_out, & 2604 surf_lsm_h%rad_sw_out, & 2605 surf_usm_h%rad_sw_out, & 2606 surf_def_v(0)%rad_sw_out, & 2607 surf_lsm_v(0)%rad_sw_out, & 2608 surf_usm_v(0)%rad_sw_out, & 2609 surf_def_v(1)%rad_sw_out, & 2610 surf_lsm_v(1)%rad_sw_out, & 2611 surf_usm_v(1)%rad_sw_out, & 2612 surf_def_v(2)%rad_sw_out, & 2613 surf_lsm_v(2)%rad_sw_out, & 2614 surf_usm_v(2)%rad_sw_out, & 2615 surf_def_v(3)%rad_sw_out, & 2616 surf_lsm_v(3)%rad_sw_out, & 2617 surf_usm_v(3)%rad_sw_out ) 2618 ELSE 2619 ! 2620 !-- Output of averaged data 2621 surfaces%var_out(:) = surfaces%var_av(:,n_out) / & 2622 REAL( average_count_surf, KIND=wp ) 2623 surfaces%var_av(:,n_out) = 0.0_wp 2624 2625 ENDIF 2626 2627 CASE ( 'ghf' ) 2628 ! 2629 !-- Output of instantaneous data 2630 IF ( av == 0 ) THEN 2631 ! 2632 !-- Sum up ground / wall heat flux. Note, for urban surfaces the 2633 !-- wall heat flux is aggregated from the different green, window 2634 !-- and wall tiles. 2635 DO m = 1, surf_usm_h%ns 2636 surf_usm_h%ghf(m) = surf_usm_h%frac(m,ind_veg_wall) & 2637 * surf_usm_h%wghf_eb(m) + & 2638 surf_usm_h%frac(m,ind_pav_green) & 2639 * surf_usm_h%wghf_eb_green(m) + & 2640 surf_usm_h%frac(m,ind_wat_win) & 2641 * surf_usm_h%wghf_eb_window(m) 2642 ENDDO 2643 DO l = 0, 3 2644 DO m = 1, surf_usm_v(l)%ns 2645 surf_usm_v(l)%ghf(m) = surf_usm_v(l)%frac(m,ind_veg_wall) & 2646 * surf_usm_v(l)%wghf_eb(m) + & 2647 surf_usm_v(l)%frac(m,ind_pav_green) & 2648 * surf_usm_v(l)%wghf_eb_green(m) + & 2649 surf_usm_v(l)%frac(m,ind_wat_win) & 2650 * surf_usm_v(l)%wghf_eb_window(m) 2651 ENDDO 2652 ENDDO 2653 2654 CALL surface_data_output_collect( surf_def_h(0)%ghf, & 2655 surf_def_h(1)%ghf, & 2656 surf_lsm_h%ghf, & 2657 surf_usm_h%ghf, & 2658 surf_def_v(0)%ghf, & 2659 surf_lsm_v(0)%ghf, & 2660 surf_usm_v(0)%ghf, & 2661 surf_def_v(1)%ghf, & 2662 surf_lsm_v(1)%ghf, & 2663 surf_usm_v(1)%ghf, & 2664 surf_def_v(2)%ghf, & 2665 surf_lsm_v(2)%ghf, & 2666 surf_usm_v(2)%ghf, & 2667 surf_def_v(3)%ghf, & 2668 surf_lsm_v(3)%ghf, & 2669 surf_usm_v(3)%ghf ) 2670 ELSE 2671 ! 2672 !-- Output of averaged data 2673 surfaces%var_out(:) = surfaces%var_av(:,n_out) / & 2674 REAL( average_count_surf, KIND=wp ) 2675 surfaces%var_av(:,n_out) = 0.0_wp 2676 2677 ENDIF 2678 2679 CASE ( 'r_a' ) 2680 ! 2681 !-- Output of instantaneous data 2682 IF ( av == 0 ) THEN 2683 CALL surface_data_output_collect( surf_def_h(0)%r_a, & 2684 surf_def_h(1)%r_a, & 2685 surf_lsm_h%r_a, & 2686 surf_usm_h%r_a, & 2687 surf_def_v(0)%r_a, & 2688 surf_lsm_v(0)%r_a, & 2689 surf_usm_v(0)%r_a, & 2690 surf_def_v(1)%r_a, & 2691 surf_lsm_v(1)%r_a, & 2692 surf_usm_v(1)%r_a, & 2693 surf_def_v(2)%r_a, & 2694 surf_lsm_v(2)%r_a, & 2695 surf_usm_v(2)%r_a, & 2696 surf_def_v(3)%r_a, & 2697 surf_lsm_v(3)%r_a, & 2698 surf_usm_v(3)%r_a ) 2699 ELSE 2700 ! 2701 !-- Output of averaged data 2702 surfaces%var_out(:) = surfaces%var_av(:,n_out) / & 2703 REAL( average_count_surf, KIND=wp ) 2704 surfaces%var_av(:,n_out) = 0.0_wp 2705 2706 ENDIF 2707 2708 CASE ( 'r_soil' ) 2709 ! 2710 !-- Output of instantaneous data 2711 IF ( av == 0 ) THEN 2712 CALL surface_data_output_collect( surf_def_h(0)%r_soil, & 2713 surf_def_h(1)%r_soil, & 2714 surf_lsm_h%r_soil, & 2715 surf_usm_h%r_soil, & 2716 surf_def_v(0)%r_soil, & 2717 surf_lsm_v(0)%r_soil, & 2718 surf_usm_v(0)%r_soil, & 2719 surf_def_v(1)%r_soil, & 2720 surf_lsm_v(1)%r_soil, & 2721 surf_usm_v(1)%r_soil, & 2722 surf_def_v(2)%r_soil, & 2723 surf_lsm_v(2)%r_soil, & 2724 surf_usm_v(2)%r_soil, & 2725 surf_def_v(3)%r_soil, & 2726 surf_lsm_v(3)%r_soil, & 2727 surf_usm_v(3)%r_soil ) 2728 ELSE 2729 ! 2730 !-- Output of averaged data 2731 surfaces%var_out(:) = surfaces%var_av(:,n_out) / & 2732 REAL( average_count_surf, KIND=wp ) 2733 surfaces%var_av(:,n_out) = 0.0_wp 2734 2735 ENDIF 2736 2737 CASE ( 'r_canopy' ) 2738 ! 2739 !-- Output of instantaneous data 2740 IF ( av == 0 ) THEN 2741 CALL surface_data_output_collect( surf_def_h(0)%r_canopy, & 2742 surf_def_h(1)%r_canopy, & 2743 surf_lsm_h%r_canopy, & 2744 surf_usm_h%r_canopy, & 2745 surf_def_v(0)%r_canopy, & 2746 surf_lsm_v(0)%r_canopy, & 2747 surf_usm_v(0)%r_canopy, & 2748 surf_def_v(1)%r_canopy, & 2749 surf_lsm_v(1)%r_canopy, & 2750 surf_usm_v(1)%r_canopy, & 2751 surf_def_v(2)%r_canopy, & 2752 surf_lsm_v(2)%r_canopy, & 2753 surf_usm_v(2)%r_canopy, & 2754 surf_def_v(3)%r_canopy, & 2755 surf_lsm_v(3)%r_canopy, & 2756 surf_usm_v(3)%r_canopy ) 2757 ELSE 2758 ! 2759 !-- Output of averaged data 2760 surfaces%var_out(:) = surfaces%var_av(:,n_out) / & 2761 REAL( average_count_surf, KIND=wp ) 2762 surfaces%var_av(:,n_out) = 0.0_wp 2763 2764 ENDIF 2765 2766 CASE ( 'r_s' ) 2767 ! 2768 !-- Output of instantaneous data 2769 IF ( av == 0 ) THEN 2770 CALL surface_data_output_collect( surf_def_h(0)%r_s, & 2771 surf_def_h(1)%r_s, & 2772 surf_lsm_h%r_s, & 2773 surf_usm_h%r_s, & 2774 surf_def_v(0)%r_s, & 2775 surf_lsm_v(0)%r_s, & 2776 surf_usm_v(0)%r_s, & 2777 surf_def_v(1)%r_s, & 2778 surf_lsm_v(1)%r_s, & 2779 surf_usm_v(1)%r_s, & 2780 surf_def_v(2)%r_s, & 2781 surf_lsm_v(2)%r_s, & 2782 surf_usm_v(2)%r_s, & 2783 surf_def_v(3)%r_s, & 2784 surf_lsm_v(3)%r_s, & 2785 surf_usm_v(3)%r_s ) 2786 ELSE 2787 ! 2788 !-- Output of averaged data 2789 surfaces%var_out(:) = surfaces%var_av(:,n_out) / & 2790 REAL( average_count_surf, KIND=wp ) 2791 surfaces%var_av(:,n_out) = 0.0_wp 2792 2793 ENDIF 2794 2795 CASE ( 'rad_sw_dir' ) 2796 ! 2797 !-- Output of instantaneous data 2798 IF ( av == 0 ) THEN 2799 CALL surface_data_output_collect( surf_def_h(0)%rad_sw_dir, & 2800 surf_def_h(1)%rad_sw_dir, & 2801 surf_lsm_h%rad_sw_dir, & 2802 surf_usm_h%rad_sw_dir, & 2803 surf_def_v(0)%rad_sw_dir, & 2804 surf_lsm_v(0)%rad_sw_dir, & 2805 surf_usm_v(0)%rad_sw_dir, & 2806 surf_def_v(1)%rad_sw_dir, & 2807 surf_lsm_v(1)%rad_sw_dir, & 2808 surf_usm_v(1)%rad_sw_dir, & 2809 surf_def_v(2)%rad_sw_dir, & 2810 surf_lsm_v(2)%rad_sw_dir, & 2811 surf_usm_v(2)%rad_sw_dir, & 2812 surf_def_v(3)%rad_sw_dir, & 2813 surf_lsm_v(3)%rad_sw_dir, & 2814 surf_usm_v(3)%rad_sw_dir ) 2815 ELSE 2816 ! 2817 !-- Output of averaged data 2818 surfaces%var_out(:) = surfaces%var_av(:,n_out) / & 2819 REAL( average_count_surf, KIND=wp ) 2820 surfaces%var_av(:,n_out) = 0.0_wp 2821 2822 ENDIF 2823 2824 CASE ( 'rad_sw_dif' ) 2825 ! 2826 !-- Output of instantaneous data 2827 IF ( av == 0 ) THEN 2828 CALL surface_data_output_collect( surf_def_h(0)%rad_sw_dif, & 2829 surf_def_h(1)%rad_sw_dif, & 2830 surf_lsm_h%rad_sw_dif, & 2831 surf_usm_h%rad_sw_dif, & 2832 surf_def_v(0)%rad_sw_dif, & 2833 surf_lsm_v(0)%rad_sw_dif, & 2834 surf_usm_v(0)%rad_sw_dif, & 2835 surf_def_v(1)%rad_sw_dif, & 2836 surf_lsm_v(1)%rad_sw_dif, & 2837 surf_usm_v(1)%rad_sw_dif, & 2838 surf_def_v(2)%rad_sw_dif, & 2839 surf_lsm_v(2)%rad_sw_dif, & 2840 surf_usm_v(2)%rad_sw_dif, & 2841 surf_def_v(3)%rad_sw_dif, & 2842 surf_lsm_v(3)%rad_sw_dif, & 2843 surf_usm_v(3)%rad_sw_dif ) 2844 ELSE 2845 ! 2846 !-- Output of averaged data 2847 surfaces%var_out(:) = surfaces%var_av(:,n_out) / & 2848 REAL( average_count_surf, KIND=wp ) 2849 surfaces%var_av(:,n_out) = 0.0_wp 2850 2851 ENDIF 2852 2853 CASE ( 'rad_sw_ref' ) 2854 ! 2855 !-- Output of instantaneous data 2856 IF ( av == 0 ) THEN 2857 CALL surface_data_output_collect( surf_def_h(0)%rad_sw_ref, & 2858 surf_def_h(1)%rad_sw_ref, & 2859 surf_lsm_h%rad_sw_ref, & 2860 surf_usm_h%rad_sw_ref, & 2861 surf_def_v(0)%rad_sw_ref, & 2862 surf_lsm_v(0)%rad_sw_ref, & 2863 surf_usm_v(0)%rad_sw_ref, & 2864 surf_def_v(1)%rad_sw_ref, & 2865 surf_lsm_v(1)%rad_sw_ref, & 2866 surf_usm_v(1)%rad_sw_ref, & 2867 surf_def_v(2)%rad_sw_ref, & 2868 surf_lsm_v(2)%rad_sw_ref, & 2869 surf_usm_v(2)%rad_sw_ref, & 2870 surf_def_v(3)%rad_sw_ref, & 2871 surf_lsm_v(3)%rad_sw_ref, & 2872 surf_usm_v(3)%rad_sw_ref ) 2873 ELSE 2874 ! 2875 !-- Output of averaged data 2876 surfaces%var_out(:) = surfaces%var_av(:,n_out) / & 2877 REAL( average_count_surf, KIND=wp ) 2878 surfaces%var_av(:,n_out) = 0.0_wp 2879 2880 ENDIF 2881 2882 CASE ( 'rad_sw_res' ) 2883 ! 2884 !-- Output of instantaneous data 2885 IF ( av == 0 ) THEN 2886 CALL surface_data_output_collect( surf_def_h(0)%rad_sw_res, & 2887 surf_def_h(1)%rad_sw_res, & 2888 surf_lsm_h%rad_sw_res, & 2889 surf_usm_h%rad_sw_res, & 2890 surf_def_v(0)%rad_sw_res, & 2891 surf_lsm_v(0)%rad_sw_res, & 2892 surf_usm_v(0)%rad_sw_res, & 2893 surf_def_v(1)%rad_sw_res, & 2894 surf_lsm_v(1)%rad_sw_res, & 2895 surf_usm_v(1)%rad_sw_res, & 2896 surf_def_v(2)%rad_sw_res, & 2897 surf_lsm_v(2)%rad_sw_res, & 2898 surf_usm_v(2)%rad_sw_res, & 2899 surf_def_v(3)%rad_sw_res, & 2900 surf_lsm_v(3)%rad_sw_res, & 2901 surf_usm_v(3)%rad_sw_res ) 2902 ELSE 2903 ! 2904 !-- Output of averaged data 2905 surfaces%var_out(:) = surfaces%var_av(:,n_out) / & 2906 REAL( average_count_surf, KIND=wp ) 2907 surfaces%var_av(:,n_out) = 0.0_wp 2908 2909 ENDIF 2910 2911 CASE ( 'rad_lw_dif' ) 2912 ! 2913 !-- Output of instantaneous data 2914 IF ( av == 0 ) THEN 2915 CALL surface_data_output_collect( surf_def_h(0)%rad_lw_dif, & 2916 surf_def_h(1)%rad_lw_dif, & 2917 surf_lsm_h%rad_lw_dif, & 2918 surf_usm_h%rad_lw_dif, & 2919 surf_def_v(0)%rad_lw_dif, & 2920 surf_lsm_v(0)%rad_lw_dif, & 2921 surf_usm_v(0)%rad_lw_dif, & 2922 surf_def_v(1)%rad_lw_dif, & 2923 surf_lsm_v(1)%rad_lw_dif, & 2924 surf_usm_v(1)%rad_lw_dif, & 2925 surf_def_v(2)%rad_lw_dif, & 2926 surf_lsm_v(2)%rad_lw_dif, & 2927 surf_usm_v(2)%rad_lw_dif, & 2928 surf_def_v(3)%rad_lw_dif, & 2929 surf_lsm_v(3)%rad_lw_dif, & 2930 surf_usm_v(3)%rad_lw_dif ) 2931 ELSE 2932 ! 2933 !-- Output of averaged data 2934 surfaces%var_out(:) = surfaces%var_av(:,n_out) / & 2935 REAL( average_count_surf, KIND=wp ) 2936 surfaces%var_av(:,n_out) = 0.0_wp 2937 2938 ENDIF 2939 2940 CASE ( 'rad_lw_ref' ) 2941 ! 2942 !-- Output of instantaneous data 2943 IF ( av == 0 ) THEN 2944 CALL surface_data_output_collect( surf_def_h(0)%rad_lw_ref, & 2945 surf_def_h(1)%rad_lw_ref, & 2946 surf_lsm_h%rad_lw_ref, & 2947 surf_usm_h%rad_lw_ref, & 2948 surf_def_v(0)%rad_lw_ref, & 2949 surf_lsm_v(0)%rad_lw_ref, & 2950 surf_usm_v(0)%rad_lw_ref, & 2951 surf_def_v(1)%rad_lw_ref, & 2952 surf_lsm_v(1)%rad_lw_ref, & 2953 surf_usm_v(1)%rad_lw_ref, & 2954 surf_def_v(2)%rad_lw_ref, & 2955 surf_lsm_v(2)%rad_lw_ref, & 2956 surf_usm_v(2)%rad_lw_ref, & 2957 surf_def_v(3)%rad_lw_ref, & 2958 surf_lsm_v(3)%rad_lw_ref, & 2959 surf_usm_v(3)%rad_lw_ref ) 2960 ELSE 2961 ! 2962 !-- Output of averaged data 2963 surfaces%var_out(:) = surfaces%var_av(:,n_out) / & 2964 REAL( average_count_surf, KIND=wp ) 2965 surfaces%var_av(:,n_out) = 0.0_wp 2966 2967 ENDIF 2968 2969 CASE ( 'rad_lw_res' ) 2970 ! 2971 !-- Output of instantaneous data 2972 IF ( av == 0 ) THEN 2973 CALL surface_data_output_collect( surf_def_h(0)%rad_lw_res, & 2974 surf_def_h(1)%rad_lw_res, & 2975 surf_lsm_h%rad_lw_res, & 2976 surf_usm_h%rad_lw_res, & 2977 surf_def_v(0)%rad_lw_res, & 2978 surf_lsm_v(0)%rad_lw_res, & 2979 surf_usm_v(0)%rad_lw_res, & 2980 surf_def_v(1)%rad_lw_res, & 2981 surf_lsm_v(1)%rad_lw_res, & 2982 surf_usm_v(1)%rad_lw_res, & 2983 surf_def_v(2)%rad_lw_res, & 2984 surf_lsm_v(2)%rad_lw_res, & 2985 surf_usm_v(2)%rad_lw_res, & 2986 surf_def_v(3)%rad_lw_res, & 2987 surf_lsm_v(3)%rad_lw_res, & 2988 surf_usm_v(3)%rad_lw_res ) 2989 ELSE 2990 ! 2991 !-- Output of averaged data 2992 surfaces%var_out(:) = surfaces%var_av(:,n_out) / & 2993 REAL( average_count_surf, KIND=wp ) 2994 surfaces%var_av(:,n_out) = 0.0_wp 2995 2996 ENDIF 2997 2998 CASE ( 'uvw1' ) 2999 ! 3000 !-- Output of instantaneous data 3001 IF ( av == 0 ) THEN 3002 CALL surface_data_output_collect( surf_def_h(0)%uvw_abs, & 3003 surf_def_h(1)%uvw_abs, & 3004 surf_lsm_h%uvw_abs, & 3005 surf_usm_h%uvw_abs, & 3006 surf_def_v(0)%uvw_abs, & 3007 surf_lsm_v(0)%uvw_abs, & 3008 surf_usm_v(0)%uvw_abs, & 3009 surf_def_v(1)%uvw_abs, & 3010 surf_lsm_v(1)%uvw_abs, & 3011 surf_usm_v(1)%uvw_abs, & 3012 surf_def_v(2)%uvw_abs, & 3013 surf_lsm_v(2)%uvw_abs, & 3014 surf_usm_v(2)%uvw_abs, & 3015 surf_def_v(3)%uvw_abs, & 3016 surf_lsm_v(3)%uvw_abs, & 3017 surf_usm_v(3)%uvw_abs ) 3018 ELSE 3019 ! 3020 !-- Output of averaged data 3021 surfaces%var_out(:) = surfaces%var_av(:,n_out) / & 3022 REAL( average_count_surf, KIND=wp ) 3023 surfaces%var_av(:,n_out) = 0.0_wp 3024 3025 ENDIF 3026 ! 3027 !-- Waste heat from indoor model 3028 CASE ( 'waste_heat' ) 3029 ! 3030 !-- Output of instantaneous data 3031 IF ( av == 0 ) THEN 3032 CALL surface_data_output_collect( surf_def_h(0)%waste_heat, & 3033 surf_def_h(1)%waste_heat, & 3034 surf_lsm_h%waste_heat, & 3035 surf_usm_h%waste_heat, & 3036 surf_def_v(0)%waste_heat, & 3037 surf_lsm_v(0)%waste_heat, & 3038 surf_usm_v(0)%waste_heat, & 3039 surf_def_v(1)%waste_heat, & 3040 surf_lsm_v(1)%waste_heat, & 3041 surf_usm_v(1)%waste_heat, & 3042 surf_def_v(2)%waste_heat, & 3043 surf_lsm_v(2)%waste_heat, & 3044 surf_usm_v(2)%waste_heat, & 3045 surf_def_v(3)%waste_heat, & 3046 surf_lsm_v(3)%waste_heat, & 3047 surf_usm_v(3)%waste_heat ) 3048 ELSE 3049 ! 3050 !-- Output of averaged data 3051 surfaces%var_out(:) = surfaces%var_av(:,n_out) / & 3052 REAL( average_count_surf, KIND=wp ) 3053 surfaces%var_av(:,n_out) = 0.0_wp 3054 3055 ENDIF 3056 ! 3057 !-- Innermost building wall flux from indoor model 3058 CASE ( 'im_hf' ) 3059 ! 3060 !-- Output of instantaneous data 3061 IF ( av == 0 ) THEN 3062 CALL surface_data_output_collect( surf_def_h(0)%iwghf_eb, & 3063 surf_def_h(1)%iwghf_eb, & 3064 surf_lsm_h%iwghf_eb, & 3065 surf_usm_h%iwghf_eb, & 3066 surf_def_v(0)%iwghf_eb, & 3067 surf_lsm_v(0)%iwghf_eb, & 3068 surf_usm_v(0)%iwghf_eb, & 3069 surf_def_v(1)%iwghf_eb, & 3070 surf_lsm_v(1)%iwghf_eb, & 3071 surf_usm_v(1)%iwghf_eb, & 3072 surf_def_v(2)%iwghf_eb, & 3073 surf_lsm_v(2)%iwghf_eb, & 3074 surf_usm_v(2)%iwghf_eb, & 3075 surf_def_v(3)%iwghf_eb, & 3076 surf_lsm_v(3)%iwghf_eb, & 3077 surf_usm_v(3)%iwghf_eb ) 3078 ELSE 3079 ! 3080 !-- Output of averaged data 3081 surfaces%var_out(:) = surfaces%var_av(:,n_out) / & 3082 REAL( average_count_surf, KIND=wp ) 3083 surfaces%var_av(:,n_out) = 0.0_wp 3084 3085 ENDIF 3086 ! 3087 !-- Surface albedo (tile approach) 3088 CASE ( 'albedo' ) 3089 ! 3090 !-- Output of instantaneous data 3091 IF ( av == 0 ) THEN 3092 CALL surface_data_output_collect( surf_def_h(0)%albedo, & 3093 surf_def_h(1)%albedo, & 3094 surf_lsm_h%albedo, & 3095 surf_usm_h%albedo, & 3096 surf_def_v(0)%albedo, & 3097 surf_lsm_v(0)%albedo, & 3098 surf_usm_v(0)%albedo, & 3099 surf_def_v(1)%albedo, & 3100 surf_lsm_v(1)%albedo, & 3101 surf_usm_v(1)%albedo, & 3102 surf_def_v(2)%albedo, & 3103 surf_lsm_v(2)%albedo, & 3104 surf_usm_v(2)%albedo, & 3105 surf_def_v(3)%albedo, & 3106 surf_lsm_v(3)%albedo, & 3107 surf_usm_v(3)%albedo ) 3108 ELSE 3109 ! 3110 !-- Output of averaged data 3111 surfaces%var_out(:) = surfaces%var_av(:,n_out) / & 3112 REAL( average_count_surf, KIND=wp ) 3113 surfaces%var_av(:,n_out) = 0.0_wp 3114 3115 ENDIF 3116 ! 3117 !-- Surface emissivity (tile approach) 3118 CASE ( 'emissivity' ) 3119 ! 3120 !-- Output of instantaneous data 3121 IF ( av == 0 ) THEN 3122 CALL surface_data_output_collect( surf_def_h(0)%emissivity, & 3123 surf_def_h(1)%emissivity, & 3124 surf_lsm_h%emissivity, & 3125 surf_usm_h%emissivity, & 3126 surf_def_v(0)%emissivity, & 3127 surf_lsm_v(0)%emissivity, & 3128 surf_usm_v(0)%emissivity, & 3129 surf_def_v(1)%emissivity, & 3130 surf_lsm_v(1)%emissivity, & 3131 surf_usm_v(1)%emissivity, & 3132 surf_def_v(2)%emissivity, & 3133 surf_lsm_v(2)%emissivity, & 3134 surf_usm_v(2)%emissivity, & 3135 surf_def_v(3)%emissivity, & 3136 surf_lsm_v(3)%emissivity, & 3137 surf_usm_v(3)%emissivity ) 3138 ELSE 3139 ! 3140 !-- Output of averaged data 3141 surfaces%var_out(:) = surfaces%var_av(:,n_out) / & 3142 REAL( average_count_surf, KIND=wp ) 3143 surfaces%var_av(:,n_out) = 0.0_wp 3144 3145 ENDIF 3146 ! 3147 !-- Add further variables: 3148 !-- 'css', 'cssws', 'qsws_liq', 'qsws_soil', 'qsws_veg' 3149 3150 END SELECT 3151 ! 3152 !-- Write to binary file: 3153 !-- - surfaces%points ( 3, 1-npoints ) 3154 !-- - surfaces%polygons ( 5, 1-ns ) 3155 !-- - surfaces%var_out ( 1-ns, time ) 3156 !-- - Dimension: 1-nsurfaces, 1-npoints - can be ordered consecutively 3157 !-- - Distinguish between average and non-average data 3158 IF ( to_vtk ) THEN 3159 DO i = 0, io_blocks-1 3160 IF ( i == io_group ) THEN 3161 WRITE ( 25+av ) LEN_TRIM( 'time' ) 3162 WRITE ( 25+av ) 'time' 3163 WRITE ( 25+av ) time_since_reference_point 3164 WRITE ( 25+av ) LEN_TRIM( trimvar ) 3165 WRITE ( 25+av ) TRIM( trimvar ) 3166 WRITE ( 25+av ) surfaces%var_out 3167 ENDIF 3168 #if defined( __parallel ) 3169 CALL MPI_BARRIER( comm2d, ierr ) 3170 #endif 3171 ENDDO 3172 ENDIF 3173 3174 IF ( to_netcdf ) THEN 3175 #if defined( __netcdf4_parallel ) 3176 ! 3177 !-- Write output array to file 3178 nc_stat = NF90_PUT_VAR( id_set_surf(av), id_var_dosurf(av,n_out), & 3179 surfaces%var_out, & 3180 start = (/ surfaces%s(1), & 3181 dosurf_time_count(av) /), & 3182 count = (/ surfaces%ns, 1 /) ) 3183 CALL netcdf_handle_error( 'surface_data_output', 6667 ) 3184 #endif 3185 ENDIF 3186 3187 ENDDO 3188 3189 ! 3190 !-- If averaged output was written to NetCDF file, set the counter to zero 3191 IF ( av == 1 ) average_count_surf = 0 3192 3193 END SUBROUTINE surface_data_output 3194 3195 !------------------------------------------------------------------------------! 2758 2759 ENDDO 2760 2761 ! 2762 !-- If averaged output was written to NetCDF file, set the counter to zero 2763 IF ( av == 1 ) average_count_surf = 0 2764 2765 END SUBROUTINE surface_data_output 2766 2767 !--------------------------------------------------------------------------------------------------! 3196 2768 ! Description: 3197 2769 ! ------------ 3198 2770 !> Routine for controlling the data averaging. 3199 !------------------------------------------------------------------------------! 3200 SUBROUTINE surface_data_output_averaging 3201 3202 IMPLICIT NONE 3203 3204 CHARACTER(LEN=100) :: trimvar !< dummy variable for current output variable 3205 3206 INTEGER(iwp) :: l !< running index for surface orientation 3207 INTEGER(iwp) :: m !< running index for surface elements 3208 INTEGER(iwp) :: n_out !< counter variables for surface output 3209 3210 n_out = 0 3211 DO WHILE ( dosurf(1,n_out+1)(1:1) /= ' ' ) 3212 3213 n_out = n_out + 1 3214 trimvar = TRIM( dosurf(1,n_out) ) 3215 3216 SELECT CASE ( trimvar ) 3217 3218 CASE ( 'us' ) 3219 CALL surface_data_output_sum_up( surf_def_h(0)%us, & 3220 surf_def_h(1)%us, & 3221 surf_lsm_h%us, & 3222 surf_usm_h%us, & 3223 surf_def_v(0)%us, & 3224 surf_lsm_v(0)%us, & 3225 surf_usm_v(0)%us, & 3226 surf_def_v(1)%us, & 3227 surf_lsm_v(1)%us, & 3228 surf_usm_v(1)%us, & 3229 surf_def_v(2)%us, & 3230 surf_lsm_v(2)%us, & 3231 surf_usm_v(2)%us, & 3232 surf_def_v(3)%us, & 3233 surf_lsm_v(3)%us, & 3234 surf_usm_v(3)%us, n_out ) 3235 3236 CASE ( 'ts' ) 3237 CALL surface_data_output_sum_up( surf_def_h(0)%ts, & 3238 surf_def_h(1)%ts, & 3239 surf_lsm_h%ts, & 3240 surf_usm_h%ts, & 3241 surf_def_v(0)%ts, & 3242 surf_lsm_v(0)%ts, & 3243 surf_usm_v(0)%ts, & 3244 surf_def_v(1)%ts, & 3245 surf_lsm_v(1)%ts, & 3246 surf_usm_v(1)%ts, & 3247 surf_def_v(2)%ts, & 3248 surf_lsm_v(2)%ts, & 3249 surf_usm_v(2)%ts, & 3250 surf_def_v(3)%ts, & 3251 surf_lsm_v(3)%ts, & 3252 surf_usm_v(3)%ts, n_out ) 3253 3254 CASE ( 'qs' ) 3255 CALL surface_data_output_sum_up( surf_def_h(0)%qs, & 3256 surf_def_h(1)%qs, & 3257 surf_lsm_h%qs, & 3258 surf_usm_h%qs, & 3259 surf_def_v(0)%qs, & 3260 surf_lsm_v(0)%qs, & 3261 surf_usm_v(0)%qs, & 3262 surf_def_v(1)%qs, & 3263 surf_lsm_v(1)%qs, & 3264 surf_usm_v(1)%qs, & 3265 surf_def_v(2)%qs, & 3266 surf_lsm_v(2)%qs, & 3267 surf_usm_v(2)%qs, & 3268 surf_def_v(3)%qs, & 3269 surf_lsm_v(3)%qs, & 3270 surf_usm_v(3)%qs, n_out ) 3271 3272 CASE ( 'ss' ) 3273 CALL surface_data_output_sum_up( surf_def_h(0)%ss, & 3274 surf_def_h(1)%ss, & 3275 surf_lsm_h%ss, & 3276 surf_usm_h%ss, & 3277 surf_def_v(0)%ss, & 3278 surf_lsm_v(0)%ss, & 3279 surf_usm_v(0)%ss, & 3280 surf_def_v(1)%ss, & 3281 surf_lsm_v(1)%ss, & 3282 surf_usm_v(1)%ss, & 3283 surf_def_v(2)%ss, & 3284 surf_lsm_v(2)%ss, & 3285 surf_usm_v(2)%ss, & 3286 surf_def_v(3)%ss, & 3287 surf_lsm_v(3)%ss, & 3288 surf_usm_v(3)%ss, n_out ) 3289 3290 CASE ( 'qcs' ) 3291 CALL surface_data_output_sum_up( surf_def_h(0)%qcs, & 3292 surf_def_h(1)%qcs, & 3293 surf_lsm_h%qcs, & 3294 surf_usm_h%qcs, & 3295 surf_def_v(0)%qcs, & 3296 surf_lsm_v(0)%qcs, & 3297 surf_usm_v(0)%qcs, & 3298 surf_def_v(1)%qcs, & 3299 surf_lsm_v(1)%qcs, & 3300 surf_usm_v(1)%qcs, & 3301 surf_def_v(2)%qcs, & 3302 surf_lsm_v(2)%qcs, & 3303 surf_usm_v(2)%qcs, & 3304 surf_def_v(3)%qcs, & 3305 surf_lsm_v(3)%qcs, & 3306 surf_usm_v(3)%qcs, n_out ) 3307 3308 CASE ( 'ncs' ) 3309 CALL surface_data_output_sum_up( surf_def_h(0)%ncs, & 3310 surf_def_h(1)%ncs, & 3311 surf_lsm_h%ncs, & 3312 surf_usm_h%ncs, & 3313 surf_def_v(0)%ncs, & 3314 surf_lsm_v(0)%ncs, & 3315 surf_usm_v(0)%ncs, & 3316 surf_def_v(1)%ncs, & 3317 surf_lsm_v(1)%ncs, & 3318 surf_usm_v(1)%ncs, & 3319 surf_def_v(2)%ncs, & 3320 surf_lsm_v(2)%ncs, & 3321 surf_usm_v(2)%ncs, & 3322 surf_def_v(3)%ncs, & 3323 surf_lsm_v(3)%ncs, & 3324 surf_usm_v(3)%ncs, n_out ) 3325 3326 CASE ( 'qis' ) 3327 CALL surface_data_output_sum_up( surf_def_h(0)%qis, & 3328 surf_def_h(1)%qis, & 3329 surf_lsm_h%qis, & 3330 surf_usm_h%qis, & 3331 surf_def_v(0)%qis, & 3332 surf_lsm_v(0)%qis, & 3333 surf_usm_v(0)%qis, & 3334 surf_def_v(1)%qis, & 3335 surf_lsm_v(1)%qis, & 3336 surf_usm_v(1)%qis, & 3337 surf_def_v(2)%qis, & 3338 surf_lsm_v(2)%qis, & 3339 surf_usm_v(2)%qis, & 3340 surf_def_v(3)%qis, & 3341 surf_lsm_v(3)%qis, & 3342 surf_usm_v(3)%qrs, n_out ) 3343 3344 CASE ( 'nis' ) 3345 CALL surface_data_output_sum_up( surf_def_h(0)%nis, & 3346 surf_def_h(1)%nis, & 3347 surf_lsm_h%nis, & 3348 surf_usm_h%nis, & 3349 surf_def_v(0)%nis, & 3350 surf_lsm_v(0)%nis, & 3351 surf_usm_v(0)%nis, & 3352 surf_def_v(1)%nis, & 3353 surf_lsm_v(1)%nis, & 3354 surf_usm_v(1)%nis, & 3355 surf_def_v(2)%nis, & 3356 surf_lsm_v(2)%nis, & 3357 surf_usm_v(2)%nis, & 3358 surf_def_v(3)%nis, & 3359 surf_lsm_v(3)%nis, & 3360 surf_usm_v(3)%nis, n_out ) 3361 3362 CASE ( 'qrs' ) 3363 CALL surface_data_output_sum_up( surf_def_h(0)%qrs, & 3364 surf_def_h(1)%qrs, & 3365 surf_lsm_h%qrs, & 3366 surf_usm_h%qrs, & 3367 surf_def_v(0)%qrs, & 3368 surf_lsm_v(0)%qrs, & 3369 surf_usm_v(0)%qrs, & 3370 surf_def_v(1)%qrs, & 3371 surf_lsm_v(1)%qrs, & 3372 surf_usm_v(1)%qrs, & 3373 surf_def_v(2)%qrs, & 3374 surf_lsm_v(2)%qrs, & 3375 surf_usm_v(2)%qrs, & 3376 surf_def_v(3)%qrs, & 3377 surf_lsm_v(3)%qrs, & 3378 surf_usm_v(3)%qrs, n_out ) 3379 3380 CASE ( 'nrs' ) 3381 CALL surface_data_output_sum_up( surf_def_h(0)%nrs, & 3382 surf_def_h(1)%nrs, & 3383 surf_lsm_h%nrs, & 3384 surf_usm_h%nrs, & 3385 surf_def_v(0)%nrs, & 3386 surf_lsm_v(0)%nrs, & 3387 surf_usm_v(0)%nrs, & 3388 surf_def_v(1)%nrs, & 3389 surf_lsm_v(1)%nrs, & 3390 surf_usm_v(1)%nrs, & 3391 surf_def_v(2)%nrs, & 3392 surf_lsm_v(2)%nrs, & 3393 surf_usm_v(2)%nrs, & 3394 surf_def_v(3)%nrs, & 3395 surf_lsm_v(3)%nrs, & 3396 surf_usm_v(3)%nrs, n_out ) 3397 3398 CASE ( 'ol' ) 3399 CALL surface_data_output_sum_up( surf_def_h(0)%ol, & 3400 surf_def_h(1)%ol, & 3401 surf_lsm_h%ol, & 3402 surf_usm_h%ol, & 3403 surf_def_v(0)%ol, & 3404 surf_lsm_v(0)%ol, & 3405 surf_usm_v(0)%ol, & 3406 surf_def_v(1)%ol, & 3407 surf_lsm_v(1)%ol, & 3408 surf_usm_v(1)%ol, & 3409 surf_def_v(2)%ol, & 3410 surf_lsm_v(2)%ol, & 3411 surf_usm_v(2)%ol, & 3412 surf_def_v(3)%ol, & 3413 surf_lsm_v(3)%ol, & 3414 surf_usm_v(3)%ol, n_out ) 3415 3416 CASE ( 'z0' ) 3417 CALL surface_data_output_sum_up( surf_def_h(0)%z0, & 3418 surf_def_h(1)%z0, & 3419 surf_lsm_h%z0, & 3420 surf_usm_h%z0, & 3421 surf_def_v(0)%z0, & 3422 surf_lsm_v(0)%z0, & 3423 surf_usm_v(0)%z0, & 3424 surf_def_v(1)%z0, & 3425 surf_lsm_v(1)%z0, & 3426 surf_usm_v(1)%z0, & 3427 surf_def_v(2)%z0, & 3428 surf_lsm_v(2)%z0, & 3429 surf_usm_v(2)%z0, & 3430 surf_def_v(3)%z0, & 3431 surf_lsm_v(3)%z0, & 3432 surf_usm_v(3)%z0, n_out ) 3433 3434 CASE ( 'z0h' ) 3435 CALL surface_data_output_sum_up( surf_def_h(0)%z0h, & 3436 surf_def_h(1)%z0h, & 3437 surf_lsm_h%z0h, & 3438 surf_usm_h%z0h, & 3439 surf_def_v(0)%z0h, & 3440 surf_lsm_v(0)%z0h, & 3441 surf_usm_v(0)%z0h, & 3442 surf_def_v(1)%z0h, & 3443 surf_lsm_v(1)%z0h, & 3444 surf_usm_v(1)%z0h, & 3445 surf_def_v(2)%z0h, & 3446 surf_lsm_v(2)%z0h, & 3447 surf_usm_v(2)%z0h, & 3448 surf_def_v(3)%z0h, & 3449 surf_lsm_v(3)%z0h, & 3450 surf_usm_v(3)%z0h, n_out ) 3451 3452 CASE ( 'z0q' ) 3453 CALL surface_data_output_sum_up( surf_def_h(0)%z0q, & 3454 surf_def_h(1)%z0q, & 3455 surf_lsm_h%z0q, & 3456 surf_usm_h%z0q, & 3457 surf_def_v(0)%z0q, & 3458 surf_lsm_v(0)%z0q, & 3459 surf_usm_v(0)%z0q, & 3460 surf_def_v(1)%z0q, & 3461 surf_lsm_v(1)%z0q, & 3462 surf_usm_v(1)%z0q, & 3463 surf_def_v(2)%z0q, & 3464 surf_lsm_v(2)%z0q, & 3465 surf_usm_v(2)%z0q, & 3466 surf_def_v(3)%z0q, & 3467 surf_lsm_v(3)%z0q, & 3468 surf_usm_v(3)%z0q, n_out ) 3469 3470 CASE ( 'theta1' ) 3471 CALL surface_data_output_sum_up( surf_def_h(0)%pt1, & 3472 surf_def_h(1)%pt1, & 3473 surf_lsm_h%pt1, & 3474 surf_usm_h%pt1, & 3475 surf_def_v(0)%pt1, & 3476 surf_lsm_v(0)%pt1, & 3477 surf_usm_v(0)%pt1, & 3478 surf_def_v(1)%pt1, & 3479 surf_lsm_v(1)%pt1, & 3480 surf_usm_v(1)%pt1, & 3481 surf_def_v(2)%pt1, & 3482 surf_lsm_v(2)%pt1, & 3483 surf_usm_v(2)%pt1, & 3484 surf_def_v(3)%pt1, & 3485 surf_lsm_v(3)%pt1, & 3486 surf_usm_v(3)%pt1, n_out ) 3487 3488 CASE ( 'qv1' ) 3489 CALL surface_data_output_sum_up( surf_def_h(0)%qv1, & 3490 surf_def_h(1)%qv1, & 3491 surf_lsm_h%qv1, & 3492 surf_usm_h%qv1, & 3493 surf_def_v(0)%qv1, & 3494 surf_lsm_v(0)%qv1, & 3495 surf_usm_v(0)%qv1, & 3496 surf_def_v(1)%qv1, & 3497 surf_lsm_v(1)%qv1, & 3498 surf_usm_v(1)%qv1, & 3499 surf_def_v(2)%qv1, & 3500 surf_lsm_v(2)%qv1, & 3501 surf_usm_v(2)%qv1, & 3502 surf_def_v(3)%qv1, & 3503 surf_lsm_v(3)%qv1, & 3504 surf_usm_v(3)%qv1, n_out ) 3505 3506 CASE ( 'thetav1' ) 3507 CALL surface_data_output_sum_up( surf_def_h(0)%vpt1, & 3508 surf_def_h(1)%vpt1, & 3509 surf_lsm_h%vpt1, & 3510 surf_usm_h%vpt1, & 3511 surf_def_v(0)%vpt1, & 3512 surf_lsm_v(0)%vpt1, & 3513 surf_usm_v(0)%vpt1, & 3514 surf_def_v(1)%vpt1, & 3515 surf_lsm_v(1)%vpt1, & 3516 surf_usm_v(1)%vpt1, & 3517 surf_def_v(2)%vpt1, & 3518 surf_lsm_v(2)%vpt1, & 3519 surf_usm_v(2)%vpt1, & 3520 surf_def_v(3)%vpt1, & 3521 surf_lsm_v(3)%vpt1, & 3522 surf_usm_v(3)%vpt1, n_out ) 3523 3524 CASE ( 'usws' ) 3525 CALL surface_data_output_sum_up( surf_def_h(0)%usws, & 3526 surf_def_h(1)%usws, & 3527 surf_lsm_h%usws, & 3528 surf_usm_h%usws, & 3529 surf_def_v(0)%usws, & 3530 surf_lsm_v(0)%usws, & 3531 surf_usm_v(0)%usws, & 3532 surf_def_v(1)%usws, & 3533 surf_lsm_v(1)%usws, & 3534 surf_usm_v(1)%usws, & 3535 surf_def_v(2)%usws, & 3536 surf_lsm_v(2)%usws, & 3537 surf_usm_v(2)%usws, & 3538 surf_def_v(3)%usws, & 3539 surf_lsm_v(3)%usws, & 3540 surf_usm_v(3)%usws, n_out, & 3541 momentumflux_output_conversion ) 3542 3543 CASE ( 'vsws' ) 3544 CALL surface_data_output_sum_up( surf_def_h(0)%vsws, & 3545 surf_def_h(1)%vsws, & 3546 surf_lsm_h%vsws, & 3547 surf_usm_h%vsws, & 3548 surf_def_v(0)%vsws, & 3549 surf_lsm_v(0)%vsws, & 3550 surf_usm_v(0)%vsws, & 3551 surf_def_v(1)%vsws, & 3552 surf_lsm_v(1)%vsws, & 3553 surf_usm_v(1)%vsws, & 3554 surf_def_v(2)%vsws, & 3555 surf_lsm_v(2)%vsws, & 3556 surf_usm_v(2)%vsws, & 3557 surf_def_v(3)%vsws, & 3558 surf_lsm_v(3)%vsws, & 3559 surf_usm_v(3)%vsws, n_out, & 3560 momentumflux_output_conversion ) 3561 3562 CASE ( 'shf' ) 3563 CALL surface_data_output_sum_up( surf_def_h(0)%shf, & 3564 surf_def_h(1)%shf, & 3565 surf_lsm_h%shf, & 3566 surf_usm_h%shf, & 3567 surf_def_v(0)%shf, & 3568 surf_lsm_v(0)%shf, & 3569 surf_usm_v(0)%shf, & 3570 surf_def_v(1)%shf, & 3571 surf_lsm_v(1)%shf, & 3572 surf_usm_v(1)%shf, & 3573 surf_def_v(2)%shf, & 3574 surf_lsm_v(2)%shf, & 3575 surf_usm_v(2)%shf, & 3576 surf_def_v(3)%shf, & 3577 surf_lsm_v(3)%shf, & 3578 surf_usm_v(3)%shf, n_out, & 3579 heatflux_output_conversion ) 3580 3581 CASE ( 'qsws' ) 3582 CALL surface_data_output_sum_up( surf_def_h(0)%qsws, & 3583 surf_def_h(1)%qsws, & 3584 surf_lsm_h%qsws, & 3585 surf_usm_h%qsws, & 3586 surf_def_v(0)%qsws, & 3587 surf_lsm_v(0)%qsws, & 3588 surf_usm_v(0)%qsws, & 3589 surf_def_v(1)%qsws, & 3590 surf_lsm_v(1)%qsws, & 3591 surf_usm_v(1)%qsws, & 3592 surf_def_v(2)%qsws, & 3593 surf_lsm_v(2)%qsws, & 3594 surf_usm_v(2)%qsws, & 3595 surf_def_v(3)%qsws, & 3596 surf_lsm_v(3)%qsws, & 3597 surf_usm_v(3)%qsws, n_out, & 3598 waterflux_output_conversion ) 3599 3600 CASE ( 'ssws' ) 3601 CALL surface_data_output_sum_up( surf_def_h(0)%ssws, & 3602 surf_def_h(1)%ssws, & 3603 surf_lsm_h%ssws, & 3604 surf_usm_h%ssws, & 3605 surf_def_v(0)%ssws, & 3606 surf_lsm_v(0)%ssws, & 3607 surf_usm_v(0)%ssws, & 3608 surf_def_v(1)%ssws, & 3609 surf_lsm_v(1)%ssws, & 3610 surf_usm_v(1)%ssws, & 3611 surf_def_v(2)%ssws, & 3612 surf_lsm_v(2)%ssws, & 3613 surf_usm_v(2)%ssws, & 3614 surf_def_v(3)%ssws, & 3615 surf_lsm_v(3)%ssws, & 3616 surf_usm_v(3)%ssws, n_out ) 3617 3618 CASE ( 'qcsws' ) 3619 CALL surface_data_output_sum_up( surf_def_h(0)%qcsws, & 3620 surf_def_h(1)%qcsws, & 3621 surf_lsm_h%qcsws, & 3622 surf_usm_h%qcsws, & 3623 surf_def_v(0)%qcsws, & 3624 surf_lsm_v(0)%qcsws, & 3625 surf_usm_v(0)%qcsws, & 3626 surf_def_v(1)%qcsws, & 3627 surf_lsm_v(1)%qcsws, & 3628 surf_usm_v(1)%qcsws, & 3629 surf_def_v(2)%qcsws, & 3630 surf_lsm_v(2)%qcsws, & 3631 surf_usm_v(2)%qcsws, & 3632 surf_def_v(3)%qcsws, & 3633 surf_lsm_v(3)%qcsws, & 3634 surf_usm_v(3)%qcsws, n_out ) 3635 3636 CASE ( 'ncsws' ) 3637 CALL surface_data_output_sum_up( surf_def_h(0)%ncsws, & 3638 surf_def_h(1)%ncsws, & 3639 surf_lsm_h%ncsws, & 3640 surf_usm_h%ncsws, & 3641 surf_def_v(0)%ncsws, & 3642 surf_lsm_v(0)%ncsws, & 3643 surf_usm_v(0)%ncsws, & 3644 surf_def_v(1)%ncsws, & 3645 surf_lsm_v(1)%ncsws, & 3646 surf_usm_v(1)%ncsws, & 3647 surf_def_v(2)%ncsws, & 3648 surf_lsm_v(2)%ncsws, & 3649 surf_usm_v(2)%ncsws, & 3650 surf_def_v(3)%ncsws, & 3651 surf_lsm_v(3)%ncsws, & 3652 surf_usm_v(3)%ncsws, n_out ) 3653 3654 CASE ( 'qisws' ) 3655 CALL surface_data_output_sum_up( surf_def_h(0)%qisws, & 3656 surf_def_h(1)%qisws, & 3657 surf_lsm_h%qisws, & 3658 surf_usm_h%qisws, & 3659 surf_def_v(0)%qisws, & 3660 surf_lsm_v(0)%qisws, & 3661 surf_usm_v(0)%qisws, & 3662 surf_def_v(1)%qisws, & 3663 surf_lsm_v(1)%qisws, & 3664 surf_usm_v(1)%qisws, & 3665 surf_def_v(2)%qisws, & 3666 surf_lsm_v(2)%qisws, & 3667 surf_usm_v(2)%qisws, & 3668 surf_def_v(3)%qisws, & 3669 surf_lsm_v(3)%qisws, & 3670 surf_usm_v(3)%qisws, n_out ) 3671 3672 CASE ( 'nisws' ) 3673 CALL surface_data_output_sum_up( surf_def_h(0)%nisws, & 3674 surf_def_h(1)%nisws, & 3675 surf_lsm_h%nisws, & 3676 surf_usm_h%nisws, & 3677 surf_def_v(0)%nisws, & 3678 surf_lsm_v(0)%nisws, & 3679 surf_usm_v(0)%nisws, & 3680 surf_def_v(1)%nisws, & 3681 surf_lsm_v(1)%nisws, & 3682 surf_usm_v(1)%nisws, & 3683 surf_def_v(2)%nisws, & 3684 surf_lsm_v(2)%nisws, & 3685 surf_usm_v(2)%nisws, & 3686 surf_def_v(3)%nisws, & 3687 surf_lsm_v(3)%nisws, & 3688 surf_usm_v(3)%nisws, n_out ) 3689 3690 CASE ( 'qrsws' ) 3691 CALL surface_data_output_sum_up( surf_def_h(0)%qrsws, & 3692 surf_def_h(1)%qrsws, & 3693 surf_lsm_h%qrsws, & 3694 surf_usm_h%qrsws, & 3695 surf_def_v(0)%qrsws, & 3696 surf_lsm_v(0)%qrsws, & 3697 surf_usm_v(0)%qrsws, & 3698 surf_def_v(1)%qrsws, & 3699 surf_lsm_v(1)%qrsws, & 3700 surf_usm_v(1)%qrsws, & 3701 surf_def_v(2)%qrsws, & 3702 surf_lsm_v(2)%qrsws, & 3703 surf_usm_v(2)%qrsws, & 3704 surf_def_v(3)%qrsws, & 3705 surf_lsm_v(3)%qrsws, & 3706 surf_usm_v(3)%qrsws, n_out ) 3707 3708 CASE ( 'nrsws' ) 3709 CALL surface_data_output_sum_up( surf_def_h(0)%nrsws, & 3710 surf_def_h(1)%nrsws, & 3711 surf_lsm_h%nrsws, & 3712 surf_usm_h%nrsws, & 3713 surf_def_v(0)%nrsws, & 3714 surf_lsm_v(0)%nrsws, & 3715 surf_usm_v(0)%nrsws, & 3716 surf_def_v(1)%nrsws, & 3717 surf_lsm_v(1)%nrsws, & 3718 surf_usm_v(1)%nrsws, & 3719 surf_def_v(2)%nrsws, & 3720 surf_lsm_v(2)%nrsws, & 3721 surf_usm_v(2)%nrsws, & 3722 surf_def_v(3)%nrsws, & 3723 surf_lsm_v(3)%nrsws, & 3724 surf_usm_v(3)%nrsws, n_out ) 3725 3726 CASE ( 'sasws' ) 3727 CALL surface_data_output_sum_up( surf_def_h(0)%sasws, & 3728 surf_def_h(1)%sasws, & 3729 surf_lsm_h%sasws, & 3730 surf_usm_h%sasws, & 3731 surf_def_v(0)%sasws, & 3732 surf_lsm_v(0)%sasws, & 3733 surf_usm_v(0)%sasws, & 3734 surf_def_v(1)%sasws, & 3735 surf_lsm_v(1)%sasws, & 3736 surf_usm_v(1)%sasws, & 3737 surf_def_v(2)%sasws, & 3738 surf_lsm_v(2)%sasws, & 3739 surf_usm_v(2)%sasws, & 3740 surf_def_v(3)%sasws, & 3741 surf_lsm_v(3)%sasws, & 3742 surf_usm_v(3)%sasws, n_out ) 3743 3744 CASE ( 'q_surface' ) 3745 CALL surface_data_output_sum_up( surf_def_h(0)%q_surface, & 3746 surf_def_h(1)%q_surface, & 3747 surf_lsm_h%q_surface, & 3748 surf_usm_h%q_surface, & 3749 surf_def_v(0)%q_surface, & 3750 surf_lsm_v(0)%q_surface, & 3751 surf_usm_v(0)%q_surface, & 3752 surf_def_v(1)%q_surface, & 3753 surf_lsm_v(1)%q_surface, & 3754 surf_usm_v(1)%q_surface, & 3755 surf_def_v(2)%q_surface, & 3756 surf_lsm_v(2)%q_surface, & 3757 surf_usm_v(2)%q_surface, & 3758 surf_def_v(3)%q_surface, & 3759 surf_lsm_v(3)%q_surface, & 3760 surf_usm_v(3)%q_surface, n_out ) 3761 3762 3763 CASE ( 'theta_surface' ) 3764 CALL surface_data_output_sum_up( surf_def_h(0)%pt_surface, & 3765 surf_def_h(1)%pt_surface, & 3766 surf_lsm_h%pt_surface, & 3767 surf_usm_h%pt_surface, & 3768 surf_def_v(0)%pt_surface, & 3769 surf_lsm_v(0)%pt_surface, & 3770 surf_usm_v(0)%pt_surface, & 3771 surf_def_v(1)%pt_surface, & 3772 surf_lsm_v(1)%pt_surface, & 3773 surf_usm_v(1)%pt_surface, & 3774 surf_def_v(2)%pt_surface, & 3775 surf_lsm_v(2)%pt_surface, & 3776 surf_usm_v(2)%pt_surface, & 3777 surf_def_v(3)%pt_surface, & 3778 surf_lsm_v(3)%pt_surface, & 3779 surf_usm_v(3)%pt_surface, n_out ) 3780 3781 CASE ( 'thetav_surface' ) 3782 CALL surface_data_output_sum_up( surf_def_h(0)%vpt_surface, & 3783 surf_def_h(1)%vpt_surface, & 3784 surf_lsm_h%vpt_surface, & 3785 surf_usm_h%vpt_surface, & 3786 surf_def_v(0)%vpt_surface, & 3787 surf_lsm_v(0)%vpt_surface, & 3788 surf_usm_v(0)%vpt_surface, & 3789 surf_def_v(1)%vpt_surface, & 3790 surf_lsm_v(1)%vpt_surface, & 3791 surf_usm_v(1)%vpt_surface, & 3792 surf_def_v(2)%vpt_surface, & 3793 surf_lsm_v(2)%vpt_surface, & 3794 surf_usm_v(2)%vpt_surface, & 3795 surf_def_v(3)%vpt_surface, & 3796 surf_lsm_v(3)%vpt_surface, & 3797 surf_usm_v(3)%vpt_surface, n_out ) 3798 3799 CASE ( 'rad_net' ) 3800 CALL surface_data_output_sum_up( surf_def_h(0)%rad_net, & 3801 surf_def_h(1)%rad_net, & 3802 surf_lsm_h%rad_net, & 3803 surf_usm_h%rad_net, & 3804 surf_def_v(0)%rad_net, & 3805 surf_lsm_v(0)%rad_net, & 3806 surf_usm_v(0)%rad_net, & 3807 surf_def_v(1)%rad_net, & 3808 surf_lsm_v(1)%rad_net, & 3809 surf_usm_v(1)%rad_net, & 3810 surf_def_v(2)%rad_net, & 3811 surf_lsm_v(2)%rad_net, & 3812 surf_usm_v(2)%rad_net, & 3813 surf_def_v(3)%rad_net, & 3814 surf_lsm_v(3)%rad_net, & 3815 surf_usm_v(3)%rad_net, n_out ) 3816 3817 CASE ( 'rad_lw_in' ) 3818 CALL surface_data_output_sum_up( surf_def_h(0)%rad_lw_in, & 3819 surf_def_h(1)%rad_lw_in, & 3820 surf_lsm_h%rad_lw_in, & 3821 surf_usm_h%rad_lw_in, & 3822 surf_def_v(0)%rad_lw_in, & 3823 surf_lsm_v(0)%rad_lw_in, & 3824 surf_usm_v(0)%rad_lw_in, & 3825 surf_def_v(1)%rad_lw_in, & 3826 surf_lsm_v(1)%rad_lw_in, & 3827 surf_usm_v(1)%rad_lw_in, & 3828 surf_def_v(2)%rad_lw_in, & 3829 surf_lsm_v(2)%rad_lw_in, & 3830 surf_usm_v(2)%rad_lw_in, & 3831 surf_def_v(3)%rad_lw_in, & 3832 surf_lsm_v(3)%rad_lw_in, & 3833 surf_usm_v(3)%rad_lw_in, n_out ) 3834 3835 CASE ( 'rad_lw_out' ) 3836 CALL surface_data_output_sum_up( surf_def_h(0)%rad_lw_out, & 3837 surf_def_h(1)%rad_lw_out, & 3838 surf_lsm_h%rad_lw_out, & 3839 surf_usm_h%rad_lw_out, & 3840 surf_def_v(0)%rad_lw_out, & 3841 surf_lsm_v(0)%rad_lw_out, & 3842 surf_usm_v(0)%rad_lw_out, & 3843 surf_def_v(1)%rad_lw_out, & 3844 surf_lsm_v(1)%rad_lw_out, & 3845 surf_usm_v(1)%rad_lw_out, & 3846 surf_def_v(2)%rad_lw_out, & 3847 surf_lsm_v(2)%rad_lw_out, & 3848 surf_usm_v(2)%rad_lw_out, & 3849 surf_def_v(3)%rad_lw_out, & 3850 surf_lsm_v(3)%rad_lw_out, & 3851 surf_usm_v(3)%rad_lw_out, n_out ) 3852 3853 CASE ( 'rad_sw_in' ) 3854 CALL surface_data_output_sum_up( surf_def_h(0)%rad_sw_in, & 3855 surf_def_h(1)%rad_sw_in, & 3856 surf_lsm_h%rad_sw_in, & 3857 surf_usm_h%rad_sw_in, & 3858 surf_def_v(0)%rad_sw_in, & 3859 surf_lsm_v(0)%rad_sw_in, & 3860 surf_usm_v(0)%rad_sw_in, & 3861 surf_def_v(1)%rad_sw_in, & 3862 surf_lsm_v(1)%rad_sw_in, & 3863 surf_usm_v(1)%rad_sw_in, & 3864 surf_def_v(2)%rad_sw_in, & 3865 surf_lsm_v(2)%rad_sw_in, & 3866 surf_usm_v(2)%rad_sw_in, & 3867 surf_def_v(3)%rad_sw_in, & 3868 surf_lsm_v(3)%rad_sw_in, & 3869 surf_usm_v(3)%rad_sw_in, n_out ) 3870 3871 CASE ( 'rad_sw_out' ) 3872 CALL surface_data_output_sum_up( surf_def_h(0)%rad_sw_out, & 3873 surf_def_h(1)%rad_sw_out, & 3874 surf_lsm_h%rad_sw_out, & 3875 surf_usm_h%rad_sw_out, & 3876 surf_def_v(0)%rad_sw_out, & 3877 surf_lsm_v(0)%rad_sw_out, & 3878 surf_usm_v(0)%rad_sw_out, & 3879 surf_def_v(1)%rad_sw_out, & 3880 surf_lsm_v(1)%rad_sw_out, & 3881 surf_usm_v(1)%rad_sw_out, & 3882 surf_def_v(2)%rad_sw_out, & 3883 surf_lsm_v(2)%rad_sw_out, & 3884 surf_usm_v(2)%rad_sw_out, & 3885 surf_def_v(3)%rad_sw_out, & 3886 surf_lsm_v(3)%rad_sw_out, & 3887 surf_usm_v(3)%rad_sw_out, n_out ) 3888 3889 CASE ( 'ghf' ) 3890 ! 3891 !-- Sum up ground / wall heat flux. Note, for urban surfaces the 3892 !-- wall heat flux is aggregated from the different green, window 3893 !-- and wall tiles. 3894 DO m = 1, surf_usm_h%ns 3895 surf_usm_h%ghf(m) = surf_usm_h%frac(m,ind_veg_wall) & 3896 * surf_usm_h%wghf_eb(m) + & 3897 surf_usm_h%frac(m,ind_pav_green) & 3898 * surf_usm_h%wghf_eb_green(m) + & 3899 surf_usm_h%frac(m,ind_wat_win) & 3900 * surf_usm_h%wghf_eb_window(m) 3901 ENDDO 3902 DO l = 0, 3 3903 DO m = 1, surf_usm_v(l)%ns 3904 surf_usm_v(l)%ghf(m) = surf_usm_v(l)%frac(m,ind_veg_wall) & 3905 * surf_usm_v(l)%wghf_eb(m) + & 3906 surf_usm_v(l)%frac(m,ind_pav_green)& 3907 * surf_usm_v(l)%wghf_eb_green(m) + & 3908 surf_usm_v(l)%frac(m,ind_wat_win) & 3909 * surf_usm_v(l)%wghf_eb_window(m) 3910 ENDDO 3911 ENDDO 3912 3913 CALL surface_data_output_sum_up( surf_def_h(0)%ghf, & 3914 surf_def_h(1)%ghf, & 3915 surf_lsm_h%ghf, & 3916 surf_usm_h%ghf, & 3917 surf_def_v(0)%ghf, & 3918 surf_lsm_v(0)%ghf, & 3919 surf_usm_v(0)%ghf, & 3920 surf_def_v(1)%ghf, & 3921 surf_lsm_v(1)%ghf, & 3922 surf_usm_v(1)%ghf, & 3923 surf_def_v(2)%ghf, & 3924 surf_lsm_v(2)%ghf, & 3925 surf_usm_v(2)%ghf, & 3926 surf_def_v(3)%ghf, & 3927 surf_lsm_v(3)%ghf, & 3928 surf_usm_v(3)%ghf, n_out ) 3929 3930 CASE ( 'r_a' ) 3931 CALL surface_data_output_sum_up( surf_def_h(0)%r_a, & 3932 surf_def_h(1)%r_a, & 3933 surf_lsm_h%r_a, & 3934 surf_usm_h%r_a, & 3935 surf_def_v(0)%r_a, & 3936 surf_lsm_v(0)%r_a, & 3937 surf_usm_v(0)%r_a, & 3938 surf_def_v(1)%r_a, & 3939 surf_lsm_v(1)%r_a, & 3940 surf_usm_v(1)%r_a, & 3941 surf_def_v(2)%r_a, & 3942 surf_lsm_v(2)%r_a, & 3943 surf_usm_v(2)%r_a, & 3944 surf_def_v(3)%r_a, & 3945 surf_lsm_v(3)%r_a, & 3946 surf_usm_v(3)%r_a, n_out ) 3947 3948 CASE ( 'r_soil' ) 3949 CALL surface_data_output_sum_up( surf_def_h(0)%r_soil, & 3950 surf_def_h(1)%r_soil, & 3951 surf_lsm_h%r_soil, & 3952 surf_usm_h%r_soil, & 3953 surf_def_v(0)%r_soil, & 3954 surf_lsm_v(0)%r_soil, & 3955 surf_usm_v(0)%r_soil, & 3956 surf_def_v(1)%r_soil, & 3957 surf_lsm_v(1)%r_soil, & 3958 surf_usm_v(1)%r_soil, & 3959 surf_def_v(2)%r_soil, & 3960 surf_lsm_v(2)%r_soil, & 3961 surf_usm_v(2)%r_soil, & 3962 surf_def_v(3)%r_soil, & 3963 surf_lsm_v(3)%r_soil, & 3964 surf_usm_v(3)%r_soil, n_out ) 3965 3966 CASE ( 'r_canopy' ) 3967 CALL surface_data_output_sum_up( surf_def_h(0)%r_canopy, & 3968 surf_def_h(1)%r_canopy, & 3969 surf_lsm_h%r_canopy, & 3970 surf_usm_h%r_canopy, & 3971 surf_def_v(0)%r_canopy, & 3972 surf_lsm_v(0)%r_canopy, & 3973 surf_usm_v(0)%r_canopy, & 3974 surf_def_v(1)%r_canopy, & 3975 surf_lsm_v(1)%r_canopy, & 3976 surf_usm_v(1)%r_canopy, & 3977 surf_def_v(2)%r_canopy, & 3978 surf_lsm_v(2)%r_canopy, & 3979 surf_usm_v(2)%r_canopy, & 3980 surf_def_v(3)%r_canopy, & 3981 surf_lsm_v(3)%r_canopy, & 3982 surf_usm_v(3)%r_canopy, n_out ) 3983 3984 CASE ( 'r_s' ) 3985 CALL surface_data_output_sum_up( surf_def_h(0)%r_s, & 3986 surf_def_h(1)%r_s, & 3987 surf_lsm_h%r_s, & 3988 surf_usm_h%r_s, & 3989 surf_def_v(0)%r_s, & 3990 surf_lsm_v(0)%r_s, & 3991 surf_usm_v(0)%r_s, & 3992 surf_def_v(1)%r_s, & 3993 surf_lsm_v(1)%r_s, & 3994 surf_usm_v(1)%r_s, & 3995 surf_def_v(2)%r_s, & 3996 surf_lsm_v(2)%r_s, & 3997 surf_usm_v(2)%r_s, & 3998 surf_def_v(3)%r_s, & 3999 surf_lsm_v(3)%r_s, & 4000 surf_usm_v(3)%r_s, n_out ) 4001 4002 4003 CASE ( 'rad_sw_dir' ) 4004 CALL surface_data_output_sum_up( surf_def_h(0)%rad_sw_dir, & 4005 surf_def_h(1)%rad_sw_dir, & 4006 surf_lsm_h%rad_sw_dir, & 4007 surf_usm_h%rad_sw_dir, & 4008 surf_def_v(0)%rad_sw_dir, & 4009 surf_lsm_v(0)%rad_sw_dir, & 4010 surf_usm_v(0)%rad_sw_dir, & 4011 surf_def_v(1)%rad_sw_dir, & 4012 surf_lsm_v(1)%rad_sw_dir, & 4013 surf_usm_v(1)%rad_sw_dir, & 4014 surf_def_v(2)%rad_sw_dir, & 4015 surf_lsm_v(2)%rad_sw_dir, & 4016 surf_usm_v(2)%rad_sw_dir, & 4017 surf_def_v(3)%rad_sw_dir, & 4018 surf_lsm_v(3)%rad_sw_dir, & 4019 surf_usm_v(3)%rad_sw_dir, n_out ) 4020 CASE ( 'rad_sw_dif' ) 4021 CALL surface_data_output_sum_up( surf_def_h(0)%rad_sw_dif, & 4022 surf_def_h(1)%rad_sw_dif, & 4023 surf_lsm_h%rad_sw_dif, & 4024 surf_usm_h%rad_sw_dif, & 4025 surf_def_v(0)%rad_sw_dif, & 4026 surf_lsm_v(0)%rad_sw_dif, & 4027 surf_usm_v(0)%rad_sw_dif, & 4028 surf_def_v(1)%rad_sw_dif, & 4029 surf_lsm_v(1)%rad_sw_dif, & 4030 surf_usm_v(1)%rad_sw_dif, & 4031 surf_def_v(2)%rad_sw_dif, & 4032 surf_lsm_v(2)%rad_sw_dif, & 4033 surf_usm_v(2)%rad_sw_dif, & 4034 surf_def_v(3)%rad_sw_dif, & 4035 surf_lsm_v(3)%rad_sw_dif, & 4036 surf_usm_v(3)%rad_sw_dif, n_out ) 4037 4038 CASE ( 'rad_sw_ref' ) 4039 CALL surface_data_output_sum_up( surf_def_h(0)%rad_sw_ref, & 4040 surf_def_h(1)%rad_sw_ref, & 4041 surf_lsm_h%rad_sw_ref, & 4042 surf_usm_h%rad_sw_ref, & 4043 surf_def_v(0)%rad_sw_ref, & 4044 surf_lsm_v(0)%rad_sw_ref, & 4045 surf_usm_v(0)%rad_sw_ref, & 4046 surf_def_v(1)%rad_sw_ref, & 4047 surf_lsm_v(1)%rad_sw_ref, & 4048 surf_usm_v(1)%rad_sw_ref, & 4049 surf_def_v(2)%rad_sw_ref, & 4050 surf_lsm_v(2)%rad_sw_ref, & 4051 surf_usm_v(2)%rad_sw_ref, & 4052 surf_def_v(3)%rad_sw_ref, & 4053 surf_lsm_v(3)%rad_sw_ref, & 4054 surf_usm_v(3)%rad_sw_ref, n_out ) 4055 4056 CASE ( 'rad_sw_res' ) 4057 CALL surface_data_output_sum_up( surf_def_h(0)%rad_sw_res, & 4058 surf_def_h(1)%rad_sw_res, & 4059 surf_lsm_h%rad_sw_res, & 4060 surf_usm_h%rad_sw_res, & 4061 surf_def_v(0)%rad_sw_res, & 4062 surf_lsm_v(0)%rad_sw_res, & 4063 surf_usm_v(0)%rad_sw_res, & 4064 surf_def_v(1)%rad_sw_res, & 4065 surf_lsm_v(1)%rad_sw_res, & 4066 surf_usm_v(1)%rad_sw_res, & 4067 surf_def_v(2)%rad_sw_res, & 4068 surf_lsm_v(2)%rad_sw_res, & 4069 surf_usm_v(2)%rad_sw_res, & 4070 surf_def_v(3)%rad_sw_res, & 4071 surf_lsm_v(3)%rad_sw_res, & 4072 surf_usm_v(3)%rad_sw_res, n_out ) 4073 4074 CASE ( 'rad_lw_dif' ) 4075 CALL surface_data_output_sum_up( surf_def_h(0)%rad_lw_dif, & 4076 surf_def_h(1)%rad_lw_dif, & 4077 surf_lsm_h%rad_lw_dif, & 4078 surf_usm_h%rad_lw_dif, & 4079 surf_def_v(0)%rad_lw_dif, & 4080 surf_lsm_v(0)%rad_lw_dif, & 4081 surf_usm_v(0)%rad_lw_dif, & 4082 surf_def_v(1)%rad_lw_dif, & 4083 surf_lsm_v(1)%rad_lw_dif, & 4084 surf_usm_v(1)%rad_lw_dif, & 4085 surf_def_v(2)%rad_lw_dif, & 4086 surf_lsm_v(2)%rad_lw_dif, & 4087 surf_usm_v(2)%rad_lw_dif, & 4088 surf_def_v(3)%rad_lw_dif, & 4089 surf_lsm_v(3)%rad_lw_dif, & 4090 surf_usm_v(3)%rad_lw_dif, n_out ) 4091 4092 CASE ( 'rad_lw_ref' ) 4093 CALL surface_data_output_sum_up( surf_def_h(0)%rad_lw_ref, & 4094 surf_def_h(1)%rad_lw_ref, & 4095 surf_lsm_h%rad_lw_ref, & 4096 surf_usm_h%rad_lw_ref, & 4097 surf_def_v(0)%rad_lw_ref, & 4098 surf_lsm_v(0)%rad_lw_ref, & 4099 surf_usm_v(0)%rad_lw_ref, & 4100 surf_def_v(1)%rad_lw_ref, & 4101 surf_lsm_v(1)%rad_lw_ref, & 4102 surf_usm_v(1)%rad_lw_ref, & 4103 surf_def_v(2)%rad_lw_ref, & 4104 surf_lsm_v(2)%rad_lw_ref, & 4105 surf_usm_v(2)%rad_lw_ref, & 4106 surf_def_v(3)%rad_lw_ref, & 4107 surf_lsm_v(3)%rad_lw_ref, & 4108 surf_usm_v(3)%rad_lw_ref, n_out ) 4109 4110 CASE ( 'rad_lw_res' ) 4111 CALL surface_data_output_sum_up( surf_def_h(0)%rad_lw_res, & 4112 surf_def_h(1)%rad_lw_res, & 4113 surf_lsm_h%rad_lw_res, & 4114 surf_usm_h%rad_lw_res, & 4115 surf_def_v(0)%rad_lw_res, & 4116 surf_lsm_v(0)%rad_lw_res, & 4117 surf_usm_v(0)%rad_lw_res, & 4118 surf_def_v(1)%rad_lw_res, & 4119 surf_lsm_v(1)%rad_lw_res, & 4120 surf_usm_v(1)%rad_lw_res, & 4121 surf_def_v(2)%rad_lw_res, & 4122 surf_lsm_v(2)%rad_lw_res, & 4123 surf_usm_v(2)%rad_lw_res, & 4124 surf_def_v(3)%rad_lw_res, & 4125 surf_lsm_v(3)%rad_lw_res, & 4126 surf_usm_v(3)%rad_lw_res, n_out ) 4127 4128 CASE ( 'uvw1' ) 4129 CALL surface_data_output_sum_up( surf_def_h(0)%uvw_abs, & 4130 surf_def_h(1)%uvw_abs, & 4131 surf_lsm_h%uvw_abs, & 4132 surf_usm_h%uvw_abs, & 4133 surf_def_v(0)%uvw_abs, & 4134 surf_lsm_v(0)%uvw_abs, & 4135 surf_usm_v(0)%uvw_abs, & 4136 surf_def_v(1)%uvw_abs, & 4137 surf_lsm_v(1)%uvw_abs, & 4138 surf_usm_v(1)%uvw_abs, & 4139 surf_def_v(2)%uvw_abs, & 4140 surf_lsm_v(2)%uvw_abs, & 4141 surf_usm_v(2)%uvw_abs, & 4142 surf_def_v(3)%uvw_abs, & 4143 surf_lsm_v(3)%uvw_abs, & 4144 surf_usm_v(3)%uvw_abs, n_out ) 4145 4146 CASE ( 'waste_heat' ) 4147 CALL surface_data_output_sum_up( surf_def_h(0)%waste_heat, & 4148 surf_def_h(1)%waste_heat, & 4149 surf_lsm_h%waste_heat, & 4150 surf_usm_h%waste_heat, & 4151 surf_def_v(0)%waste_heat, & 4152 surf_lsm_v(0)%waste_heat, & 4153 surf_usm_v(0)%waste_heat, & 4154 surf_def_v(1)%waste_heat, & 4155 surf_lsm_v(1)%waste_heat, & 4156 surf_usm_v(1)%waste_heat, & 4157 surf_def_v(2)%waste_heat, & 4158 surf_lsm_v(2)%waste_heat, & 4159 surf_usm_v(2)%waste_heat, & 4160 surf_def_v(3)%waste_heat, & 4161 surf_lsm_v(3)%waste_heat, & 4162 surf_usm_v(3)%waste_heat, n_out ) 4163 4164 CASE ( 'im_hf' ) 4165 CALL surface_data_output_sum_up( surf_def_h(0)%iwghf_eb, & 4166 surf_def_h(1)%iwghf_eb, & 4167 surf_lsm_h%iwghf_eb, & 4168 surf_usm_h%iwghf_eb, & 4169 surf_def_v(0)%iwghf_eb, & 4170 surf_lsm_v(0)%iwghf_eb, & 4171 surf_usm_v(0)%iwghf_eb, & 4172 surf_def_v(1)%iwghf_eb, & 4173 surf_lsm_v(1)%iwghf_eb, & 4174 surf_usm_v(1)%iwghf_eb, & 4175 surf_def_v(2)%iwghf_eb, & 4176 surf_lsm_v(2)%iwghf_eb, & 4177 surf_usm_v(2)%iwghf_eb, & 4178 surf_def_v(3)%iwghf_eb, & 4179 surf_lsm_v(3)%iwghf_eb, & 4180 surf_usm_v(3)%iwghf_eb, n_out ) 4181 4182 CASE ( 'albedo' ) 4183 CALL surface_data_output_sum_up( surf_def_h(0)%albedo, & 4184 surf_def_h(1)%albedo, & 4185 surf_lsm_h%albedo, & 4186 surf_usm_h%albedo, & 4187 surf_def_v(0)%albedo, & 4188 surf_lsm_v(0)%albedo, & 4189 surf_usm_v(0)%albedo, & 4190 surf_def_v(1)%albedo, & 4191 surf_lsm_v(1)%albedo, & 4192 surf_usm_v(1)%albedo, & 4193 surf_def_v(2)%albedo, & 4194 surf_lsm_v(2)%albedo, & 4195 surf_usm_v(2)%albedo, & 4196 surf_def_v(3)%albedo, & 4197 surf_lsm_v(3)%albedo, & 4198 surf_usm_v(3)%albedo, n_out ) 4199 4200 4201 CASE ( 'emissivity' ) 4202 CALL surface_data_output_sum_up( surf_def_h(0)%emissivity, & 4203 surf_def_h(1)%emissivity, & 4204 surf_lsm_h%emissivity, & 4205 surf_usm_h%emissivity, & 4206 surf_def_v(0)%emissivity, & 4207 surf_lsm_v(0)%emissivity, & 4208 surf_usm_v(0)%emissivity, & 4209 surf_def_v(1)%emissivity, & 4210 surf_lsm_v(1)%emissivity, & 4211 surf_usm_v(1)%emissivity, & 4212 surf_def_v(2)%emissivity, & 4213 surf_lsm_v(2)%emissivity, & 4214 surf_usm_v(2)%emissivity, & 4215 surf_def_v(3)%emissivity, & 4216 surf_lsm_v(3)%emissivity, & 4217 surf_usm_v(3)%emissivity, n_out ) 4218 4219 END SELECT 4220 ENDDO 4221 4222 4223 END SUBROUTINE surface_data_output_averaging 4224 4225 !------------------------------------------------------------------------------! 2771 !--------------------------------------------------------------------------------------------------! 2772 SUBROUTINE surface_data_output_averaging 2773 2774 IMPLICIT NONE 2775 2776 CHARACTER(LEN=100) :: trimvar !< dummy variable for current output variable 2777 2778 INTEGER(iwp) :: l !< running index for surface orientation 2779 INTEGER(iwp) :: m !< running index for surface elements 2780 INTEGER(iwp) :: n_out !< counter variables for surface output 2781 2782 n_out = 0 2783 DO WHILE ( dosurf(1,n_out+1)(1:1) /= ' ' ) 2784 2785 n_out = n_out + 1 2786 trimvar = TRIM( dosurf(1,n_out) ) 2787 2788 SELECT CASE ( trimvar ) 2789 2790 CASE ( 'us' ) 2791 CALL surface_data_output_sum_up( surf_def_h(0)%us, surf_def_h(1)%us, surf_lsm_h%us, & 2792 surf_usm_h%us, surf_def_v(0)%us, surf_lsm_v(0)%us, & 2793 surf_usm_v(0)%us, surf_def_v(1)%us, & 2794 surf_lsm_v(1)%us, surf_usm_v(1)%us, & 2795 surf_def_v(2)%us, surf_lsm_v(2)%us, & 2796 surf_usm_v(2)%us, surf_def_v(3)%us, & 2797 surf_lsm_v(3)%us, surf_usm_v(3)%us, n_out ) 2798 2799 CASE ( 'ts' ) 2800 CALL surface_data_output_sum_up( surf_def_h(0)%ts, surf_def_h(1)%ts, surf_lsm_h%ts, & 2801 surf_usm_h%ts, surf_def_v(0)%ts, surf_lsm_v(0)%ts, & 2802 surf_usm_v(0)%ts, surf_def_v(1)%ts, & 2803 surf_lsm_v(1)%ts, surf_usm_v(1)%ts, & 2804 surf_def_v(2)%ts, surf_lsm_v(2)%ts, & 2805 surf_usm_v(2)%ts, surf_def_v(3)%ts, & 2806 surf_lsm_v(3)%ts, surf_usm_v(3)%ts, n_out ) 2807 2808 CASE ( 'qs' ) 2809 CALL surface_data_output_sum_up( surf_def_h(0)%qs, surf_def_h(1)%qs, surf_lsm_h%qs, & 2810 surf_usm_h%qs, surf_def_v(0)%qs, surf_lsm_v(0)%qs, & 2811 surf_usm_v(0)%qs, surf_def_v(1)%qs, & 2812 surf_lsm_v(1)%qs, surf_usm_v(1)%qs, & 2813 surf_def_v(2)%qs, surf_lsm_v(2)%qs, & 2814 surf_usm_v(2)%qs, surf_def_v(3)%qs, & 2815 surf_lsm_v(3)%qs, surf_usm_v(3)%qs, n_out ) 2816 2817 CASE ( 'ss' ) 2818 CALL surface_data_output_sum_up( surf_def_h(0)%ss, surf_def_h(1)%ss, surf_lsm_h%ss, & 2819 surf_usm_h%ss, surf_def_v(0)%ss, surf_lsm_v(0)%ss, & 2820 surf_usm_v(0)%ss, surf_def_v(1)%ss, & 2821 surf_lsm_v(1)%ss, surf_usm_v(1)%ss, & 2822 surf_def_v(2)%ss, surf_lsm_v(2)%ss, & 2823 surf_usm_v(2)%ss, surf_def_v(3)%ss, & 2824 surf_lsm_v(3)%ss, surf_usm_v(3)%ss, n_out ) 2825 2826 CASE ( 'qcs' ) 2827 CALL surface_data_output_sum_up( surf_def_h(0)%qcs, surf_def_h(1)%qcs, & 2828 surf_lsm_h%qcs, surf_usm_h%qcs, surf_def_v(0)%qcs, & 2829 surf_lsm_v(0)%qcs, surf_usm_v(0)%qcs, & 2830 surf_def_v(1)%qcs, surf_lsm_v(1)%qcs, & 2831 surf_usm_v(1)%qcs, surf_def_v(2)%qcs, & 2832 surf_lsm_v(2)%qcs, surf_usm_v(2)%qcs, & 2833 surf_def_v(3)%qcs, surf_lsm_v(3)%qcs, & 2834 surf_usm_v(3)%qcs, n_out ) 2835 2836 CASE ( 'ncs' ) 2837 CALL surface_data_output_sum_up( surf_def_h(0)%ncs, surf_def_h(1)%ncs, surf_lsm_h%ncs,& 2838 surf_usm_h%ncs, surf_def_v(0)%ncs, & 2839 surf_lsm_v(0)%ncs, surf_usm_v(0)%ncs, & 2840 surf_def_v(1)%ncs, surf_lsm_v(1)%ncs, & 2841 surf_usm_v(1)%ncs, surf_def_v(2)%ncs, & 2842 surf_lsm_v(2)%ncs, surf_usm_v(2)%ncs, & 2843 surf_def_v(3)%ncs, surf_lsm_v(3)%ncs, & 2844 surf_usm_v(3)%ncs, n_out ) 2845 2846 CASE ( 'qis' ) 2847 CALL surface_data_output_sum_up( surf_def_h(0)%qis, surf_def_h(1)%qis, & 2848 surf_lsm_h%qis, surf_usm_h%qis, surf_def_v(0)%qis, & 2849 surf_lsm_v(0)%qis, surf_usm_v(0)%qis, & 2850 surf_def_v(1)%qis, surf_lsm_v(1)%qis, & 2851 surf_usm_v(1)%qis, surf_def_v(2)%qis, & 2852 surf_lsm_v(2)%qis, surf_usm_v(2)%qis, & 2853 surf_def_v(3)%qis, surf_lsm_v(3)%qis, & 2854 surf_usm_v(3)%qrs, n_out ) 2855 2856 CASE ( 'nis' ) 2857 CALL surface_data_output_sum_up( surf_def_h(0)%nis, surf_def_h(1)%nis, & 2858 surf_lsm_h%nis, surf_usm_h%nis, surf_def_v(0)%nis, & 2859 surf_lsm_v(0)%nis, surf_usm_v(0)%nis, & 2860 surf_def_v(1)%nis, surf_lsm_v(1)%nis, & 2861 surf_usm_v(1)%nis, surf_def_v(2)%nis, & 2862 surf_lsm_v(2)%nis, surf_usm_v(2)%nis, & 2863 surf_def_v(3)%nis, surf_lsm_v(3)%nis, & 2864 surf_usm_v(3)%nis, n_out ) 2865 2866 CASE ( 'qrs' ) 2867 CALL surface_data_output_sum_up( surf_def_h(0)%qrs, surf_def_h(1)%qrs, & 2868 surf_lsm_h%qrs, surf_usm_h%qrs, surf_def_v(0)%qrs, & 2869 surf_lsm_v(0)%qrs, surf_usm_v(0)%qrs, & 2870 surf_def_v(1)%qrs, surf_lsm_v(1)%qrs, & 2871 surf_usm_v(1)%qrs, surf_def_v(2)%qrs, & 2872 surf_lsm_v(2)%qrs, surf_usm_v(2)%qrs, & 2873 surf_def_v(3)%qrs, surf_lsm_v(3)%qrs, & 2874 surf_usm_v(3)%qrs, n_out ) 2875 2876 CASE ( 'nrs' ) 2877 CALL surface_data_output_sum_up( surf_def_h(0)%nrs, surf_def_h(1)%nrs, & 2878 surf_lsm_h%nrs, surf_usm_h%nrs, surf_def_v(0)%nrs, & 2879 surf_lsm_v(0)%nrs, surf_usm_v(0)%nrs, & 2880 surf_def_v(1)%nrs, surf_lsm_v(1)%nrs, & 2881 surf_usm_v(1)%nrs, surf_def_v(2)%nrs, & 2882 surf_lsm_v(2)%nrs, surf_usm_v(2)%nrs, & 2883 surf_def_v(3)%nrs, surf_lsm_v(3)%nrs, & 2884 surf_usm_v(3)%nrs, n_out ) 2885 2886 CASE ( 'ol' ) 2887 CALL surface_data_output_sum_up( surf_def_h(0)%ol, surf_def_h(1)%ol, surf_lsm_h%ol, & 2888 surf_usm_h%ol, surf_def_v(0)%ol, surf_lsm_v(0)%ol, & 2889 surf_usm_v(0)%ol, surf_def_v(1)%ol, & 2890 surf_lsm_v(1)%ol, surf_usm_v(1)%ol, & 2891 surf_def_v(2)%ol, surf_lsm_v(2)%ol, & 2892 surf_usm_v(2)%ol, surf_def_v(3)%ol, & 2893 surf_lsm_v(3)%ol, surf_usm_v(3)%ol, n_out ) 2894 2895 CASE ( 'z0' ) 2896 CALL surface_data_output_sum_up( surf_def_h(0)%z0, surf_def_h(1)%z0, surf_lsm_h%z0, & 2897 surf_usm_h%z0, surf_def_v(0)%z0, surf_lsm_v(0)%z0, & 2898 surf_usm_v(0)%z0, surf_def_v(1)%z0, & 2899 surf_lsm_v(1)%z0, surf_usm_v(1)%z0, & 2900 surf_def_v(2)%z0, surf_lsm_v(2)%z0, & 2901 surf_usm_v(2)%z0, surf_def_v(3)%z0, & 2902 surf_lsm_v(3)%z0, surf_usm_v(3)%z0, n_out ) 2903 2904 CASE ( 'z0h' ) 2905 CALL surface_data_output_sum_up( surf_def_h(0)%z0h, surf_def_h(1)%z0h, & 2906 surf_lsm_h%z0h, surf_usm_h%z0h, surf_def_v(0)%z0h, & 2907 surf_lsm_v(0)%z0h, surf_usm_v(0)%z0h, & 2908 surf_def_v(1)%z0h, surf_lsm_v(1)%z0h, & 2909 surf_usm_v(1)%z0h, surf_def_v(2)%z0h, & 2910 surf_lsm_v(2)%z0h, surf_usm_v(2)%z0h, & 2911 surf_def_v(3)%z0h, surf_lsm_v(3)%z0h, & 2912 surf_usm_v(3)%z0h, n_out ) 2913 2914 CASE ( 'z0q' ) 2915 CALL surface_data_output_sum_up( surf_def_h(0)%z0q, surf_def_h(1)%z0q, & 2916 surf_lsm_h%z0q, surf_usm_h%z0q, surf_def_v(0)%z0q, & 2917 surf_lsm_v(0)%z0q, surf_usm_v(0)%z0q, & 2918 surf_def_v(1)%z0q, surf_lsm_v(1)%z0q, & 2919 surf_usm_v(1)%z0q, surf_def_v(2)%z0q, & 2920 surf_lsm_v(2)%z0q, surf_usm_v(2)%z0q, & 2921 surf_def_v(3)%z0q, surf_lsm_v(3)%z0q, & 2922 surf_usm_v(3)%z0q, n_out ) 2923 2924 CASE ( 'theta1' ) 2925 CALL surface_data_output_sum_up( surf_def_h(0)%pt1, surf_def_h(1)%pt1, & 2926 surf_lsm_h%pt1, surf_usm_h%pt1, surf_def_v(0)%pt1, & 2927 surf_lsm_v(0)%pt1, surf_usm_v(0)%pt1, & 2928 surf_def_v(1)%pt1, surf_lsm_v(1)%pt1, & 2929 surf_usm_v(1)%pt1, surf_def_v(2)%pt1, & 2930 surf_lsm_v(2)%pt1, surf_usm_v(2)%pt1, & 2931 surf_def_v(3)%pt1, surf_lsm_v(3)%pt1, & 2932 surf_usm_v(3)%pt1, n_out ) 2933 2934 CASE ( 'qv1' ) 2935 CALL surface_data_output_sum_up( surf_def_h(0)%qv1, surf_def_h(1)%qv1, & 2936 surf_lsm_h%qv1, surf_usm_h%qv1, surf_def_v(0)%qv1, & 2937 surf_lsm_v(0)%qv1, surf_usm_v(0)%qv1, & 2938 surf_def_v(1)%qv1, surf_lsm_v(1)%qv1, & 2939 surf_usm_v(1)%qv1, surf_def_v(2)%qv1, & 2940 surf_lsm_v(2)%qv1, surf_usm_v(2)%qv1, & 2941 surf_def_v(3)%qv1, surf_lsm_v(3)%qv1, & 2942 surf_usm_v(3)%qv1, n_out ) 2943 2944 CASE ( 'thetav1' ) 2945 CALL surface_data_output_sum_up( surf_def_h(0)%vpt1, surf_def_h(1)%vpt1, & 2946 surf_lsm_h%vpt1, surf_usm_h%vpt1, & 2947 surf_def_v(0)%vpt1, surf_lsm_v(0)%vpt1, & 2948 surf_usm_v(0)%vpt1, surf_def_v(1)%vpt1, & 2949 surf_lsm_v(1)%vpt1, surf_usm_v(1)%vpt1, & 2950 surf_def_v(2)%vpt1, surf_lsm_v(2)%vpt1, & 2951 surf_usm_v(2)%vpt1, surf_def_v(3)%vpt1, & 2952 surf_lsm_v(3)%vpt1, surf_usm_v(3)%vpt1, n_out ) 2953 2954 CASE ( 'usws' ) 2955 CALL surface_data_output_sum_up( surf_def_h(0)%usws, surf_def_h(1)%usws, & 2956 surf_lsm_h%usws, surf_usm_h%usws, & 2957 surf_def_v(0)%usws, surf_lsm_v(0)%usws, & 2958 surf_usm_v(0)%usws, surf_def_v(1)%usws, & 2959 surf_lsm_v(1)%usws, surf_usm_v(1)%usws, & 2960 surf_def_v(2)%usws, surf_lsm_v(2)%usws, & 2961 surf_usm_v(2)%usws, surf_def_v(3)%usws, & 2962 surf_lsm_v(3)%usws, surf_usm_v(3)%usws, n_out, & 2963 momentumflux_output_conversion ) 2964 2965 CASE ( 'vsws' ) 2966 CALL surface_data_output_sum_up( surf_def_h(0)%vsws, surf_def_h(1)%vsws, & 2967 surf_lsm_h%vsws, surf_usm_h%vsws, & 2968 surf_def_v(0)%vsws, surf_lsm_v(0)%vsws, & 2969 surf_usm_v(0)%vsws, surf_def_v(1)%vsws, & 2970 surf_lsm_v(1)%vsws, surf_usm_v(1)%vsws, & 2971 surf_def_v(2)%vsws, surf_lsm_v(2)%vsws, & 2972 surf_usm_v(2)%vsws, surf_def_v(3)%vsws, & 2973 surf_lsm_v(3)%vsws, surf_usm_v(3)%vsws, n_out, & 2974 momentumflux_output_conversion ) 2975 2976 CASE ( 'shf' ) 2977 CALL surface_data_output_sum_up( surf_def_h(0)%shf, surf_def_h(1)%shf, & 2978 surf_lsm_h%shf, surf_usm_h%shf, surf_def_v(0)%shf, & 2979 surf_lsm_v(0)%shf, surf_usm_v(0)%shf, & 2980 surf_def_v(1)%shf, surf_lsm_v(1)%shf, & 2981 surf_usm_v(1)%shf, surf_def_v(2)%shf, & 2982 surf_lsm_v(2)%shf, surf_usm_v(2)%shf, & 2983 surf_def_v(3)%shf, surf_lsm_v(3)%shf, & 2984 surf_usm_v(3)%shf, n_out, heatflux_output_conversion ) 2985 2986 CASE ( 'qsws' ) 2987 CALL surface_data_output_sum_up( surf_def_h(0)%qsws, surf_def_h(1)%qsws, & 2988 surf_lsm_h%qsws, surf_usm_h%qsws, & 2989 surf_def_v(0)%qsws, surf_lsm_v(0)%qsws, & 2990 surf_usm_v(0)%qsws, surf_def_v(1)%qsws, & 2991 surf_lsm_v(1)%qsws, surf_usm_v(1)%qsws, & 2992 surf_def_v(2)%qsws, surf_lsm_v(2)%qsws, & 2993 surf_usm_v(2)%qsws, surf_def_v(3)%qsws, & 2994 surf_lsm_v(3)%qsws, surf_usm_v(3)%qsws, n_out, & 2995 waterflux_output_conversion ) 2996 2997 CASE ( 'ssws' ) 2998 CALL surface_data_output_sum_up( surf_def_h(0)%ssws, surf_def_h(1)%ssws, & 2999 surf_lsm_h%ssws, surf_usm_h%ssws, & 3000 surf_def_v(0)%ssws, surf_lsm_v(0)%ssws, & 3001 surf_usm_v(0)%ssws, surf_def_v(1)%ssws, & 3002 surf_lsm_v(1)%ssws, surf_usm_v(1)%ssws, & 3003 surf_def_v(2)%ssws, surf_lsm_v(2)%ssws, & 3004 surf_usm_v(2)%ssws, surf_def_v(3)%ssws, & 3005 surf_lsm_v(3)%ssws, surf_usm_v(3)%ssws, n_out ) 3006 3007 CASE ( 'qcsws' ) 3008 CALL surface_data_output_sum_up( surf_def_h(0)%qcsws, surf_def_h(1)%qcsws, & 3009 surf_lsm_h%qcsws, surf_usm_h%qcsws, & 3010 surf_def_v(0)%qcsws, surf_lsm_v(0)%qcsws, & 3011 surf_usm_v(0)%qcsws, surf_def_v(1)%qcsws, & 3012 surf_lsm_v(1)%qcsws, surf_usm_v(1)%qcsws, & 3013 surf_def_v(2)%qcsws, surf_lsm_v(2)%qcsws, & 3014 surf_usm_v(2)%qcsws, surf_def_v(3)%qcsws, & 3015 surf_lsm_v(3)%qcsws, surf_usm_v(3)%qcsws, n_out ) 3016 3017 CASE ( 'ncsws' ) 3018 CALL surface_data_output_sum_up( surf_def_h(0)%ncsws, surf_def_h(1)%ncsws, & 3019 surf_lsm_h%ncsws, surf_usm_h%ncsws, & 3020 surf_def_v(0)%ncsws, surf_lsm_v(0)%ncsws, & 3021 surf_usm_v(0)%ncsws, surf_def_v(1)%ncsws, & 3022 surf_lsm_v(1)%ncsws, surf_usm_v(1)%ncsws, & 3023 surf_def_v(2)%ncsws, surf_lsm_v(2)%ncsws, & 3024 surf_usm_v(2)%ncsws, surf_def_v(3)%ncsws, & 3025 surf_lsm_v(3)%ncsws, surf_usm_v(3)%ncsws, n_out ) 3026 3027 CASE ( 'qisws' ) 3028 CALL surface_data_output_sum_up( surf_def_h(0)%qisws, surf_def_h(1)%qisws, & 3029 surf_lsm_h%qisws, surf_usm_h%qisws, & 3030 surf_def_v(0)%qisws, surf_lsm_v(0)%qisws, & 3031 surf_usm_v(0)%qisws, surf_def_v(1)%qisws, & 3032 surf_lsm_v(1)%qisws, surf_usm_v(1)%qisws, & 3033 surf_def_v(2)%qisws, surf_lsm_v(2)%qisws, & 3034 surf_usm_v(2)%qisws, surf_def_v(3)%qisws, & 3035 surf_lsm_v(3)%qisws, surf_usm_v(3)%qisws, n_out ) 3036 3037 CASE ( 'nisws' ) 3038 CALL surface_data_output_sum_up( surf_def_h(0)%nisws, surf_def_h(1)%nisws, & 3039 surf_lsm_h%nisws, surf_usm_h%nisws, & 3040 surf_def_v(0)%nisws, surf_lsm_v(0)%nisws, & 3041 surf_usm_v(0)%nisws, surf_def_v(1)%nisws, & 3042 surf_lsm_v(1)%nisws, surf_usm_v(1)%nisws, & 3043 surf_def_v(2)%nisws, surf_lsm_v(2)%nisws, & 3044 surf_usm_v(2)%nisws, surf_def_v(3)%nisws, & 3045 surf_lsm_v(3)%nisws, surf_usm_v(3)%nisws, n_out ) 3046 3047 CASE ( 'qrsws' ) 3048 CALL surface_data_output_sum_up( surf_def_h(0)%qrsws, surf_def_h(1)%qrsws, & 3049 surf_lsm_h%qrsws, surf_usm_h%qrsws, & 3050 surf_def_v(0)%qrsws, surf_lsm_v(0)%qrsws, & 3051 surf_usm_v(0)%qrsws, surf_def_v(1)%qrsws, & 3052 surf_lsm_v(1)%qrsws, surf_usm_v(1)%qrsws, & 3053 surf_def_v(2)%qrsws, surf_lsm_v(2)%qrsws, & 3054 surf_usm_v(2)%qrsws, surf_def_v(3)%qrsws, & 3055 surf_lsm_v(3)%qrsws, surf_usm_v(3)%qrsws, n_out ) 3056 3057 CASE ( 'nrsws' ) 3058 CALL surface_data_output_sum_up( surf_def_h(0)%nrsws, surf_def_h(1)%nrsws, & 3059 surf_lsm_h%nrsws, surf_usm_h%nrsws, & 3060 surf_def_v(0)%nrsws, surf_lsm_v(0)%nrsws, & 3061 surf_usm_v(0)%nrsws, surf_def_v(1)%nrsws, & 3062 surf_lsm_v(1)%nrsws, surf_usm_v(1)%nrsws, & 3063 surf_def_v(2)%nrsws, surf_lsm_v(2)%nrsws, & 3064 surf_usm_v(2)%nrsws, surf_def_v(3)%nrsws, & 3065 surf_lsm_v(3)%nrsws, surf_usm_v(3)%nrsws, n_out ) 3066 3067 CASE ( 'sasws' ) 3068 CALL surface_data_output_sum_up( surf_def_h(0)%sasws, surf_def_h(1)%sasws, & 3069 surf_lsm_h%sasws, surf_usm_h%sasws, & 3070 surf_def_v(0)%sasws, surf_lsm_v(0)%sasws, & 3071 surf_usm_v(0)%sasws, surf_def_v(1)%sasws, & 3072 surf_lsm_v(1)%sasws, surf_usm_v(1)%sasws, & 3073 surf_def_v(2)%sasws, surf_lsm_v(2)%sasws, & 3074 surf_usm_v(2)%sasws, surf_def_v(3)%sasws, & 3075 surf_lsm_v(3)%sasws, surf_usm_v(3)%sasws, n_out ) 3076 3077 CASE ( 'q_surface' ) 3078 CALL surface_data_output_sum_up( surf_def_h(0)%q_surface, surf_def_h(1)%q_surface, & 3079 surf_lsm_h%q_surface, surf_usm_h%q_surface, & 3080 surf_def_v(0)%q_surface, surf_lsm_v(0)%q_surface, & 3081 surf_usm_v(0)%q_surface, surf_def_v(1)%q_surface, & 3082 surf_lsm_v(1)%q_surface, surf_usm_v(1)%q_surface, & 3083 surf_def_v(2)%q_surface, surf_lsm_v(2)%q_surface, & 3084 surf_usm_v(2)%q_surface, surf_def_v(3)%q_surface, & 3085 surf_lsm_v(3)%q_surface, surf_usm_v(3)%q_surface, & 3086 n_out ) 3087 3088 3089 CASE ( 'theta_surface' ) 3090 CALL surface_data_output_sum_up( surf_def_h(0)%pt_surface, surf_def_h(1)%pt_surface, & 3091 surf_lsm_h%pt_surface, surf_usm_h%pt_surface, & 3092 surf_def_v(0)%pt_surface, surf_lsm_v(0)%pt_surface, & 3093 surf_usm_v(0)%pt_surface, surf_def_v(1)%pt_surface, & 3094 surf_lsm_v(1)%pt_surface, surf_usm_v(1)%pt_surface, & 3095 surf_def_v(2)%pt_surface, surf_lsm_v(2)%pt_surface, & 3096 surf_usm_v(2)%pt_surface, surf_def_v(3)%pt_surface, & 3097 surf_lsm_v(3)%pt_surface, surf_usm_v(3)%pt_surface, & 3098 n_out ) 3099 3100 CASE ( 'thetav_surface' ) 3101 CALL surface_data_output_sum_up( surf_def_h(0)%vpt_surface, & 3102 surf_def_h(1)%vpt_surface, surf_lsm_h%vpt_surface, & 3103 surf_usm_h%vpt_surface, surf_def_v(0)%vpt_surface, & 3104 surf_lsm_v(0)%vpt_surface, & 3105 surf_usm_v(0)%vpt_surface, & 3106 surf_def_v(1)%vpt_surface, & 3107 surf_lsm_v(1)%vpt_surface, & 3108 surf_usm_v(1)%vpt_surface, & 3109 surf_def_v(2)%vpt_surface, & 3110 surf_lsm_v(2)%vpt_surface, & 3111 surf_usm_v(2)%vpt_surface, & 3112 surf_def_v(3)%vpt_surface, & 3113 surf_lsm_v(3)%vpt_surface, & 3114 surf_usm_v(3)%vpt_surface, n_out ) 3115 3116 CASE ( 'rad_net' ) 3117 CALL surface_data_output_sum_up( surf_def_h(0)%rad_net, surf_def_h(1)%rad_net, & 3118 surf_lsm_h%rad_net, surf_usm_h%rad_net, & 3119 surf_def_v(0)%rad_net, surf_lsm_v(0)%rad_net, & 3120 surf_usm_v(0)%rad_net, surf_def_v(1)%rad_net, & 3121 surf_lsm_v(1)%rad_net, surf_usm_v(1)%rad_net, & 3122 surf_def_v(2)%rad_net, surf_lsm_v(2)%rad_net, & 3123 surf_usm_v(2)%rad_net, surf_def_v(3)%rad_net, & 3124 surf_lsm_v(3)%rad_net, surf_usm_v(3)%rad_net, n_out ) 3125 3126 CASE ( 'rad_lw_in' ) 3127 CALL surface_data_output_sum_up( surf_def_h(0)%rad_lw_in, surf_def_h(1)%rad_lw_in, & 3128 surf_lsm_h%rad_lw_in, surf_usm_h%rad_lw_in, & 3129 surf_def_v(0)%rad_lw_in, surf_lsm_v(0)%rad_lw_in, & 3130 surf_usm_v(0)%rad_lw_in, surf_def_v(1)%rad_lw_in, & 3131 surf_lsm_v(1)%rad_lw_in, surf_usm_v(1)%rad_lw_in, & 3132 surf_def_v(2)%rad_lw_in, surf_lsm_v(2)%rad_lw_in, & 3133 surf_usm_v(2)%rad_lw_in, surf_def_v(3)%rad_lw_in, & 3134 surf_lsm_v(3)%rad_lw_in, surf_usm_v(3)%rad_lw_in, & 3135 n_out ) 3136 3137 CASE ( 'rad_lw_out' ) 3138 CALL surface_data_output_sum_up( surf_def_h(0)%rad_lw_out, surf_def_h(1)%rad_lw_out, & 3139 surf_lsm_h%rad_lw_out, surf_usm_h%rad_lw_out, & 3140 surf_def_v(0)%rad_lw_out, surf_lsm_v(0)%rad_lw_out, & 3141 surf_usm_v(0)%rad_lw_out, surf_def_v(1)%rad_lw_out, & 3142 surf_lsm_v(1)%rad_lw_out, surf_usm_v(1)%rad_lw_out, & 3143 surf_def_v(2)%rad_lw_out, surf_lsm_v(2)%rad_lw_out, & 3144 surf_usm_v(2)%rad_lw_out, surf_def_v(3)%rad_lw_out, & 3145 surf_lsm_v(3)%rad_lw_out, surf_usm_v(3)%rad_lw_out, & 3146 n_out ) 3147 3148 CASE ( 'rad_sw_in' ) 3149 CALL surface_data_output_sum_up( surf_def_h(0)%rad_sw_in, surf_def_h(1)%rad_sw_in, & 3150 surf_lsm_h%rad_sw_in, surf_usm_h%rad_sw_in, & 3151 surf_def_v(0)%rad_sw_in, surf_lsm_v(0)%rad_sw_in, & 3152 surf_usm_v(0)%rad_sw_in, surf_def_v(1)%rad_sw_in, & 3153 surf_lsm_v(1)%rad_sw_in, surf_usm_v(1)%rad_sw_in, & 3154 surf_def_v(2)%rad_sw_in, surf_lsm_v(2)%rad_sw_in, & 3155 surf_usm_v(2)%rad_sw_in, surf_def_v(3)%rad_sw_in, & 3156 surf_lsm_v(3)%rad_sw_in, surf_usm_v(3)%rad_sw_in, & 3157 n_out ) 3158 3159 CASE ( 'rad_sw_out' ) 3160 CALL surface_data_output_sum_up( surf_def_h(0)%rad_sw_out, surf_def_h(1)%rad_sw_out, & 3161 surf_lsm_h%rad_sw_out, surf_usm_h%rad_sw_out, & 3162 surf_def_v(0)%rad_sw_out, surf_lsm_v(0)%rad_sw_out, & 3163 surf_usm_v(0)%rad_sw_out, surf_def_v(1)%rad_sw_out, & 3164 surf_lsm_v(1)%rad_sw_out, surf_usm_v(1)%rad_sw_out, & 3165 surf_def_v(2)%rad_sw_out, surf_lsm_v(2)%rad_sw_out, & 3166 surf_usm_v(2)%rad_sw_out, surf_def_v(3)%rad_sw_out, & 3167 surf_lsm_v(3)%rad_sw_out, surf_usm_v(3)%rad_sw_out, & 3168 n_out ) 3169 3170 CASE ( 'ghf' ) 3171 ! 3172 !-- Sum up ground / wall heat flux. Note, for urban surfaces the wall heat flux is 3173 !-- aggregated from the different green, window and wall tiles. 3174 DO m = 1, surf_usm_h%ns 3175 surf_usm_h%ghf(m) = surf_usm_h%frac(m,ind_veg_wall) * surf_usm_h%wghf_eb(m) + & 3176 surf_usm_h%frac(m,ind_pav_green) * & 3177 surf_usm_h%wghf_eb_green(m) + surf_usm_h%frac(m,ind_wat_win) * & 3178 surf_usm_h%wghf_eb_window(m) 3179 ENDDO 3180 DO l = 0, 3 3181 DO m = 1, surf_usm_v(l)%ns 3182 surf_usm_v(l)%ghf(m) = surf_usm_v(l)%frac(m,ind_veg_wall) * & 3183 surf_usm_v(l)%wghf_eb(m) + & 3184 surf_usm_v(l)%frac(m,ind_pav_green) * & 3185 surf_usm_v(l)%wghf_eb_green(m) + & 3186 surf_usm_v(l)%frac(m,ind_wat_win) * & 3187 surf_usm_v(l)%wghf_eb_window(m) 3188 ENDDO 3189 ENDDO 3190 3191 CALL surface_data_output_sum_up( surf_def_h(0)%ghf, surf_def_h(1)%ghf, & 3192 surf_lsm_h%ghf, surf_usm_h%ghf, surf_def_v(0)%ghf, & 3193 surf_lsm_v(0)%ghf, surf_usm_v(0)%ghf, & 3194 surf_def_v(1)%ghf, surf_lsm_v(1)%ghf, & 3195 surf_usm_v(1)%ghf, surf_def_v(2)%ghf, & 3196 surf_lsm_v(2)%ghf, surf_usm_v(2)%ghf, & 3197 surf_def_v(3)%ghf, surf_lsm_v(3)%ghf, & 3198 surf_usm_v(3)%ghf, n_out ) 3199 3200 CASE ( 'r_a' ) 3201 CALL surface_data_output_sum_up( surf_def_h(0)%r_a, surf_def_h(1)%r_a, & 3202 surf_lsm_h%r_a, surf_usm_h%r_a, & 3203 surf_def_v(0)%r_a, surf_lsm_v(0)%r_a, & 3204 surf_usm_v(0)%r_a, surf_def_v(1)%r_a, & 3205 surf_lsm_v(1)%r_a, surf_usm_v(1)%r_a, & 3206 surf_def_v(2)%r_a, surf_lsm_v(2)%r_a, & 3207 surf_usm_v(2)%r_a, surf_def_v(3)%r_a, & 3208 surf_lsm_v(3)%r_a, surf_usm_v(3)%r_a, n_out ) 3209 3210 CASE ( 'r_soil' ) 3211 CALL surface_data_output_sum_up( surf_def_h(0)%r_soil, surf_def_h(1)%r_soil, & 3212 surf_lsm_h%r_soil, surf_usm_h%r_soil, & 3213 surf_def_v(0)%r_soil, surf_lsm_v(0)%r_soil, & 3214 surf_usm_v(0)%r_soil, surf_def_v(1)%r_soil, & 3215 surf_lsm_v(1)%r_soil, surf_usm_v(1)%r_soil, & 3216 surf_def_v(2)%r_soil, surf_lsm_v(2)%r_soil, & 3217 surf_usm_v(2)%r_soil, surf_def_v(3)%r_soil, & 3218 surf_lsm_v(3)%r_soil, surf_usm_v(3)%r_soil, n_out ) 3219 3220 CASE ( 'r_canopy' ) 3221 CALL surface_data_output_sum_up( surf_def_h(0)%r_canopy, surf_def_h(1)%r_canopy, & 3222 surf_lsm_h%r_canopy, surf_usm_h%r_canopy, & 3223 surf_def_v(0)%r_canopy, surf_lsm_v(0)%r_canopy, & 3224 surf_usm_v(0)%r_canopy, surf_def_v(1)%r_canopy, & 3225 surf_lsm_v(1)%r_canopy, surf_usm_v(1)%r_canopy, & 3226 surf_def_v(2)%r_canopy, surf_lsm_v(2)%r_canopy, & 3227 surf_usm_v(2)%r_canopy, surf_def_v(3)%r_canopy, & 3228 surf_lsm_v(3)%r_canopy, surf_usm_v(3)%r_canopy, & 3229 n_out ) 3230 3231 CASE ( 'r_s' ) 3232 CALL surface_data_output_sum_up( surf_def_h(0)%r_s, surf_def_h(1)%r_s, & 3233 surf_lsm_h%r_s, surf_usm_h%r_s, surf_def_v(0)%r_s, & 3234 surf_lsm_v(0)%r_s, surf_usm_v(0)%r_s, & 3235 surf_def_v(1)%r_s, surf_lsm_v(1)%r_s, & 3236 surf_usm_v(1)%r_s, surf_def_v(2)%r_s, & 3237 surf_lsm_v(2)%r_s, surf_usm_v(2)%r_s, & 3238 surf_def_v(3)%r_s, surf_lsm_v(3)%r_s, & 3239 surf_usm_v(3)%r_s, n_out ) 3240 3241 3242 CASE ( 'rad_sw_dir' ) 3243 CALL surface_data_output_sum_up( surf_def_h(0)%rad_sw_dir, surf_def_h(1)%rad_sw_dir, & 3244 surf_lsm_h%rad_sw_dir, surf_usm_h%rad_sw_dir, & 3245 surf_def_v(0)%rad_sw_dir, surf_lsm_v(0)%rad_sw_dir, & 3246 surf_usm_v(0)%rad_sw_dir, surf_def_v(1)%rad_sw_dir, & 3247 surf_lsm_v(1)%rad_sw_dir, surf_usm_v(1)%rad_sw_dir, & 3248 surf_def_v(2)%rad_sw_dir, surf_lsm_v(2)%rad_sw_dir, & 3249 surf_usm_v(2)%rad_sw_dir, surf_def_v(3)%rad_sw_dir, & 3250 surf_lsm_v(3)%rad_sw_dir, surf_usm_v(3)%rad_sw_dir, & 3251 n_out ) 3252 CASE ( 'rad_sw_dif' ) 3253 CALL surface_data_output_sum_up( surf_def_h(0)%rad_sw_dif, surf_def_h(1)%rad_sw_dif, & 3254 surf_lsm_h%rad_sw_dif, surf_usm_h%rad_sw_dif, & 3255 surf_def_v(0)%rad_sw_dif, surf_lsm_v(0)%rad_sw_dif, & 3256 surf_usm_v(0)%rad_sw_dif, surf_def_v(1)%rad_sw_dif, & 3257 surf_lsm_v(1)%rad_sw_dif, surf_usm_v(1)%rad_sw_dif, & 3258 surf_def_v(2)%rad_sw_dif, surf_lsm_v(2)%rad_sw_dif, & 3259 surf_usm_v(2)%rad_sw_dif, surf_def_v(3)%rad_sw_dif, & 3260 surf_lsm_v(3)%rad_sw_dif, surf_usm_v(3)%rad_sw_dif, & 3261 n_out ) 3262 3263 CASE ( 'rad_sw_ref' ) 3264 CALL surface_data_output_sum_up( surf_def_h(0)%rad_sw_ref, surf_def_h(1)%rad_sw_ref, & 3265 surf_lsm_h%rad_sw_ref, surf_usm_h%rad_sw_ref, & 3266 surf_def_v(0)%rad_sw_ref, surf_lsm_v(0)%rad_sw_ref, & 3267 surf_usm_v(0)%rad_sw_ref, surf_def_v(1)%rad_sw_ref, & 3268 surf_lsm_v(1)%rad_sw_ref, surf_usm_v(1)%rad_sw_ref, & 3269 surf_def_v(2)%rad_sw_ref, surf_lsm_v(2)%rad_sw_ref, & 3270 surf_usm_v(2)%rad_sw_ref, surf_def_v(3)%rad_sw_ref, & 3271 surf_lsm_v(3)%rad_sw_ref, surf_usm_v(3)%rad_sw_ref, & 3272 n_out ) 3273 3274 CASE ( 'rad_sw_res' ) 3275 CALL surface_data_output_sum_up( surf_def_h(0)%rad_sw_res, surf_def_h(1)%rad_sw_res, & 3276 surf_lsm_h%rad_sw_res, surf_usm_h%rad_sw_res, & 3277 surf_def_v(0)%rad_sw_res, surf_lsm_v(0)%rad_sw_res, & 3278 surf_usm_v(0)%rad_sw_res, surf_def_v(1)%rad_sw_res, & 3279 surf_lsm_v(1)%rad_sw_res, surf_usm_v(1)%rad_sw_res, & 3280 surf_def_v(2)%rad_sw_res, surf_lsm_v(2)%rad_sw_res, & 3281 surf_usm_v(2)%rad_sw_res, surf_def_v(3)%rad_sw_res, & 3282 surf_lsm_v(3)%rad_sw_res, surf_usm_v(3)%rad_sw_res, & 3283 n_out ) 3284 3285 CASE ( 'rad_lw_dif' ) 3286 CALL surface_data_output_sum_up( surf_def_h(0)%rad_lw_dif, surf_def_h(1)%rad_lw_dif, & 3287 surf_lsm_h%rad_lw_dif, surf_usm_h%rad_lw_dif, & 3288 surf_def_v(0)%rad_lw_dif, surf_lsm_v(0)%rad_lw_dif, & 3289 surf_usm_v(0)%rad_lw_dif, surf_def_v(1)%rad_lw_dif, & 3290 surf_lsm_v(1)%rad_lw_dif, surf_usm_v(1)%rad_lw_dif, & 3291 surf_def_v(2)%rad_lw_dif, surf_lsm_v(2)%rad_lw_dif, & 3292 surf_usm_v(2)%rad_lw_dif, surf_def_v(3)%rad_lw_dif, & 3293 surf_lsm_v(3)%rad_lw_dif, surf_usm_v(3)%rad_lw_dif, & 3294 n_out ) 3295 3296 CASE ( 'rad_lw_ref' ) 3297 CALL surface_data_output_sum_up( surf_def_h(0)%rad_lw_ref, surf_def_h(1)%rad_lw_ref, & 3298 surf_lsm_h%rad_lw_ref, surf_usm_h%rad_lw_ref, & 3299 surf_def_v(0)%rad_lw_ref, surf_lsm_v(0)%rad_lw_ref, & 3300 surf_usm_v(0)%rad_lw_ref, surf_def_v(1)%rad_lw_ref, & 3301 surf_lsm_v(1)%rad_lw_ref, surf_usm_v(1)%rad_lw_ref, & 3302 surf_def_v(2)%rad_lw_ref, surf_lsm_v(2)%rad_lw_ref, & 3303 surf_usm_v(2)%rad_lw_ref, surf_def_v(3)%rad_lw_ref, & 3304 surf_lsm_v(3)%rad_lw_ref, surf_usm_v(3)%rad_lw_ref, & 3305 n_out ) 3306 3307 CASE ( 'rad_lw_res' ) 3308 CALL surface_data_output_sum_up( surf_def_h(0)%rad_lw_res, surf_def_h(1)%rad_lw_res, & 3309 surf_lsm_h%rad_lw_res, surf_usm_h%rad_lw_res, & 3310 surf_def_v(0)%rad_lw_res, surf_lsm_v(0)%rad_lw_res, & 3311 surf_usm_v(0)%rad_lw_res, surf_def_v(1)%rad_lw_res, & 3312 surf_lsm_v(1)%rad_lw_res, surf_usm_v(1)%rad_lw_res, & 3313 surf_def_v(2)%rad_lw_res, surf_lsm_v(2)%rad_lw_res, & 3314 surf_usm_v(2)%rad_lw_res, surf_def_v(3)%rad_lw_res, & 3315 surf_lsm_v(3)%rad_lw_res, surf_usm_v(3)%rad_lw_res, & 3316 n_out ) 3317 3318 CASE ( 'uvw1' ) 3319 CALL surface_data_output_sum_up( surf_def_h(0)%uvw_abs, surf_def_h(1)%uvw_abs, & 3320 surf_lsm_h%uvw_abs, surf_usm_h%uvw_abs, & 3321 surf_def_v(0)%uvw_abs, surf_lsm_v(0)%uvw_abs, & 3322 surf_usm_v(0)%uvw_abs, surf_def_v(1)%uvw_abs, & 3323 surf_lsm_v(1)%uvw_abs, surf_usm_v(1)%uvw_abs, & 3324 surf_def_v(2)%uvw_abs, surf_lsm_v(2)%uvw_abs, & 3325 surf_usm_v(2)%uvw_abs, surf_def_v(3)%uvw_abs, & 3326 surf_lsm_v(3)%uvw_abs, surf_usm_v(3)%uvw_abs, n_out ) 3327 3328 CASE ( 'waste_heat' ) 3329 CALL surface_data_output_sum_up( surf_def_h(0)%waste_heat, surf_def_h(1)%waste_heat, & 3330 surf_lsm_h%waste_heat, surf_usm_h%waste_heat, & 3331 surf_def_v(0)%waste_heat, surf_lsm_v(0)%waste_heat, & 3332 surf_usm_v(0)%waste_heat, surf_def_v(1)%waste_heat, & 3333 surf_lsm_v(1)%waste_heat, surf_usm_v(1)%waste_heat, & 3334 surf_def_v(2)%waste_heat, surf_lsm_v(2)%waste_heat, & 3335 surf_usm_v(2)%waste_heat, surf_def_v(3)%waste_heat, & 3336 surf_lsm_v(3)%waste_heat, surf_usm_v(3)%waste_heat, & 3337 n_out ) 3338 3339 CASE ( 'im_hf' ) 3340 CALL surface_data_output_sum_up( surf_def_h(0)%iwghf_eb, surf_def_h(1)%iwghf_eb, & 3341 surf_lsm_h%iwghf_eb, surf_usm_h%iwghf_eb, & 3342 surf_def_v(0)%iwghf_eb, surf_lsm_v(0)%iwghf_eb, & 3343 surf_usm_v(0)%iwghf_eb, surf_def_v(1)%iwghf_eb, & 3344 surf_lsm_v(1)%iwghf_eb, surf_usm_v(1)%iwghf_eb, & 3345 surf_def_v(2)%iwghf_eb, surf_lsm_v(2)%iwghf_eb, & 3346 surf_usm_v(2)%iwghf_eb, surf_def_v(3)%iwghf_eb, & 3347 surf_lsm_v(3)%iwghf_eb, surf_usm_v(3)%iwghf_eb, n_out ) 3348 3349 CASE ( 'albedo' ) 3350 CALL surface_data_output_sum_up( surf_def_h(0)%albedo, surf_def_h(1)%albedo, & 3351 surf_lsm_h%albedo, surf_usm_h%albedo, & 3352 surf_def_v(0)%albedo, surf_lsm_v(0)%albedo, & 3353 surf_usm_v(0)%albedo, surf_def_v(1)%albedo, & 3354 surf_lsm_v(1)%albedo, surf_usm_v(1)%albedo, & 3355 surf_def_v(2)%albedo, surf_lsm_v(2)%albedo, & 3356 surf_usm_v(2)%albedo, surf_def_v(3)%albedo, & 3357 surf_lsm_v(3)%albedo, surf_usm_v(3)%albedo, n_out ) 3358 3359 3360 CASE ( 'emissivity' ) 3361 CALL surface_data_output_sum_up( surf_def_h(0)%emissivity, surf_def_h(1)%emissivity, & 3362 surf_lsm_h%emissivity, surf_usm_h%emissivity, & 3363 surf_def_v(0)%emissivity, surf_lsm_v(0)%emissivity, & 3364 surf_usm_v(0)%emissivity, surf_def_v(1)%emissivity, & 3365 surf_lsm_v(1)%emissivity, surf_usm_v(1)%emissivity, & 3366 surf_def_v(2)%emissivity, surf_lsm_v(2)%emissivity, & 3367 surf_usm_v(2)%emissivity, surf_def_v(3)%emissivity, & 3368 surf_lsm_v(3)%emissivity, surf_usm_v(3)%emissivity, & 3369 n_out ) 3370 3371 END SELECT 3372 ENDDO 3373 3374 3375 END SUBROUTINE surface_data_output_averaging 3376 3377 !--------------------------------------------------------------------------------------------------! 4226 3378 ! Description: 4227 3379 ! ------------ 4228 3380 !> Sum-up the surface data for average output variables. 4229 !------------------------------------------------------------------------------! 4230 SUBROUTINE surface_data_output_sum_up_1d( var_def_h0, var_def_h1, & 4231 var_lsm_h, var_usm_h, & 4232 var_def_v0, var_lsm_v0, var_usm_v0, & 4233 var_def_v1, var_lsm_v1, var_usm_v1, & 4234 var_def_v2, var_lsm_v2, var_usm_v2, & 4235 var_def_v3, var_lsm_v3, var_usm_v3, n_out,& 4236 fac ) 4237 4238 IMPLICIT NONE 4239 4240 INTEGER(iwp) :: k !< height index of surface element 4241 INTEGER(iwp) :: m !< running index for surface elements 4242 INTEGER(iwp) :: n_out !< index for output variable 4243 INTEGER(iwp) :: n_surf !< running index for surface elements 4244 4245 REAL(wp), DIMENSION(:), OPTIONAL :: fac !< passed output conversion factor for heatflux output 4246 REAL(wp), DIMENSION(nzb:nzt+1) :: conversion_factor !< effective array for output conversion factor 4247 4248 REAL(wp), DIMENSION(:), ALLOCATABLE, INTENT(IN) :: var_def_h0 !< output variable at upward-facing default-type surfaces 4249 REAL(wp), DIMENSION(:), ALLOCATABLE, INTENT(IN) :: var_def_h1 !< output variable at downward-facing default-type surfaces 4250 REAL(wp), DIMENSION(:), ALLOCATABLE, INTENT(IN) :: var_lsm_h !< output variable at upward-facing natural-type surfaces 4251 REAL(wp), DIMENSION(:), ALLOCATABLE, INTENT(IN) :: var_usm_h !< output variable at upward-facing urban-type surfaces 4252 REAL(wp), DIMENSION(:), ALLOCATABLE, INTENT(IN) :: var_def_v0 !< output variable at northward-facing default-type surfaces 4253 REAL(wp), DIMENSION(:), ALLOCATABLE, INTENT(IN) :: var_def_v1 !< output variable at southward-facing default-type surfaces 4254 REAL(wp), DIMENSION(:), ALLOCATABLE, INTENT(IN) :: var_def_v2 !< output variable at eastward-facing default-type surfaces 4255 REAL(wp), DIMENSION(:), ALLOCATABLE, INTENT(IN) :: var_def_v3 !< output variable at westward-facing default-type surfaces 4256 REAL(wp), DIMENSION(:), ALLOCATABLE, INTENT(IN) :: var_lsm_v0 !< output variable at northward-facing natural-type surfaces 4257 REAL(wp), DIMENSION(:), ALLOCATABLE, INTENT(IN) :: var_lsm_v1 !< output variable at southward-facing natural-type surfaces 4258 REAL(wp), DIMENSION(:), ALLOCATABLE, INTENT(IN) :: var_lsm_v2 !< output variable at eastward-facing natural-type surfaces 4259 REAL(wp), DIMENSION(:), ALLOCATABLE, INTENT(IN) :: var_lsm_v3 !< output variable at westward-facing natural-type surfaces 4260 REAL(wp), DIMENSION(:), ALLOCATABLE, INTENT(IN) :: var_usm_v0 !< output variable at northward-facing urban-type surfaces 4261 REAL(wp), DIMENSION(:), ALLOCATABLE, INTENT(IN) :: var_usm_v1 !< output variable at southward-facing urban-type surfaces 4262 REAL(wp), DIMENSION(:), ALLOCATABLE, INTENT(IN) :: var_usm_v2 !< output variable at eastward-facing urban-type surfaces 4263 REAL(wp), DIMENSION(:), ALLOCATABLE, INTENT(IN) :: var_usm_v3 !< output variable at westward-facing urban-type surfaces 4264 4265 ! 4266 !-- Set conversion factor to one if not present 4267 IF ( .NOT. PRESENT( fac ) ) THEN 4268 conversion_factor = 1.0_wp 4269 ELSE 4270 conversion_factor = fac 4271 ENDIF 4272 ! 4273 !-- Set counter variable to zero before the variable is written to 4274 !-- the output array. 4275 n_surf = 0 4276 4277 ! 4278 !-- Write the horizontal surfaces. 4279 !-- Before each the variable is written to the output data structure, first 4280 !-- check if the variable for the respective surface type is defined. 4281 !-- If a variable is not defined, skip the block and increment the counter 4282 !-- variable by the number of surface elements of this type. Usually this 4283 !-- is zere, however, there might be the situation that e.g. urban surfaces 4284 !-- are defined but the respective variable is not allocated for this surface 4285 !-- type. To write the data on the exact position, increment the counter. 4286 IF ( ALLOCATED( var_def_h0 ) ) THEN 4287 DO m = 1, surf_def_h(0)%ns 4288 n_surf = n_surf + 1 4289 k = surf_def_h(0)%k(m) 4290 surfaces%var_av(n_surf,n_out) = surfaces%var_av(n_surf,n_out) & 4291 + var_def_h0(m) * conversion_factor(k) 4292 ENDDO 4293 ELSE 4294 n_surf = n_surf + surf_def_h(0)%ns 4295 ENDIF 4296 IF ( ALLOCATED( var_def_h1 ) ) THEN 4297 DO m = 1, surf_def_h(1)%ns 4298 n_surf = n_surf + 1 4299 k = surf_def_h(1)%k(m) 4300 surfaces%var_av(n_surf,n_out) = surfaces%var_av(n_surf,n_out) & 4301 + var_def_h1(m) * conversion_factor(k) 4302 ENDDO 4303 ELSE 4304 n_surf = n_surf + surf_def_h(1)%ns 4305 ENDIF 4306 IF ( ALLOCATED( var_lsm_h ) ) THEN 4307 DO m = 1, surf_lsm_h%ns 4308 n_surf = n_surf + 1 4309 k = surf_lsm_h%k(m) 4310 surfaces%var_av(n_surf,n_out) = surfaces%var_av(n_surf,n_out) & 4311 + var_lsm_h(m) * conversion_factor(k) 4312 ENDDO 4313 ELSE 4314 n_surf = n_surf + surf_lsm_h%ns 4315 ENDIF 4316 IF ( ALLOCATED( var_usm_h ) ) THEN 4317 DO m = 1, surf_usm_h%ns 4318 n_surf = n_surf + 1 4319 k = surf_usm_h%k(m) 4320 surfaces%var_av(n_surf,n_out) = surfaces%var_av(n_surf,n_out) & 4321 + var_usm_h(m) * conversion_factor(k) 4322 ENDDO 4323 ELSE 4324 n_surf = n_surf + surf_usm_h%ns 4325 ENDIF 4326 ! 4327 !-- Write northward-facing 4328 IF ( ALLOCATED( var_def_v0 ) ) THEN 4329 DO m = 1, surf_def_v(0)%ns 4330 n_surf = n_surf + 1 4331 k = surf_def_v(0)%k(m) 4332 surfaces%var_av(n_surf,n_out) = surfaces%var_av(n_surf,n_out) & 4333 + var_def_v0(m) * conversion_factor(k) 4334 ENDDO 4335 ELSE 4336 n_surf = n_surf + surf_def_v(0)%ns 4337 ENDIF 4338 IF ( ALLOCATED( var_lsm_v0 ) ) THEN 4339 DO m = 1, surf_lsm_v(0)%ns 4340 n_surf = n_surf + 1 4341 k = surf_lsm_v(0)%k(m) 4342 surfaces%var_av(n_surf,n_out) = surfaces%var_av(n_surf,n_out) & 4343 + var_lsm_v0(m) * conversion_factor(k) 4344 ENDDO 4345 ELSE 4346 n_surf = n_surf + surf_lsm_v(0)%ns 4347 ENDIF 4348 IF ( ALLOCATED( var_usm_v0 ) ) THEN 4349 DO m = 1, surf_usm_v(0)%ns 4350 n_surf = n_surf + 1 4351 k = surf_usm_v(0)%k(m) 4352 surfaces%var_av(n_surf,n_out) = surfaces%var_av(n_surf,n_out) & 4353 + var_usm_v0(m) * conversion_factor(k) 4354 ENDDO 4355 ELSE 4356 n_surf = n_surf + surf_usm_v(0)%ns 4357 ENDIF 4358 ! 4359 !-- Write southward-facing 4360 IF ( ALLOCATED( var_def_v1 ) ) THEN 4361 DO m = 1, surf_def_v(1)%ns 4362 n_surf = n_surf + 1 4363 k = surf_def_v(1)%k(m) 4364 surfaces%var_av(n_surf,n_out) = surfaces%var_av(n_surf,n_out) & 4365 + var_def_v1(m) * conversion_factor(k) 4366 ENDDO 4367 ELSE 4368 n_surf = n_surf + surf_def_v(1)%ns 4369 ENDIF 4370 IF ( ALLOCATED( var_lsm_v1 ) ) THEN 4371 DO m = 1, surf_lsm_v(1)%ns 4372 n_surf = n_surf + 1 4373 k = surf_lsm_v(1)%k(m) 4374 surfaces%var_av(n_surf,n_out) = surfaces%var_av(n_surf,n_out) & 4375 + var_lsm_v1(m) * conversion_factor(k) 4376 ENDDO 4377 ELSE 4378 n_surf = n_surf + surf_lsm_v(1)%ns 4379 ENDIF 4380 IF ( ALLOCATED( var_usm_v1 ) ) THEN 4381 DO m = 1, surf_usm_v(1)%ns 4382 n_surf = n_surf + 1 4383 k = surf_usm_v(1)%k(m) 4384 surfaces%var_av(n_surf,n_out) = surfaces%var_av(n_surf,n_out) & 4385 + var_usm_v1(m) * conversion_factor(k) 4386 ENDDO 4387 ELSE 4388 n_surf = n_surf + surf_usm_v(1)%ns 4389 ENDIF 4390 ! 4391 !-- Write eastward-facing 4392 IF ( ALLOCATED( var_def_v2 ) ) THEN 4393 DO m = 1, surf_def_v(2)%ns 4394 n_surf = n_surf + 1 4395 k = surf_def_v(2)%k(m) 4396 surfaces%var_av(n_surf,n_out) = surfaces%var_av(n_surf,n_out) & 4397 + var_def_v2(m) * conversion_factor(k) 4398 ENDDO 4399 ELSE 4400 n_surf = n_surf + surf_def_v(2)%ns 4401 ENDIF 4402 IF ( ALLOCATED( var_lsm_v2 ) ) THEN 4403 DO m = 1, surf_lsm_v(2)%ns 4404 n_surf = n_surf + 1 4405 k = surf_lsm_v(2)%k(m) 4406 surfaces%var_av(n_surf,n_out) = surfaces%var_av(n_surf,n_out) & 4407 + var_lsm_v2(m) * conversion_factor(k) 4408 ENDDO 4409 ELSE 4410 n_surf = n_surf + surf_lsm_v(2)%ns 4411 ENDIF 4412 IF ( ALLOCATED( var_usm_v2 ) ) THEN 4413 DO m = 1, surf_usm_v(2)%ns 4414 n_surf = n_surf + 1 4415 k = surf_usm_v(2)%k(m) 4416 surfaces%var_av(n_surf,n_out) = surfaces%var_av(n_surf,n_out) & 4417 + var_usm_v2(m) * conversion_factor(k) 4418 ENDDO 4419 ELSE 4420 n_surf = n_surf + surf_usm_v(2)%ns 4421 ENDIF 4422 ! 4423 !-- Write westward-facing 4424 IF ( ALLOCATED( var_def_v3 ) ) THEN 4425 DO m = 1, surf_def_v(3)%ns 4426 n_surf = n_surf + 1 4427 k = surf_def_v(3)%k(m) 4428 surfaces%var_av(n_surf,n_out) = surfaces%var_av(n_surf,n_out) & 4429 + var_def_v3(m) * conversion_factor(k) 4430 ENDDO 4431 ELSE 4432 n_surf = n_surf + surf_def_v(3)%ns 4433 ENDIF 4434 IF ( ALLOCATED( var_lsm_v3 ) ) THEN 4435 DO m = 1, surf_lsm_v(3)%ns 4436 n_surf = n_surf + 1 4437 k = surf_lsm_v(3)%k(m) 4438 surfaces%var_av(n_surf,n_out) = surfaces%var_av(n_surf,n_out) & 4439 + var_lsm_v3(m) * conversion_factor(k) 4440 ENDDO 4441 ELSE 4442 n_surf = n_surf + surf_lsm_v(3)%ns 4443 ENDIF 4444 IF ( ALLOCATED( var_usm_v3 ) ) THEN 4445 DO m = 1, surf_usm_v(3)%ns 4446 n_surf = n_surf + 1 4447 k = surf_usm_v(3)%k(m) 4448 surfaces%var_av(n_surf,n_out) = surfaces%var_av(n_surf,n_out) & 4449 + var_usm_v3(m) * conversion_factor(k) 4450 ENDDO 4451 ELSE 4452 n_surf = n_surf + surf_usm_v(3)%ns 4453 ENDIF 4454 4455 END SUBROUTINE surface_data_output_sum_up_1d 4456 4457 !------------------------------------------------------------------------------! 3381 !--------------------------------------------------------------------------------------------------! 3382 SUBROUTINE surface_data_output_sum_up_1d( var_def_h0, var_def_h1, var_lsm_h, var_usm_h, & 3383 var_def_v0, var_lsm_v0, var_usm_v0, var_def_v1, & 3384 var_lsm_v1, var_usm_v1, var_def_v2, var_lsm_v2, & 3385 var_usm_v2, var_def_v3, var_lsm_v3, var_usm_v3, n_out, & 3386 fac ) 3387 3388 IMPLICIT NONE 3389 3390 INTEGER(iwp) :: k !< height index of surface element 3391 INTEGER(iwp) :: m !< running index for surface elements 3392 INTEGER(iwp) :: n_out !< index for output variable 3393 INTEGER(iwp) :: n_surf !< running index for surface elements 3394 3395 REAL(wp), DIMENSION(:), OPTIONAL :: fac !< passed output conversion factor for heatflux output 3396 REAL(wp), DIMENSION(nzb:nzt+1) :: conversion_factor !< effective array for output conversion factor 3397 3398 REAL(wp), DIMENSION(:), ALLOCATABLE, INTENT(IN) :: var_def_h0 !< output variable at upward-facing default-type surfaces 3399 REAL(wp), DIMENSION(:), ALLOCATABLE, INTENT(IN) :: var_def_h1 !< output variable at downward-facing default-type surfaces 3400 REAL(wp), DIMENSION(:), ALLOCATABLE, INTENT(IN) :: var_lsm_h !< output variable at upward-facing natural-type surfaces 3401 REAL(wp), DIMENSION(:), ALLOCATABLE, INTENT(IN) :: var_usm_h !< output variable at upward-facing urban-type surfaces 3402 REAL(wp), DIMENSION(:), ALLOCATABLE, INTENT(IN) :: var_def_v0 !< output variable at northward-facing default-type surfaces 3403 REAL(wp), DIMENSION(:), ALLOCATABLE, INTENT(IN) :: var_def_v1 !< output variable at southward-facing default-type surfaces 3404 REAL(wp), DIMENSION(:), ALLOCATABLE, INTENT(IN) :: var_def_v2 !< output variable at eastward-facing default-type surfaces 3405 REAL(wp), DIMENSION(:), ALLOCATABLE, INTENT(IN) :: var_def_v3 !< output variable at westward-facing default-type surfaces 3406 REAL(wp), DIMENSION(:), ALLOCATABLE, INTENT(IN) :: var_lsm_v0 !< output variable at northward-facing natural-type surfaces 3407 REAL(wp), DIMENSION(:), ALLOCATABLE, INTENT(IN) :: var_lsm_v1 !< output variable at southward-facing natural-type surfaces 3408 REAL(wp), DIMENSION(:), ALLOCATABLE, INTENT(IN) :: var_lsm_v2 !< output variable at eastward-facing natural-type surfaces 3409 REAL(wp), DIMENSION(:), ALLOCATABLE, INTENT(IN) :: var_lsm_v3 !< output variable at westward-facing natural-type surfaces 3410 REAL(wp), DIMENSION(:), ALLOCATABLE, INTENT(IN) :: var_usm_v0 !< output variable at northward-facing urban-type surfaces 3411 REAL(wp), DIMENSION(:), ALLOCATABLE, INTENT(IN) :: var_usm_v1 !< output variable at southward-facing urban-type surfaces 3412 REAL(wp), DIMENSION(:), ALLOCATABLE, INTENT(IN) :: var_usm_v2 !< output variable at eastward-facing urban-type surfaces 3413 REAL(wp), DIMENSION(:), ALLOCATABLE, INTENT(IN) :: var_usm_v3 !< output variable at westward-facing urban-type surfaces 3414 3415 ! 3416 !-- Set conversion factor to one if not present 3417 IF ( .NOT. PRESENT( fac ) ) THEN 3418 conversion_factor = 1.0_wp 3419 ELSE 3420 conversion_factor = fac 3421 ENDIF 3422 ! 3423 !-- Set counter variable to zero before the variable is written to the output array. 3424 n_surf = 0 3425 3426 ! 3427 !-- Write the horizontal surfaces. 3428 !-- Before each variable is written to the output data structure, first check if the variable 3429 !-- for the respective surface type is defined. If a variable is not defined, skip the block and 3430 !-- increment the counter variable by the number of surface elements of this type. Usually this is 3431 !-- zero, however, there might be the situation that e.g. urban surfaces are defined but the 3432 !-- respective variable is not allocated for this surface type. To write the data on the exact 3433 !-- position, increment the counter. 3434 IF ( ALLOCATED( var_def_h0 ) ) THEN 3435 DO m = 1, surf_def_h(0)%ns 3436 n_surf = n_surf + 1 3437 k = surf_def_h(0)%k(m) 3438 surfaces%var_av(n_surf,n_out) = surfaces%var_av(n_surf,n_out) + var_def_h0(m) * & 3439 conversion_factor(k) 3440 ENDDO 3441 ELSE 3442 n_surf = n_surf + surf_def_h(0)%ns 3443 ENDIF 3444 IF ( ALLOCATED( var_def_h1 ) ) THEN 3445 DO m = 1, surf_def_h(1)%ns 3446 n_surf = n_surf + 1 3447 k = surf_def_h(1)%k(m) 3448 surfaces%var_av(n_surf,n_out) = surfaces%var_av(n_surf,n_out) + var_def_h1(m) * & 3449 conversion_factor(k) 3450 ENDDO 3451 ELSE 3452 n_surf = n_surf + surf_def_h(1)%ns 3453 ENDIF 3454 IF ( ALLOCATED( var_lsm_h ) ) THEN 3455 DO m = 1, surf_lsm_h%ns 3456 n_surf = n_surf + 1 3457 k = surf_lsm_h%k(m) 3458 surfaces%var_av(n_surf,n_out) = surfaces%var_av(n_surf,n_out) + var_lsm_h(m) * & 3459 conversion_factor(k) 3460 ENDDO 3461 ELSE 3462 n_surf = n_surf + surf_lsm_h%ns 3463 ENDIF 3464 IF ( ALLOCATED( var_usm_h ) ) THEN 3465 DO m = 1, surf_usm_h%ns 3466 n_surf = n_surf + 1 3467 k = surf_usm_h%k(m) 3468 surfaces%var_av(n_surf,n_out) = surfaces%var_av(n_surf,n_out) + var_usm_h(m) * & 3469 conversion_factor(k) 3470 ENDDO 3471 ELSE 3472 n_surf = n_surf + surf_usm_h%ns 3473 ENDIF 3474 ! 3475 !-- Write northward-facing 3476 IF ( ALLOCATED( var_def_v0 ) ) THEN 3477 DO m = 1, surf_def_v(0)%ns 3478 n_surf = n_surf + 1 3479 k = surf_def_v(0)%k(m) 3480 surfaces%var_av(n_surf,n_out) = surfaces%var_av(n_surf,n_out) + var_def_v0(m) * & 3481 conversion_factor(k) 3482 ENDDO 3483 ELSE 3484 n_surf = n_surf + surf_def_v(0)%ns 3485 ENDIF 3486 IF ( ALLOCATED( var_lsm_v0 ) ) THEN 3487 DO m = 1, surf_lsm_v(0)%ns 3488 n_surf = n_surf + 1 3489 k = surf_lsm_v(0)%k(m) 3490 surfaces%var_av(n_surf,n_out) = surfaces%var_av(n_surf,n_out) + var_lsm_v0(m) * & 3491 conversion_factor(k) 3492 ENDDO 3493 ELSE 3494 n_surf = n_surf + surf_lsm_v(0)%ns 3495 ENDIF 3496 IF ( ALLOCATED( var_usm_v0 ) ) THEN 3497 DO m = 1, surf_usm_v(0)%ns 3498 n_surf = n_surf + 1 3499 k = surf_usm_v(0)%k(m) 3500 surfaces%var_av(n_surf,n_out) = surfaces%var_av(n_surf,n_out) + var_usm_v0(m) * & 3501 conversion_factor(k) 3502 ENDDO 3503 ELSE 3504 n_surf = n_surf + surf_usm_v(0)%ns 3505 ENDIF 3506 ! 3507 !-- Write southward-facing 3508 IF ( ALLOCATED( var_def_v1 ) ) THEN 3509 DO m = 1, surf_def_v(1)%ns 3510 n_surf = n_surf + 1 3511 k = surf_def_v(1)%k(m) 3512 surfaces%var_av(n_surf,n_out) = surfaces%var_av(n_surf,n_out) + var_def_v1(m) * & 3513 conversion_factor(k) 3514 ENDDO 3515 ELSE 3516 n_surf = n_surf + surf_def_v(1)%ns 3517 ENDIF 3518 IF ( ALLOCATED( var_lsm_v1 ) ) THEN 3519 DO m = 1, surf_lsm_v(1)%ns 3520 n_surf = n_surf + 1 3521 k = surf_lsm_v(1)%k(m) 3522 surfaces%var_av(n_surf,n_out) = surfaces%var_av(n_surf,n_out) + var_lsm_v1(m) * & 3523 conversion_factor(k) 3524 ENDDO 3525 ELSE 3526 n_surf = n_surf + surf_lsm_v(1)%ns 3527 ENDIF 3528 IF ( ALLOCATED( var_usm_v1 ) ) THEN 3529 DO m = 1, surf_usm_v(1)%ns 3530 n_surf = n_surf + 1 3531 k = surf_usm_v(1)%k(m) 3532 surfaces%var_av(n_surf,n_out) = surfaces%var_av(n_surf,n_out) + var_usm_v1(m) * & 3533 conversion_factor(k) 3534 ENDDO 3535 ELSE 3536 n_surf = n_surf + surf_usm_v(1)%ns 3537 ENDIF 3538 ! 3539 !-- Write eastward-facing 3540 IF ( ALLOCATED( var_def_v2 ) ) THEN 3541 DO m = 1, surf_def_v(2)%ns 3542 n_surf = n_surf + 1 3543 k = surf_def_v(2)%k(m) 3544 surfaces%var_av(n_surf,n_out) = surfaces%var_av(n_surf,n_out) & 3545 + var_def_v2(m) * conversion_factor(k) 3546 ENDDO 3547 ELSE 3548 n_surf = n_surf + surf_def_v(2)%ns 3549 ENDIF 3550 IF ( ALLOCATED( var_lsm_v2 ) ) THEN 3551 DO m = 1, surf_lsm_v(2)%ns 3552 n_surf = n_surf + 1 3553 k = surf_lsm_v(2)%k(m) 3554 surfaces%var_av(n_surf,n_out) = surfaces%var_av(n_surf,n_out) & 3555 + var_lsm_v2(m) * conversion_factor(k) 3556 ENDDO 3557 ELSE 3558 n_surf = n_surf + surf_lsm_v(2)%ns 3559 ENDIF 3560 IF ( ALLOCATED( var_usm_v2 ) ) THEN 3561 DO m = 1, surf_usm_v(2)%ns 3562 n_surf = n_surf + 1 3563 k = surf_usm_v(2)%k(m) 3564 surfaces%var_av(n_surf,n_out) = surfaces%var_av(n_surf,n_out) & 3565 + var_usm_v2(m) * conversion_factor(k) 3566 ENDDO 3567 ELSE 3568 n_surf = n_surf + surf_usm_v(2)%ns 3569 ENDIF 3570 ! 3571 !-- Write westward-facing 3572 IF ( ALLOCATED( var_def_v3 ) ) THEN 3573 DO m = 1, surf_def_v(3)%ns 3574 n_surf = n_surf + 1 3575 k = surf_def_v(3)%k(m) 3576 surfaces%var_av(n_surf,n_out) = surfaces%var_av(n_surf,n_out) & 3577 + var_def_v3(m) * conversion_factor(k) 3578 ENDDO 3579 ELSE 3580 n_surf = n_surf + surf_def_v(3)%ns 3581 ENDIF 3582 IF ( ALLOCATED( var_lsm_v3 ) ) THEN 3583 DO m = 1, surf_lsm_v(3)%ns 3584 n_surf = n_surf + 1 3585 k = surf_lsm_v(3)%k(m) 3586 surfaces%var_av(n_surf,n_out) = surfaces%var_av(n_surf,n_out) & 3587 + var_lsm_v3(m) * conversion_factor(k) 3588 ENDDO 3589 ELSE 3590 n_surf = n_surf + surf_lsm_v(3)%ns 3591 ENDIF 3592 IF ( ALLOCATED( var_usm_v3 ) ) THEN 3593 DO m = 1, surf_usm_v(3)%ns 3594 n_surf = n_surf + 1 3595 k = surf_usm_v(3)%k(m) 3596 surfaces%var_av(n_surf,n_out) = surfaces%var_av(n_surf,n_out) & 3597 + var_usm_v3(m) * conversion_factor(k) 3598 ENDDO 3599 ELSE 3600 n_surf = n_surf + surf_usm_v(3)%ns 3601 ENDIF 3602 3603 END SUBROUTINE surface_data_output_sum_up_1d 3604 3605 !--------------------------------------------------------------------------------------------------! 4458 3606 ! Description: 4459 3607 ! ------------ 4460 !> Sum-up the surface data for average output variables for properties which 4461 !> are defined using tile approach. 4462 !------------------------------------------------------------------------------! 4463 SUBROUTINE surface_data_output_sum_up_2d( var_def_h0, var_def_h1, & 4464 var_lsm_h, var_usm_h, & 4465 var_def_v0, var_lsm_v0, var_usm_v0, & 4466 var_def_v1, var_lsm_v1, var_usm_v1, & 4467 var_def_v2, var_lsm_v2, var_usm_v2, & 4468 var_def_v3, var_lsm_v3, var_usm_v3, n_out,& 4469 fac ) 4470 4471 IMPLICIT NONE 4472 4473 INTEGER(iwp) :: k !< height index of surface element 4474 INTEGER(iwp) :: m !< running index for surface elements 4475 INTEGER(iwp) :: n_out !< index for output variable 4476 INTEGER(iwp) :: n_surf !< running index for surface elements 4477 4478 REAL(wp), DIMENSION(:), OPTIONAL :: fac !< passed output conversion factor for heatflux output 4479 REAL(wp), DIMENSION(nzb:nzt+1) :: conversion_factor !< effective array for output conversion factor 4480 4481 REAL(wp), DIMENSION(:,:), ALLOCATABLE, INTENT(IN) :: var_def_h0 !< output variable at upward-facing default-type surfaces 4482 REAL(wp), DIMENSION(:,:), ALLOCATABLE, INTENT(IN) :: var_def_h1 !< output variable at downward-facing default-type surfaces 4483 REAL(wp), DIMENSION(:,:), ALLOCATABLE, INTENT(IN) :: var_lsm_h !< output variable at upward-facing natural-type surfaces 4484 REAL(wp), DIMENSION(:,:), ALLOCATABLE, INTENT(IN) :: var_usm_h !< output variable at upward-facing urban-type surfaces 4485 REAL(wp), DIMENSION(:,:), ALLOCATABLE, INTENT(IN) :: var_def_v0 !< output variable at northward-facing default-type surfaces 4486 REAL(wp), DIMENSION(:,:), ALLOCATABLE, INTENT(IN) :: var_def_v1 !< output variable at southward-facing default-type surfaces 4487 REAL(wp), DIMENSION(:,:), ALLOCATABLE, INTENT(IN) :: var_def_v2 !< output variable at eastward-facing default-type surfaces 4488 REAL(wp), DIMENSION(:,:), ALLOCATABLE, INTENT(IN) :: var_def_v3 !< output variable at westward-facing default-type surfaces 4489 REAL(wp), DIMENSION(:,:), ALLOCATABLE, INTENT(IN) :: var_lsm_v0 !< output variable at northward-facing natural-type surfaces 4490 REAL(wp), DIMENSION(:,:), ALLOCATABLE, INTENT(IN) :: var_lsm_v1 !< output variable at southward-facing natural-type surfaces 4491 REAL(wp), DIMENSION(:,:), ALLOCATABLE, INTENT(IN) :: var_lsm_v2 !< output variable at eastward-facing natural-type surfaces 4492 REAL(wp), DIMENSION(:,:), ALLOCATABLE, INTENT(IN) :: var_lsm_v3 !< output variable at westward-facing natural-type surfaces 4493 REAL(wp), DIMENSION(:,:), ALLOCATABLE, INTENT(IN) :: var_usm_v0 !< output variable at northward-facing urban-type surfaces 4494 REAL(wp), DIMENSION(:,:), ALLOCATABLE, INTENT(IN) :: var_usm_v1 !< output variable at southward-facing urban-type surfaces 4495 REAL(wp), DIMENSION(:,:), ALLOCATABLE, INTENT(IN) :: var_usm_v2 !< output variable at eastward-facing urban-type surfaces 4496 REAL(wp), DIMENSION(:,:), ALLOCATABLE, INTENT(IN) :: var_usm_v3 !< output variable at westward-facing urban-type surfaces 4497 4498 ! 4499 !-- Set conversion factor to one if not present 4500 IF ( .NOT. PRESENT( fac ) ) THEN 4501 conversion_factor = 1.0_wp 4502 ELSE 4503 conversion_factor = fac 4504 ENDIF 4505 ! 4506 !-- Set counter variable to zero before the variable is written to 4507 !-- the output array. 4508 n_surf = 0 4509 4510 ! 4511 !-- Write the horizontal surfaces. 4512 !-- Before each the variable is written to the output data structure, first 4513 !-- check if the variable for the respective surface type is defined. 4514 !-- If a variable is not defined, skip the block and increment the counter 4515 !-- variable by the number of surface elements of this type. Usually this 4516 !-- is zere, however, there might be the situation that e.g. urban surfaces 4517 !-- are defined but the respective variable is not allocated for this surface 4518 !-- type. To write the data on the exact position, increment the counter. 4519 IF ( ALLOCATED( var_def_h0 ) ) THEN 4520 DO m = 1, surf_def_h(0)%ns 4521 n_surf = n_surf + 1 4522 k = surf_def_h(0)%k(m) 4523 surfaces%var_av(n_surf,n_out) = surfaces%var_av(n_surf,n_out) & 4524 + SUM ( surf_def_h(0)%frac(m,:) * & 4525 var_def_h0(m,:) ) * conversion_factor(k) 4526 ENDDO 4527 ELSE 4528 n_surf = n_surf + surf_def_h(0)%ns 4529 ENDIF 4530 IF ( ALLOCATED( var_def_h1 ) ) THEN 4531 DO m = 1, surf_def_h(1)%ns 4532 n_surf = n_surf + 1 4533 k = surf_def_h(1)%k(m) 4534 surfaces%var_av(n_surf,n_out) = surfaces%var_av(n_surf,n_out) & 4535 + SUM ( surf_def_h(1)%frac(m,:) * & 4536 var_def_h1(m,:) ) * conversion_factor(k) 4537 ENDDO 4538 ELSE 4539 n_surf = n_surf + surf_def_h(1)%ns 4540 ENDIF 4541 IF ( ALLOCATED( var_lsm_h ) ) THEN 4542 DO m = 1, surf_lsm_h%ns 4543 n_surf = n_surf + 1 4544 k = surf_lsm_h%k(m) 4545 surfaces%var_av(n_surf,n_out) = surfaces%var_av(n_surf,n_out) & 4546 + SUM ( surf_lsm_h%frac(m,:) * & 4547 var_lsm_h(m,:) ) * conversion_factor(k) 4548 ENDDO 4549 ELSE 4550 n_surf = n_surf + surf_lsm_h%ns 4551 ENDIF 4552 IF ( ALLOCATED( var_usm_h ) ) THEN 4553 DO m = 1, surf_usm_h%ns 4554 n_surf = n_surf + 1 4555 k = surf_usm_h%k(m) 4556 surfaces%var_av(n_surf,n_out) = surfaces%var_av(n_surf,n_out) & 4557 + SUM ( surf_usm_h%frac(m,:) * & 4558 var_usm_h(m,:) ) * conversion_factor(k) 4559 ENDDO 4560 ELSE 4561 n_surf = n_surf + surf_usm_h%ns 4562 ENDIF 4563 ! 4564 !-- Write northward-facing 4565 IF ( ALLOCATED( var_def_v0 ) ) THEN 4566 DO m = 1, surf_def_v(0)%ns 4567 n_surf = n_surf + 1 4568 k = surf_def_v(0)%k(m) 4569 surfaces%var_av(n_surf,n_out) = surfaces%var_av(n_surf,n_out) & 4570 + SUM ( surf_def_v(0)%frac(m,:) * & 4571 var_def_v0(m,:) ) * conversion_factor(k) 4572 ENDDO 4573 ELSE 4574 n_surf = n_surf + surf_def_v(0)%ns 4575 ENDIF 4576 IF ( ALLOCATED( var_lsm_v0 ) ) THEN 4577 DO m = 1, surf_lsm_v(0)%ns 4578 n_surf = n_surf + 1 4579 k = surf_lsm_v(0)%k(m) 4580 surfaces%var_av(n_surf,n_out) = surfaces%var_av(n_surf,n_out) & 4581 + SUM ( surf_lsm_v(0)%frac(m,:) * & 4582 var_lsm_v0(m,:) ) * conversion_factor(k) 4583 ENDDO 4584 ELSE 4585 n_surf = n_surf + surf_lsm_v(0)%ns 4586 ENDIF 4587 IF ( ALLOCATED( var_usm_v0 ) ) THEN 4588 DO m = 1, surf_usm_v(0)%ns 4589 n_surf = n_surf + 1 4590 k = surf_usm_v(0)%k(m) 4591 surfaces%var_av(n_surf,n_out) = surfaces%var_av(n_surf,n_out) & 4592 + SUM ( surf_usm_v(0)%frac(m,:) * & 4593 var_usm_v0(m,:) ) * conversion_factor(k) 4594 ENDDO 4595 ELSE 4596 n_surf = n_surf + surf_usm_v(0)%ns 4597 ENDIF 4598 ! 4599 !-- Write southward-facing 4600 IF ( ALLOCATED( var_def_v1 ) ) THEN 4601 DO m = 1, surf_def_v(1)%ns 4602 n_surf = n_surf + 1 4603 k = surf_def_v(1)%k(m) 4604 surfaces%var_av(n_surf,n_out) = surfaces%var_av(n_surf,n_out) & 4605 + SUM ( surf_def_v(1)%frac(m,:) * & 4606 var_def_v1(m,:) ) * conversion_factor(k) 4607 ENDDO 4608 ELSE 4609 n_surf = n_surf + surf_def_v(1)%ns 4610 ENDIF 4611 IF ( ALLOCATED( var_lsm_v1 ) ) THEN 4612 DO m = 1, surf_lsm_v(1)%ns 4613 n_surf = n_surf + 1 4614 k = surf_lsm_v(1)%k(m) 4615 surfaces%var_av(n_surf,n_out) = surfaces%var_av(n_surf,n_out) & 4616 + SUM ( surf_lsm_v(1)%frac(m,:) * & 4617 var_lsm_v1(m,:) ) * conversion_factor(k) 4618 ENDDO 4619 ELSE 4620 n_surf = n_surf + surf_lsm_v(1)%ns 4621 ENDIF 4622 IF ( ALLOCATED( var_usm_v1 ) ) THEN 4623 DO m = 1, surf_usm_v(1)%ns 4624 n_surf = n_surf + 1 4625 k = surf_usm_v(1)%k(m) 4626 surfaces%var_av(n_surf,n_out) = surfaces%var_av(n_surf,n_out) & 4627 + SUM ( surf_usm_v(1)%frac(m,:) * & 4628 var_usm_v1(m,:) ) * conversion_factor(k) 4629 ENDDO 4630 ELSE 4631 n_surf = n_surf + surf_usm_v(1)%ns 4632 ENDIF 4633 ! 4634 !-- Write eastward-facing 4635 IF ( ALLOCATED( var_def_v2 ) ) THEN 4636 DO m = 1, surf_def_v(2)%ns 4637 n_surf = n_surf + 1 4638 k = surf_def_v(2)%k(m) 4639 surfaces%var_av(n_surf,n_out) = surfaces%var_av(n_surf,n_out) & 4640 + SUM ( surf_def_v(2)%frac(m,:) * & 4641 var_def_v2(m,:) ) * conversion_factor(k) 4642 ENDDO 4643 ELSE 4644 n_surf = n_surf + surf_def_v(2)%ns 4645 ENDIF 4646 IF ( ALLOCATED( var_lsm_v2 ) ) THEN 4647 DO m = 1, surf_lsm_v(2)%ns 4648 n_surf = n_surf + 1 4649 k = surf_lsm_v(2)%k(m) 4650 surfaces%var_av(n_surf,n_out) = surfaces%var_av(n_surf,n_out) & 4651 + SUM ( surf_lsm_v(2)%frac(m,:) * & 4652 var_lsm_v2(m,:) ) * conversion_factor(k) 4653 ENDDO 4654 ELSE 4655 n_surf = n_surf + surf_lsm_v(2)%ns 4656 ENDIF 4657 IF ( ALLOCATED( var_usm_v2 ) ) THEN 4658 DO m = 1, surf_usm_v(2)%ns 4659 n_surf = n_surf + 1 4660 k = surf_usm_v(2)%k(m) 4661 surfaces%var_av(n_surf,n_out) = surfaces%var_av(n_surf,n_out) & 4662 + SUM ( surf_usm_v(2)%frac(m,:) * & 4663 var_usm_v2(m,:) ) * conversion_factor(k) 4664 ENDDO 4665 ELSE 4666 n_surf = n_surf + surf_usm_v(2)%ns 4667 ENDIF 4668 ! 4669 !-- Write westward-facing 4670 IF ( ALLOCATED( var_def_v3 ) ) THEN 4671 DO m = 1, surf_def_v(3)%ns 4672 n_surf = n_surf + 1 4673 k = surf_def_v(3)%k(m) 4674 surfaces%var_av(n_surf,n_out) = surfaces%var_av(n_surf,n_out) & 4675 + SUM ( surf_def_v(3)%frac(m,:) * & 4676 var_def_v3(m,:) ) * conversion_factor(k) 4677 ENDDO 4678 ELSE 4679 n_surf = n_surf + surf_def_v(3)%ns 4680 ENDIF 4681 IF ( ALLOCATED( var_lsm_v3 ) ) THEN 4682 DO m = 1, surf_lsm_v(3)%ns 4683 n_surf = n_surf + 1 4684 k = surf_lsm_v(3)%k(m) 4685 surfaces%var_av(n_surf,n_out) = surfaces%var_av(n_surf,n_out) & 4686 + SUM ( surf_lsm_v(3)%frac(m,:) * & 4687 var_lsm_v3(m,:) ) * conversion_factor(k) 4688 ENDDO 4689 ELSE 4690 n_surf = n_surf + surf_lsm_v(3)%ns 4691 ENDIF 4692 IF ( ALLOCATED( var_usm_v3 ) ) THEN 4693 DO m = 1, surf_usm_v(3)%ns 4694 n_surf = n_surf + 1 4695 k = surf_usm_v(3)%k(m) 4696 surfaces%var_av(n_surf,n_out) = surfaces%var_av(n_surf,n_out) & 4697 + SUM ( surf_usm_v(3)%frac(m,:) * & 4698 var_usm_v3(m,:) ) * conversion_factor(k) 4699 ENDDO 4700 ELSE 4701 n_surf = n_surf + surf_usm_v(3)%ns 4702 ENDIF 4703 4704 END SUBROUTINE surface_data_output_sum_up_2d 4705 4706 !------------------------------------------------------------------------------! 3608 !> Sum-up the surface data for average output variables for properties which are defined using tile 3609 !> approach. 3610 !--------------------------------------------------------------------------------------------------! 3611 SUBROUTINE surface_data_output_sum_up_2d( var_def_h0, var_def_h1, var_lsm_h, var_usm_h, & 3612 var_def_v0, var_lsm_v0, var_usm_v0, var_def_v1, & 3613 var_lsm_v1, var_usm_v1, var_def_v2, var_lsm_v2, & 3614 var_usm_v2, var_def_v3, var_lsm_v3, var_usm_v3, n_out, & 3615 fac ) 3616 3617 IMPLICIT NONE 3618 3619 INTEGER(iwp) :: k !< height index of surface element 3620 INTEGER(iwp) :: m !< running index for surface elements 3621 INTEGER(iwp) :: n_out !< index for output variable 3622 INTEGER(iwp) :: n_surf !< running index for surface elements 3623 3624 REAL(wp), DIMENSION(:), OPTIONAL :: fac !< passed output conversion factor for heatflux output 3625 REAL(wp), DIMENSION(nzb:nzt+1) :: conversion_factor !< effective array for output conversion factor 3626 3627 REAL(wp), DIMENSION(:,:), ALLOCATABLE, INTENT(IN) :: var_def_h0 !< output variable at upward-facing default-type surfaces 3628 REAL(wp), DIMENSION(:,:), ALLOCATABLE, INTENT(IN) :: var_def_h1 !< output variable at downward-facing default-type surfaces 3629 REAL(wp), DIMENSION(:,:), ALLOCATABLE, INTENT(IN) :: var_lsm_h !< output variable at upward-facing natural-type surfaces 3630 REAL(wp), DIMENSION(:,:), ALLOCATABLE, INTENT(IN) :: var_usm_h !< output variable at upward-facing urban-type surfaces 3631 REAL(wp), DIMENSION(:,:), ALLOCATABLE, INTENT(IN) :: var_def_v0 !< output variable at northward-facing default-type surfaces 3632 REAL(wp), DIMENSION(:,:), ALLOCATABLE, INTENT(IN) :: var_def_v1 !< output variable at southward-facing default-type surfaces 3633 REAL(wp), DIMENSION(:,:), ALLOCATABLE, INTENT(IN) :: var_def_v2 !< output variable at eastward-facing default-type surfaces 3634 REAL(wp), DIMENSION(:,:), ALLOCATABLE, INTENT(IN) :: var_def_v3 !< output variable at westward-facing default-type surfaces 3635 REAL(wp), DIMENSION(:,:), ALLOCATABLE, INTENT(IN) :: var_lsm_v0 !< output variable at northward-facing natural-type surfaces 3636 REAL(wp), DIMENSION(:,:), ALLOCATABLE, INTENT(IN) :: var_lsm_v1 !< output variable at southward-facing natural-type surfaces 3637 REAL(wp), DIMENSION(:,:), ALLOCATABLE, INTENT(IN) :: var_lsm_v2 !< output variable at eastward-facing natural-type surfaces 3638 REAL(wp), DIMENSION(:,:), ALLOCATABLE, INTENT(IN) :: var_lsm_v3 !< output variable at westward-facing natural-type surfaces 3639 REAL(wp), DIMENSION(:,:), ALLOCATABLE, INTENT(IN) :: var_usm_v0 !< output variable at northward-facing urban-type surfaces 3640 REAL(wp), DIMENSION(:,:), ALLOCATABLE, INTENT(IN) :: var_usm_v1 !< output variable at southward-facing urban-type surfaces 3641 REAL(wp), DIMENSION(:,:), ALLOCATABLE, INTENT(IN) :: var_usm_v2 !< output variable at eastward-facing urban-type surfaces 3642 REAL(wp), DIMENSION(:,:), ALLOCATABLE, INTENT(IN) :: var_usm_v3 !< output variable at westward-facing urban-type surfaces 3643 3644 ! 3645 !-- Set conversion factor to one if not present 3646 IF ( .NOT. PRESENT( fac ) ) THEN 3647 conversion_factor = 1.0_wp 3648 ELSE 3649 conversion_factor = fac 3650 ENDIF 3651 ! 3652 !-- Set counter variable to zero before the variable is written to the output array. 3653 n_surf = 0 3654 3655 ! 3656 !-- Write the horizontal surfaces. 3657 !-- Before each variable is written to the output data structure, first check if the variable 3658 !-- for the respective surface type is defined. If a variable is not defined, skip the block and 3659 !-- increment the counter variable by the number of surface elements of this type. Usually this is 3660 !-- zero, however, there might be the situation that e.g. urban surfaces are defined but the 3661 !-- respective variable is not allocated for this surface type. To write the data on the exact 3662 !-- position, increment the counter. 3663 IF ( ALLOCATED( var_def_h0 ) ) THEN 3664 DO m = 1, surf_def_h(0)%ns 3665 n_surf = n_surf + 1 3666 k = surf_def_h(0)%k(m) 3667 surfaces%var_av(n_surf,n_out) = surfaces%var_av(n_surf,n_out) & 3668 + SUM ( surf_def_h(0)%frac(m,:) * & 3669 var_def_h0(m,:) ) * conversion_factor(k) 3670 ENDDO 3671 ELSE 3672 n_surf = n_surf + surf_def_h(0)%ns 3673 ENDIF 3674 IF ( ALLOCATED( var_def_h1 ) ) THEN 3675 DO m = 1, surf_def_h(1)%ns 3676 n_surf = n_surf + 1 3677 k = surf_def_h(1)%k(m) 3678 surfaces%var_av(n_surf,n_out) = surfaces%var_av(n_surf,n_out) & 3679 + SUM ( surf_def_h(1)%frac(m,:) * & 3680 var_def_h1(m,:) ) * conversion_factor(k) 3681 ENDDO 3682 ELSE 3683 n_surf = n_surf + surf_def_h(1)%ns 3684 ENDIF 3685 IF ( ALLOCATED( var_lsm_h ) ) THEN 3686 DO m = 1, surf_lsm_h%ns 3687 n_surf = n_surf + 1 3688 k = surf_lsm_h%k(m) 3689 surfaces%var_av(n_surf,n_out) = surfaces%var_av(n_surf,n_out) & 3690 + SUM ( surf_lsm_h%frac(m,:) * & 3691 var_lsm_h(m,:) ) * conversion_factor(k) 3692 ENDDO 3693 ELSE 3694 n_surf = n_surf + surf_lsm_h%ns 3695 ENDIF 3696 IF ( ALLOCATED( var_usm_h ) ) THEN 3697 DO m = 1, surf_usm_h%ns 3698 n_surf = n_surf + 1 3699 k = surf_usm_h%k(m) 3700 surfaces%var_av(n_surf,n_out) = surfaces%var_av(n_surf,n_out) & 3701 + SUM ( surf_usm_h%frac(m,:) * & 3702 var_usm_h(m,:) ) * conversion_factor(k) 3703 ENDDO 3704 ELSE 3705 n_surf = n_surf + surf_usm_h%ns 3706 ENDIF 3707 ! 3708 !-- Write northward-facing 3709 IF ( ALLOCATED( var_def_v0 ) ) THEN 3710 DO m = 1, surf_def_v(0)%ns 3711 n_surf = n_surf + 1 3712 k = surf_def_v(0)%k(m) 3713 surfaces%var_av(n_surf,n_out) = surfaces%var_av(n_surf,n_out) & 3714 + SUM ( surf_def_v(0)%frac(m,:) * & 3715 var_def_v0(m,:) ) * conversion_factor(k) 3716 ENDDO 3717 ELSE 3718 n_surf = n_surf + surf_def_v(0)%ns 3719 ENDIF 3720 IF ( ALLOCATED( var_lsm_v0 ) ) THEN 3721 DO m = 1, surf_lsm_v(0)%ns 3722 n_surf = n_surf + 1 3723 k = surf_lsm_v(0)%k(m) 3724 surfaces%var_av(n_surf,n_out) = surfaces%var_av(n_surf,n_out) & 3725 + SUM ( surf_lsm_v(0)%frac(m,:) * & 3726 var_lsm_v0(m,:) ) * conversion_factor(k) 3727 ENDDO 3728 ELSE 3729 n_surf = n_surf + surf_lsm_v(0)%ns 3730 ENDIF 3731 IF ( ALLOCATED( var_usm_v0 ) ) THEN 3732 DO m = 1, surf_usm_v(0)%ns 3733 n_surf = n_surf + 1 3734 k = surf_usm_v(0)%k(m) 3735 surfaces%var_av(n_surf,n_out) = surfaces%var_av(n_surf,n_out) & 3736 + SUM ( surf_usm_v(0)%frac(m,:) * & 3737 var_usm_v0(m,:) ) * conversion_factor(k) 3738 ENDDO 3739 ELSE 3740 n_surf = n_surf + surf_usm_v(0)%ns 3741 ENDIF 3742 ! 3743 !-- Write southward-facing 3744 IF ( ALLOCATED( var_def_v1 ) ) THEN 3745 DO m = 1, surf_def_v(1)%ns 3746 n_surf = n_surf + 1 3747 k = surf_def_v(1)%k(m) 3748 surfaces%var_av(n_surf,n_out) = surfaces%var_av(n_surf,n_out) & 3749 + SUM ( surf_def_v(1)%frac(m,:) * & 3750 var_def_v1(m,:) ) * conversion_factor(k) 3751 ENDDO 3752 ELSE 3753 n_surf = n_surf + surf_def_v(1)%ns 3754 ENDIF 3755 IF ( ALLOCATED( var_lsm_v1 ) ) THEN 3756 DO m = 1, surf_lsm_v(1)%ns 3757 n_surf = n_surf + 1 3758 k = surf_lsm_v(1)%k(m) 3759 surfaces%var_av(n_surf,n_out) = surfaces%var_av(n_surf,n_out) & 3760 + SUM ( surf_lsm_v(1)%frac(m,:) * & 3761 var_lsm_v1(m,:) ) * conversion_factor(k) 3762 ENDDO 3763 ELSE 3764 n_surf = n_surf + surf_lsm_v(1)%ns 3765 ENDIF 3766 IF ( ALLOCATED( var_usm_v1 ) ) THEN 3767 DO m = 1, surf_usm_v(1)%ns 3768 n_surf = n_surf + 1 3769 k = surf_usm_v(1)%k(m) 3770 surfaces%var_av(n_surf,n_out) = surfaces%var_av(n_surf,n_out) & 3771 + SUM ( surf_usm_v(1)%frac(m,:) * & 3772 var_usm_v1(m,:) ) * conversion_factor(k) 3773 ENDDO 3774 ELSE 3775 n_surf = n_surf + surf_usm_v(1)%ns 3776 ENDIF 3777 ! 3778 !-- Write eastward-facing 3779 IF ( ALLOCATED( var_def_v2 ) ) THEN 3780 DO m = 1, surf_def_v(2)%ns 3781 n_surf = n_surf + 1 3782 k = surf_def_v(2)%k(m) 3783 surfaces%var_av(n_surf,n_out) = surfaces%var_av(n_surf,n_out) & 3784 + SUM ( surf_def_v(2)%frac(m,:) * & 3785 var_def_v2(m,:) ) * conversion_factor(k) 3786 ENDDO 3787 ELSE 3788 n_surf = n_surf + surf_def_v(2)%ns 3789 ENDIF 3790 IF ( ALLOCATED( var_lsm_v2 ) ) THEN 3791 DO m = 1, surf_lsm_v(2)%ns 3792 n_surf = n_surf + 1 3793 k = surf_lsm_v(2)%k(m) 3794 surfaces%var_av(n_surf,n_out) = surfaces%var_av(n_surf,n_out) & 3795 + SUM ( surf_lsm_v(2)%frac(m,:) * & 3796 var_lsm_v2(m,:) ) * conversion_factor(k) 3797 ENDDO 3798 ELSE 3799 n_surf = n_surf + surf_lsm_v(2)%ns 3800 ENDIF 3801 IF ( ALLOCATED( var_usm_v2 ) ) THEN 3802 DO m = 1, surf_usm_v(2)%ns 3803 n_surf = n_surf + 1 3804 k = surf_usm_v(2)%k(m) 3805 surfaces%var_av(n_surf,n_out) = surfaces%var_av(n_surf,n_out) & 3806 + SUM ( surf_usm_v(2)%frac(m,:) * & 3807 var_usm_v2(m,:) ) * conversion_factor(k) 3808 ENDDO 3809 ELSE 3810 n_surf = n_surf + surf_usm_v(2)%ns 3811 ENDIF 3812 ! 3813 !-- Write westward-facing 3814 IF ( ALLOCATED( var_def_v3 ) ) THEN 3815 DO m = 1, surf_def_v(3)%ns 3816 n_surf = n_surf + 1 3817 k = surf_def_v(3)%k(m) 3818 surfaces%var_av(n_surf,n_out) = surfaces%var_av(n_surf,n_out) & 3819 + SUM ( surf_def_v(3)%frac(m,:) * & 3820 var_def_v3(m,:) ) * conversion_factor(k) 3821 ENDDO 3822 ELSE 3823 n_surf = n_surf + surf_def_v(3)%ns 3824 ENDIF 3825 IF ( ALLOCATED( var_lsm_v3 ) ) THEN 3826 DO m = 1, surf_lsm_v(3)%ns 3827 n_surf = n_surf + 1 3828 k = surf_lsm_v(3)%k(m) 3829 surfaces%var_av(n_surf,n_out) = surfaces%var_av(n_surf,n_out) & 3830 + SUM ( surf_lsm_v(3)%frac(m,:) * & 3831 var_lsm_v3(m,:) ) * conversion_factor(k) 3832 ENDDO 3833 ELSE 3834 n_surf = n_surf + surf_lsm_v(3)%ns 3835 ENDIF 3836 IF ( ALLOCATED( var_usm_v3 ) ) THEN 3837 DO m = 1, surf_usm_v(3)%ns 3838 n_surf = n_surf + 1 3839 k = surf_usm_v(3)%k(m) 3840 surfaces%var_av(n_surf,n_out) = surfaces%var_av(n_surf,n_out) & 3841 + SUM ( surf_usm_v(3)%frac(m,:) * & 3842 var_usm_v3(m,:) ) * conversion_factor(k) 3843 ENDDO 3844 ELSE 3845 n_surf = n_surf + surf_usm_v(3)%ns 3846 ENDIF 3847 3848 END SUBROUTINE surface_data_output_sum_up_2d 3849 3850 !--------------------------------------------------------------------------------------------------! 4707 3851 ! Description: 4708 3852 ! ------------ 4709 3853 !> Collect the surface data from different types and different orientation. 4710 !------------------------------------------------------------------------------! 4711 SUBROUTINE surface_data_output_collect_1d( var_def_h0, var_def_h1, & 4712 var_lsm_h, var_usm_h, & 4713 var_def_v0, var_lsm_v0, var_usm_v0, & 4714 var_def_v1, var_lsm_v1, var_usm_v1, & 4715 var_def_v2, var_lsm_v2, var_usm_v2, & 4716 var_def_v3, var_lsm_v3, var_usm_v3, & 4717 fac ) 4718 4719 IMPLICIT NONE 4720 4721 INTEGER(iwp) :: k !< height index of surface element 4722 INTEGER(iwp) :: m !< running index for surface elements 4723 INTEGER(iwp) :: n_surf !< running index for surface elements 4724 4725 REAL(wp), DIMENSION(:), OPTIONAL :: fac !< passed output conversion factor for heatflux output 4726 REAL(wp), DIMENSION(nzb:nzt+1) :: conversion_factor !< effective array for output conversion factor 4727 4728 REAL(wp), DIMENSION(:), ALLOCATABLE, INTENT(IN) :: var_def_h0 !< output variable at upward-facing default-type surfaces 4729 REAL(wp), DIMENSION(:), ALLOCATABLE, INTENT(IN) :: var_def_h1 !< output variable at downward-facing default-type surfaces 4730 REAL(wp), DIMENSION(:), ALLOCATABLE, INTENT(IN) :: var_lsm_h !< output variable at upward-facing natural-type surfaces 4731 REAL(wp), DIMENSION(:), ALLOCATABLE, INTENT(IN) :: var_usm_h !< output variable at upward-facing urban-type surfaces 4732 REAL(wp), DIMENSION(:), ALLOCATABLE, INTENT(IN) :: var_def_v0 !< output variable at northward-facing default-type surfaces 4733 REAL(wp), DIMENSION(:), ALLOCATABLE, INTENT(IN) :: var_def_v1 !< output variable at southward-facing default-type surfaces 4734 REAL(wp), DIMENSION(:), ALLOCATABLE, INTENT(IN) :: var_def_v2 !< output variable at eastward-facing default-type surfaces 4735 REAL(wp), DIMENSION(:), ALLOCATABLE, INTENT(IN) :: var_def_v3 !< output variable at westward-facing default-type surfaces 4736 REAL(wp), DIMENSION(:), ALLOCATABLE, INTENT(IN) :: var_lsm_v0 !< output variable at northward-facing natural-type surfaces 4737 REAL(wp), DIMENSION(:), ALLOCATABLE, INTENT(IN) :: var_lsm_v1 !< output variable at southward-facing natural-type surfaces 4738 REAL(wp), DIMENSION(:), ALLOCATABLE, INTENT(IN) :: var_lsm_v2 !< output variable at eastward-facing natural-type surfaces 4739 REAL(wp), DIMENSION(:), ALLOCATABLE, INTENT(IN) :: var_lsm_v3 !< output variable at westward-facing natural-type surfaces 4740 REAL(wp), DIMENSION(:), ALLOCATABLE, INTENT(IN) :: var_usm_v0 !< output variable at northward-facing urban-type surfaces 4741 REAL(wp), DIMENSION(:), ALLOCATABLE, INTENT(IN) :: var_usm_v1 !< output variable at southward-facing urban-type surfaces 4742 REAL(wp), DIMENSION(:), ALLOCATABLE, INTENT(IN) :: var_usm_v2 !< output variable at eastward-facing urban-type surfaces 4743 REAL(wp), DIMENSION(:), ALLOCATABLE, INTENT(IN) :: var_usm_v3 !< output variable at westward-facing urban-type surfaces 4744 4745 ! 4746 !-- Set conversion factor to one if not present 4747 IF ( .NOT. PRESENT( fac ) ) THEN 4748 conversion_factor = 1.0_wp 4749 ELSE 4750 conversion_factor = fac 4751 ENDIF 4752 ! 4753 !-- Set counter variable to zero before the variable is written to 4754 !-- the output array. 4755 n_surf = 0 4756 ! 4757 !-- Write the horizontal surfaces. 4758 !-- Before each the variable is written to the output data structure, first 4759 !-- check if the variable for the respective surface type is defined. 4760 !-- If a variable is not defined, skip the block and increment the counter 4761 !-- variable by the number of surface elements of this type. Usually this 4762 !-- is zero, however, there might be the situation that e.g. urban surfaces 4763 !-- are defined but the respective variable is not allocated for this surface 4764 !-- type. To write the data on the exact position, increment the counter. 4765 IF ( ALLOCATED( var_def_h0 ) ) THEN 4766 DO m = 1, surf_def_h(0)%ns 4767 n_surf = n_surf + 1 4768 k = surf_def_h(0)%k(m) 4769 surfaces%var_out(n_surf) = var_def_h0(m) * conversion_factor(k) 4770 ENDDO 4771 ELSE 4772 n_surf = n_surf + surf_def_h(0)%ns 4773 ENDIF 4774 IF ( ALLOCATED( var_def_h1 ) ) THEN 4775 DO m = 1, surf_def_h(1)%ns 4776 n_surf = n_surf + 1 4777 k = surf_def_h(1)%k(m) 4778 surfaces%var_out(n_surf) = var_def_h1(m) * conversion_factor(k) 4779 ENDDO 4780 ELSE 4781 n_surf = n_surf + surf_def_h(1)%ns 4782 ENDIF 4783 IF ( ALLOCATED( var_lsm_h ) ) THEN 4784 DO m = 1, surf_lsm_h%ns 4785 n_surf = n_surf + 1 4786 k = surf_lsm_h%k(m) 4787 surfaces%var_out(n_surf) = var_lsm_h(m) * conversion_factor(k) 4788 ENDDO 4789 ELSE 4790 n_surf = n_surf + surf_lsm_h%ns 4791 ENDIF 4792 IF ( ALLOCATED( var_usm_h ) ) THEN 4793 DO m = 1, surf_usm_h%ns 4794 n_surf = n_surf + 1 4795 k = surf_usm_h%k(m) 4796 surfaces%var_out(n_surf) = var_usm_h(m) * conversion_factor(k) 4797 ENDDO 4798 ELSE 4799 n_surf = n_surf + surf_usm_h%ns 4800 ENDIF 4801 ! 4802 !-- Write northward-facing 4803 IF ( ALLOCATED( var_def_v0 ) ) THEN 4804 DO m = 1, surf_def_v(0)%ns 4805 n_surf = n_surf + 1 4806 k = surf_def_v(0)%k(m) 4807 surfaces%var_out(n_surf) = var_def_v0(m) * conversion_factor(k) 4808 ENDDO 4809 ELSE 4810 n_surf = n_surf + surf_def_v(0)%ns 4811 ENDIF 4812 IF ( ALLOCATED( var_lsm_v0 ) ) THEN 4813 DO m = 1, surf_lsm_v(0)%ns 4814 n_surf = n_surf + 1 4815 k = surf_lsm_v(0)%k(m) 4816 surfaces%var_out(n_surf) = var_lsm_v0(m) * conversion_factor(k) 4817 ENDDO 4818 ELSE 4819 n_surf = n_surf + surf_lsm_v(0)%ns 4820 ENDIF 4821 IF ( ALLOCATED( var_usm_v0 ) ) THEN 4822 DO m = 1, surf_usm_v(0)%ns 4823 n_surf = n_surf + 1 4824 k = surf_usm_v(0)%k(m) 4825 surfaces%var_out(n_surf) = var_usm_v0(m) * conversion_factor(k) 4826 ENDDO 4827 ELSE 4828 n_surf = n_surf + surf_usm_v(0)%ns 4829 ENDIF 4830 ! 4831 !-- Write southward-facing 4832 IF ( ALLOCATED( var_def_v1 ) ) THEN 4833 DO m = 1, surf_def_v(1)%ns 4834 n_surf = n_surf + 1 4835 k = surf_def_v(1)%k(m) 4836 surfaces%var_out(n_surf) = var_def_v1(m) * conversion_factor(k) 4837 ENDDO 4838 ELSE 4839 n_surf = n_surf + surf_def_v(1)%ns 4840 ENDIF 4841 IF ( ALLOCATED( var_lsm_v1 ) ) THEN 4842 DO m = 1, surf_lsm_v(1)%ns 4843 n_surf = n_surf + 1 4844 k = surf_lsm_v(1)%k(m) 4845 surfaces%var_out(n_surf) = var_lsm_v1(m) * conversion_factor(k) 4846 ENDDO 4847 ELSE 4848 n_surf = n_surf + surf_lsm_v(1)%ns 4849 ENDIF 4850 IF ( ALLOCATED( var_usm_v1 ) ) THEN 4851 DO m = 1, surf_usm_v(1)%ns 4852 n_surf = n_surf + 1 4853 k = surf_usm_v(1)%k(m) 4854 surfaces%var_out(n_surf) = var_usm_v1(m) * conversion_factor(k) 4855 ENDDO 4856 ELSE 4857 n_surf = n_surf + surf_usm_v(1)%ns 4858 ENDIF 4859 ! 4860 !-- Write eastward-facing 4861 IF ( ALLOCATED( var_def_v2 ) ) THEN 4862 DO m = 1, surf_def_v(2)%ns 4863 n_surf = n_surf + 1 4864 k = surf_def_v(2)%k(m) 4865 surfaces%var_out(n_surf) = var_def_v2(m) * conversion_factor(k) 4866 ENDDO 4867 ELSE 4868 n_surf = n_surf + surf_def_v(2)%ns 4869 ENDIF 4870 IF ( ALLOCATED( var_lsm_v2 ) ) THEN 4871 DO m = 1, surf_lsm_v(2)%ns 4872 n_surf = n_surf + 1 4873 k = surf_lsm_v(2)%k(m) 4874 surfaces%var_out(n_surf) = var_lsm_v2(m) * conversion_factor(k) 4875 ENDDO 4876 ELSE 4877 n_surf = n_surf + surf_lsm_v(2)%ns 4878 ENDIF 4879 IF ( ALLOCATED( var_usm_v2 ) ) THEN 4880 DO m = 1, surf_usm_v(2)%ns 4881 n_surf = n_surf + 1 4882 k = surf_usm_v(2)%k(m) 4883 surfaces%var_out(n_surf) = var_usm_v2(m) * conversion_factor(k) 4884 ENDDO 4885 ELSE 4886 n_surf = n_surf + surf_usm_v(2)%ns 4887 ENDIF 4888 ! 4889 !-- Write westward-facing 4890 IF ( ALLOCATED( var_def_v3 ) ) THEN 4891 DO m = 1, surf_def_v(3)%ns 4892 n_surf = n_surf + 1 4893 k = surf_def_v(3)%k(m) 4894 surfaces%var_out(n_surf) = var_def_v3(m) * conversion_factor(k) 4895 ENDDO 4896 ELSE 4897 n_surf = n_surf + surf_def_v(3)%ns 4898 ENDIF 4899 IF ( ALLOCATED( var_lsm_v3 ) ) THEN 4900 DO m = 1, surf_lsm_v(3)%ns 4901 n_surf = n_surf + 1 4902 k = surf_lsm_v(3)%k(m) 4903 surfaces%var_out(n_surf) = var_lsm_v3(m) * conversion_factor(k) 4904 ENDDO 4905 ELSE 4906 n_surf = n_surf + surf_lsm_v(3)%ns 4907 ENDIF 4908 IF ( ALLOCATED( var_usm_v3 ) ) THEN 4909 DO m = 1, surf_usm_v(3)%ns 4910 n_surf = n_surf + 1 4911 k = surf_usm_v(3)%k(m) 4912 surfaces%var_out(n_surf) = var_usm_v3(m) * conversion_factor(k) 4913 ENDDO 4914 ELSE 4915 n_surf = n_surf + surf_usm_v(3)%ns 4916 ENDIF 4917 4918 END SUBROUTINE surface_data_output_collect_1d 4919 4920 !------------------------------------------------------------------------------! 3854 !--------------------------------------------------------------------------------------------------! 3855 SUBROUTINE surface_data_output_collect_1d( var_def_h0, var_def_h1, var_lsm_h, var_usm_h, & 3856 var_def_v0, var_lsm_v0, var_usm_v0, var_def_v1, & 3857 var_lsm_v1, var_usm_v1, var_def_v2, var_lsm_v2, & 3858 var_usm_v2, var_def_v3, var_lsm_v3, var_usm_v3, fac ) 3859 3860 IMPLICIT NONE 3861 3862 INTEGER(iwp) :: k !< height index of surface element 3863 INTEGER(iwp) :: m !< running index for surface elements 3864 INTEGER(iwp) :: n_surf !< running index for surface elements 3865 3866 REAL(wp), DIMENSION(:), OPTIONAL :: fac !< passed output conversion factor for heatflux output 3867 REAL(wp), DIMENSION(nzb:nzt+1) :: conversion_factor !< effective array for output conversion factor 3868 3869 REAL(wp), DIMENSION(:), ALLOCATABLE, INTENT(IN) :: var_def_h0 !< output variable at upward-facing default-type surfaces 3870 REAL(wp), DIMENSION(:), ALLOCATABLE, INTENT(IN) :: var_def_h1 !< output variable at downward-facing default-type surfaces 3871 REAL(wp), DIMENSION(:), ALLOCATABLE, INTENT(IN) :: var_lsm_h !< output variable at upward-facing natural-type surfaces 3872 REAL(wp), DIMENSION(:), ALLOCATABLE, INTENT(IN) :: var_usm_h !< output variable at upward-facing urban-type surfaces 3873 REAL(wp), DIMENSION(:), ALLOCATABLE, INTENT(IN) :: var_def_v0 !< output variable at northward-facing default-type surfaces 3874 REAL(wp), DIMENSION(:), ALLOCATABLE, INTENT(IN) :: var_def_v1 !< output variable at southward-facing default-type surfaces 3875 REAL(wp), DIMENSION(:), ALLOCATABLE, INTENT(IN) :: var_def_v2 !< output variable at eastward-facing default-type surfaces 3876 REAL(wp), DIMENSION(:), ALLOCATABLE, INTENT(IN) :: var_def_v3 !< output variable at westward-facing default-type surfaces 3877 REAL(wp), DIMENSION(:), ALLOCATABLE, INTENT(IN) :: var_lsm_v0 !< output variable at northward-facing natural-type surfaces 3878 REAL(wp), DIMENSION(:), ALLOCATABLE, INTENT(IN) :: var_lsm_v1 !< output variable at southward-facing natural-type surfaces 3879 REAL(wp), DIMENSION(:), ALLOCATABLE, INTENT(IN) :: var_lsm_v2 !< output variable at eastward-facing natural-type surfaces 3880 REAL(wp), DIMENSION(:), ALLOCATABLE, INTENT(IN) :: var_lsm_v3 !< output variable at westward-facing natural-type surfaces 3881 REAL(wp), DIMENSION(:), ALLOCATABLE, INTENT(IN) :: var_usm_v0 !< output variable at northward-facing urban-type surfaces 3882 REAL(wp), DIMENSION(:), ALLOCATABLE, INTENT(IN) :: var_usm_v1 !< output variable at southward-facing urban-type surfaces 3883 REAL(wp), DIMENSION(:), ALLOCATABLE, INTENT(IN) :: var_usm_v2 !< output variable at eastward-facing urban-type surfaces 3884 REAL(wp), DIMENSION(:), ALLOCATABLE, INTENT(IN) :: var_usm_v3 !< output variable at westward-facing urban-type surfaces 3885 3886 ! 3887 !-- Set conversion factor to one if not present 3888 IF ( .NOT. PRESENT( fac ) ) THEN 3889 conversion_factor = 1.0_wp 3890 ELSE 3891 conversion_factor = fac 3892 ENDIF 3893 ! 3894 !-- Set counter variable to zero before the variable is written to the output array. 3895 n_surf = 0 3896 ! 3897 !-- Write the horizontal surfaces. 3898 !-- Before each variable is written to the output data structure, first check if the variable 3899 !-- for the respective surface type is defined. If a variable is not defined, skip the block and 3900 !-- increment the counter variable by the number of surface elements of this type. Usually this is 3901 !-- zero, however, there might be the situation that e.g. urban surfaces are defined but the 3902 !-- respective variable is not allocated for this surface type. To write the data on the exact 3903 !-- position, increment the counter. 3904 IF ( ALLOCATED( var_def_h0 ) ) THEN 3905 DO m = 1, surf_def_h(0)%ns 3906 n_surf = n_surf + 1 3907 k = surf_def_h(0)%k(m) 3908 surfaces%var_out(n_surf) = var_def_h0(m) * conversion_factor(k) 3909 ENDDO 3910 ELSE 3911 n_surf = n_surf + surf_def_h(0)%ns 3912 ENDIF 3913 IF ( ALLOCATED( var_def_h1 ) ) THEN 3914 DO m = 1, surf_def_h(1)%ns 3915 n_surf = n_surf + 1 3916 k = surf_def_h(1)%k(m) 3917 surfaces%var_out(n_surf) = var_def_h1(m) * conversion_factor(k) 3918 ENDDO 3919 ELSE 3920 n_surf = n_surf + surf_def_h(1)%ns 3921 ENDIF 3922 IF ( ALLOCATED( var_lsm_h ) ) THEN 3923 DO m = 1, surf_lsm_h%ns 3924 n_surf = n_surf + 1 3925 k = surf_lsm_h%k(m) 3926 surfaces%var_out(n_surf) = var_lsm_h(m) * conversion_factor(k) 3927 ENDDO 3928 ELSE 3929 n_surf = n_surf + surf_lsm_h%ns 3930 ENDIF 3931 IF ( ALLOCATED( var_usm_h ) ) THEN 3932 DO m = 1, surf_usm_h%ns 3933 n_surf = n_surf + 1 3934 k = surf_usm_h%k(m) 3935 surfaces%var_out(n_surf) = var_usm_h(m) * conversion_factor(k) 3936 ENDDO 3937 ELSE 3938 n_surf = n_surf + surf_usm_h%ns 3939 ENDIF 3940 ! 3941 !-- Write northward-facing 3942 IF ( ALLOCATED( var_def_v0 ) ) THEN 3943 DO m = 1, surf_def_v(0)%ns 3944 n_surf = n_surf + 1 3945 k = surf_def_v(0)%k(m) 3946 surfaces%var_out(n_surf) = var_def_v0(m) * conversion_factor(k) 3947 ENDDO 3948 ELSE 3949 n_surf = n_surf + surf_def_v(0)%ns 3950 ENDIF 3951 IF ( ALLOCATED( var_lsm_v0 ) ) THEN 3952 DO m = 1, surf_lsm_v(0)%ns 3953 n_surf = n_surf + 1 3954 k = surf_lsm_v(0)%k(m) 3955 surfaces%var_out(n_surf) = var_lsm_v0(m) * conversion_factor(k) 3956 ENDDO 3957 ELSE 3958 n_surf = n_surf + surf_lsm_v(0)%ns 3959 ENDIF 3960 IF ( ALLOCATED( var_usm_v0 ) ) THEN 3961 DO m = 1, surf_usm_v(0)%ns 3962 n_surf = n_surf + 1 3963 k = surf_usm_v(0)%k(m) 3964 surfaces%var_out(n_surf) = var_usm_v0(m) * conversion_factor(k) 3965 ENDDO 3966 ELSE 3967 n_surf = n_surf + surf_usm_v(0)%ns 3968 ENDIF 3969 ! 3970 !-- Write southward-facing 3971 IF ( ALLOCATED( var_def_v1 ) ) THEN 3972 DO m = 1, surf_def_v(1)%ns 3973 n_surf = n_surf + 1 3974 k = surf_def_v(1)%k(m) 3975 surfaces%var_out(n_surf) = var_def_v1(m) * conversion_factor(k) 3976 ENDDO 3977 ELSE 3978 n_surf = n_surf + surf_def_v(1)%ns 3979 ENDIF 3980 IF ( ALLOCATED( var_lsm_v1 ) ) THEN 3981 DO m = 1, surf_lsm_v(1)%ns 3982 n_surf = n_surf + 1 3983 k = surf_lsm_v(1)%k(m) 3984 surfaces%var_out(n_surf) = var_lsm_v1(m) * conversion_factor(k) 3985 ENDDO 3986 ELSE 3987 n_surf = n_surf + surf_lsm_v(1)%ns 3988 ENDIF 3989 IF ( ALLOCATED( var_usm_v1 ) ) THEN 3990 DO m = 1, surf_usm_v(1)%ns 3991 n_surf = n_surf + 1 3992 k = surf_usm_v(1)%k(m) 3993 surfaces%var_out(n_surf) = var_usm_v1(m) * conversion_factor(k) 3994 ENDDO 3995 ELSE 3996 n_surf = n_surf + surf_usm_v(1)%ns 3997 ENDIF 3998 ! 3999 !-- Write eastward-facing 4000 IF ( ALLOCATED( var_def_v2 ) ) THEN 4001 DO m = 1, surf_def_v(2)%ns 4002 n_surf = n_surf + 1 4003 k = surf_def_v(2)%k(m) 4004 surfaces%var_out(n_surf) = var_def_v2(m) * conversion_factor(k) 4005 ENDDO 4006 ELSE 4007 n_surf = n_surf + surf_def_v(2)%ns 4008 ENDIF 4009 IF ( ALLOCATED( var_lsm_v2 ) ) THEN 4010 DO m = 1, surf_lsm_v(2)%ns 4011 n_surf = n_surf + 1 4012 k = surf_lsm_v(2)%k(m) 4013 surfaces%var_out(n_surf) = var_lsm_v2(m) * conversion_factor(k) 4014 ENDDO 4015 ELSE 4016 n_surf = n_surf + surf_lsm_v(2)%ns 4017 ENDIF 4018 IF ( ALLOCATED( var_usm_v2 ) ) THEN 4019 DO m = 1, surf_usm_v(2)%ns 4020 n_surf = n_surf + 1 4021 k = surf_usm_v(2)%k(m) 4022 surfaces%var_out(n_surf) = var_usm_v2(m) * conversion_factor(k) 4023 ENDDO 4024 ELSE 4025 n_surf = n_surf + surf_usm_v(2)%ns 4026 ENDIF 4027 ! 4028 !-- Write westward-facing 4029 IF ( ALLOCATED( var_def_v3 ) ) THEN 4030 DO m = 1, surf_def_v(3)%ns 4031 n_surf = n_surf + 1 4032 k = surf_def_v(3)%k(m) 4033 surfaces%var_out(n_surf) = var_def_v3(m) * conversion_factor(k) 4034 ENDDO 4035 ELSE 4036 n_surf = n_surf + surf_def_v(3)%ns 4037 ENDIF 4038 IF ( ALLOCATED( var_lsm_v3 ) ) THEN 4039 DO m = 1, surf_lsm_v(3)%ns 4040 n_surf = n_surf + 1 4041 k = surf_lsm_v(3)%k(m) 4042 surfaces%var_out(n_surf) = var_lsm_v3(m) * conversion_factor(k) 4043 ENDDO 4044 ELSE 4045 n_surf = n_surf + surf_lsm_v(3)%ns 4046 ENDIF 4047 IF ( ALLOCATED( var_usm_v3 ) ) THEN 4048 DO m = 1, surf_usm_v(3)%ns 4049 n_surf = n_surf + 1 4050 k = surf_usm_v(3)%k(m) 4051 surfaces%var_out(n_surf) = var_usm_v3(m) * conversion_factor(k) 4052 ENDDO 4053 ELSE 4054 n_surf = n_surf + surf_usm_v(3)%ns 4055 ENDIF 4056 4057 END SUBROUTINE surface_data_output_collect_1d 4058 4059 !--------------------------------------------------------------------------------------------------! 4921 4060 ! Description: 4922 4061 ! ------------ 4923 !> Collect the surface data from different types and different orientation 4924 !> for properties which are defined using tile approach. 4925 !------------------------------------------------------------------------------! 4926 SUBROUTINE surface_data_output_collect_2d( var_def_h0, var_def_h1, & 4927 var_lsm_h, var_usm_h, & 4928 var_def_v0, var_lsm_v0, var_usm_v0, & 4929 var_def_v1, var_lsm_v1, var_usm_v1, & 4930 var_def_v2, var_lsm_v2, var_usm_v2, & 4931 var_def_v3, var_lsm_v3, var_usm_v3, & 4932 fac ) 4933 4934 IMPLICIT NONE 4935 4936 INTEGER(iwp) :: k !< height index of surface element 4937 INTEGER(iwp) :: m !< running index for surface elements 4938 INTEGER(iwp) :: n_surf !< running index for surface elements 4939 4940 REAL(wp), DIMENSION(:), OPTIONAL :: fac !< passed output conversion factor for heatflux output 4941 REAL(wp), DIMENSION(nzb:nzt+1) :: conversion_factor !< effective array for output conversion factor 4942 4943 REAL(wp), DIMENSION(:,:), ALLOCATABLE, INTENT(IN) :: var_def_h0 !< output variable at upward-facing default-type surfaces 4944 REAL(wp), DIMENSION(:,:), ALLOCATABLE, INTENT(IN) :: var_def_h1 !< output variable at downward-facing default-type surfaces 4945 REAL(wp), DIMENSION(:,:), ALLOCATABLE, INTENT(IN) :: var_lsm_h !< output variable at upward-facing natural-type surfaces 4946 REAL(wp), DIMENSION(:,:), ALLOCATABLE, INTENT(IN) :: var_usm_h !< output variable at upward-facing urban-type surfaces 4947 REAL(wp), DIMENSION(:,:), ALLOCATABLE, INTENT(IN) :: var_def_v0 !< output variable at northward-facing default-type surfaces 4948 REAL(wp), DIMENSION(:,:), ALLOCATABLE, INTENT(IN) :: var_def_v1 !< output variable at southward-facing default-type surfaces 4949 REAL(wp), DIMENSION(:,:), ALLOCATABLE, INTENT(IN) :: var_def_v2 !< output variable at eastward-facing default-type surfaces 4950 REAL(wp), DIMENSION(:,:), ALLOCATABLE, INTENT(IN) :: var_def_v3 !< output variable at westward-facing default-type surfaces 4951 REAL(wp), DIMENSION(:,:), ALLOCATABLE, INTENT(IN) :: var_lsm_v0 !< output variable at northward-facing natural-type surfaces 4952 REAL(wp), DIMENSION(:,:), ALLOCATABLE, INTENT(IN) :: var_lsm_v1 !< output variable at southward-facing natural-type surfaces 4953 REAL(wp), DIMENSION(:,:), ALLOCATABLE, INTENT(IN) :: var_lsm_v2 !< output variable at eastward-facing natural-type surfaces 4954 REAL(wp), DIMENSION(:,:), ALLOCATABLE, INTENT(IN) :: var_lsm_v3 !< output variable at westward-facing natural-type surfaces 4955 REAL(wp), DIMENSION(:,:), ALLOCATABLE, INTENT(IN) :: var_usm_v0 !< output variable at northward-facing urban-type surfaces 4956 REAL(wp), DIMENSION(:,:), ALLOCATABLE, INTENT(IN) :: var_usm_v1 !< output variable at southward-facing urban-type surfaces 4957 REAL(wp), DIMENSION(:,:), ALLOCATABLE, INTENT(IN) :: var_usm_v2 !< output variable at eastward-facing urban-type surfaces 4958 REAL(wp), DIMENSION(:,:), ALLOCATABLE, INTENT(IN) :: var_usm_v3 !< output variable at westward-facing urban-type surfaces 4959 4960 ! 4961 !-- Set conversion factor to one if not present 4962 IF ( .NOT. PRESENT( fac ) ) THEN 4963 conversion_factor = 1.0_wp 4964 ELSE 4965 conversion_factor = fac 4966 ENDIF 4967 ! 4968 !-- Set counter variable to zero before the variable is written to 4969 !-- the output array. 4970 n_surf = 0 4971 ! 4972 !-- Write the horizontal surfaces. 4973 !-- Before each the variable is written to the output data structure, first 4974 !-- check if the variable for the respective surface type is defined. 4975 !-- If a variable is not defined, skip the block and increment the counter 4976 !-- variable by the number of surface elements of this type. Usually this 4977 !-- is zero, however, there might be the situation that e.g. urban surfaces 4978 !-- are defined but the respective variable is not allocated for this surface 4979 !-- type. To write the data on the exact position, increment the counter. 4980 IF ( ALLOCATED( var_def_h0 ) ) THEN 4981 DO m = 1, surf_def_h(0)%ns 4982 n_surf = n_surf + 1 4983 k = surf_def_h(0)%k(m) 4984 surfaces%var_out(n_surf) = SUM ( surf_def_h(0)%frac(m,:) * & 4985 var_def_h0(m,:) ) * conversion_factor(k) 4986 ENDDO 4987 ELSE 4988 n_surf = n_surf + surf_def_h(0)%ns 4989 ENDIF 4990 IF ( ALLOCATED( var_def_h1 ) ) THEN 4991 DO m = 1, surf_def_h(1)%ns 4992 n_surf = n_surf + 1 4993 k = surf_def_h(1)%k(m) 4994 surfaces%var_out(n_surf) = SUM ( surf_def_h(1)%frac(m,:) * & 4995 var_def_h1(m,:) ) * conversion_factor(k) 4996 ENDDO 4997 ELSE 4998 n_surf = n_surf + surf_def_h(1)%ns 4999 ENDIF 5000 IF ( ALLOCATED( var_lsm_h ) ) THEN 5001 DO m = 1, surf_lsm_h%ns 5002 n_surf = n_surf + 1 5003 k = surf_lsm_h%k(m) 5004 surfaces%var_out(n_surf) = SUM ( surf_lsm_h%frac(m,:) * & 5005 var_lsm_h(m,:) ) * conversion_factor(k) 5006 ENDDO 5007 ELSE 5008 n_surf = n_surf + surf_lsm_h%ns 5009 ENDIF 5010 IF ( ALLOCATED( var_usm_h ) ) THEN 5011 DO m = 1, surf_usm_h%ns 5012 n_surf = n_surf + 1 5013 k = surf_usm_h%k(m) 5014 surfaces%var_out(n_surf) = SUM ( surf_usm_h%frac(m,:) * & 5015 var_usm_h(m,:) ) * conversion_factor(k) 5016 ENDDO 5017 ELSE 5018 n_surf = n_surf + surf_usm_h%ns 5019 ENDIF 5020 ! 5021 !-- Write northward-facing 5022 IF ( ALLOCATED( var_def_v0 ) ) THEN 5023 DO m = 1, surf_def_v(0)%ns 5024 n_surf = n_surf + 1 5025 k = surf_def_v(0)%k(m) 5026 surfaces%var_out(n_surf) = SUM ( surf_def_v(0)%frac(m,:) * & 5027 var_def_v0(m,:) ) * conversion_factor(k) 5028 ENDDO 5029 ELSE 5030 n_surf = n_surf + surf_def_v(0)%ns 5031 ENDIF 5032 IF ( ALLOCATED( var_lsm_v0 ) ) THEN 5033 DO m = 1, surf_lsm_v(0)%ns 5034 n_surf = n_surf + 1 5035 k = surf_lsm_v(0)%k(m) 5036 surfaces%var_out(n_surf) = SUM ( surf_lsm_v(0)%frac(m,:) * & 5037 var_lsm_v0(m,:) ) * conversion_factor(k) 5038 ENDDO 5039 ELSE 5040 n_surf = n_surf + surf_lsm_v(0)%ns 5041 ENDIF 5042 IF ( ALLOCATED( var_usm_v0 ) ) THEN 5043 DO m = 1, surf_usm_v(0)%ns 5044 n_surf = n_surf + 1 5045 k = surf_usm_v(0)%k(m) 5046 surfaces%var_out(n_surf) = SUM ( surf_usm_v(0)%frac(m,:) * & 5047 var_usm_v0(m,:) ) * conversion_factor(k) 5048 ENDDO 5049 ELSE 5050 n_surf = n_surf + surf_usm_v(0)%ns 5051 ENDIF 5052 ! 5053 !-- Write southward-facing 5054 IF ( ALLOCATED( var_def_v1 ) ) THEN 5055 DO m = 1, surf_def_v(1)%ns 5056 n_surf = n_surf + 1 5057 k = surf_def_v(1)%k(m) 5058 surfaces%var_out(n_surf) = SUM ( surf_def_v(1)%frac(m,:) * & 5059 var_def_v1(m,:) ) * conversion_factor(k) 5060 ENDDO 5061 ELSE 5062 n_surf = n_surf + surf_def_v(1)%ns 5063 ENDIF 5064 IF ( ALLOCATED( var_lsm_v1 ) ) THEN 5065 DO m = 1, surf_lsm_v(1)%ns 5066 n_surf = n_surf + 1 5067 k = surf_lsm_v(1)%k(m) 5068 surfaces%var_out(n_surf) = SUM ( surf_lsm_v(1)%frac(m,:) * & 5069 var_lsm_v1(m,:) ) * conversion_factor(k) 5070 ENDDO 5071 ELSE 5072 n_surf = n_surf + surf_lsm_v(1)%ns 5073 ENDIF 5074 IF ( ALLOCATED( var_usm_v1 ) ) THEN 5075 DO m = 1, surf_usm_v(1)%ns 5076 n_surf = n_surf + 1 5077 k = surf_usm_v(1)%k(m) 5078 surfaces%var_out(n_surf) = SUM ( surf_usm_v(1)%frac(m,:) * & 5079 var_usm_v1(m,:) ) * conversion_factor(k) 5080 ENDDO 5081 ELSE 5082 n_surf = n_surf + surf_usm_v(1)%ns 5083 ENDIF 5084 ! 5085 !-- Write eastward-facing 5086 IF ( ALLOCATED( var_def_v2 ) ) THEN 5087 DO m = 1, surf_def_v(2)%ns 5088 n_surf = n_surf + 1 5089 k = surf_def_v(2)%k(m) 5090 surfaces%var_out(n_surf) = SUM ( surf_def_v(2)%frac(m,:) * & 5091 var_def_v2(m,:) ) * conversion_factor(k) 5092 ENDDO 5093 ELSE 5094 n_surf = n_surf + surf_def_v(2)%ns 5095 ENDIF 5096 IF ( ALLOCATED( var_lsm_v2 ) ) THEN 5097 DO m = 1, surf_lsm_v(2)%ns 5098 n_surf = n_surf + 1 5099 k = surf_lsm_v(2)%k(m) 5100 surfaces%var_out(n_surf) = SUM ( surf_lsm_v(2)%frac(m,:) * & 5101 var_lsm_v2(m,:) ) * conversion_factor(k) 5102 ENDDO 5103 ELSE 5104 n_surf = n_surf + surf_lsm_v(2)%ns 5105 ENDIF 5106 IF ( ALLOCATED( var_usm_v2 ) ) THEN 5107 DO m = 1, surf_usm_v(2)%ns 5108 n_surf = n_surf + 1 5109 k = surf_usm_v(2)%k(m) 5110 surfaces%var_out(n_surf) = SUM ( surf_usm_v(2)%frac(m,:) * & 5111 var_usm_v2(m,:) ) * conversion_factor(k) 5112 ENDDO 5113 ELSE 5114 n_surf = n_surf + surf_usm_v(2)%ns 5115 ENDIF 5116 ! 5117 !-- Write westward-facing 5118 IF ( ALLOCATED( var_def_v3 ) ) THEN 5119 DO m = 1, surf_def_v(3)%ns 5120 n_surf = n_surf + 1 5121 k = surf_def_v(3)%k(m) 5122 surfaces%var_out(n_surf) = SUM ( surf_def_v(3)%frac(m,:) * & 5123 var_def_v3(m,:) ) * conversion_factor(k) 5124 ENDDO 5125 ELSE 5126 n_surf = n_surf + surf_def_v(3)%ns 5127 ENDIF 5128 IF ( ALLOCATED( var_lsm_v3 ) ) THEN 5129 DO m = 1, surf_lsm_v(3)%ns 5130 n_surf = n_surf + 1 5131 k = surf_lsm_v(3)%k(m) 5132 surfaces%var_out(n_surf) = SUM ( surf_lsm_v(3)%frac(m,:) * & 5133 var_lsm_v3(m,:) ) * conversion_factor(k) 5134 ENDDO 5135 ELSE 5136 n_surf = n_surf + surf_lsm_v(3)%ns 5137 ENDIF 5138 IF ( ALLOCATED( var_usm_v3 ) ) THEN 5139 DO m = 1, surf_usm_v(3)%ns 5140 n_surf = n_surf + 1 5141 k = surf_usm_v(3)%k(m) 5142 surfaces%var_out(n_surf) = SUM ( surf_usm_v(3)%frac(m,:) * & 5143 var_usm_v3(m,:) ) * conversion_factor(k) 5144 ENDDO 5145 ELSE 5146 n_surf = n_surf + surf_usm_v(3)%ns 5147 ENDIF 5148 5149 END SUBROUTINE surface_data_output_collect_2d 5150 5151 !------------------------------------------------------------------------------! 4062 !> Collect the surface data from different types and different orientation for properties which are 4063 !> defined using tile approach. 4064 !--------------------------------------------------------------------------------------------------! 4065 SUBROUTINE surface_data_output_collect_2d( var_def_h0, var_def_h1, var_lsm_h, var_usm_h, & 4066 var_def_v0, var_lsm_v0, var_usm_v0, var_def_v1, & 4067 var_lsm_v1, var_usm_v1, var_def_v2, var_lsm_v2, & 4068 var_usm_v2, var_def_v3, var_lsm_v3, var_usm_v3, fac ) 4069 4070 IMPLICIT NONE 4071 4072 INTEGER(iwp) :: k !< height index of surface element 4073 INTEGER(iwp) :: m !< running index for surface elements 4074 INTEGER(iwp) :: n_surf !< running index for surface elements 4075 4076 REAL(wp), DIMENSION(:), OPTIONAL :: fac !< passed output conversion factor for heatflux output 4077 REAL(wp), DIMENSION(nzb:nzt+1) :: conversion_factor !< effective array for output conversion factor 4078 4079 REAL(wp), DIMENSION(:,:), ALLOCATABLE, INTENT(IN) :: var_def_h0 !< output variable at upward-facing default-type surfaces 4080 REAL(wp), DIMENSION(:,:), ALLOCATABLE, INTENT(IN) :: var_def_h1 !< output variable at downward-facing default-type surfaces 4081 REAL(wp), DIMENSION(:,:), ALLOCATABLE, INTENT(IN) :: var_lsm_h !< output variable at upward-facing natural-type surfaces 4082 REAL(wp), DIMENSION(:,:), ALLOCATABLE, INTENT(IN) :: var_usm_h !< output variable at upward-facing urban-type surfaces 4083 REAL(wp), DIMENSION(:,:), ALLOCATABLE, INTENT(IN) :: var_def_v0 !< output variable at northward-facing default-type surfaces 4084 REAL(wp), DIMENSION(:,:), ALLOCATABLE, INTENT(IN) :: var_def_v1 !< output variable at southward-facing default-type surfaces 4085 REAL(wp), DIMENSION(:,:), ALLOCATABLE, INTENT(IN) :: var_def_v2 !< output variable at eastward-facing default-type surfaces 4086 REAL(wp), DIMENSION(:,:), ALLOCATABLE, INTENT(IN) :: var_def_v3 !< output variable at westward-facing default-type surfaces 4087 REAL(wp), DIMENSION(:,:), ALLOCATABLE, INTENT(IN) :: var_lsm_v0 !< output variable at northward-facing natural-type surfaces 4088 REAL(wp), DIMENSION(:,:), ALLOCATABLE, INTENT(IN) :: var_lsm_v1 !< output variable at southward-facing natural-type surfaces 4089 REAL(wp), DIMENSION(:,:), ALLOCATABLE, INTENT(IN) :: var_lsm_v2 !< output variable at eastward-facing natural-type surfaces 4090 REAL(wp), DIMENSION(:,:), ALLOCATABLE, INTENT(IN) :: var_lsm_v3 !< output variable at westward-facing natural-type surfaces 4091 REAL(wp), DIMENSION(:,:), ALLOCATABLE, INTENT(IN) :: var_usm_v0 !< output variable at northward-facing urban-type surfaces 4092 REAL(wp), DIMENSION(:,:), ALLOCATABLE, INTENT(IN) :: var_usm_v1 !< output variable at southward-facing urban-type surfaces 4093 REAL(wp), DIMENSION(:,:), ALLOCATABLE, INTENT(IN) :: var_usm_v2 !< output variable at eastward-facing urban-type surfaces 4094 REAL(wp), DIMENSION(:,:), ALLOCATABLE, INTENT(IN) :: var_usm_v3 !< output variable at westward-facing urban-type surfaces 4095 4096 ! 4097 !-- Set conversion factor to one if not present 4098 IF ( .NOT. PRESENT( fac ) ) THEN 4099 conversion_factor = 1.0_wp 4100 ELSE 4101 conversion_factor = fac 4102 ENDIF 4103 ! 4104 !-- Set counter variable to zero before the variable is written to the output array. 4105 n_surf = 0 4106 ! 4107 !-- Write the horizontal surfaces. 4108 !-- Before each variable is written to the output data structure, first check if the variable 4109 !-- for the respective surface type is defined. If a variable is not defined, skip the block and 4110 !-- increment the counter variable by the number of surface elements of this type. Usually this is 4111 !-- zero, however, there might be the situation that e.g. urban surfaces are defined but the 4112 !-- respective variable is not allocated for this surface type. To write the data on the exact 4113 !-- position, increment the counter. 4114 IF ( ALLOCATED( var_def_h0 ) ) THEN 4115 DO m = 1, surf_def_h(0)%ns 4116 n_surf = n_surf + 1 4117 k = surf_def_h(0)%k(m) 4118 surfaces%var_out(n_surf) = SUM ( surf_def_h(0)%frac(m,:) * var_def_h0(m,:) ) * & 4119 conversion_factor(k) 4120 ENDDO 4121 ELSE 4122 n_surf = n_surf + surf_def_h(0)%ns 4123 ENDIF 4124 IF ( ALLOCATED( var_def_h1 ) ) THEN 4125 DO m = 1, surf_def_h(1)%ns 4126 n_surf = n_surf + 1 4127 k = surf_def_h(1)%k(m) 4128 surfaces%var_out(n_surf) = SUM ( surf_def_h(1)%frac(m,:) * var_def_h1(m,:) ) * & 4129 conversion_factor(k) 4130 ENDDO 4131 ELSE 4132 n_surf = n_surf + surf_def_h(1)%ns 4133 ENDIF 4134 IF ( ALLOCATED( var_lsm_h ) ) THEN 4135 DO m = 1, surf_lsm_h%ns 4136 n_surf = n_surf + 1 4137 k = surf_lsm_h%k(m) 4138 surfaces%var_out(n_surf) = SUM ( surf_lsm_h%frac(m,:) * var_lsm_h(m,:) ) * & 4139 conversion_factor(k) 4140 ENDDO 4141 ELSE 4142 n_surf = n_surf + surf_lsm_h%ns 4143 ENDIF 4144 IF ( ALLOCATED( var_usm_h ) ) THEN 4145 DO m = 1, surf_usm_h%ns 4146 n_surf = n_surf + 1 4147 k = surf_usm_h%k(m) 4148 surfaces%var_out(n_surf) = SUM ( surf_usm_h%frac(m,:) * var_usm_h(m,:) ) & 4149 * conversion_factor(k) 4150 ENDDO 4151 ELSE 4152 n_surf = n_surf + surf_usm_h%ns 4153 ENDIF 4154 ! 4155 !-- Write northward-facing 4156 IF ( ALLOCATED( var_def_v0 ) ) THEN 4157 DO m = 1, surf_def_v(0)%ns 4158 n_surf = n_surf + 1 4159 k = surf_def_v(0)%k(m) 4160 surfaces%var_out(n_surf) = SUM ( surf_def_v(0)%frac(m,:) * var_def_v0(m,:) ) * & 4161 conversion_factor(k) 4162 ENDDO 4163 ELSE 4164 n_surf = n_surf + surf_def_v(0)%ns 4165 ENDIF 4166 IF ( ALLOCATED( var_lsm_v0 ) ) THEN 4167 DO m = 1, surf_lsm_v(0)%ns 4168 n_surf = n_surf + 1 4169 k = surf_lsm_v(0)%k(m) 4170 surfaces%var_out(n_surf) = SUM ( surf_lsm_v(0)%frac(m,:) * var_lsm_v0(m,:) ) * & 4171 conversion_factor(k) 4172 ENDDO 4173 ELSE 4174 n_surf = n_surf + surf_lsm_v(0)%ns 4175 ENDIF 4176 IF ( ALLOCATED( var_usm_v0 ) ) THEN 4177 DO m = 1, surf_usm_v(0)%ns 4178 n_surf = n_surf + 1 4179 k = surf_usm_v(0)%k(m) 4180 surfaces%var_out(n_surf) = SUM ( surf_usm_v(0)%frac(m,:) * var_usm_v0(m,:) ) * & 4181 conversion_factor(k) 4182 ENDDO 4183 ELSE 4184 n_surf = n_surf + surf_usm_v(0)%ns 4185 ENDIF 4186 ! 4187 !-- Write southward-facing 4188 IF ( ALLOCATED( var_def_v1 ) ) THEN 4189 DO m = 1, surf_def_v(1)%ns 4190 n_surf = n_surf + 1 4191 k = surf_def_v(1)%k(m) 4192 surfaces%var_out(n_surf) = SUM ( surf_def_v(1)%frac(m,:) * var_def_v1(m,:) ) * & 4193 conversion_factor(k) 4194 ENDDO 4195 ELSE 4196 n_surf = n_surf + surf_def_v(1)%ns 4197 ENDIF 4198 IF ( ALLOCATED( var_lsm_v1 ) ) THEN 4199 DO m = 1, surf_lsm_v(1)%ns 4200 n_surf = n_surf + 1 4201 k = surf_lsm_v(1)%k(m) 4202 surfaces%var_out(n_surf) = SUM ( surf_lsm_v(1)%frac(m,:) * var_lsm_v1(m,:) ) * & 4203 conversion_factor(k) 4204 ENDDO 4205 ELSE 4206 n_surf = n_surf + surf_lsm_v(1)%ns 4207 ENDIF 4208 IF ( ALLOCATED( var_usm_v1 ) ) THEN 4209 DO m = 1, surf_usm_v(1)%ns 4210 n_surf = n_surf + 1 4211 k = surf_usm_v(1)%k(m) 4212 surfaces%var_out(n_surf) = SUM ( surf_usm_v(1)%frac(m,:) * var_usm_v1(m,:) ) * & 4213 conversion_factor(k) 4214 ENDDO 4215 ELSE 4216 n_surf = n_surf + surf_usm_v(1)%ns 4217 ENDIF 4218 ! 4219 !-- Write eastward-facing 4220 IF ( ALLOCATED( var_def_v2 ) ) THEN 4221 DO m = 1, surf_def_v(2)%ns 4222 n_surf = n_surf + 1 4223 k = surf_def_v(2)%k(m) 4224 surfaces%var_out(n_surf) = SUM ( surf_def_v(2)%frac(m,:) * var_def_v2(m,:) ) * & 4225 conversion_factor(k) 4226 ENDDO 4227 ELSE 4228 n_surf = n_surf + surf_def_v(2)%ns 4229 ENDIF 4230 IF ( ALLOCATED( var_lsm_v2 ) ) THEN 4231 DO m = 1, surf_lsm_v(2)%ns 4232 n_surf = n_surf + 1 4233 k = surf_lsm_v(2)%k(m) 4234 surfaces%var_out(n_surf) = SUM ( surf_lsm_v(2)%frac(m,:) * var_lsm_v2(m,:) ) * & 4235 conversion_factor(k) 4236 ENDDO 4237 ELSE 4238 n_surf = n_surf + surf_lsm_v(2)%ns 4239 ENDIF 4240 IF ( ALLOCATED( var_usm_v2 ) ) THEN 4241 DO m = 1, surf_usm_v(2)%ns 4242 n_surf = n_surf + 1 4243 k = surf_usm_v(2)%k(m) 4244 surfaces%var_out(n_surf) = SUM ( surf_usm_v(2)%frac(m,:) * var_usm_v2(m,:) ) * & 4245 conversion_factor(k) 4246 ENDDO 4247 ELSE 4248 n_surf = n_surf + surf_usm_v(2)%ns 4249 ENDIF 4250 ! 4251 !-- Write westward-facing 4252 IF ( ALLOCATED( var_def_v3 ) ) THEN 4253 DO m = 1, surf_def_v(3)%ns 4254 n_surf = n_surf + 1 4255 k = surf_def_v(3)%k(m) 4256 surfaces%var_out(n_surf) = SUM ( surf_def_v(3)%frac(m,:) * var_def_v3(m,:) ) * & 4257 conversion_factor(k) 4258 ENDDO 4259 ELSE 4260 n_surf = n_surf + surf_def_v(3)%ns 4261 ENDIF 4262 IF ( ALLOCATED( var_lsm_v3 ) ) THEN 4263 DO m = 1, surf_lsm_v(3)%ns 4264 n_surf = n_surf + 1 4265 k = surf_lsm_v(3)%k(m) 4266 surfaces%var_out(n_surf) = SUM ( surf_lsm_v(3)%frac(m,:) * var_lsm_v3(m,:) ) * & 4267 conversion_factor(k) 4268 ENDDO 4269 ELSE 4270 n_surf = n_surf + surf_lsm_v(3)%ns 4271 ENDIF 4272 IF ( ALLOCATED( var_usm_v3 ) ) THEN 4273 DO m = 1, surf_usm_v(3)%ns 4274 n_surf = n_surf + 1 4275 k = surf_usm_v(3)%k(m) 4276 surfaces%var_out(n_surf) = SUM ( surf_usm_v(3)%frac(m,:) * var_usm_v3(m,:) ) * & 4277 conversion_factor(k) 4278 ENDDO 4279 ELSE 4280 n_surf = n_surf + surf_usm_v(3)%ns 4281 ENDIF 4282 4283 END SUBROUTINE surface_data_output_collect_2d 4284 4285 !--------------------------------------------------------------------------------------------------! 5152 4286 ! Description: 5153 4287 ! ------------ 5154 4288 !> Parin for output of surface parameters 5155 !------------------------------------------------------------------------------! 5156 SUBROUTINE surface_data_output_parin 5157 5158 IMPLICIT NONE 5159 5160 CHARACTER (LEN=80) :: line !< dummy string that contains the current line of the parameter file 5161 5162 5163 NAMELIST /surface_data_output_parameters/ & 5164 averaging_interval_surf, data_output_surf, & 5165 dt_dosurf, dt_dosurf_av, & 5166 skip_time_dosurf, skip_time_dosurf_av, & 5167 to_netcdf, to_vtk 5168 5169 line = ' ' 5170 5171 ! 5172 !-- Try to find the namelist 5173 REWIND ( 11 ) 5174 line = ' ' 5175 DO WHILE ( INDEX( line, '&surface_data_output_parameters' ) == 0 ) 5176 READ ( 11, '(A)', END=14 ) line 5177 ENDDO 5178 BACKSPACE ( 11 ) 5179 5180 ! 5181 !-- Read namelist 5182 READ ( 11, surface_data_output_parameters, ERR = 10 ) 5183 ! 5184 !-- Set flag that indicates that surface data output is switched on 5185 surface_output = .TRUE. 5186 GOTO 14 5187 5188 10 BACKSPACE( 11 ) 5189 READ( 11 , '(A)') line 5190 CALL parin_fail_message( 'surface_data_output_parameters', line ) 5191 5192 14 CONTINUE 5193 5194 5195 END SUBROUTINE surface_data_output_parin 5196 5197 5198 !------------------------------------------------------------------------------! 4289 !--------------------------------------------------------------------------------------------------! 4290 SUBROUTINE surface_data_output_parin 4291 4292 IMPLICIT NONE 4293 4294 CHARACTER (LEN=80) :: line !< dummy string that contains the current line of the parameter file 4295 4296 4297 NAMELIST /surface_data_output_parameters/ averaging_interval_surf, data_output_surf, & 4298 dt_dosurf, dt_dosurf_av, skip_time_dosurf, & 4299 skip_time_dosurf_av, to_netcdf, to_vtk 4300 4301 line = ' ' 4302 4303 ! 4304 !-- Try to find the namelist 4305 REWIND ( 11 ) 4306 line = ' ' 4307 DO WHILE ( INDEX( line, '&surface_data_output_parameters' ) == 0 ) 4308 READ ( 11, '(A)', END=14 ) line 4309 ENDDO 4310 BACKSPACE ( 11 ) 4311 4312 ! 4313 !-- Read namelist 4314 READ ( 11, surface_data_output_parameters, ERR = 10 ) 4315 ! 4316 !-- Set flag that indicates that surface data output is switched on 4317 surface_output = .TRUE. 4318 GOTO 14 4319 4320 10 BACKSPACE( 11 ) 4321 READ( 11 , '(A)') line 4322 CALL parin_fail_message( 'surface_data_output_parameters', line ) 4323 4324 14 CONTINUE 4325 4326 4327 END SUBROUTINE surface_data_output_parin 4328 4329 4330 !--------------------------------------------------------------------------------------------------! 5199 4331 ! Description: 5200 4332 ! ------------ 5201 !> Check the input parameters for consistency. Further pre-process the given 5202 !> output variables, i.e. separate them into average and non-average output 5203 !> variables and map them onto internal output array. 5204 !------------------------------------------------------------------------------! 5205 SUBROUTINE surface_data_output_check_parameters 5206 5207 USE control_parameters, & 5208 ONLY: averaging_interval, dt_data_output, indoor_model, & 5209 initializing_actions, message_string 5210 5211 USE pegrid, & 5212 ONLY: numprocs_previous_run 5213 5214 IMPLICIT NONE 5215 5216 CHARACTER(LEN=100) :: trimvar !< dummy for single output variable 5217 CHARACTER(LEN=100) :: unit !< dummy for unit of output variable 5218 5219 INTEGER(iwp) :: av !< id indicating average or non-average data output 5220 INTEGER(iwp) :: ilen !< string length 5221 INTEGER(iwp) :: n_out !< running index for number of output variables 5222 ! 5223 !-- Check if any output file type is selected 5224 IF ( .NOT. to_vtk .AND. .NOT. to_netcdf ) THEN 5225 WRITE( message_string, * ) & 5226 'no output file type selected for surface-data output!&' // & 5227 'Set at least either "to_vtk" or "to_netcdf" to .TRUE.' 5228 CALL message( 'surface_data_output_check_parameters', & 5229 'PA0662', 1, 2, 0, 6, 0 ) 4333 !> Check the input parameters for consistency. Further pre-process the given output variables, i.e. 4334 !> separate them into average and non-average output variables and map them onto internal output 4335 !> array. 4336 !--------------------------------------------------------------------------------------------------! 4337 SUBROUTINE surface_data_output_check_parameters 4338 4339 USE control_parameters, & 4340 ONLY: averaging_interval, & 4341 dt_data_output, & 4342 indoor_model, & 4343 initializing_actions, & 4344 message_string 4345 4346 USE pegrid, & 4347 ONLY: numprocs_previous_run 4348 4349 IMPLICIT NONE 4350 4351 CHARACTER(LEN=100) :: trimvar !< dummy for single output variable 4352 CHARACTER(LEN=100) :: unit !< dummy for unit of output variable 4353 4354 INTEGER(iwp) :: av !< id indicating average or non-average data output 4355 INTEGER(iwp) :: ilen !< string length 4356 INTEGER(iwp) :: n_out !< running index for number of output variables 4357 ! 4358 !-- Check if any output file type is selected 4359 IF ( .NOT. to_vtk .AND. .NOT. to_netcdf ) THEN 4360 WRITE( message_string, * ) 'no output file type selected for surface-data output!&' // & 4361 'Set at least either "to_vtk" or "to_netcdf" to .TRUE.' 4362 CALL message( 'surface_data_output_check_parameters', 'PA0662', 1, 2, 0, 6, 0 ) 4363 ENDIF 4364 ! 4365 !-- Check the average interval 4366 IF ( averaging_interval_surf == 9999999.9_wp ) THEN 4367 averaging_interval_surf = averaging_interval 4368 ENDIF 4369 ! 4370 !-- Set the default data-output interval dt_data_output if necessary 4371 IF ( dt_dosurf == 9999999.9_wp ) dt_dosurf = dt_data_output 4372 IF ( dt_dosurf_av == 9999999.9_wp ) dt_dosurf_av = dt_data_output 4373 4374 IF ( averaging_interval_surf > dt_dosurf_av ) THEN 4375 WRITE( message_string, * ) 'averaging_interval_surf = ', averaging_interval_surf, & 4376 ' must be <= dt_dosurf_av = ', dt_dosurf_av 4377 CALL message( 'surface_data_output_check_parameters', 'PA0536', 1, 2, 0, 6, 0 ) 4378 ENDIF 4379 4380 #if ! defined( __netcdf4_parallel ) 4381 ! 4382 !-- Surface output via NetCDF requires parallel NetCDF 4383 IF ( to_netcdf ) THEN 4384 message_string = 'to_netcdf = .True. requires parallel NetCDF' 4385 CALL message( 'surface_data_output_check_parameters', 'PA0116', 1, 2, 0, 6, 0 ) 4386 ENDIF 4387 #endif 4388 ! 4389 !-- In case of parallel NetCDF output the output timestep must not be zero. This is because the 4390 !-- number of requiered output timesteps is pre-calculated, which is not possible with zero output 4391 !-- timestep. 4392 IF ( netcdf_data_format > 4 ) THEN 4393 IF ( dt_dosurf == 0.0_wp ) THEN 4394 message_string = 'dt_dosurf = 0.0 while using a variable timestep and parallel ' // & 4395 'netCDF4 is not allowed.' 4396 CALL message( 'surface_data_output_check_parameters', 'PA0081', 1, 2, 0, 6, 0 ) 5230 4397 ENDIF 5231 ! 5232 !-- Check the average interval 5233 IF ( averaging_interval_surf == 9999999.9_wp ) THEN 5234 averaging_interval_surf = averaging_interval 4398 4399 IF ( dt_dosurf_av == 0.0_wp ) THEN 4400 message_string = 'dt_dosurf_av = 0.0 while using a variable timestep and parallel ' // & 4401 'netCDF4 is not allowed.' 4402 CALL message( 'surface_data_output_check_parameters', 'PA0081', 1, 2, 0, 6, 0 ) 5235 4403 ENDIF 5236 ! 5237 !-- Set the default data-output interval dt_data_output if necessary 5238 IF ( dt_dosurf == 9999999.9_wp ) dt_dosurf = dt_data_output 5239 IF ( dt_dosurf_av == 9999999.9_wp ) dt_dosurf_av = dt_data_output 5240 5241 IF ( averaging_interval_surf > dt_dosurf_av ) THEN 5242 WRITE( message_string, * ) 'averaging_interval_surf = ', & 5243 averaging_interval_surf, ' must be <= dt_dosurf_av = ', & 5244 dt_dosurf_av 5245 CALL message( 'surface_data_output_check_parameters', & 5246 'PA0536', 1, 2, 0, 6, 0 ) 5247 ENDIF 5248 5249 #if ! defined( __netcdf4_parallel ) 5250 ! 5251 !-- Surface output via NetCDF requires parallel NetCDF 5252 IF ( to_netcdf ) THEN 5253 message_string = 'to_netcdf = .True. requires parallel NetCDF' 5254 CALL message( 'surface_data_output_check_parameters', & 5255 'PA0116', 1, 2, 0, 6, 0 ) 5256 ENDIF 5257 #endif 5258 ! 5259 !-- In case of parallel NetCDF output the output timestep must not be zero. 5260 !-- This is because the number of requiered output timesteps is 5261 !-- pre-calculated, which is not possible with zero output timestep. 5262 IF ( netcdf_data_format > 4 ) THEN 5263 IF ( dt_dosurf == 0.0_wp ) THEN 5264 message_string = 'dt_dosurf = 0.0 while using a ' // & 5265 'variable timestep and parallel netCDF4 ' // & 5266 'is not allowed.' 5267 CALL message( 'surface_data_output_check_parameters', 'PA0081', & 5268 1, 2, 0, 6, 0 ) 5269 ENDIF 5270 5271 IF ( dt_dosurf_av == 0.0_wp ) THEN 5272 message_string = 'dt_dosurf_av = 0.0 while using a ' // & 5273 'variable timestep and parallel netCDF4 ' // & 5274 'is not allowed.' 5275 CALL message( 'surface_data_output_check_parameters', 'PA0081', & 5276 1, 2, 0, 6, 0 ) 4404 ENDIF 4405 4406 ! 4407 !-- In case of restart runs, check it the number of cores has been changed. 4408 !-- With surface output this is not allowed. 4409 IF ( TRIM( initializing_actions ) == 'read_restart_data' .AND. & 4410 numprocs_previous_run /= numprocs ) THEN 4411 message_string = 'The number of cores has been changed between restart runs. ' // & 4412 'This is not allowed when surface data output is used.' 4413 CALL message( 'surface_data_output_check_parameters', 'PA0585', 1, 2, 0, 6, 0 ) 4414 ENDIF 4415 ! 4416 !-- Count number of output variables and separate output strings for average and non-average output 4417 !-- variables. 4418 n_out = 0 4419 DO WHILE ( data_output_surf(n_out+1)(1:1) /= ' ' ) 4420 4421 n_out = n_out + 1 4422 ilen = LEN_TRIM( data_output_surf(n_out) ) 4423 trimvar = TRIM( data_output_surf(n_out) ) 4424 4425 ! 4426 !-- Check for data averaging 4427 av = 0 4428 IF ( ilen > 3 ) THEN 4429 IF ( data_output_surf(n_out)(ilen-2:ilen) == '_av' ) THEN 4430 trimvar = data_output_surf(n_out)(1:ilen-3) 4431 av = 1 5277 4432 ENDIF 5278 4433 ENDIF 5279 4434 5280 ! 5281 !-- In case of restart runs, check it the number of cores has been changed. 5282 !-- With surface output this is not allowed. 5283 IF ( TRIM( initializing_actions ) == 'read_restart_data' .AND. & 5284 numprocs_previous_run /= numprocs ) THEN 5285 message_string = 'The number of cores has been changed between ' // & 5286 'restart runs. This is not allowed when surface ' // & 5287 'data output is used.' 5288 CALL message( 'surface_data_output_check_parameters', & 5289 'PA0585', 1, 2, 0, 6, 0 ) 5290 ENDIF 5291 ! 5292 !-- Count number of output variables and separate output strings for 5293 !-- average and non-average output variables. 5294 n_out = 0 5295 DO WHILE ( data_output_surf(n_out+1)(1:1) /= ' ' ) 5296 5297 n_out = n_out + 1 5298 ilen = LEN_TRIM( data_output_surf(n_out) ) 5299 trimvar = TRIM( data_output_surf(n_out) ) 5300 5301 ! 5302 !-- Check for data averaging 5303 av = 0 5304 IF ( ilen > 3 ) THEN 5305 IF ( data_output_surf(n_out)(ilen-2:ilen) == '_av' ) THEN 5306 trimvar = data_output_surf(n_out)(1:ilen-3) 5307 av = 1 5308 ENDIF 5309 ENDIF 5310 5311 dosurf_no(av) = dosurf_no(av) + 1 5312 dosurf(av,dosurf_no(av)) = TRIM( trimvar ) 5313 5314 ! 5315 !-- Check if all output variables are known and assign a unit 5316 unit = 'not set' 5317 SELECT CASE ( TRIM( trimvar ) ) 5318 5319 CASE ( 'css', 'cssws', 'qsws_liq', 'qsws_soil', 'qsws_veg' ) 5320 message_string = TRIM( trimvar ) // & 5321 ' is not yet implemented in the surface output' 5322 CALL message( 'surface_data_output_check_parameters', & 5323 'PA0537', 1, 2, 0, 6, 0 ) 5324 5325 CASE ( 'us', 'uvw1' ) 5326 unit = 'm/s' 5327 5328 CASE ( 'ss', 'qcs', 'ncs', 'qis', 'nis', 'qrs', 'nrs' ) 5329 unit = '1' 5330 5331 CASE ( 'z0', 'z0h', 'z0q', 'ol' ) 5332 unit = 'm' 5333 5334 CASE ( 'ts', 'theta1', 'thetav1', 'theta_surface', 'thetav_surface' ) 5335 unit = 'K' 5336 5337 CASE ( 'usws', 'vsws' ) 5338 unit = 'm2/s2' 5339 5340 CASE ( 'qcsws', 'ncsws', 'qisws', 'nisws', 'qrsws', 'nrsws', 'sasws' ) 5341 5342 CASE ( 'shf' ) 5343 unit = 'K m/s' 5344 5345 CASE ( 'qsws' ) 5346 unit = 'kg/kg m/s' 5347 5348 CASE ( 'ssws' ) 5349 unit = 'kg/m2/s' 5350 5351 CASE ( 'qs', 'q_surface', 'qv1' ) 5352 unit = 'kg/kg' 5353 5354 CASE ( 'rad_net' ) 5355 unit = 'W/m2' 5356 5357 CASE ( 'rad_lw_in', 'rad_lw_out', 'rad_lw_dif', 'rad_lw_ref', & 5358 'rad_lw_res' ) 5359 unit = 'W/m2' 5360 5361 CASE ( 'rad_sw_in', 'rad_sw_out', 'rad_sw_dif', 'rad_sw_ref', & 5362 'rad_sw_res', 'rad_sw_dir' ) 5363 unit = 'W/m2' 5364 5365 CASE ( 'ghf' ) 5366 unit = 'W/m2' 5367 5368 CASE ( 'r_a', 'r_canopy', 'r_soil', 'r_s' ) 5369 unit = 's/m' 5370 5371 CASE ( 'waste_heat', 'im_hf' ) 5372 IF ( .NOT. indoor_model ) THEN 5373 message_string = TRIM( trimvar ) // & 5374 ' requires the indoor model' 5375 CALL message( 'surface_data_output_check_parameters', & 5376 'PA0588', 1, 2, 0, 6, 0 ) 5377 ENDIF 5378 5379 unit = 'W/m2' 5380 5381 CASE ( 'albedo', 'emissivity' ) 5382 unit = '1' 5383 5384 CASE DEFAULT 5385 message_string = TRIM( trimvar ) // & 5386 ' is not part of the surface output' 5387 CALL message( 'surface_data_output_check_parameters', & 5388 'PA0538', 1, 2, 0, 6, 0 ) 5389 END SELECT 5390 5391 dosurf_unit(av,dosurf_no(av)) = unit 5392 5393 ENDDO 5394 5395 END SUBROUTINE surface_data_output_check_parameters 5396 5397 5398 !------------------------------------------------------------------------------! 4435 dosurf_no(av) = dosurf_no(av) + 1 4436 dosurf(av,dosurf_no(av)) = TRIM( trimvar ) 4437 4438 ! 4439 !-- Check if all output variables are known and assign a unit 4440 unit = 'not set' 4441 SELECT CASE ( TRIM( trimvar ) ) 4442 4443 CASE ( 'css', 'cssws', 'qsws_liq', 'qsws_soil', 'qsws_veg' ) 4444 message_string = TRIM( trimvar ) // ' is not yet implemented in the surface output' 4445 CALL message( 'surface_data_output_check_parameters', 'PA0537', 1, 2, 0, 6, 0 ) 4446 4447 CASE ( 'us', 'uvw1' ) 4448 unit = 'm/s' 4449 4450 CASE ( 'ss', 'qcs', 'ncs', 'qis', 'nis', 'qrs', 'nrs' ) 4451 unit = '1' 4452 4453 CASE ( 'z0', 'z0h', 'z0q', 'ol' ) 4454 unit = 'm' 4455 4456 CASE ( 'ts', 'theta1', 'thetav1', 'theta_surface', 'thetav_surface' ) 4457 unit = 'K' 4458 4459 CASE ( 'usws', 'vsws' ) 4460 unit = 'm2/s2' 4461 4462 CASE ( 'qcsws', 'ncsws', 'qisws', 'nisws', 'qrsws', 'nrsws', 'sasws' ) 4463 4464 CASE ( 'shf' ) 4465 unit = 'K m/s' 4466 4467 CASE ( 'qsws' ) 4468 unit = 'kg/kg m/s' 4469 4470 CASE ( 'ssws' ) 4471 unit = 'kg/m2/s' 4472 4473 CASE ( 'qs', 'q_surface', 'qv1' ) 4474 unit = 'kg/kg' 4475 4476 CASE ( 'rad_net' ) 4477 unit = 'W/m2' 4478 4479 CASE ( 'rad_lw_in', 'rad_lw_out', 'rad_lw_dif', 'rad_lw_ref', 'rad_lw_res' ) 4480 unit = 'W/m2' 4481 4482 CASE ( 'rad_sw_in', 'rad_sw_out', 'rad_sw_dif', 'rad_sw_ref', 'rad_sw_res', 'rad_sw_dir' ) 4483 unit = 'W/m2' 4484 4485 CASE ( 'ghf' ) 4486 unit = 'W/m2' 4487 4488 CASE ( 'r_a', 'r_canopy', 'r_soil', 'r_s' ) 4489 unit = 's/m' 4490 4491 CASE ( 'waste_heat', 'im_hf' ) 4492 IF ( .NOT. indoor_model ) THEN 4493 message_string = TRIM( trimvar ) // ' requires the indoor model' 4494 CALL message( 'surface_data_output_check_parameters', 'PA0588', 1, 2, 0, 6, 0 ) 4495 ENDIF 4496 4497 unit = 'W/m2' 4498 4499 CASE ( 'albedo', 'emissivity' ) 4500 unit = '1' 4501 4502 CASE DEFAULT 4503 message_string = TRIM( trimvar ) // ' is not part of the surface output' 4504 CALL message( 'surface_data_output_check_parameters', 'PA0538', 1, 2, 0, 6, 0 ) 4505 END SELECT 4506 4507 dosurf_unit(av,dosurf_no(av)) = unit 4508 4509 ENDDO 4510 4511 END SUBROUTINE surface_data_output_check_parameters 4512 4513 4514 !--------------------------------------------------------------------------------------------------! 5399 4515 ! Description: 5400 4516 ! ------------ 5401 4517 !> Last action. 5402 !------------------------------------------------------------------------------! 5403 SUBROUTINE surface_data_output_last_action( av ) 5404 5405 USE control_parameters, & 5406 ONLY: io_blocks, io_group 4518 !--------------------------------------------------------------------------------------------------! 4519 SUBROUTINE surface_data_output_last_action( av ) 4520 4521 USE control_parameters, & 4522 ONLY: io_blocks, & 4523 io_group 5407 4524 5408 4525 #if defined( __parallel ) 5409 USE pegrid, & 5410 ONLY: comm2d, ierr 4526 USE pegrid, & 4527 ONLY: comm2d, & 4528 ierr 5411 4529 #endif 5412 4530 5413 IMPLICIT NONE 5414 5415 INTEGER(iwp) :: av !< id indicating average or non-average data output 5416 INTEGER(iwp) :: i !< loop index 5417 5418 ! 5419 !-- Return, if nothing to output 5420 IF ( dosurf_no(av) == 0 ) RETURN 5421 ! 5422 !-- If output to VTK files is enabled, check if files are open and write 5423 !-- an end-of-file statement. 5424 IF ( to_vtk ) THEN 5425 CALL check_open( 25+av ) 5426 ! 5427 !-- Write time coordinate 5428 DO i = 0, io_blocks-1 5429 IF ( i == io_group ) THEN 5430 WRITE ( 25+av ) LEN_TRIM( 'END' ) 5431 WRITE ( 25+av ) 'END' 5432 ENDIF 4531 IMPLICIT NONE 4532 4533 INTEGER(iwp) :: av !< id indicating average or non-average data output 4534 INTEGER(iwp) :: i !< loop index 4535 4536 ! 4537 !--Return, if nothing to output 4538 IF ( dosurf_no(av) == 0 ) RETURN 4539 ! 4540 !--If output to VTK files is enabled, check if files are open and write an end-of-file statement. 4541 IF ( to_vtk ) THEN 4542 CALL check_open( 25 + av ) 4543 ! 4544 !-- Write time coordinate 4545 DO i = 0, io_blocks - 1 4546 IF ( i == io_group ) THEN 4547 WRITE ( 25 + av ) LEN_TRIM( 'END' ) 4548 WRITE ( 25 + av ) 'END' 4549 ENDIF 5433 4550 #if defined( __parallel ) 5434 4551 CALL MPI_BARRIER( comm2d, ierr ) 5435 4552 #endif 5436 5437 5438 5439 5440 5441 5442 !------------------------------------------------------------------------------ !4553 ENDDO 4554 ENDIF 4555 4556 END SUBROUTINE surface_data_output_last_action 4557 4558 4559 !--------------------------------------------------------------------------------------------------! 5443 4560 ! Description: 5444 4561 ! ------------ 5445 4562 !> Read module-specific global restart data (Fortran binary format). 5446 !------------------------------------------------------------------------------! 5447 SUBROUTINE surface_data_output_rrd_global_ftn( found ) 5448 5449 5450 USE control_parameters, & 5451 ONLY: length, restart_string 5452 5453 IMPLICIT NONE 5454 5455 LOGICAL, INTENT(OUT) :: found !< flag indicating if variable was found 5456 5457 found = .TRUE. 5458 5459 SELECT CASE ( restart_string(1:length) ) 5460 5461 CASE ( 'average_count_surf' ) 5462 READ ( 13 ) average_count_surf 5463 5464 CASE DEFAULT 5465 5466 found = .FALSE. 5467 5468 END SELECT 5469 5470 5471 END SUBROUTINE surface_data_output_rrd_global_ftn 5472 5473 5474 !------------------------------------------------------------------------------! 4563 !---------------------------------------------------------------------------------------------------! 4564 SUBROUTINE surface_data_output_rrd_global_ftn( found ) 4565 4566 4567 USE control_parameters, & 4568 ONLY: length, & 4569 restart_string 4570 4571 IMPLICIT NONE 4572 4573 LOGICAL, INTENT(OUT) :: found !< flag indicating if variable was found 4574 4575 found = .TRUE. 4576 4577 SELECT CASE ( restart_string(1:length) ) 4578 4579 CASE ( 'average_count_surf' ) 4580 READ ( 13 ) average_count_surf 4581 4582 CASE DEFAULT 4583 4584 found = .FALSE. 4585 4586 END SELECT 4587 4588 4589 END SUBROUTINE surface_data_output_rrd_global_ftn 4590 4591 4592 !--------------------------------------------------------------------------------------------------! 5475 4593 ! Description: 5476 4594 ! ------------ 5477 4595 !> Read module-specific global restart data (MPI-IO). 5478 !------------------------------------------------------------------------------ !5479 5480 5481 5482 5483 5484 5485 5486 !------------------------------------------------------------------------------ !4596 !--------------------------------------------------------------------------------------------------! 4597 SUBROUTINE surface_data_output_rrd_global_mpi 4598 4599 CALL rrd_mpi_io( 'average_count_surf', average_count_surf ) 4600 4601 END SUBROUTINE surface_data_output_rrd_global_mpi 4602 4603 4604 !--------------------------------------------------------------------------------------------------! 5487 4605 ! Description: 5488 4606 ! ------------ 5489 4607 !> Read module-specific local restart data arrays (Fortran binary format). 5490 !------------------------------------------------------------------------------! 5491 SUBROUTINE surface_data_output_rrd_local_ftn( found ) 5492 5493 5494 USE control_parameters, & 5495 ONLY: length, restart_string 5496 5497 IMPLICIT NONE 5498 5499 LOGICAL, INTENT(OUT) :: found 5500 5501 5502 found = .TRUE. 5503 5504 SELECT CASE ( restart_string(1:length) ) 5505 5506 CASE ( 'surfaces%var_av' ) 5507 READ ( 13 ) surfaces%var_av 5508 5509 CASE DEFAULT 5510 5511 found = .FALSE. 5512 5513 END SELECT 5514 5515 5516 END SUBROUTINE surface_data_output_rrd_local_ftn 5517 5518 5519 !------------------------------------------------------------------------------! 4608 !--------------------------------------------------------------------------------------------------! 4609 SUBROUTINE surface_data_output_rrd_local_ftn( found ) 4610 4611 4612 USE control_parameters, & 4613 ONLY: length, & 4614 restart_string 4615 4616 IMPLICIT NONE 4617 4618 LOGICAL, INTENT(OUT) :: found 4619 4620 4621 found = .TRUE. 4622 4623 SELECT CASE ( restart_string(1:length) ) 4624 4625 CASE ( 'surfaces%var_av' ) 4626 READ ( 13 ) surfaces%var_av 4627 4628 CASE DEFAULT 4629 4630 found = .FALSE. 4631 4632 END SELECT 4633 4634 4635 END SUBROUTINE surface_data_output_rrd_local_ftn 4636 4637 4638 !--------------------------------------------------------------------------------------------------! 5520 4639 ! Description: 5521 4640 ! ------------ 5522 4641 !> Read module-specific local restart data arrays (MPI-IO). 5523 !------------------------------------------------------------------------------ !5524 5525 5526 5527 5528 5529 5530 5531 4642 !--------------------------------------------------------------------------------------------------! 4643 SUBROUTINE surface_data_output_rrd_local_mpi 4644 4645 IMPLICIT NONE 4646 4647 LOGICAL :: array_found !< 4648 4649 4650 CALL rd_mpi_io_check_array( 'surfaces%var_av' , found = array_found ) 5532 4651 5533 4652 !> does not work this way: surface%var_av has non-standard dimensions 5534 ! 5535 ! 5536 ! 5537 ! 5538 5539 5540 5541 5542 !------------------------------------------------------------------------------ !4653 ! IF ( array_found ) THEN 4654 ! IF ( .NOT. ALLOCATED( surfaces%var_av ) ) ALLOCATE( ....... ) 4655 ! CALL rrd_mpi_io( 'surfaces%var_av', surfaces%var_av ) 4656 ! ENDIF 4657 4658 END SUBROUTINE surface_data_output_rrd_local_mpi 4659 4660 4661 !--------------------------------------------------------------------------------------------------! 5543 4662 ! Description: 5544 4663 ! ------------ 5545 4664 !> This routine writes the respective restart data. 5546 !------------------------------------------------------------------------------ !5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 !------------------------------------------------------------------------------ !4665 !--------------------------------------------------------------------------------------------------! 4666 SUBROUTINE surface_data_output_wrd_global 4667 4668 IMPLICIT NONE 4669 4670 IF ( TRIM( restart_data_format_output ) == 'fortran_binary' ) THEN 4671 4672 CALL wrd_write_string( 'average_count_surf' ) 4673 WRITE ( 14 ) average_count_surf 4674 4675 ELSEIF ( restart_data_format_output(1:3) == 'mpi' ) THEN 4676 4677 CALL wrd_mpi_io( 'average_count_surf', average_count_surf ) 4678 4679 ENDIF 4680 4681 END SUBROUTINE surface_data_output_wrd_global 4682 4683 4684 !--------------------------------------------------------------------------------------------------! 5566 4685 ! Description: 5567 4686 ! ------------ 5568 4687 !> This routine writes restart data which individual on each PE 5569 !------------------------------------------------------------------------------! 5570 SUBROUTINE surface_data_output_wrd_local 5571 5572 IMPLICIT NONE 5573 5574 IF ( TRIM( restart_data_format_output ) == 'fortran_binary' ) THEN 5575 5576 IF ( ALLOCATED( surfaces%var_av ) ) THEN 5577 CALL wrd_write_string( 'surfaces%var_av' ) 5578 WRITE ( 14 ) surfaces%var_av 5579 ENDIF 5580 5581 ELSEIF ( restart_data_format_output(1:3) == 'mpi' ) THEN 5582 5583 IF ( ALLOCATED( surfaces%var_av ) ) CALL wrd_mpi_io( 'surfaces%var_av', surfaces%var_av ) 5584 4688 !--------------------------------------------------------------------------------------------------! 4689 SUBROUTINE surface_data_output_wrd_local 4690 4691 IMPLICIT NONE 4692 4693 IF ( TRIM( restart_data_format_output ) == 'fortran_binary' ) THEN 4694 4695 IF ( ALLOCATED( surfaces%var_av ) ) THEN 4696 CALL wrd_write_string( 'surfaces%var_av' ) 4697 WRITE ( 14 ) surfaces%var_av 5585 4698 ENDIF 5586 4699 5587 END SUBROUTINE surface_data_output_wrd_local 4700 ELSEIF ( restart_data_format_output(1:3) == 'mpi' ) THEN 4701 4702 IF ( ALLOCATED( surfaces%var_av ) ) CALL wrd_mpi_io( 'surfaces%var_av', surfaces%var_av ) 4703 4704 ENDIF 4705 4706 END SUBROUTINE surface_data_output_wrd_local 5588 4707 5589 4708
Note: See TracChangeset
for help on using the changeset viewer.