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

Beautify CXX code

parent 5b4b92d2
No related branches found
No related tags found
No related merge requests found
......@@ -85,7 +85,7 @@ extern "C" {
};
// use sfx_esm_param
struct sfx_esm_param
struct sfx_esm_param_C
{
float kappa;
float Pr_t_0_inv;
......@@ -99,14 +99,14 @@ extern "C" {
float Rib_max;
};
struct sfx_esm_numericsTypeC
struct sfx_esm_numericsType_C
{
int maxiters_convection;
int maxiters_charnock;
};
// use sfx_sheba_param
struct sfx_sheba_param
struct sfx_sheba_param_C
{
float kappa;
float Pr_t_0_inv;
......@@ -120,7 +120,7 @@ extern "C" {
float c_h;
};
struct sfx_sheba_numericsTypeC
struct sfx_sheba_numericsType_C
{
int maxiters_charnock;
};
......
......@@ -7,17 +7,17 @@ extern "C" {
void surf_flux_esm_CXX(struct sfxDataVecTypeC* sfx,
struct meteoDataVecTypeC* meteo,
const struct sfx_esm_param* model_param,
const struct sfx_esm_param_C* model_param,
const struct sfx_surface_param* surface_param,
const struct sfx_esm_numericsTypeC* numerics,
const struct sfx_esm_numericsType_C* numerics,
const struct sfx_phys_constants* constants,
const int grid_size);
void surf_flux_sheba_CXX(struct sfxDataVecTypeC* sfx,
struct meteoDataVecTypeC* meteo,
const struct sfx_sheba_param* model_param,
const struct sfx_sheba_param_C* model_param,
const struct sfx_surface_param* surface_param,
const struct sfx_sheba_numericsTypeC* numerics,
const struct sfx_sheba_numericsType_C* numerics,
const struct sfx_phys_constants* constants,
const int grid_size);
#ifdef __cplusplus
......
......@@ -14,17 +14,17 @@ public:
using ModelBase<T, memIn, memOut, RunMem>::ifAllocated;
using ModelBase<T, memIn, memOut, RunMem>::allocated_size;
sfx_surface_param surface_param;
sfx_phys_constants phys_constants;
sfx_esm_param model_param;
sfx_esm_numericsTypeC numerics;
sfx_surface_param surface;
sfx_phys_constants phys;
sfx_esm_param_C model;
sfx_esm_numericsType_C numerics;
FluxEsmBase(sfxDataVecTypeC* sfx,
meteoDataVecTypeC* meteo,
const sfx_esm_param model_param,
const sfx_surface_param surface_param,
const sfx_esm_numericsTypeC numerics,
const sfx_phys_constants phys_constants,
const sfx_esm_param_C model,
const sfx_surface_param surface,
const sfx_esm_numericsType_C numerics,
const sfx_phys_constants phys,
const int grid_size);
~FluxEsmBase();
};
......@@ -39,22 +39,22 @@ class FluxEsm<T, memIn, memOut, MemType::CPU> : public FluxEsmBase<T, memIn, mem
using FluxEsmBase<T, memIn, memOut, MemType::CPU>::res_sfx;
using FluxEsmBase<T, memIn, memOut, MemType::CPU>::sfx;
using FluxEsmBase<T, memIn, memOut, MemType::CPU>::meteo;
using FluxEsmBase<T, memIn, memOut, MemType::CPU>::surface_param;
using FluxEsmBase<T, memIn, memOut, MemType::CPU>::phys_constants;
using FluxEsmBase<T, memIn, memOut, MemType::CPU>::surface;
using FluxEsmBase<T, memIn, memOut, MemType::CPU>::phys;
using FluxEsmBase<T, memIn, memOut, MemType::CPU>::grid_size;
using FluxEsmBase<T, memIn, memOut, MemType::CPU>::ifAllocated;
using FluxEsmBase<T, memIn, memOut, MemType::CPU>::allocated_size;
using FluxEsmBase<T, memIn, memOut, MemType::CPU>::model_param;
using FluxEsmBase<T, memIn, memOut, MemType::CPU>::model;
using FluxEsmBase<T, memIn, memOut, MemType::CPU>::numerics;
public:
FluxEsm(sfxDataVecTypeC* sfx,
meteoDataVecTypeC* meteo,
const sfx_esm_param model_param,
const sfx_surface_param surface_param,
const sfx_esm_numericsTypeC numerics,
const sfx_phys_constants phys_constants,
const int grid_size) : FluxEsmBase<T, memIn, memOut, MemType::CPU>(sfx, meteo, model_param,
surface_param, numerics, phys_constants, grid_size) {}
const sfx_esm_param_C model,
const sfx_surface_param surface,
const sfx_esm_numericsType_C numerics,
const sfx_phys_constants phys,
const int grid_size) : FluxEsmBase<T, memIn, memOut, MemType::CPU>(sfx, meteo, model,
surface, numerics, phys, grid_size) {}
~FluxEsm() = default;
void compute_flux();
};
......@@ -66,22 +66,22 @@ class FluxEsm<T, memIn, memOut, MemType::GPU> : public FluxEsmBase<T, memIn, mem
using FluxEsmBase<T, memIn, memOut, MemType::GPU>::res_sfx;
using FluxEsmBase<T, memIn, memOut, MemType::GPU>::sfx;
using FluxEsmBase<T, memIn, memOut, MemType::GPU>::meteo;
using FluxEsmBase<T, memIn, memOut, MemType::GPU>::surface_param;
using FluxEsmBase<T, memIn, memOut, MemType::GPU>::phys_constants;
using FluxEsmBase<T, memIn, memOut, MemType::GPU>::surface;
using FluxEsmBase<T, memIn, memOut, MemType::GPU>::phys;
using FluxEsmBase<T, memIn, memOut, MemType::GPU>::grid_size;
using FluxEsmBase<T, memIn, memOut, MemType::GPU>::ifAllocated;
using FluxEsmBase<T, memIn, memOut, MemType::GPU>::allocated_size;
using FluxEsmBase<T, memIn, memOut, MemType::GPU>::model_param;
using FluxEsmBase<T, memIn, memOut, MemType::GPU>::model;
using FluxEsmBase<T, memIn, memOut, MemType::GPU>::numerics;
public:
FluxEsm(sfxDataVecTypeC* sfx,
meteoDataVecTypeC* meteo,
const sfx_esm_param model_param,
const sfx_surface_param surface_param,
const sfx_esm_numericsTypeC numerics,
const sfx_phys_constants phys_constants,
const int grid_size) : FluxEsmBase<T, memIn, memOut, MemType::GPU>(sfx, meteo, model_param,
surface_param, numerics, phys_constants, grid_size) {}
const sfx_esm_param_C model,
const sfx_surface_param surface,
const sfx_esm_numericsType_C numerics,
const sfx_phys_constants phys,
const int grid_size) : FluxEsmBase<T, memIn, memOut, MemType::GPU>(sfx, meteo, model,
surface, numerics, phys, grid_size) {}
~FluxEsm() = default;
void compute_flux();
};
......
......@@ -14,17 +14,17 @@ public:
using ModelBase<T, memIn, memOut, RunMem>::ifAllocated;
using ModelBase<T, memIn, memOut, RunMem>::allocated_size;
sfx_surface_param surface_param;
sfx_phys_constants phys_constants;
sfx_sheba_param model_param;
sfx_sheba_numericsTypeC numerics;
sfx_surface_param surface;
sfx_phys_constants phys;
sfx_sheba_param_C model;
sfx_sheba_numericsType_C numerics;
FluxShebaBase(sfxDataVecTypeC* sfx,
meteoDataVecTypeC* meteo,
const sfx_sheba_param model_param,
const sfx_surface_param surface_param,
const sfx_sheba_numericsTypeC numerics,
const sfx_phys_constants phys_constants,
const sfx_sheba_param_C model,
const sfx_surface_param surface,
const sfx_sheba_numericsType_C numerics,
const sfx_phys_constants phys,
const int grid_size);
~FluxShebaBase();
};
......@@ -39,22 +39,22 @@ class FluxSheba<T, memIn, memOut, MemType::CPU> : public FluxShebaBase<T, memIn,
using FluxShebaBase<T, memIn, memOut, MemType::CPU>::res_sfx;
using FluxShebaBase<T, memIn, memOut, MemType::CPU>::sfx;
using FluxShebaBase<T, memIn, memOut, MemType::CPU>::meteo;
using FluxShebaBase<T, memIn, memOut, MemType::CPU>::surface_param;
using FluxShebaBase<T, memIn, memOut, MemType::CPU>::phys_constants;
using FluxShebaBase<T, memIn, memOut, MemType::CPU>::surface;
using FluxShebaBase<T, memIn, memOut, MemType::CPU>::phys;
using FluxShebaBase<T, memIn, memOut, MemType::CPU>::grid_size;
using FluxShebaBase<T, memIn, memOut, MemType::CPU>::ifAllocated;
using FluxShebaBase<T, memIn, memOut, MemType::CPU>::allocated_size;
using FluxShebaBase<T, memIn, memOut, MemType::CPU>::model_param;
using FluxShebaBase<T, memIn, memOut, MemType::CPU>::model;
using FluxShebaBase<T, memIn, memOut, MemType::CPU>::numerics;
public:
FluxSheba(sfxDataVecTypeC* sfx,
meteoDataVecTypeC* meteo,
const sfx_sheba_param model_param,
const sfx_surface_param surface_param,
const sfx_sheba_numericsTypeC numerics,
const sfx_phys_constants phys_constants,
const int grid_size) : FluxShebaBase<T, memIn, memOut, MemType::CPU>(sfx, meteo, model_param,
surface_param, numerics, phys_constants, grid_size) {}
const sfx_sheba_param_C model,
const sfx_surface_param surface,
const sfx_sheba_numericsType_C numerics,
const sfx_phys_constants phys,
const int grid_size) : FluxShebaBase<T, memIn, memOut, MemType::CPU>(sfx, meteo, model,
surface, numerics, phys, grid_size) {}
~FluxSheba() = default;
void compute_flux();
};
......@@ -66,22 +66,22 @@ class FluxSheba<T, memIn, memOut, MemType::GPU> : public FluxShebaBase<T, memIn,
using FluxShebaBase<T, memIn, memOut, MemType::GPU>::res_sfx;
using FluxShebaBase<T, memIn, memOut, MemType::GPU>::sfx;
using FluxShebaBase<T, memIn, memOut, MemType::GPU>::meteo;
using FluxShebaBase<T, memIn, memOut, MemType::GPU>::surface_param;
using FluxShebaBase<T, memIn, memOut, MemType::GPU>::phys_constants;
using FluxShebaBase<T, memIn, memOut, MemType::GPU>::surface;
using FluxShebaBase<T, memIn, memOut, MemType::GPU>::phys;
using FluxShebaBase<T, memIn, memOut, MemType::GPU>::grid_size;
using FluxShebaBase<T, memIn, memOut, MemType::GPU>::ifAllocated;
using FluxShebaBase<T, memIn, memOut, MemType::GPU>::allocated_size;
using FluxShebaBase<T, memIn, memOut, MemType::GPU>::model_param;
using FluxShebaBase<T, memIn, memOut, MemType::GPU>::model;
using FluxShebaBase<T, memIn, memOut, MemType::GPU>::numerics;
public:
FluxSheba(sfxDataVecTypeC* sfx,
meteoDataVecTypeC* meteo,
const sfx_sheba_param model_param,
const sfx_surface_param surface_param,
const sfx_sheba_numericsTypeC numerics,
const sfx_phys_constants phys_constants,
const int grid_size) : FluxShebaBase<T, memIn, memOut, MemType::GPU>(sfx, meteo, model_param,
surface_param, numerics, phys_constants, grid_size) {}
const sfx_sheba_param_C model,
const sfx_surface_param surface,
const sfx_sheba_numericsType_C numerics,
const sfx_phys_constants phys,
const int grid_size) : FluxShebaBase<T, memIn, memOut, MemType::GPU>(sfx, meteo, model,
surface, numerics, phys, grid_size) {}
~FluxSheba() = default;
void compute_flux();
};
......
......@@ -6,9 +6,9 @@
void get_surface_fluxes_esm (struct sfxDataVecTypeC* sfx,
struct meteoDataVecTypeC* meteo,
const struct sfx_esm_param* model_param,
const struct sfx_esm_param_C* model_param,
const struct sfx_surface_param* surface_param,
const struct sfx_esm_numericsTypeC* numerics,
const struct sfx_esm_numericsType_C* numerics,
const struct sfx_phys_constants* constants,
const int *grid_size)
{
......@@ -17,9 +17,9 @@ void get_surface_fluxes_esm (struct sfxDataVecTypeC* sfx,
void get_surface_fluxes_sheba (struct sfxDataVecTypeC* sfx,
struct meteoDataVecTypeC* meteo,
const struct sfx_sheba_param* model_param,
const struct sfx_sheba_param_C* model_param,
const struct sfx_surface_param* surface_param,
const struct sfx_sheba_numericsTypeC* numerics,
const struct sfx_sheba_numericsType_C* numerics,
const struct sfx_phys_constants* constants,
const int *grid_size)
{
......
......@@ -11,20 +11,20 @@ namespace sfx_kernel
template<typename T>
__global__ void compute_flux(sfxDataVecTypeC sfx,
meteoDataVecTypeC meteo,
const sfx_esm_param model_param,
const sfx_surface_param surface_param,
const sfx_esm_numericsTypeC numerics,
const sfx_phys_constants phys_constants,
const sfx_esm_param_C model,
const sfx_surface_param surface,
const sfx_esm_numericsType_C numerics,
const sfx_phys_constants phys,
const int grid_size);
}
template<typename T>
__global__ void sfx_kernel::compute_flux(sfxDataVecTypeC sfx,
meteoDataVecTypeC meteo,
const sfx_esm_param model_param,
const sfx_surface_param surface_param,
const sfx_esm_numericsTypeC numerics,
const sfx_phys_constants phys_constants,
const sfx_esm_param_C model,
const sfx_surface_param surface,
const sfx_esm_numericsType_C numerics,
const sfx_phys_constants phys,
const int grid_size)
{
const int index = blockIdx.x * blockDim.x + threadIdx.x;
......@@ -42,66 +42,66 @@ __global__ void sfx_kernel::compute_flux(sfxDataVecTypeC sfx,
h = meteo.h[index];
z0_m = meteo.z0_m[index];
surface_type = z0_m < 0.0 ? surface_param.surface_ocean : surface_param.surface_land;
surface_type = z0_m < 0.0 ? surface.surface_ocean : surface.surface_land;
if (surface_type == surface_param.surface_ocean)
if (surface_type == surface.surface_ocean)
{
get_charnock_roughness(z0_m, u_dyn0, U, h, surface_param, numerics.maxiters_charnock);
get_charnock_roughness(z0_m, u_dyn0, U, h, surface, numerics.maxiters_charnock);
h0_m = h / z0_m;
}
if (surface_type == surface_param.surface_land)
if (surface_type == surface.surface_land)
{
h0_m = h / z0_m;
u_dyn0 = U * model_param.kappa / log(h0_m);
u_dyn0 = U * model.kappa / log(h0_m);
}
Re = u_dyn0 * z0_m / phys_constants.nu_air;
get_thermal_roughness(z0_t, B, z0_m, Re, surface_param, surface_type);
Re = u_dyn0 * z0_m / phys.nu_air;
get_thermal_roughness(z0_t, B, z0_m, Re, surface, surface_type);
h0_t = h / z0_t;
Rib = (phys_constants.g / Tsemi) * h * (dT + 0.61e0 * Tsemi * dQ) / (U*U);
Rib = (phys.g / Tsemi) * h * (dT + 0.61e0 * Tsemi * dQ) / (U*U);
get_convection_lim(zeta_conv_lim, Rib_conv_lim, f_m_conv_lim, f_h_conv_lim,
h0_m, h0_t, B,
model_param);
model);
if (Rib > 0.0)
{
Rib = sfx_math::min(Rib, model_param.Rib_max);
get_psi_stable(psi_m, psi_h, zeta, Rib, h0_m, h0_t, B, model_param);
Rib = sfx_math::min(Rib, model.Rib_max);
get_psi_stable(psi_m, psi_h, zeta, Rib, h0_m, h0_t, B, model);
fval = model_param.beta_m * zeta;
fval = model.beta_m * zeta;
phi_m = 1.0 + fval;
phi_h = 1.0/model_param.Pr_t_0_inv + fval;
phi_h = 1.0/model.Pr_t_0_inv + fval;
}
else if (Rib < Rib_conv_lim)
{
get_psi_convection(psi_m, psi_h, zeta, Rib, h0_m, h0_t, B, zeta_conv_lim, f_m_conv_lim, f_h_conv_lim, model_param, numerics.maxiters_convection);
get_psi_convection(psi_m, psi_h, zeta, Rib, h0_m, h0_t, B, zeta_conv_lim, f_m_conv_lim, f_h_conv_lim, model, numerics.maxiters_convection);
fval = pow(zeta_conv_lim / zeta, 1.0/3.0);
phi_m = fval / f_m_conv_lim;
phi_h = fval / (model_param.Pr_t_0_inv * f_h_conv_lim);
phi_h = fval / (model.Pr_t_0_inv * f_h_conv_lim);
}
else if (Rib > -0.001)
{
get_psi_neutral(psi_m, psi_h, zeta, h0_m, h0_t, B, model_param);
get_psi_neutral(psi_m, psi_h, zeta, h0_m, h0_t, B, model);
phi_m = 1.0;
phi_h = 1.0 / model_param.Pr_t_0_inv;
phi_h = 1.0 / model.Pr_t_0_inv;
}
else
{
get_psi_semi_convection(psi_m, psi_h, zeta, Rib, h0_m, h0_t, B, model_param, numerics.maxiters_convection);
get_psi_semi_convection(psi_m, psi_h, zeta, Rib, h0_m, h0_t, B, model, numerics.maxiters_convection);
phi_m = pow(1.0 - model_param.alpha_m * zeta, -0.25);
phi_h = 1.0 / (model_param.Pr_t_0_inv * sqrt(1.0 - model_param.alpha_h_fix * zeta));
phi_m = pow(1.0 - model.alpha_m * zeta, -0.25);
phi_h = 1.0 / (model.Pr_t_0_inv * sqrt(1.0 - model.alpha_h_fix * zeta));
}
Cm = model_param.kappa / psi_m;
Ct = model_param.kappa / psi_h;
Cm = model.kappa / psi_m;
Ct = model.kappa / psi_h;
Km = model_param.kappa * Cm * U * h / phi_m;
Km = model.kappa * Cm * U * h / phi_m;
Pr_t_inv = phi_m / phi_h;
sfx.zeta[index] = zeta;
......@@ -125,8 +125,8 @@ void FluxEsm<T, memIn, memOut, MemType::GPU>::compute_flux()
dim3 cuBlock = dim3(1024, 1, 1);
dim3 cuGrid = dim3(BlockCount, 1, 1);
sfx_kernel::compute_flux<T><<<cuGrid, cuBlock>>>(sfx, meteo, model_param,
surface_param, numerics, phys_constants, grid_size);
sfx_kernel::compute_flux<T><<<cuGrid, cuBlock>>>(sfx, meteo, model,
surface, numerics, phys, grid_size);
if(MemType::GPU != memOut)
{
......
......@@ -11,20 +11,20 @@ namespace sfx_kernel
template<typename T>
__global__ void compute_flux(sfxDataVecTypeC sfx,
meteoDataVecTypeC meteo,
const sfx_sheba_param model_param,
const sfx_surface_param surface_param,
const sfx_sheba_numericsTypeC numerics,
const sfx_phys_constants phys_constants,
const sfx_sheba_param_C model,
const sfx_surface_param surface,
const sfx_sheba_numericsType_C numerics,
const sfx_phys_constants phys,
const int grid_size);
}
template<typename T>
__global__ void sfx_kernel::compute_flux(sfxDataVecTypeC sfx,
meteoDataVecTypeC meteo,
const sfx_sheba_param model_param,
const sfx_surface_param surface_param,
const sfx_sheba_numericsTypeC numerics,
const sfx_phys_constants phys_constants,
const sfx_sheba_param_C model,
const sfx_surface_param surface,
const sfx_sheba_numericsType_C numerics,
const sfx_phys_constants phys,
const int grid_size)
{
const int index = blockIdx.x * blockDim.x + threadIdx.x;
......@@ -43,35 +43,35 @@ __global__ void sfx_kernel::compute_flux(sfxDataVecTypeC sfx,
h = meteo.h[index];
z0_m = meteo.z0_m[index];
surface_type = z0_m < 0.0 ? surface_param.surface_ocean : surface_param.surface_land;
surface_type = z0_m < 0.0 ? surface.surface_ocean : surface.surface_land;
if (surface_type == surface_param.surface_ocean)
if (surface_type == surface.surface_ocean)
{
get_charnock_roughness(z0_m, u_dyn0, U, h, surface_param, numerics.maxiters_charnock);
get_charnock_roughness(z0_m, u_dyn0, U, h, surface, numerics.maxiters_charnock);
h0_m = h / z0_m;
}
if (surface_type == surface_param.surface_land)
if (surface_type == surface.surface_land)
{
h0_m = h / z0_m;
u_dyn0 = U * model_param.kappa / log(h0_m);
u_dyn0 = U * model.kappa / log(h0_m);
}
Re = u_dyn0 * z0_m / phys_constants.nu_air;
get_thermal_roughness(z0_t, B, z0_m, Re, surface_param, surface_type);
Re = u_dyn0 * z0_m / phys.nu_air;
get_thermal_roughness(z0_t, B, z0_m, Re, surface, surface_type);
// --- define relative height [thermal]
h0_t = h / z0_t;
// --- define Ri-bulk
Rib = (phys_constants.g / Tsemi) * h * (dT + 0.61e0 * Tsemi * dQ) / (U*U);
Rib = (phys.g / Tsemi) * h * (dT + 0.61e0 * Tsemi * dQ) / (U*U);
// --- get the fluxes
// ----------------------------------------------------------------------------
get_dynamic_scales(Udyn, Tdyn, Qdyn, zeta,
U, Tsemi, dT, dQ, h, z0_m, z0_t, (phys_constants.g / Tsemi), model_param, 10);
U, Tsemi, dT, dQ, h, z0_m, z0_t, (phys.g / Tsemi), model, 10);
// ----------------------------------------------------------------------------
get_phi(phi_m, phi_h, zeta, model_param);
get_phi(phi_m, phi_h, zeta, model);
// ----------------------------------------------------------------------------
// --- define transfer coeff. (momentum) & (heat)
......@@ -83,7 +83,7 @@ __global__ void sfx_kernel::compute_flux(sfxDataVecTypeC sfx,
Ct = Tdyn / dT;
// --- define eddy viscosity & inverse Prandtl number
Km = model_param.kappa * Cm * U * h / phi_m;
Km = model.kappa * Cm * U * h / phi_m;
Pr_t_inv = phi_m / phi_h;
sfx.zeta[index] = zeta;
......@@ -107,8 +107,8 @@ void FluxSheba<T, memIn, memOut, MemType::GPU>::compute_flux()
dim3 cuBlock = dim3(1024, 1, 1);
dim3 cuGrid = dim3(BlockCount, 1, 1);
sfx_kernel::compute_flux<T><<<cuGrid, cuBlock>>>(sfx, meteo, model_param,
surface_param, numerics, phys_constants, grid_size);
sfx_kernel::compute_flux<T><<<cuGrid, cuBlock>>>(sfx, meteo, model,
surface, numerics, phys, grid_size);
if(MemType::GPU != memOut)
{
......
......@@ -8,9 +8,9 @@
// -------------------------------------------------------------------------- //
void surf_flux_esm_CXX (sfxDataVecTypeC* sfx,
meteoDataVecTypeC* meteo,
const sfx_esm_param* model_param,
const sfx_esm_param_C* model_param,
const sfx_surface_param* surface_param,
const sfx_esm_numericsTypeC* numerics,
const sfx_esm_numericsType_C* numerics,
const sfx_phys_constants* constants,
const int grid_size)
{
......@@ -25,9 +25,9 @@ void surf_flux_esm_CXX (sfxDataVecTypeC* sfx,
void surf_flux_sheba_CXX (sfxDataVecTypeC* sfx,
meteoDataVecTypeC* meteo,
const sfx_sheba_param* model_param,
const sfx_sheba_param_C* model_param,
const sfx_surface_param* surface_param,
const sfx_sheba_numericsTypeC* numerics,
const sfx_sheba_numericsType_C* numerics,
const sfx_phys_constants* constants,
const int grid_size)
{
......
......@@ -13,15 +13,15 @@
template<typename T, MemType memIn, MemType memOut, MemType RunMem >
FluxEsmBase<T, memIn, memOut, RunMem>::FluxEsmBase(sfxDataVecTypeC* sfx_in,
meteoDataVecTypeC* meteo_in,
const sfx_esm_param model_param_in,
const sfx_esm_param_C model_param_in,
const sfx_surface_param surface_param_in,
const sfx_esm_numericsTypeC numerics_in,
const sfx_esm_numericsType_C numerics_in,
const sfx_phys_constants phys_constants_in,
const int grid_size_in) : ModelBase<T, memIn, memOut, RunMem>(sfx_in, meteo_in, grid_size_in)
{
surface_param = surface_param_in;
phys_constants = phys_constants_in;
model_param = model_param_in;
surface = surface_param_in;
phys = phys_constants_in;
model = model_param_in;
numerics = numerics_in;
}
......@@ -45,66 +45,66 @@ void FluxEsm<T, memIn, memOut, MemType::CPU>::compute_flux()
h = meteo.h[step];
z0_m = meteo.z0_m[step];
surface_type = z0_m < 0.0 ? surface_param.surface_ocean : surface_param.surface_land;
surface_type = z0_m < 0.0 ? surface.surface_ocean : surface.surface_land;
if (surface_type == surface_param.surface_ocean)
if (surface_type == surface.surface_ocean)
{
get_charnock_roughness(z0_m, u_dyn0, U, h, surface_param, numerics.maxiters_charnock);
get_charnock_roughness(z0_m, u_dyn0, U, h, surface, numerics.maxiters_charnock);
h0_m = h / z0_m;
}
if (surface_type == surface_param.surface_land)
if (surface_type == surface.surface_land)
{
h0_m = h / z0_m;
u_dyn0 = U * model_param.kappa / log(h0_m);
u_dyn0 = U * model.kappa / log(h0_m);
}
Re = u_dyn0 * z0_m / phys_constants.nu_air;
get_thermal_roughness(z0_t, B, z0_m, Re, surface_param, surface_type);
Re = u_dyn0 * z0_m / phys.nu_air;
get_thermal_roughness(z0_t, B, z0_m, Re, surface, surface_type);
h0_t = h / z0_t;
Rib = (phys_constants.g / Tsemi) * h * (dT + 0.61e0 * Tsemi * dQ) / (U*U);
Rib = (phys.g / Tsemi) * h * (dT + 0.61e0 * Tsemi * dQ) / (U*U);
get_convection_lim(zeta_conv_lim, Rib_conv_lim, f_m_conv_lim, f_h_conv_lim,
h0_m, h0_t, B,
model_param);
model);
if (Rib > 0.0)
{
Rib = std::min(Rib, model_param.Rib_max);
get_psi_stable(psi_m, psi_h, zeta, Rib, h0_m, h0_t, B, model_param);
Rib = std::min(Rib, model.Rib_max);
get_psi_stable(psi_m, psi_h, zeta, Rib, h0_m, h0_t, B, model);
fval = model_param.beta_m * zeta;
fval = model.beta_m * zeta;
phi_m = 1.0 + fval;
phi_h = 1.0/model_param.Pr_t_0_inv + fval;
phi_h = 1.0/model.Pr_t_0_inv + fval;
}
else if (Rib < Rib_conv_lim)
{
get_psi_convection(psi_m, psi_h, zeta, Rib, h0_m, h0_t, B, zeta_conv_lim, f_m_conv_lim, f_h_conv_lim, model_param, numerics.maxiters_convection);
get_psi_convection(psi_m, psi_h, zeta, Rib, h0_m, h0_t, B, zeta_conv_lim, f_m_conv_lim, f_h_conv_lim, model, numerics.maxiters_convection);
fval = pow(zeta_conv_lim / zeta, 1.0/3.0);
phi_m = fval / f_m_conv_lim;
phi_h = fval / (model_param.Pr_t_0_inv * f_h_conv_lim);
phi_h = fval / (model.Pr_t_0_inv * f_h_conv_lim);
}
else if (Rib > -0.001)
{
get_psi_neutral(psi_m, psi_h, zeta, h0_m, h0_t, B, model_param);
get_psi_neutral(psi_m, psi_h, zeta, h0_m, h0_t, B, model);
phi_m = 1.0;
phi_h = 1.0 / model_param.Pr_t_0_inv;
phi_h = 1.0 / model.Pr_t_0_inv;
}
else
{
get_psi_semi_convection(psi_m, psi_h, zeta, Rib, h0_m, h0_t, B, model_param, numerics.maxiters_convection);
get_psi_semi_convection(psi_m, psi_h, zeta, Rib, h0_m, h0_t, B, model, numerics.maxiters_convection);
phi_m = pow(1.0 - model_param.alpha_m * zeta, -0.25);
phi_h = 1.0 / (model_param.Pr_t_0_inv * sqrt(1.0 - model_param.alpha_h_fix * zeta));
phi_m = pow(1.0 - model.alpha_m * zeta, -0.25);
phi_h = 1.0 / (model.Pr_t_0_inv * sqrt(1.0 - model.alpha_h_fix * zeta));
}
Cm = model_param.kappa / psi_m;
Ct = model_param.kappa / psi_h;
Cm = model.kappa / psi_m;
Ct = model.kappa / psi_h;
Km = model_param.kappa * Cm * U * h / phi_m;
Km = model.kappa * Cm * U * h / phi_m;
Pr_t_inv = phi_m / phi_h;
sfx.zeta[step] = zeta;
......
......@@ -13,15 +13,15 @@
template<typename T, MemType memIn, MemType memOut, MemType RunMem >
FluxShebaBase<T, memIn, memOut, RunMem>::FluxShebaBase(sfxDataVecTypeC* sfx_in,
meteoDataVecTypeC* meteo_in,
const sfx_sheba_param model_param_in,
const sfx_sheba_param_C model_param_in,
const sfx_surface_param surface_param_in,
const sfx_sheba_numericsTypeC numerics_in,
const sfx_sheba_numericsType_C numerics_in,
const sfx_phys_constants phys_constants_in,
const int grid_size_in) : ModelBase<T, memIn, memOut, RunMem>(sfx_in, meteo_in, grid_size_in)
{
surface_param = surface_param_in;
phys_constants = phys_constants_in;
model_param = model_param_in;
surface = surface_param_in;
phys = phys_constants_in;
model = model_param_in;
numerics = numerics_in;
}
......@@ -46,35 +46,35 @@ void FluxSheba<T, memIn, memOut, MemType::CPU>::compute_flux()
h = meteo.h[step];
z0_m = meteo.z0_m[step];
surface_type = z0_m < 0.0 ? surface_param.surface_ocean : surface_param.surface_land;
surface_type = z0_m < 0.0 ? surface.surface_ocean : surface.surface_land;
if (surface_type == surface_param.surface_ocean)
if (surface_type == surface.surface_ocean)
{
get_charnock_roughness(z0_m, u_dyn0, U, h, surface_param, numerics.maxiters_charnock);
get_charnock_roughness(z0_m, u_dyn0, U, h, surface, numerics.maxiters_charnock);
h0_m = h / z0_m;
}
if (surface_type == surface_param.surface_land)
if (surface_type == surface.surface_land)
{
h0_m = h / z0_m;
u_dyn0 = U * model_param.kappa / log(h0_m);
u_dyn0 = U * model.kappa / log(h0_m);
}
Re = u_dyn0 * z0_m / phys_constants.nu_air;
get_thermal_roughness(z0_t, B, z0_m, Re, surface_param, surface_type);
Re = u_dyn0 * z0_m / phys.nu_air;
get_thermal_roughness(z0_t, B, z0_m, Re, surface, surface_type);
// --- define relative height [thermal]
h0_t = h / z0_t;
// --- define Ri-bulk
Rib = (phys_constants.g / Tsemi) * h * (dT + 0.61e0 * Tsemi * dQ) / (U*U);
Rib = (phys.g / Tsemi) * h * (dT + 0.61e0 * Tsemi * dQ) / (U*U);
// --- get the fluxes
// ----------------------------------------------------------------------------
get_dynamic_scales(Udyn, Tdyn, Qdyn, zeta,
U, Tsemi, dT, dQ, h, z0_m, z0_t, (phys_constants.g / Tsemi), model_param, 10);
U, Tsemi, dT, dQ, h, z0_m, z0_t, (phys.g / Tsemi), model, 10);
// ----------------------------------------------------------------------------
get_phi(phi_m, phi_h, zeta, model_param);
get_phi(phi_m, phi_h, zeta, model);
// ----------------------------------------------------------------------------
// --- define transfer coeff. (momentum) & (heat)
......@@ -86,7 +86,7 @@ void FluxSheba<T, memIn, memOut, MemType::CPU>::compute_flux()
Ct = Tdyn / dT;
// --- define eddy viscosity & inverse Prandtl number
Km = model_param.kappa * Cm * U * h / phi_m;
Km = model.kappa * Cm * U * h / phi_m;
Pr_t_inv = phi_m / phi_h;
sfx.zeta[step] = zeta;
......
......@@ -137,43 +137,6 @@ module sfx_data
real(C_FLOAT) :: g;
real(C_FLOAT) :: nu_air;
end type
! ESM strcuctures
type, BIND(C), public :: sfx_esm_param
real(C_FLOAT) :: kappa
real(C_FLOAT) :: Pr_t_0_inv
real(C_FLOAT) :: Pr_t_inf_inv
real(C_FLOAT) :: alpha_m
real(C_FLOAT) :: alpha_h
real(C_FLOAT) :: alpha_h_fix
real(C_FLOAT) :: beta_m
real(C_FLOAT) :: beta_h
real(C_FLOAT) :: Rib_max
end type
type, BIND(C), public :: sfx_esm_numericsTypeC
integer(C_INT) :: maxiters_convection
integer(C_INT) :: maxiters_charnock
end type
! SHEBA strcuctures
type, BIND(C), public :: sfx_sheba_param
real(C_FLOAT) :: kappa
real(C_FLOAT) :: Pr_t_0_inv
real(C_FLOAT) :: alpha_m
real(C_FLOAT) :: alpha_h
real(C_FLOAT) :: a_m
real(C_FLOAT) :: b_m
real(C_FLOAT) :: a_h
real(C_FLOAT) :: b_h
real(C_FLOAT) :: c_h
end type
type, BIND(C), public :: sfx_sheba_numericsTypeC
integer(C_INT) :: maxiters_charnock
end type
#endif
! --------------------------------------------------------------------------------
......
......@@ -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, C_PTR
use iso_c_binding, only: C_LOC, C_PTR, C_INT, C_FLOAT
use C_FUNC
#endif
! --------------------------------------------------------------------------------
......@@ -36,12 +36,48 @@ module sfx_esm
end type
! --------------------------------------------------------------------------------
#if defined(INCLUDE_CXX)
type, BIND(C), public :: sfx_esm_param_C
real(C_FLOAT) :: kappa
real(C_FLOAT) :: Pr_t_0_inv
real(C_FLOAT) :: Pr_t_inf_inv
real(C_FLOAT) :: alpha_m
real(C_FLOAT) :: alpha_h
real(C_FLOAT) :: alpha_h_fix
real(C_FLOAT) :: beta_m
real(C_FLOAT) :: beta_h
real(C_FLOAT) :: Rib_max
end type
type, BIND(C), public :: sfx_esm_numericsType_C
integer(C_INT) :: maxiters_convection
integer(C_INT) :: maxiters_charnock
end type
INTERFACE
SUBROUTINE get_surface_fluxes_esm(sfx, meteo, model_param, surface_param, numerics, constants, grid_size) BIND(C)
use sfx_data
use, intrinsic :: ISO_C_BINDING, ONLY: C_INT, C_PTR
Import :: sfx_esm_param_C, sfx_esm_numericsType_C
implicit none
integer(C_INT) :: grid_size
type(C_PTR), value :: sfx
type(C_PTR), value :: meteo
type(sfx_esm_param_C) :: model_param
type(sfx_surface_param) :: surface_param
type(sfx_esm_numericsType_C) :: numerics
type(sfx_phys_constants) :: constants
END SUBROUTINE get_surface_fluxes_esm
END INTERFACE
#endif
contains
! --------------------------------------------------------------------------------
#if defined(INCLUDE_CXX)
subroutine set_c_struct_sfx_esm_param_values(sfx_model_param)
type (sfx_esm_param), intent(inout) :: sfx_model_param
type (sfx_esm_param_C), intent(inout) :: sfx_model_param
sfx_model_param%kappa = kappa
sfx_model_param%Pr_t_0_inv = Pr_t_0_inv
sfx_model_param%Pr_t_inf_inv = Pr_t_inf_inv
......@@ -75,9 +111,9 @@ contains
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_esm_param_C) :: model_param
type (sfx_surface_param) :: surface_param
type (sfx_esm_numericsTypeC) :: numerics_c
type (sfx_esm_numericsType_C) :: numerics_c
type (sfx_phys_constants) :: phys_constants
numerics_c%maxiters_convection = numerics%maxiters_convection
......
module C_FUNC
#if defined(INCLUDE_CXX)
INTERFACE
SUBROUTINE get_surface_fluxes_esm(sfx, meteo, model_param, surface_param, numerics, constants, grid_size) BIND(C)
use sfx_data
USE, INTRINSIC :: ISO_C_BINDING, ONLY: C_INT, C_PTR
IMPLICIT NONE
INTEGER(C_INT) :: grid_size
type(C_PTR), value :: sfx
type(C_PTR), value :: meteo
type(sfx_esm_param) :: model_param
type(sfx_surface_param) :: surface_param
type(sfx_esm_numericsTypeC) :: numerics
type(sfx_phys_constants) :: constants
END SUBROUTINE get_surface_fluxes_esm
SUBROUTINE get_surface_fluxes_sheba(sfx, meteo, model_param, surface_param, numerics, constants, grid_size) BIND(C)
use sfx_data
USE, INTRINSIC :: ISO_C_BINDING, ONLY: C_INT, C_PTR
IMPLICIT NONE
INTEGER(C_INT) :: grid_size
type(C_PTR), value :: sfx
type(C_PTR), value :: meteo
type(sfx_sheba_param) :: model_param
type(sfx_surface_param) :: surface_param
type(sfx_sheba_numericsTypeC) :: numerics
type(sfx_phys_constants) :: constants
END SUBROUTINE get_surface_fluxes_sheba
END INTERFACE
contains
subroutine set_c_struct_sfx_phys_constants_values(constants)
......@@ -41,6 +12,7 @@ module C_FUNC
constants%g = g
constants%nu_air = nu_air
end subroutine set_c_struct_sfx_phys_constants_values
#endif
end module C_FUNC
......@@ -13,7 +13,7 @@ module sfx_sheba
use sfx_sheba_param
#if defined(INCLUDE_CXX)
use iso_c_binding, only: C_LOC, C_PTR
use iso_c_binding, only: C_LOC, C_PTR, C_INT, C_FLOAT
use C_FUNC
#endif
! --------------------------------------------------------------------------------
......@@ -36,11 +36,46 @@ module sfx_sheba
end type
! --------------------------------------------------------------------------------
#if defined(INCLUDE_CXX)
type, BIND(C), public :: sfx_sheba_param_C
real(C_FLOAT) :: kappa
real(C_FLOAT) :: Pr_t_0_inv
real(C_FLOAT) :: alpha_m
real(C_FLOAT) :: alpha_h
real(C_FLOAT) :: a_m
real(C_FLOAT) :: b_m
real(C_FLOAT) :: a_h
real(C_FLOAT) :: b_h
real(C_FLOAT) :: c_h
end type
type, BIND(C), public :: sfx_sheba_numericsType_C
integer(C_INT) :: maxiters_charnock
end type
INTERFACE
SUBROUTINE get_surface_fluxes_sheba(sfx, meteo, model_param, surface_param, numerics, constants, grid_size) BIND(C)
use sfx_data
use, intrinsic :: ISO_C_BINDING, ONLY: C_INT, C_PTR
Import :: sfx_sheba_param_C, sfx_sheba_numericsType_C
implicit none
INTEGER(C_INT) :: grid_size
type(C_PTR), value :: sfx
type(C_PTR), value :: meteo
type(sfx_sheba_param_C) :: model_param
type(sfx_surface_param) :: surface_param
type(sfx_sheba_numericsType_C) :: numerics
type(sfx_phys_constants) :: constants
END SUBROUTINE get_surface_fluxes_sheba
END INTERFACE
#endif
contains
#if defined(INCLUDE_CXX)
subroutine set_c_struct_sfx_sheba_param_values(sfx_model_param)
type (sfx_sheba_param), intent(inout) :: sfx_model_param
type (sfx_sheba_param_C), intent(inout) :: sfx_model_param
sfx_model_param%kappa = kappa
sfx_model_param%Pr_t_0_inv = Pr_t_0_inv
......@@ -75,9 +110,9 @@ contains
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_sheba_param_C) :: model_param
type (sfx_surface_param) :: surface_param
type (sfx_sheba_numericsTypeC) :: numerics_c
type (sfx_sheba_numericsType_C) :: numerics_c
type (sfx_phys_constants) :: phys_constants
numerics_c%maxiters_charnock = numerics%maxiters_charnock
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment