Changeset 4497 for palm/trunk/SOURCE/user_module.f90
- Timestamp:
- Apr 15, 2020 10:20:51 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
palm/trunk/SOURCE/user_module.f90
r4495 r4497 1 1 !> @file user_module.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: … … 25 25 ! ----------------- 26 26 ! $Id$ 27 ! file re-formatted to follow the PALM coding standard 28 ! 29 ! 30 ! 4495 2020-04-13 20:11:20Z raasch 27 31 ! restart data handling with MPI-IO added 28 ! 32 ! 29 33 ! 4360 2020-01-07 11:25:50Z suehring 30 ! Introduction of wall_flags_total_0, which currently sets bits based on static 31 ! topographyinformation used in wall_flags_static_032 ! 34 ! Introduction of wall_flags_total_0, which currently sets bits based on static topography 35 ! information used in wall_flags_static_0 36 ! 33 37 ! 4329 2019-12-10 15:46:36Z motisi 34 38 ! Renamed wall_flags_0 to wall_flags_static_0 35 ! 39 ! 36 40 ! 4287 2019-11-01 14:50:20Z raasch 37 41 ! reading of namelist file and actions in case of namelist errors revised so that statement labels 38 ! and goto statements are not required any more; this revision also removes a previous bug 39 ! whichappeared when the namelist has been commented out in the namelist file40 ! 42 ! and goto statements are not required any more; this revision also removes a previous bug which 43 ! appeared when the namelist has been commented out in the namelist file 44 ! 41 45 ! 4182 2019-08-22 15:20:23Z scharf 42 46 ! Corrected "Former revisions" section 43 ! 47 ! 44 48 ! 3986 2019-05-20 14:08:14Z Giersch 45 49 ! Redundant integration of control parameters in user_rrd_global removed 46 ! 50 ! 47 51 ! 3911 2019-04-17 12:26:19Z knoop 48 52 ! Bugfix: added before_prognostic_equations case in user_actions 49 ! 53 ! 50 54 ! 3768 2019-02-27 14:35:58Z raasch 51 55 ! variables commented + statements added to avoid compiler warnings about unused variables … … 53 57 ! 3767 2019-02-27 08:18:02Z raasch 54 58 ! unused variable for file index removed from rrd-subroutines parameter list 55 ! 59 ! 56 60 ! 3747 2019-02-16 15:15:23Z gronemeier 57 61 ! Add routine user_init_arrays 58 ! 62 ! 59 63 ! 3703 2019-01-29 16:43:53Z knoop 60 64 ! An example for a user defined global variable has been added (Giersch) … … 66 70 ! Description: 67 71 ! ------------ 68 !> Declaration of user-defined variables. This module may only be used 69 !> in the user-defined routines(contained in user_interface.f90).70 !------------------------------------------------------------------------------ !72 !> Declaration of user-defined variables. This module may only be used in the user-defined routines 73 !> (contained in user_interface.f90). 74 !--------------------------------------------------------------------------------------------------! 71 75 MODULE user 72 76 73 74 77 USE arrays_3d 75 78 … … 90 93 IMPLICIT NONE 91 94 92 INTEGER(iwp) :: dots_num_palm !<93 INTEGER(iwp) :: dots_num_user = 0 !< 94 INTEGER(iwp) :: user_idummy !<95 96 LOGICAL :: user_module_enabled = .FALSE. !<97 98 REAL(wp) :: user_rdummy !<95 INTEGER(iwp) :: dots_num_palm !< 96 INTEGER(iwp) :: dots_num_user = 0 !< 97 INTEGER(iwp) :: user_idummy !< 98 99 LOGICAL :: user_module_enabled = .FALSE. !< 100 101 REAL(wp) :: user_rdummy !< 99 102 100 103 ! 101 104 !-- Sample for user-defined output 102 ! REAL(wp) :: global_parameter !< user defined global parameter103 ! 104 ! REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: u2 105 ! REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: u2_av 106 ! REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: ustvst 105 ! REAL(wp) :: global_parameter !< user defined global parameter 106 ! 107 ! REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: u2 !< user defined array 108 ! REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: u2_av !< user defined array 109 ! REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: ustvst !< user defined array 107 110 108 111 SAVE … … 112 115 ! 113 116 !- Public functions 114 PUBLIC & 115 user_parin, & 116 user_check_parameters, & 117 user_check_data_output_ts, & 118 user_check_data_output_pr, & 119 user_check_data_output, & 120 user_define_netcdf_grid, & 121 user_init, & 122 user_init_arrays, & 123 user_header, & 124 user_actions, & 125 user_3d_data_averaging, & 126 user_data_output_2d, & 127 user_data_output_3d, & 128 user_statistics, & 129 user_rrd_global, & 130 user_rrd_local, & 131 user_wrd_global, & 132 user_wrd_local, & 133 user_last_actions 117 PUBLIC & 118 user_actions, & 119 user_check_data_output, & 120 user_check_data_output_pr, & 121 user_check_data_output_ts, & 122 user_check_parameters, & 123 user_data_output_2d, & 124 user_data_output_3d, & 125 user_define_netcdf_grid, & 126 user_header, & 127 user_init, & 128 user_init_arrays, & 129 user_last_actions, & 130 user_parin, & 131 user_rrd_global, & 132 user_rrd_local, & 133 user_statistics, & 134 user_3d_data_averaging, & 135 user_wrd_global, & 136 user_wrd_local 137 134 138 135 139 ! 136 140 !- Public parameters, constants and initial values 137 PUBLIC &141 PUBLIC & 138 142 user_module_enabled 139 143 … … 220 224 221 225 222 !------------------------------------------------------------------------------ !226 !--------------------------------------------------------------------------------------------------! 223 227 ! Description: 224 228 ! ------------ 225 229 !> Parin for &user_parameters for user module 226 !------------------------------------------------------------------------------ !230 !--------------------------------------------------------------------------------------------------! 227 231 SUBROUTINE user_parin 228 232 229 CHARACTER (LEN=80) :: line 230 231 INTEGER(iwp) :: i 232 INTEGER(iwp) :: io_status 233 INTEGER(iwp) :: j !<233 CHARACTER (LEN=80) :: line !< string containing the last line read from namelist file 234 235 INTEGER(iwp) :: i !< 236 INTEGER(iwp) :: io_status !< status after reading the namelist file 237 INTEGER(iwp) :: j !< 234 238 235 239 … … 247 251 248 252 ! 249 !-- Set revision number of this default interface version. It will be checked within 250 !-- the main program (palm). Please change the revision number in case that the251 !-- current revision does not match with previous revisions (e.g. if routines252 !-- have been added/deleted or if parameter listsin subroutines have been changed).253 !-- Set revision number of this default interface version. It will be checked within the main 254 !-- program (palm). Please change the revision number in case that the current revision does not 255 !-- match with previous revisions (e.g. if routines have been added/deleted or if parameter lists 256 !-- in subroutines have been changed). 253 257 user_interface_current_revision = 'r4495' 254 258 255 259 ! 256 !-- Position the namelist-file at the beginning (it was already opened in257 !-- parin), and try toread (find) a namelist named "user_parameters".260 !-- Position the namelist-file at the beginning (it has already been opened in parin), and try to 261 !-- read (find) a namelist named "user_parameters". 258 262 REWIND ( 11 ) 259 263 READ( 11, user_parameters, IOSTAT=io_status ) … … 278 282 279 283 ! 280 !-- Determine the number of user-defined profiles and append them to the 281 !-- standard data output(data_output_pr)284 !-- Determine the number of user-defined profiles and append them to the standard data output 285 !-- (data_output_pr) 282 286 IF ( user_module_enabled ) THEN 283 287 IF ( data_output_pr_user(1) /= ' ' ) THEN … … 300 304 301 305 302 !------------------------------------------------------------------------------ !306 !--------------------------------------------------------------------------------------------------! 303 307 ! Description: 304 308 ! ------------ 305 309 !> Check &userpar control parameters and deduce further quantities. 306 !------------------------------------------------------------------------------ !310 !--------------------------------------------------------------------------------------------------! 307 311 SUBROUTINE user_check_parameters 308 312 309 310 !-- Here the user may add code to check the validity of further &userpar 311 !-- control parameters ordeduce further quantities.313 ! 314 !-- Here the user may add code to check the validity of further &userpar control parameters or 315 !-- deduce further quantities. 312 316 313 317 … … 315 319 316 320 317 !------------------------------------------------------------------------------ !321 !--------------------------------------------------------------------------------------------------! 318 322 ! Description: 319 323 ! ------------ 320 324 !> Set module-specific timeseries units and labels 321 !------------------------------------------------------------------------------ !325 !--------------------------------------------------------------------------------------------------! 322 326 SUBROUTINE user_check_data_output_ts( dots_max, dots_num, dots_label, dots_unit ) 323 327 324 325 INTEGER(iwp), INTENT(IN ) :: dots_max326 INTEGER(iwp), INTENT(INOUT) :: dots_num 327 CHARACTER (LEN=*), DIMENSION(dots_max), INTENT(INOUT) :: dots_label328 CHARACTER (LEN=*), DIMENSION(dots_max), INTENT(INOUT) :: dots_unit328 INTEGER(iwp), INTENT(IN) :: dots_max !< 329 INTEGER(iwp), INTENT(INOUT) :: dots_num !< 330 331 CHARACTER(LEN=*), DIMENSION(dots_max), INTENT(INOUT) :: dots_label !< 332 CHARACTER(LEN=*), DIMENSION(dots_max), INTENT(INOUT) :: dots_unit !< 329 333 330 334 ! … … 333 337 334 338 ! 335 !-- Sample for user-defined time series 336 !-- For each time series quantity you have to give a label and a unit, 337 !-- which will be used for the NetCDF file. They must not contain more than 338 !-- seven characters. The value of dots_num has to be increased by the 339 !-- number of new time series quantities. Its old value has to be store in 340 !-- dots_num_palm. See routine user_statistics on how to output calculate 341 !-- and output these quantities. 339 !-- Sample for user-defined time series: 340 !-- For each time series quantity you have to give a label and a unit, which will be used for the 341 !-- NetCDF file. They must not contain more than seven characters. The value of dots_num has to be 342 !-- increased by the number of new time series quantities. Its old value has to be stored in 343 !-- dots_num_palm. See routine user_statistics on how to calculate and output these quantities. 342 344 343 345 ! dots_num_palm = dots_num … … 357 359 358 360 359 !------------------------------------------------------------------------------! 360 ! Description: 361 ! ------------ 362 !> Set the unit of user defined profile output quantities. For those variables 363 !> not recognized by the user, the parameter unit is set to "illegal", which 364 !> tells the calling routine that the output variable is not defined and leads 365 !> to a program abort. 366 !------------------------------------------------------------------------------! 361 !--------------------------------------------------------------------------------------------------! 362 ! Description: 363 ! ------------ 364 !> Set the unit of user defined profile output quantities. For those variables not recognized by the 365 !> user, the parameter unit is set to "illegal", which tells the calling routine that the 366 !> output variable is not defined and leads to a program abort. 367 !--------------------------------------------------------------------------------------------------! 367 368 SUBROUTINE user_check_data_output_pr( variable, var_count, unit, dopr_unit ) 368 369 … … 371 372 372 373 373 CHARACTER (LEN=*) :: unit !<374 CHARACTER (LEN=*) :: variable !<374 CHARACTER (LEN=*) :: unit !< 375 CHARACTER (LEN=*) :: variable !< 375 376 CHARACTER (LEN=*) :: dopr_unit !< local value of dopr_unit 376 377 377 ! INTEGER(iwp) :: user_pr_index !<378 INTEGER(iwp) :: var_count !<378 ! INTEGER(iwp) :: user_pr_index !< 379 INTEGER(iwp) :: var_count !< 379 380 380 381 ! … … 386 387 ! 387 388 !-- Uncomment and extend the following lines, if necessary. 388 !-- Add additional CASE statements depending on the number of quantities 389 !-- for which profiles are to be calculated. The respective calculations 390 !-- to be performed have to be added in routine user_statistics. 391 !-- The quantities are (internally) identified by a user-profile-number 392 !-- (see variable "user_pr_index" below). The first user-profile must be assigned 393 !-- the number "pr_palm+1", the second one "pr_palm+2", etc. The respective 394 !-- user-profile-numbers have also to be used in routine user_statistics! 395 ! CASE ( 'u*v*' ) ! quantity string as given in 396 ! ! data_output_pr_user 389 !-- Add additional CASE statements depending on the number of quantities for which profiles are 390 !-- to be calculated. The respective calculations to be performed have to be added in routine 391 !-- user_statistics. The quantities are (internally) identified by a user-profile-number 392 !-- (see variable "user_pr_index" below). The first user-profile must be assigned the number 393 !-- "pr_palm+1", the second one "pr_palm+2", etc. The respective user-profile-numbers have also 394 !-- to be used in routine user_statistics! 395 ! CASE ( 'u*v*' ) ! quantity string as given in data_output_pr_user 397 396 ! user_pr_index = pr_palm + 1 398 397 ! dopr_index(var_count) = user_pr_index ! quantities' user-profile-number 399 398 ! dopr_unit = 'm2/s2' ! quantity unit 400 399 ! unit = dopr_unit 401 ! hom(:,2,user_pr_index,:) 402 ! ! grid on which the quantity is 403 ! ! defined (use zu or zw)400 ! hom(:,2,user_pr_index,:) = SPREAD( zu, 2, statistic_regions+1 ) 401 ! ! grid on which the quantity is defined (use zu or zw) 402 ! 404 403 405 404 CASE DEFAULT … … 412 411 413 412 414 !------------------------------------------------------------------------------! 415 ! Description: 416 ! ------------ 417 !> Set the unit of user defined output quantities. For those variables 418 !> not recognized by the user, the parameter unit is set to "illegal", which 419 !> tells the calling routine that the output variable is not defined and leads 420 !> to a program abort. 421 !------------------------------------------------------------------------------! 413 !--------------------------------------------------------------------------------------------------! 414 ! Description: 415 ! ------------ 416 !> Set the unit of user defined output quantities. For those variables not recognized by the user, 417 !> the parameter unit is set to "illegal", which tells the calling routine that the output variable 418 !> is not defined and leads to a program abort. 419 !--------------------------------------------------------------------------------------------------! 422 420 SUBROUTINE user_check_data_output( variable, unit ) 423 421 424 422 425 CHARACTER (LEN=*) :: unit !<426 CHARACTER (LEN=*) :: variable !<423 CHARACTER (LEN=*) :: unit !< 424 CHARACTER (LEN=*) :: variable !< 427 425 428 426 … … 446 444 447 445 448 !------------------------------------------------------------------------------ !446 !--------------------------------------------------------------------------------------------------! 449 447 ! Description: 450 448 ! ------------ 451 449 !> Initialize user-defined arrays 452 !------------------------------------------------------------------------------ !450 !--------------------------------------------------------------------------------------------------! 453 451 SUBROUTINE user_init_arrays 454 452 … … 468 466 ! IF ( statistic_regions >= 1 ) THEN 469 467 ! region = 1 470 ! 468 ! 471 469 ! rmask(:,:,region) = 0.0_wp 472 470 ! DO i = nxl, nxr … … 479 477 ! ENDIF 480 478 ! ENDDO 481 ! 479 ! 482 480 ! ENDIF 483 481 … … 485 483 486 484 487 !------------------------------------------------------------------------------ !485 !--------------------------------------------------------------------------------------------------! 488 486 ! Description: 489 487 ! ------------ 490 488 !> Execution of user-defined initializing actions 491 !------------------------------------------------------------------------------ !489 !--------------------------------------------------------------------------------------------------! 492 490 SUBROUTINE user_init 493 491 494 492 495 ! CHARACTER (LEN=20) :: field_char!<493 ! CHARACTER(LEN=20) :: field_char !< 496 494 ! 497 495 !-- Here the user-defined initializing actions follow: … … 503 501 504 502 505 !------------------------------------------------------------------------------! 506 ! Description: 507 ! ------------ 508 !> Set the grids on which user-defined output quantities are defined. 509 !> Allowed values for grid_x are "x" and "xu", for grid_y "y" and "yv", and 510 !> for grid_z "zu" and "zw". 511 !------------------------------------------------------------------------------! 503 !--------------------------------------------------------------------------------------------------! 504 ! Description: 505 ! ------------ 506 !> Set the grids on which user-defined output quantities are defined. Allowed values for grid_x are 507 !> "x" and "xu", for grid_y "y" and "yv", and for grid_z "zu" and "zw". 508 !--------------------------------------------------------------------------------------------------! 512 509 SUBROUTINE user_define_netcdf_grid( variable, found, grid_x, grid_y, grid_z ) 513 510 … … 551 548 552 549 553 !------------------------------------------------------------------------------ !550 !--------------------------------------------------------------------------------------------------! 554 551 ! Description: 555 552 ! ------------ 556 553 !> Print a header with user-defined information. 557 !------------------------------------------------------------------------------ !554 !--------------------------------------------------------------------------------------------------! 558 555 SUBROUTINE user_header( io ) 559 556 560 557 561 INTEGER(iwp) :: i !< 562 INTEGER(iwp) :: io !< 563 564 ! 565 !-- If no user-defined variables are read from the namelist-file, no 566 !-- information will be printed. 558 INTEGER(iwp) :: i !< 559 INTEGER(iwp) :: io !< 560 561 ! 562 !-- If no user-defined variables are read from the namelist-file, no information will be printed. 567 563 IF ( .NOT. user_module_enabled ) THEN 568 564 WRITE ( io, 100 ) … … 584 580 !-- Format-descriptors 585 581 100 FORMAT (//' *** no user-defined variables found'/) 586 110 FORMAT (//1X,78('#') & 587 //' User-defined variables and actions:'/ & 588 ' -----------------------------------'//) 582 110 FORMAT (//1X,78('#') // ' User-defined variables and actions:' / & 583 ' -----------------------------------'//) 589 584 200 FORMAT (' Output of profiles and time series for following regions:' /) 590 585 201 FORMAT (4X,'Region ',I1,': ',A) … … 594 589 595 590 596 !------------------------------------------------------------------------------ !591 !--------------------------------------------------------------------------------------------------! 597 592 ! Description: 598 593 ! ------------ 599 594 !> Call for all grid points 600 !------------------------------------------------------------------------------ !595 !--------------------------------------------------------------------------------------------------! 601 596 SUBROUTINE user_actions( location ) 602 597 603 598 604 CHARACTER (LEN=*) :: location !<605 606 ! INTEGER(iwp) :: i !<607 ! INTEGER(iwp) :: j !<608 ! INTEGER(iwp) :: k !<599 CHARACTER(LEN=*) :: location !< 600 601 ! INTEGER(iwp) :: i !< 602 ! INTEGER(iwp) :: j !< 603 ! INTEGER(iwp) :: k !< 609 604 610 605 CALL cpu_log( log_point(24), 'user_actions', 'start' ) 611 606 612 607 ! 613 !-- Here the user-defined actions follow 614 !-- No calls for single grid points are allowed at locations before and 615 !-- after the timestep, since these calls are not within an i,j-loop 608 !-- Here the user-defined actions follow. No calls for single grid points are allowed at locations 609 !-- before and after the timestep, since these calls are not within an i,j-loop 616 610 SELECT CASE ( location ) 617 611 … … 626 620 CASE ( 'after_integration' ) 627 621 ! 628 !-- Enter actions to be done after every time integration (before 629 !-- data output) 622 !-- Enter actions to be done after every time integration (before data output) 630 623 !-- Sample for user-defined output: 631 624 ! DO i = nxlg, nxrg … … 640 633 ! DO k = nzb, nzt+1 641 634 ! ustvst(k,j,i) = & 642 ! ( 0.5_wp * ( u(k,j,i) + u(k,j,i+1) ) - hom(k,1,1,0) ) * &635 ! ( 0.5_wp * ( u(k,j,i) + u(k,j,i+1) ) - hom(k,1,1,0) ) * & 643 636 ! ( 0.5_wp * ( v(k,j,i) + v(k,j+1,i) ) - hom(k,1,2,0) ) 644 637 ! ENDDO … … 688 681 689 682 690 !------------------------------------------------------------------------------ !683 !--------------------------------------------------------------------------------------------------! 691 684 ! Description: 692 685 ! ------------ 693 686 !> Call for grid point i,j 694 !------------------------------------------------------------------------------ !687 !--------------------------------------------------------------------------------------------------! 695 688 SUBROUTINE user_actions_ij( i, j, location ) 696 689 697 690 698 CHARACTER (LEN=*) :: location699 700 INTEGER(iwp) :: i 701 INTEGER(iwp) :: j 691 CHARACTER(LEN=*) :: location !< 692 693 INTEGER(iwp) :: i !< 694 INTEGER(iwp) :: j !< 702 695 703 696 ! … … 744 737 745 738 746 !------------------------------------------------------------------------------ !747 ! Description: 748 ! ------------ 749 !> Sum up and time-average user-defined output quantities as well as allocate 750 !> the array necessaryfor storing the average.751 !------------------------------------------------------------------------------ !739 !--------------------------------------------------------------------------------------------------! 740 ! Description: 741 ! ------------ 742 !> Sum up and time-average user-defined output quantities as well as allocate the array necessary 743 !> for storing the average. 744 !--------------------------------------------------------------------------------------------------! 752 745 SUBROUTINE user_3d_data_averaging( mode, variable ) 753 746 754 747 755 CHARACTER (LEN=*) :: mode !<756 CHARACTER (LEN=*) :: variable !<757 758 ! INTEGER(iwp) :: i !<759 ! INTEGER(iwp) :: j !<760 ! INTEGER(iwp) :: k !<748 CHARACTER(LEN=*) :: mode !< 749 CHARACTER(LEN=*) :: variable !< 750 751 ! INTEGER(iwp) :: i !< 752 ! INTEGER(iwp) :: j !< 753 ! INTEGER(iwp) :: k !< 761 754 762 755 IF ( mode == 'allocate' ) THEN … … 766 759 ! 767 760 !-- Uncomment and extend the following lines, if necessary. 768 !-- The arrays for storing the user defined quantities (here u2_av) have 769 !-- to be declared anddefined by the user!761 !-- The arrays for storing the user defined quantities (here u2_av) have to be declared and 762 !-- defined by the user! 770 763 !-- Sample for user-defined output: 771 764 ! CASE ( 'u2' ) … … 786 779 ! 787 780 !-- Uncomment and extend the following lines, if necessary. 788 !-- The arrays for storing the user defined quantities (here u2 and 789 !-- u2_av) have to be declaredand defined by the user!781 !-- The arrays for storing the user defined quantities (here u2 and u2_av) have to be declared 782 !-- and defined by the user! 790 783 !-- Sample for user-defined output: 791 784 ! CASE ( 'u2' ) 792 ! IF ( ALLOCATED( u2_av ) ) THEN785 ! IF ( ALLOCATED( u2_av ) ) THEN 793 786 ! DO i = nxlg, nxrg 794 787 ! DO j = nysg, nyng … … 811 804 ! 812 805 !-- Uncomment and extend the following lines, if necessary. 813 !-- The arrays for storing the user defined quantities (here u2_av) have 814 !-- to be declared anddefined by the user!806 !-- The arrays for storing the user defined quantities (here u2_av) have to be declared and 807 !-- defined by the user! 815 808 !-- Sample for user-defined output: 816 809 ! CASE ( 'u2' ) 817 ! IF ( ALLOCATED( u2_av ) ) THEN810 ! IF ( ALLOCATED( u2_av ) ) THEN 818 811 ! DO i = nxlg, nxrg 819 812 ! DO j = nysg, nyng … … 833 826 834 827 835 !------------------------------------------------------------------------------! 836 ! Description: 837 ! ------------ 838 !> Resorts the user-defined output quantity with indices (k,j,i) to a 839 !> temporary array with indices (i,j,k) and sets the grid on which it is defined. 840 !> Allowed values for grid are "zu" and "zw". 841 !------------------------------------------------------------------------------! 828 !--------------------------------------------------------------------------------------------------! 829 ! Description: 830 ! ------------ 831 !> Resorts the user-defined output quantity with indices (k,j,i) to a temporary array with indices 832 !> (i,j,k) and sets the grid on which it is defined. Allowed values for grid are "zu" and "zw". 833 !--------------------------------------------------------------------------------------------------! 842 834 SUBROUTINE user_data_output_2d( av, variable, found, grid, local_pf, two_d, nzb_do, nzt_do ) 843 835 844 836 845 CHARACTER (LEN=*) :: grid !<846 CHARACTER (LEN=*) :: variable !<847 848 INTEGER(iwp) :: av !< flag to control data output of instantaneous or time-averaged data849 ! INTEGER(iwp) :: i !< grid index along x-direction850 ! INTEGER(iwp) :: j !< grid index along y-direction851 ! INTEGER(iwp) :: k !< grid index along z-direction852 ! INTEGER(iwp) :: m !< running index surface elements853 INTEGER(iwp) :: nzb_do !< lower limit of the domain (usually nzb)854 INTEGER(iwp) :: nzt_do !< upper limit of the domain (usually nzt+1)855 856 LOGICAL :: found !<857 LOGICAL :: two_d !< flag parameter that indicates 2D variables (horizontal cross sections)837 CHARACTER(LEN=*) :: grid !< 838 CHARACTER(LEN=*) :: variable !< 839 840 INTEGER(iwp) :: av !< flag to control data output of instantaneous or time-averaged data 841 ! INTEGER(iwp) :: i !< grid index along x-direction 842 ! INTEGER(iwp) :: j !< grid index along y-direction 843 ! INTEGER(iwp) :: k !< grid index along z-direction 844 ! INTEGER(iwp) :: m !< running index surface elements 845 INTEGER(iwp) :: nzb_do !< lower limit of the domain (usually nzb) 846 INTEGER(iwp) :: nzt_do !< upper limit of the domain (usually nzt+1) 847 848 LOGICAL :: found !< 849 LOGICAL :: two_d !< flag parameter that indicates 2D variables (horizontal cross sections) 858 850 859 851 ! REAL(wp) :: fill_value = -999.0_wp !< value for the _FillValue attribute 860 852 861 REAL(wp), DIMENSION(nxl:nxr,nys:nyn,nzb_do:nzt_do) :: local_pf !<853 REAL(wp), DIMENSION(nxl:nxr,nys:nyn,nzb_do:nzt_do) :: local_pf !< 862 854 863 855 ! … … 872 864 ! 873 865 !-- Uncomment and extend the following lines, if necessary. 874 !-- The arrays for storing the user defined quantities (here u2 and u2_av) 875 !-- have to be declaredand defined by the user!866 !-- The arrays for storing the user defined quantities (here u2 and u2_av) have to be declared 867 !-- and defined by the user! 876 868 !-- Sample for user-defined output: 877 869 ! CASE ( 'u2_xy', 'u2_xz', 'u2_yz' ) … … 885 877 ! ENDDO 886 878 ! ELSE 887 ! IF ( .NOT. ALLOCATED( u2_av ) ) THEN879 ! IF ( .NOT. ALLOCATED( u2_av ) ) THEN 888 880 ! ALLOCATE( u2_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) 889 881 ! u2_av = REAL( fill_value, KIND = wp ) … … 900 892 ! grid = 'zu' 901 893 ! 902 !-- In case two-dimensional surface variables are output, the user 903 !-- has to access related surface-type. Uncomment and extend following lines 904 !-- appropriately (example output of vertical surface momentum flux of u- 905 !-- component). Please note, surface elements can be distributed over 906 !-- several data type, depending on their respective surface properties. 894 !-- In case two-dimensional surface variables are output, the user has to access related 895 !-- surface-type. Uncomment and extend following lines appropriately (example output of vertical 896 !-- surface momentum flux of u-component). Please note, surface elements can be distributed over 897 !-- several data types, depending on their respective surface properties. 907 898 ! CASE ( 'usws_xy' ) 908 899 ! IF ( av == 0 ) THEN … … 931 922 ! 932 923 ! grid = 'zu' 933 !-- 924 !-- 934 925 935 926 … … 944 935 945 936 946 !------------------------------------------------------------------------------ !947 ! Description: 948 ! ------------ 949 !> Resorts the user-defined output quantity with indices (k,j,i) to a 950 !> temporary array with indices(i,j,k).951 !------------------------------------------------------------------------------ !937 !--------------------------------------------------------------------------------------------------! 938 ! Description: 939 ! ------------ 940 !> Resorts the user-defined output quantity with indices (k,j,i) to a temporary array with indices 941 !> (i,j,k). 942 !--------------------------------------------------------------------------------------------------! 952 943 SUBROUTINE user_data_output_3d( av, variable, found, local_pf, nzb_do, nzt_do ) 953 944 954 945 955 CHARACTER (LEN=*) :: variable !<956 957 INTEGER(iwp) :: av !<958 ! INTEGER(iwp) :: i !<959 ! INTEGER(iwp) :: j !<960 ! INTEGER(iwp) :: k !<946 CHARACTER(LEN=*) :: variable !< 947 948 INTEGER(iwp) :: av !< 949 ! INTEGER(iwp) :: i !< 950 ! INTEGER(iwp) :: j !< 951 ! INTEGER(iwp) :: k !< 961 952 INTEGER(iwp) :: nzb_do !< lower limit of the data output (usually 0) 962 953 INTEGER(iwp) :: nzt_do !< vertical upper limit of the data output (usually nz_do3d) 963 954 964 LOGICAL :: found !<965 966 ! REAL(wp) :: fill_value = -999.0_wp 967 968 REAL(sp), DIMENSION(nxl:nxr,nys:nyn,nzb_do:nzt_do) :: local_pf !<955 LOGICAL :: found !< 956 957 ! REAL(wp) :: fill_value = -999.0_wp !< value for the _FillValue attribute 958 959 REAL(sp), DIMENSION(nxl:nxr,nys:nyn,nzb_do:nzt_do) :: local_pf !< 969 960 970 961 ! … … 979 970 ! 980 971 !-- Uncomment and extend the following lines, if necessary. 981 !-- The arrays for storing the user defined quantities (here u2 and u2_av) 982 !-- have to be declaredand defined by the user!972 !-- The arrays for storing the user defined quantities (here u2 and u2_av) have to be declared 973 !-- and defined by the user! 983 974 !-- Sample for user-defined output: 984 975 ! CASE ( 'u2' ) … … 992 983 ! ENDDO 993 984 ! ELSE 994 ! IF ( .NOT. ALLOCATED( u2_av ) ) THEN985 ! IF ( .NOT. ALLOCATED( u2_av ) ) THEN 995 986 ! ALLOCATE( u2_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) 996 987 ! u2_av = REAL( fill_value, KIND = wp ) … … 1015 1006 1016 1007 1017 !------------------------------------------------------------------------------! 1018 ! Description: 1019 ! ------------ 1020 !> Calculation of user-defined statistics, i.e. horizontally averaged profiles 1021 !> and time series. 1022 !> This routine is called for every statistic region sr defined by the user, 1023 !> but at least for the region "total domain" (sr=0). 1024 !> See section 3.5.4 on how to define, calculate, and output user defined 1025 !> quantities. 1026 !------------------------------------------------------------------------------! 1008 !--------------------------------------------------------------------------------------------------! 1009 ! Description: 1010 ! ------------ 1011 !> Calculation of user-defined statistics, i.e. horizontally averaged profiles and time series. 1012 !> This routine is called for every statistic region sr defined by the user, but at least for the 1013 !> region "total domain" (sr=0). See section 3.5.4 on how to define, calculate, and output user 1014 !> defined quantities. 1015 !--------------------------------------------------------------------------------------------------! 1027 1016 SUBROUTINE user_statistics( mode, sr, tn ) 1028 1017 1029 1018 1030 CHARACTER (LEN=*) :: mode !<1031 ! INTEGER(iwp) :: i 1032 ! INTEGER(iwp) :: j 1033 ! INTEGER(iwp) :: k 1034 INTEGER(iwp) :: sr !<1035 INTEGER(iwp) :: tn !<1036 1037 ! REAL(wp), DIMENSION(:), ALLOCATABLE :: ts_value_l 1019 CHARACTER(LEN=*) :: mode !< 1020 ! INTEGER(iwp) :: i !< 1021 ! INTEGER(iwp) :: j !< 1022 ! INTEGER(iwp) :: k !< 1023 INTEGER(iwp) :: sr !< 1024 INTEGER(iwp) :: tn !< 1025 1026 ! REAL(wp), DIMENSION(:), ALLOCATABLE :: ts_value_l !< 1038 1027 1039 1028 ! … … 1044 1033 1045 1034 ! 1046 !-- Sample on how to calculate horizontally averaged profiles of user- 1047 !-- defined quantities. Each quantity is identified by the index 1048 !-- "pr_palm+#" where "#" is an integer starting from 1. These 1049 !-- user-profile-numbers must also be assigned to the respective strings 1050 !-- given by data_output_pr_user in routine user_check_data_output_pr. 1035 !-- Sample on how to calculate horizontally averaged profiles of user-defined quantities. Each 1036 !-- quantity is identified by the index "pr_palm+#" where "#" is an integer starting from 1. 1037 !-- These user-profile-numbers must also be assigned to the respective strings given by 1038 !-- data_output_pr_user in routine user_check_data_output_pr. 1051 1039 ! !$OMP DO 1052 1040 ! DO i = nxl, nxr … … 1054 1042 ! DO k = nzb+1, nzt 1055 1043 !! 1056 !!-- Sample on how to calculate the profile of the resolved-scale 1057 !!-- horizontal momentum flux u*v* 1058 ! sums_l(k,pr_palm+1,tn) = sums_l(k,pr_palm+1,tn) + & 1059 ! ( 0.5_wp * ( u(k,j,i) + u(k,j,i+1) ) - hom(k,1,1,sr) ) *& 1060 ! ( 0.5_wp * ( v(k,j,i) + v(k,j+1,i) ) - hom(k,1,2,sr) ) & 1061 ! * rmask(j,i,sr) & 1062 ! * MERGE( 1.0_wp, 0.0_wp, & 1063 ! BTEST( wall_flags_total_0(k,j,i), 0 ) ) 1044 !!-- Sample on how to calculate the profile of the resolved-scale horizontal momentum 1045 !!-- flux u*v* 1046 ! sums_l(k,pr_palm+1,tn) = sums_l(k,pr_palm+1,tn) + & 1047 ! ( 0.5_wp * ( u(k,j,i) + u(k,j,i+1) ) - hom(k,1,1,sr) ) * & 1048 ! ( 0.5_wp * ( v(k,j,i) + v(k,j+1,i) ) - hom(k,1,2,sr) ) * & 1049 ! rmask(j,i,sr) * MERGE( 1.0_wp, 0.0_wp, & 1050 ! BTEST( wall_flags_total_0(k,j,i), 0 ) ) 1064 1051 !! 1065 !!-- Further profiles can be defined and calculated by increasing 1066 !!-- the second index of array sums_l (replace ... appropriately) 1067 ! sums_l(k,pr_palm+2,tn) = sums_l(k,pr_palm+2,tn) + ... & 1068 ! * rmask(j,i,sr) 1052 !!-- Further profiles can be defined and calculated by increasing the second index of 1053 !!-- array sums_l (replace ... appropriately) 1054 ! sums_l(k,pr_palm+2,tn) = sums_l(k,pr_palm+2,tn) + ... * rmask(j,i,sr) 1069 1055 ! ENDDO 1070 1056 ! ENDDO … … 1077 1063 ! 1078 1064 !-- Sample on how to add values for the user-defined time series quantities. 1079 !-- These have to be defined before in routine user_init. This sample 1080 !-- creates two time series for the absolut values of the horizontal 1081 !-- velocities u and v. 1065 !-- These have to be defined before in routine user_init. This sample creates two time series for 1066 !-- the absolut values of the horizontal velocities u and v. 1082 1067 ! ts_value_l = 0.0_wp 1083 1068 ! ts_value_l(1) = ABS( u_max ) … … 1085 1070 ! 1086 1071 !-- Collect / send values to PE0, because only PE0 outputs the time series. 1087 !-- CAUTION: Collection is done by taking the sum over all processors. 1088 !-- You may have to normalize this sum, depending on the quantity 1089 !-- that you like to calculate. For serial runs, nothing has to be 1090 !-- done. 1091 !-- HINT: If the time series value that you are calculating has the same 1092 !-- value on all PEs, you can omit the MPI_ALLREDUCE call and 1093 !-- assign ts_value(dots_num_palm+1:,sr) = ts_value_l directly. 1072 !-- CAUTION: Collection is done by taking the sum over all processors. You may have to normalize 1073 !-- this sum, depending on the quantity that you like to calculate. For serial runs, 1074 !-- nothing has to be done. 1075 !-- HINT: If the time series value that you are calculating has the same value on all PEs, you 1076 !-- can omit the MPI_ALLREDUCE call and assign ts_value(dots_num_palm+1:,sr) = ts_value_l directly. 1094 1077 !#if defined( __parallel ) 1095 1078 ! IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) 1096 ! CALL MPI_ALLREDUCE( ts_value_l(1), & 1097 ! ts_value(dots_num_palm+1,sr), & 1098 ! dots_num_user, MPI_REAL, MPI_MAX, comm2d, & 1099 ! ierr ) 1079 ! CALL MPI_ALLREDUCE( ts_value_l(1), ts_value(dots_num_palm+1,sr), dots_num_user, MPI_REAL, & 1080 ! MPI_MAX, comm2d, ierr ) 1100 1081 !#else 1101 1082 ! ts_value(dots_num_palm+1:dots_num_palm+dots_num_user,sr) = ts_value_l … … 1107 1088 1108 1089 1109 !------------------------------------------------------------------------------ !1090 !--------------------------------------------------------------------------------------------------! 1110 1091 ! Description: 1111 1092 ! ------------ 1112 1093 !> Read module-specific global restart data (Fortran binary format). 1113 !------------------------------------------------------------------------------ !1094 !--------------------------------------------------------------------------------------------------! 1114 1095 SUBROUTINE user_rrd_global_ftn( found ) 1115 1096 1116 1097 1117 LOGICAL, INTENT(OUT) :: found 1098 LOGICAL, INTENT(OUT) :: found !< 1118 1099 1119 1100 … … 1127 1108 1128 1109 CASE DEFAULT 1129 1110 1130 1111 found = .FALSE. 1131 1112 … … 1136 1117 1137 1118 1138 !------------------------------------------------------------------------------ !1119 !--------------------------------------------------------------------------------------------------! 1139 1120 ! Description: 1140 1121 ! ------------ 1141 1122 !> Read module-specific global restart data (MPI-IO). 1142 !------------------------------------------------------------------------------ !1123 !--------------------------------------------------------------------------------------------------! 1143 1124 SUBROUTINE user_rrd_global_mpi 1144 1125 … … 1149 1130 1150 1131 1151 !------------------------------------------------------------------------------! 1152 ! Description: 1153 ! ------------ 1154 !> Reading processor specific restart data from file(s) that has been defined 1155 !> by the user. 1156 !> Subdomain index limits on file are given by nxl_on_file, etc. 1157 !> Indices nxlc, etc. indicate the range of gridpoints to be mapped from the 1158 !> subdomain on file (f) to the subdomain of the current PE (c). They have been 1159 !> calculated in routine rrd_local. 1160 !------------------------------------------------------------------------------! 1161 SUBROUTINE user_rrd_local( k, nxlf, nxlc, nxl_on_file, nxrf, nxrc, & 1162 nxr_on_file, nynf, nync, nyn_on_file, nysf, & 1163 nysc, nys_on_file, tmp_3d, found ) 1132 !--------------------------------------------------------------------------------------------------! 1133 ! Description: 1134 ! ------------ 1135 !> Reading processor specific restart data from file(s) that has been defined by the user. Subdomain 1136 !> index limits on file are given by nxl_on_file, etc. Indices nxlc, etc. indicate the range of 1137 !> gridpoints to be mapped from the subdomain on file (f) to the subdomain of the current PE (c). 1138 !> They have been calculated in routine rrd_local. 1139 !--------------------------------------------------------------------------------------------------! 1140 SUBROUTINE user_rrd_local( k, nxlf, nxlc, nxl_on_file, nxrf, nxrc, nxr_on_file, nynf, nync, & 1141 nyn_on_file, nysf, nysc, nys_on_file, tmp_3d, found ) 1164 1142 1165 1143 … … 1179 1157 INTEGER(iwp) :: nys_on_file !< 1180 1158 1181 LOGICAL, INTENT(OUT) :: found 1182 1183 REAL(wp), DIMENSION(nzb:nzt+1,nys_on_file-nbgp:nyn_on_file+nbgp,nxl_on_file-nbgp:nxr_on_file+nbgp) :: tmp_3d 1159 LOGICAL, INTENT(OUT) :: found !< 1160 1161 REAL(wp), DIMENSION(nzb:nzt+1,nys_on_file-nbgp:nyn_on_file+nbgp,nxl_on_file-nbgp:nxr_on_file+nbgp) :: tmp_3d !< 1184 1162 1185 1163 ! … … 1197 1175 1198 1176 CASE ( 'u2_av' ) 1199 ! IF ( .NOT. ALLOCATED( u2_av ) ) THEN1177 ! IF ( .NOT. ALLOCATED( u2_av ) ) THEN 1200 1178 ! ALLOCATE( u2_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) 1201 1179 ! ENDIF 1202 1180 ! IF ( k == 1 ) READ ( 13 ) tmp_3d 1203 ! u2_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) = &1204 ! 1181 ! u2_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) = & 1182 ! tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp) 1205 1183 ! 1206 1184 CASE DEFAULT … … 1213 1191 1214 1192 1215 !------------------------------------------------------------------------------! 1216 ! Description: 1217 ! ------------ 1218 !> Writes global and user-defined restart data into binary file(s) for restart 1219 !> runs. 1220 !------------------------------------------------------------------------------! 1193 !--------------------------------------------------------------------------------------------------! 1194 ! Description: 1195 ! ------------ 1196 !> Writes global and user-defined restart data into binary file(s) for restart runs. 1197 !--------------------------------------------------------------------------------------------------! 1221 1198 SUBROUTINE user_wrd_global 1222 1199 … … 1235 1212 1236 1213 1237 !------------------------------------------------------------------------------! 1238 ! Description: 1239 ! ------------ 1240 !> Writes processor specific and user-defined restart data into binary file(s) 1241 !> for restart runs. 1242 !------------------------------------------------------------------------------! 1214 !--------------------------------------------------------------------------------------------------! 1215 ! Description: 1216 ! ------------ 1217 !> Writes processor specific and user-defined restart data into binary file(s) for restart runs. 1218 !--------------------------------------------------------------------------------------------------! 1243 1219 SUBROUTINE user_wrd_local 1244 1220 … … 1262 1238 1263 1239 1264 !------------------------------------------------------------------------------ !1240 !--------------------------------------------------------------------------------------------------! 1265 1241 ! Description: 1266 1242 ! ------------ 1267 1243 !> Execution of user-defined actions at the end of a job. 1268 !------------------------------------------------------------------------------ !1244 !--------------------------------------------------------------------------------------------------! 1269 1245 SUBROUTINE user_last_actions 1270 1246
Note: See TracChangeset
for help on using the changeset viewer.