Skip to content
Snippets Groups Projects
Commit e428de69 authored by 数学の武士's avatar 数学の武士
Browse files

Remove pointers

parent 1262b184
Branches
Tags
No related merge requests found
......@@ -40,21 +40,12 @@ module sfx_data
!> @brief meteorological input for surface flux calculation
!> &details using arrays as input
type, public :: meteoDataVecType
#if defined(INCLUDE_CXX)
real, pointer, contiguous :: h(:) !< constant flux layer height [m]
real, pointer, contiguous :: U(:) !< abs(wind speed) at 'h' [m/s]
real, pointer, contiguous :: dT(:) !< difference between potential temperature at 'h' and at surface [K]
real, pointer, contiguous :: Tsemi(:) !< semi-sum of potential temperature at 'h' and at surface [K]
real, pointer, contiguous :: dQ(:) !< difference between humidity at 'h' and at surface [g/g]
real, pointer, contiguous :: z0_m(:) !< surface aerodynamic roughness (should be < 0 for water bodies surface)
#else
real, allocatable :: h(:) !< constant flux layer height [m]
real, allocatable :: U(:) !< abs(wind speed) at 'h' [m/s]
real, allocatable :: dT(:) !< difference between potential temperature at 'h' and at surface [K]
real, allocatable :: Tsemi(:) !< semi-sum of potential temperature at 'h' and at surface [K]
real, allocatable :: dQ(:) !< difference between humidity at 'h' and at surface [g/g]
real, allocatable :: z0_m(:) !< surface aerodynamic roughness (should be < 0 for water bodies surface)
#endif
end type
#if defined(INCLUDE_CXX)
......@@ -90,19 +81,7 @@ module sfx_data
!> @brief surface flux output data
!> &details using arrays as output
type, public :: sfxDataVecType
#if defined(INCLUDE_CXX)
real, pointer, contiguous :: zeta(:) !< = z/L [n/d]
real, pointer, contiguous :: Rib(:) !< bulk Richardson number [n/d]
real, pointer, contiguous :: Re(:) !< Reynolds number [n/d]
real, pointer, contiguous :: B(:) !< = log(z0_m / z0_h) [n/d]
real, pointer, contiguous :: z0_m(:) !< aerodynamic roughness [m]
real, pointer, contiguous :: z0_t(:) !< thermal roughness [m]
real, pointer, contiguous :: Rib_conv_lim(:) !< Ri-bulk convection critical value [n/d]
real, pointer, contiguous :: Cm(:) !< transfer coefficient for momentum [n/d]
real, pointer, contiguous :: Ct(:) !< transfer coefficient for heat [n/d]
real, pointer, contiguous :: Km(:) !< eddy viscosity coeff. at h [m^2/s]
real, pointer, contiguous :: Pr_t_inv(:) !< inverse turbulent Prandtl number at h [n/d]
#else
real, allocatable :: zeta(:) !< = z/L [n/d]
real, allocatable :: Rib(:) !< bulk Richardson number [n/d]
real, allocatable :: Re(:) !< Reynolds number [n/d]
......@@ -114,7 +93,7 @@ module sfx_data
real, allocatable :: Ct(:) !< transfer coefficient for heat [n/d]
real, allocatable :: Km(:) !< eddy viscosity coeff. at h [m^2/s]
real, allocatable :: Pr_t_inv(:) !< inverse turbulent Prandtl number at h [n/d]
#endif
end type
#if defined(INCLUDE_CXX)
......@@ -222,10 +201,8 @@ contains
subroutine set_meteo_vec_c(meteo, meteo_C)
!> @brief allocate meteo data vector
! ----------------------------------------------------------------------------
type (meteoDataVecType) , intent(in) :: meteo
type (meteoDataVecTypeC), pointer, intent(inout) :: meteo_C
allocate(meteo_C)
type (meteoDataVecType), target :: meteo
type (meteoDataVecTypeC), intent(inout) :: meteo_C
meteo_C%h = c_loc(meteo%h)
meteo_C%U = c_loc(meteo%U)
......@@ -281,10 +258,8 @@ contains
subroutine set_sfx_vec_c(sfx, sfx_C)
!> @brief allocate surface fluxes data vector
! ----------------------------------------------------------------------------
type (sfxDataVecType), intent(inout) :: sfx
type (sfxDataVecTypeC), pointer, intent(inout) :: sfx_C
allocate(sfx_C)
type (sfxDataVecType), target :: sfx
type (sfxDataVecTypeC), intent(inout) :: sfx_C
sfx_C%zeta = c_loc(sfx%zeta)
sfx_C%Rib = c_loc(sfx%Rib)
......
......@@ -12,7 +12,7 @@ module sfx_esm
use sfx_surface
use sfx_esm_param
#if defined(INCLUDE_CXX)
use iso_c_binding, only: c_loc
use iso_c_binding, only: C_LOC, C_PTR
use C_FUNC
#endif
! --------------------------------------------------------------------------------
......@@ -72,8 +72,9 @@ contains
integer i
! ----------------------------------------------------------------------------
#if defined(INCLUDE_CXX)
type (meteoDataVecTypeC), pointer :: meteo_c !< meteorological data (input)
type (sfxDataVecTypeC), pointer :: sfx_c !< surface flux data (output)
type (meteoDataVecTypeC), target :: meteo_c !< meteorological data (input)
type (sfxDataVecTypeC), target :: sfx_c !< surface flux data (output)
type(C_PTR) :: meteo_c_ptr, sfx_c_ptr
type (sfx_esm_param) :: model_param
type (sfx_surface_param) :: surface_param
type (sfx_esm_numericsTypeC) :: numerics_c
......@@ -90,11 +91,10 @@ contains
call set_c_struct_sfx_surface_param_values(surface_param)
call set_meteo_vec_c(meteo, meteo_c)
call set_sfx_vec_c(sfx, sfx_c)
meteo_c_ptr = C_LOC(meteo_c)
sfx_c_ptr = C_LOC(sfx_c)
call get_surface_fluxes_esm(c_loc(sfx_c), c_loc(meteo_c), model_param, surface_param, numerics_c, phys_constants, n)
deallocate(meteo_c)
deallocate(sfx_c)
call get_surface_fluxes_esm(sfx_c_ptr, meteo_c_ptr, model_param, surface_param, numerics_c, phys_constants, n)
#else
do i = 1, n
#ifdef SFX_FORCE_DEPRECATED_ESM_CODE
......
......@@ -12,8 +12,8 @@ module sfx_sheba
use sfx_surface
use sfx_sheba_param
#if defined(INCLUDE_CUDA) || defined(INCLUDE_CXX)
use iso_c_binding, only: c_loc
#if defined(INCLUDE_CXX)
use iso_c_binding, only: C_LOC, C_PTR
use C_FUNC
#endif
! --------------------------------------------------------------------------------
......@@ -74,6 +74,7 @@ contains
#if defined(INCLUDE_CXX)
type (meteoDataVecTypeC), pointer :: meteo_c !< meteorological data (input)
type (sfxDataVecTypeC), pointer :: sfx_c !< surface flux data (output)
type(C_PTR) :: meteo_c_ptr, sfx_c_ptr
type (sfx_sheba_param) :: model_param
type (sfx_surface_param) :: surface_param
type (sfx_sheba_numericsTypeC) :: numerics_c
......@@ -90,10 +91,10 @@ contains
call set_meteo_vec_c(meteo, meteo_c)
call set_sfx_vec_c(sfx, sfx_c)
call get_surface_fluxes_sheba(c_loc(sfx_c), c_loc(meteo_c), model_param, surface_param, numerics_c, phys_constants, n)
meteo_c_ptr = C_LOC(meteo_c)
sfx_c_ptr = C_LOC(sfx_c)
deallocate(meteo_c)
deallocate(sfx_c)
call get_surface_fluxes_sheba(sfx_c_ptr, meteo_c_ptr, model_param, surface_param, numerics_c, phys_constants, n)
#else
do i = 1, n
meteo_cell = meteoDataType(&
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment