Changeset 4756 for palm/trunk/UTIL/inifor/src/inifor_transform.f90
- Timestamp:
- Oct 26, 2020 10:05:58 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
palm/trunk/UTIL/inifor/src/inifor_transform.f90
r4714 r4756 26 26 ! ----------------- 27 27 ! $Id$ 28 ! Fixed an error in surface pressure extrapolation where the cosmo grid was 29 ! misinterpreted as palm grid 30 ! Improved code readability and formatting 31 ! 32 ! 33 ! 4714 2020-09-29 12:47:35Z eckhard 28 34 ! Fixed off-by-one indexing error for profile quantities 29 35 ! … … 381 387 !------------------------------------------------------------------------------! 382 388 SUBROUTINE interp_average_profile(source_array, profile_array, avg_grid) 383 TYPE(grid_definition), INTENT(IN) 384 REAL(wp), DIMENSION(:,:,:), INTENT(IN) 385 REAL(wp), DIMENSION(:), INTENT(OUT) 389 TYPE(grid_definition), INTENT(IN) :: avg_grid 390 REAL(wp), DIMENSION(:,:,:), INTENT(IN) :: source_array(0:,0:,:) 391 REAL(wp), DIMENSION(:), INTENT(OUT) :: profile_array 386 392 387 393 INTEGER(iwp) :: i_source, j_source, k_profile, k_source, l, m … … 438 444 SUBROUTINE average_profile( source_array, profile_array, avg_grid ) 439 445 440 TYPE(grid_definition), INTENT(IN) 441 REAL(wp), DIMENSION(:,:,:), INTENT(IN):: source_array(0:,0:,:)442 REAL(wp), DIMENSION(:), INTENT(OUT) :: profile_array446 TYPE(grid_definition), INTENT(IN) :: avg_grid 447 REAL(wp), INTENT(IN) :: source_array(0:,0:,:) 448 REAL(wp), INTENT(OUT) :: profile_array(:) 443 449 444 450 INTEGER(iwp) :: i_source, j_source, l, nz, nlev … … 484 490 cosmo_grid, avg_grid ) 485 491 486 TYPE(grid_definition), INTENT(IN) :: cosmo_grid, avg_grid 487 REAL(wp), DIMENSION(:,:,:), INTENT(IN) :: cosmo_pressure(0:,0:,:) 488 REAL(wp), DIMENSION(:), INTENT(OUT) :: profile_array 489 490 INTEGER(iwp) :: i_source, j_source, l, nz, nlev 491 492 REAL(wp) :: ni_columns 493 REAL(wp), DIMENSION(:), ALLOCATABLE :: basic_state_pressure 492 TYPE(grid_definition), INTENT(IN) :: cosmo_grid, avg_grid 493 REAL(wp), INTENT(IN) :: cosmo_pressure(0:,0:,:) 494 REAL(wp), INTENT(OUT) :: profile_array(:) 495 496 INTEGER(iwp) :: i_source, j_source, l, nz, nlev 497 REAL(wp) :: ni_columns 498 REAL(wp), ALLOCATABLE :: basic_state_pressure(:) 494 499 495 500 nlev = SIZE( cosmo_pressure, 3 ) … … 624 629 ! Description: 625 630 ! ------------ 626 !> Takes the averaged pressure profile <p>and sets the lowest entry to the627 !> extrapolated pressure at the surface .628 !------------------------------------------------------------------------------! 629 SUBROUTINE get_surface_pressure(p , rho, avg_grid)630 REAL(wp), DIMENSION(:), INTENT(IN) :: rho 631 REAL(wp), DIMENSION(:), INTENT(INOUT) :: p 631 !> Takes the averaged pressure profile p_palm and sets the lowest entry to the 632 !> extrapolated pressure at the surface, assuming a linear density profile. 633 !------------------------------------------------------------------------------! 634 SUBROUTINE get_surface_pressure(p_palm, rho_cosmo, avg_grid) 635 REAL(wp), DIMENSION(:), INTENT(IN) :: rho_cosmo 636 REAL(wp), DIMENSION(:), INTENT(INOUT) :: p_palm 632 637 TYPE(grid_definition), INTENT(IN) :: avg_grid 633 638 634 REAL(wp) :: drhodz, dz, zk, rhok 635 INTEGER(iwp) :: k_min 636 637 k_min = avg_grid%k_min 638 zk = avg_grid%z(k_min) 639 rhok = rho(k_min) 640 dz = avg_grid%z(k_min + 1) - avg_grid%z(k_min) 641 drhodz = ( rho(k_min + 1) - rho(k_min) ) / dz 642 643 p(1) = linear_density_pressure( p(k_min), zk, rhok, drhodz, & 644 z = 0.0_wp, g=G ) 639 REAL(wp) :: drhodz_surface_cosmo 640 INTEGER(iwp) :: k_min_palm 641 642 drhodz_surface_cosmo = & 643 ( rho_cosmo(2) - rho_cosmo(1) ) / & 644 ( avg_grid%intermediate_h(1,1,2) - avg_grid%intermediate_h(1,1,1) ) 645 646 k_min_palm = avg_grid%k_min 647 648 p_palm(1) = linear_density_pressure( & 649 p0 = p_palm(k_min_palm), & 650 z0 = avg_grid%z(k_min_palm), & 651 rho00 = rho_cosmo(1), & 652 z00 = avg_grid%intermediate_h(1,1,1), & 653 drhodz = drhodz_surface_cosmo, & 654 g = G, & 655 z = 0.0_wp & 656 ) 645 657 646 658 END SUBROUTINE get_surface_pressure 647 659 648 660 649 FUNCTION linear_density_pressure(pk, zk, rhok, drhodz, z, g) RESULT(p) 650 651 REAL(wp), INTENT(IN) :: pk, zk, rhok, drhodz, g, z 661 !------------------------------------------------------------------------------! 662 ! Description: 663 ! ----------- 664 !> Computes the hydrostatic pressure p at height z given the pressure p0 at 665 !> height z0. The pressure is computed based on the solution of the hydrostatic 666 !> equation assuming a linear density profile with density rho00 at z00 and the 667 !> vertical density gradient drhodz. 668 !------------------------------------------------------------------------------! 669 FUNCTION linear_density_pressure(p0, z0, rho00, z00, drhodz, g, z) RESULT(p) 670 671 REAL(wp), INTENT(IN) :: p0, z0, rho00, z00, drhodz, g, z 652 672 REAL(wp) :: p 653 673 654 p = pk + ( zk - z ) * g * ( rhok - 0.5_wp * drhodz * (zk - z) ) 674 p = p0 - ( z - z0 ) * g * ( & 675 rho00 + 0.5_wp * drhodz * ( z + z0 - 2.0_wp * z00 ) & 676 ) 655 677 656 678 END FUNCTION linear_density_pressure 657 679 658 !----------------------------------------------------------------------------- !680 !------------------------------------------------------------------------------! 659 681 ! Description: 660 682 ! ----------- 661 683 !> This routine computes profiles of the two geostrophic wind components ug and 662 684 !> vg. 663 !----------------------------------------------------------------------------- !685 !------------------------------------------------------------------------------! 664 686 SUBROUTINE geostrophic_winds(p_north, p_south, p_east, p_west, rho, f3, & 665 687 Lx, Ly, phi_n, lam_n, phi_g, lam_g, ug, vg) … … 683 705 684 706 685 !----------------------------------------------------------------------------- !707 !------------------------------------------------------------------------------! 686 708 ! Description: 687 709 ! ----------- … … 689 711 !> Cartesian coordinates (x,y) onto a sphere. It returns the latitude and 690 712 !> lngitude of a geographical system centered at x0 and y0. 691 !----------------------------------------------------------------------------- !713 !------------------------------------------------------------------------------! 692 714 SUBROUTINE inv_plate_carree(x, y, x0, y0, r, lat, lon) 693 715 REAL(wp), INTENT(IN) :: x(:), y(:), x0, y0, r … … 706 728 707 729 708 !----------------------------------------------------------------------------- !730 !------------------------------------------------------------------------------! 709 731 ! Description: 710 732 ! ------------
Note: See TracChangeset
for help on using the changeset viewer.