Variables and properties can be accessed both in Fortran and in C using the cs_field API.
First, let us specify a few conventions used in code_saturne:
 , α, νt).
, α, νt). The designation “scalar” refers to (usually scalar) variables which are solution of an advection equation, apart from the dynamic variables listed above; for instance the temperature, scalars which may be passive or not, user-defined or model-defined.
The mean value of the square of the fluctuations of a “scalar” is a “scalar”, too.
Scalars may be divided into two groups: user-defined scalars and model-defined (sometimes referred to as “specific physics”) scalars.
 for a fluctuating scalar ϕ). This can be made either via the interface or by declaring that scalar using
 for a fluctuating scalar ϕ). This can be made either via the interface or by declaring that scalar using cs_parameters_add_variable_variance in cs_user_parameters.c.cs_real_t *cvar_pr = cs_field_by_name("pressure")->val;  cvar_pr[cell_id]  pressure = CS_F_(p)->val[cell_id], cp = CS_F_(cp)->val[cell_id] temp = CS_F_(t)->val[cell_id] uz = CS_F_(vel)->val[3*cell_id + 2]cs_real_3_t *cvar_vel = (cs_real_3_t *)CS_F_(vel)->val ux = cvar_vel[cell_id][0]vel, p, or cp  are defined in cs_field_pointer.h. CS_FI_(name,ii-1)->val[cell_id]. field_t *tf = cs_thermal_model_field();tf->val[cell_id]. cs_real_t *cvar_pr = cs_field_by_name("pressure")->val  if (f->type & CS_FIELD_USER) ... cell_id = iel-1.call field_get_val_s_by_name("pressure", cvar_pr) 
 pres = cvar_pr(iel) call field_get_val_s(ivarfl(ipr), cvar_pr) 
 pres = cvar_pr(iel) call field_get_val_s(icp, cpro_cp) 
 cp = cpro_cp(iel) call field_get_val_s(ivarfl(isca(iscalt)), cvar_scalt) 
 temp = cvar_scalt(iel) call field_get_val_v(ivarfl(iu), cvar_vel) 
 ux = cvar_vel(1,iel) j, where 1 <= j <= nscal, is given by the iscal array. So to access the associated field, use:ivarfl(iscal(j))). j, where 1 <= j <= nscapp, is given by the iscapp array. So to access the associated field, use:ivarfl(iscal(iscapp(j)))). iscalt index in the list of the scalars. It's variable number is thus  isca(iscalt) .iscalt is equal to -1. Cross-reference tables are available for the variables and properties of the standard solver and the specific physics features:
The Fortran variables indexes are defined in the files numvar.f90 (with the exception of ihm and iscal, which are respectively defined in ppincl.f90 and optcal.f90) and the C variables names are defined in cs_field_pointer.h. 
 Note that dt is accessible by its name (using the cs_field_by_name family of functions), but not through a permanent index..
| C code | Fortran code | Description | 
|---|---|---|
|  CS_F_(p)->val    |  call field_get_val_s(ivarfl(ipr), cvar_pr)    |  Pressure     | 
|  CS_F_(vel)->val    |  call field_get_val_v(ivarfl(iu), cvar_vel)    |  Velocity     | 
|  CS_F_(void_f)->val    |  call field_get_val_s(ivarfl(ivolf2), cvar_voidf)    |  Void fraction for Volume of Fluid model     | 
|  CS_F_(k)->val    |  call field_get_val_s(ivarfl(ik ), cvar_k )    |  Turbulent kinetic energy  | 
|  CS_F_(eps)->val    |  call field_get_val_s(ivarfl(iep ), cvar_eps)    |  Turbulent dissipation  | 
|  CS_F_(rij)->val    |  call field_get_val_v(ivarfl(irij), cvar_rij)    |  Reynolds stress tensor  | 
|  CS_F_(phi)->val    |  call field_get_val_s(ivarfl(iphi), cvar_phi)    |   | 
|  CS_F_(f_bar)->val    |  call field_get_val_s(ivarfl(ifb ), cvar_fb )    |   | 
|  CS_F_(alp_bl)->val    |  call field_get_val_s(ivarfl(ial ), cvar_al )    |   | 
|  CS_F_(omg)->val    |  call field_get_val_s(ivarfl(iomg), cvar_omg)    |   | 
|  CS_F_(nusa)->val    |  call field_get_val_s(ivarfl(inusa), cvar_nusa)    |   | 
|  CS_F_(mesh_u)->val    |  call field_get_val_v(ivarfl(iuma), cvar_mesh_v)    |  Mesh velocity     | 
|  CS_F_(h)->val    |  call field_get_val_s(ivarfl(isca(ihm)), cvar_hm)    |  Enthalpy     | 
|  CS_F_(t)->val    |  call field_get_val_s(ivarfl(isca(iscalt)), cvar_scalt)    |  Temperature  | 
These properties are defined in the files numvar.f90 and cs_field_pointer.h.
| C code | Fortran code | Description | 
|---|---|---|
|  CS_F_(dt)->val    |  dt    |  Local time step     | 
|  CS_F_(mu)->val    |  call field_get_val_s(iviscl, cpro_viscl)    |  Molecular viscosity     | 
|  CS_F_(mu_t)->val    |  call field_get_val_s(ivisct, cpro_visct)    |  Turbulent dynamic viscosity     | 
|  CS_F_(cp)->val    |  call field_get_val_s(icp, cpro_cp)    |  Specific heat     | 
|  CS_F_(rho)->val    |  call field_get_val_s(icrom, cpro_crom)    |  Density (at cells)     | 
|  CS_F_(rho_b)->val[face_id]    |  call field_get_val_s(ibrom, bpro_rho)    |  Density (at boundary faces)     | 
|  cs_real_t *cpro_smago = cs_field_by_name("smagorinsky_constant^2")->val    |  call field_get_val_s(ismago, cpro_smago)    |  Field id of the anisotropic turbulent viscosity     | 
|  cs_real_t *cpro_cour = cs_field_by_name("courant_number")->val    |  call field_get_val_s(icour, cpro_cour)    |  Courant number     | 
|  cs_real_t *cpro_four = cs_field_by_name("fourier_number")->val    |  call field_get_val_s(ifour, cpro_four)    |  Fourier number     | 
|  cs_real_t *cpro_prtot = cs_field_by_name("total_pressure")->val    |  call field_get_val_s(iprtot, cpro_prtot)    |  Total pressure at cell centers     | 
|  cs_real_t *cpro_visma_s = cs_field_by_name("mesh_viscosity")->val    |  call field_get_val_s(ivisma, cpro_visma_s)    |  Mesh velocity viscosity (scalar) for the ALE module     | 
|  cs_real_t *cpro_visma_v = cs_field_by_name("mesh_viscosity")->val    |  call field_get_val_v(ivisma, cpro_visma_s)    |  Mesh velocity viscosity (vector) for the ALE module     | 
|  cs_real_t *cpro_tsrho = cs_field_by_name("dila_st")->val    |  call field_get_val_s(itsrho), cpro_tsrho )    |  Global dilatation source terms     | 
|  cs_real_t *cpro_beta = cs_field_by_name("thermal_expansion")->val    |  call field_get_val_s(ibeta), cpro_beta )    |  Thermal expansion coefficient    | 
CS_F_(poro)->val | Porosity call field_get_val_s(ipori, cpro_ipori) | CS_F_(t_poro)->val | Tensorial porosity call field_get_val_v(iporf, cpro_iporf) | cs_real_t *bpro_forbr = cs_field_by_name("boundary_forces")->val |call field_get_val_v(iforbr, bpro_forbr) | Field id of the stresses at boundary cs_real_t *bpro_yplus = cs_field_by_name("yplus")->val |call field_get_val_s(iyplbr, bpro_yplus) | Field id of  at boundary
 at boundary cs_real_t *dttens = cs_field_by_name("dttens")->val |call field_get_val_v(idtten, dttens) | Field id for the dttens tensor CS_F_(t_b)->val |call field_get_val_s(itempb, t_b) | Boundary temperature 
Some physical properties such as specific heat or dynamic diffusivity are often constant (depending on the model or user parameters). In that case, these properties are stored as a simple real numbers rather than in a field over all mesh cells.
cp0 in Fortran).icp in Fortran) should remain set to 0.icp is initialized to 1 (by the GUI, or in cs_user_parameters.c, it is automatically reset to the id of the cell-based property field referenced in the above table.When K is constant, its value is based on the field's reference dynamic diffusivity, accessible through the scalar field's diffusivity_ref keyword.
When it is variable, the matching field can be specified and accessed using the base scalar field's diffusivity_id key (accessible using cs_field_key_id("diffusivity_id") in C, or kivisl in Fortran).
 For example, for a scalar field f:
  int k_f_id = cs_field_get_key_int(f, cs_field_key_id("diffusivity_id")); 
 cs_field_t *kf = cs_field_by_id(k_f_id); 
 Reference physical values represent either the fluid properties if they are constant, either simple mean values for the initialization if properties are variable and defined in cs_user_physical_properties. Reference values can be set in the GUI or in files cs_user_parameters.f90 and cs_user_parameters.c.
| C code | Fortran code | Description | 
|---|---|---|
|  cs_glob_fluid_properties->p0    |  p0    |  Reference total pressure     | 
|  cs_glob_fluid_properties->ro0    |  ro0    |  Reference density     | 
|  cs_glob_fluid_properties->viscl0    |  viscl0    |  Reference molecular dynamic viscosity     | 
|  cs_glob_fluid_properties->cp0    |  cp0    |  Reference specific heat  | 
 
 Defined in optcal.f90, atincl.f90, atvarp.f90 and cs_field_pointer.h. Note, esp_id = iesp -1.
| C code | Fortran code | Description | 
|---|---|---|
|  CS_F_(pot_t)->val  | call field_get_val_s(ivarfl(isca(iscalt)), cvar_scalt) | Potential temperature | 
|  CS_F_(ym_w)->val  | - | Total water content | 
|  CS_F_(ntdrp)->val  | call field_get_val_s(ivarfl(isca(intdrp)), cvar_intdrp) | Total number of droplets | 
|  CS_FI_(chemistry,esp_id)->val  | call field_get_val_s(ivarfl(isca(isca_chem(iesp))), cvar_sc) | Chemistry species (indexed) | 
 Defined in ppincl.f90, ppcpfu.f90 and cs_field_pointer.h. Note, esp_id = iesp -1.
| C code | Fortran code | Description | 
|---|---|---|
|  CS_FI_(np,esp_id)->val  |  call field_get_val_s(isca(inp(iesp)), cvar_inpcl)  | Particles per kg for coal class | 
|  CS_FI_(xch,esp_id)->val  |  call field_get_val_s(isca(ixch(iesp)), cvar_xchcl)  | Reactive coal mass fraction for coal class | 
|  CS_FI_(xck,esp_id)->val  |  call field_get_val_s(isca(ixck(iesp)), cvar_xckcl)  | Coke mass fraction for coal class | 
|  CS_FI_(xwt,esp_id)->val  |  call field_get_val_s(isca(ixwt(iesp)), cvar_xwtcl)  | Water mass fraction for coal class | 
|  CS_FI_(h2,esp_id)->val  |  call field_get_val_s(isca(ih2(iesp)), cvar_h2cl)  | Mass enthalpy for coal class (permeatic case) | 
|  CS_FI_(f1m,esp_id)->val  |  call field_get_val_s(isca(if1m(iesp)), cvar_f1mcl)  | Mean value light volatiles for coal class | 
|  CS_FI_(f2m,esp_id)->val  |  call field_get_val_s(isca(if2m(iesp)), cvar_f2mcl)  | Mean value heavy volatiles for coal class | 
|  CS_F_(f4m)->val  |  call field_get_val_s(isca(if4m), cvar_f4m)  | Oxydant 2 mass fraction | 
|  CS_F_(f5m)->val  |  call field_get_val_s(isca(if5m), cvar_f5m))  | Oxydant 3 mass fraction | 
|  CS_F_(f6m)->val  |  call field_get_val_s(isca(if6m), cvar_f6m))  | Water from coal drying mass fraction | 
|  CS_F_(f7m)->val  |  call field_get_val_s(isca(if7m), cvar_f7m))  | Carbon from coal oxidyzed by O2 mass fraction | 
|  CS_F_(f8m)->val  |  call field_get_val_s(isca(if8m), cvar_f8m))  | Carbon from coal gasified by CO2 mass fraction | 
|  CS_F_(f9m)->val  |  call field_get_val_s(isca(if9m), cvar_f9m))  | Carbon from coal gasified by H2O mass fraction | 
|  CS_F_(fvp2m)->val  |  call field_get_val_s(isca(ifvp2m), cvar_fvp2m)  | f1f2 variance | 
|  CS_F_(yco2)->val  |  call field_get_val_s(isca(iyco2), cvar_yco2)  | CO2 fraction | 
|  CS_F_(yhcn)->val  |  call field_get_val_s(isca(iyhcn), cvar_yhnc)  | HCN fraction | 
|  CS_F_(yno)->val  |  call field_get_val_s(isca(iyno), cvar, yno)  | NO fraction | 
|  CS_F_(ynh3)->val  |  call field_get_val_s(isca(iynh3), cvar_ynh3)  | NH3 enthalpy | 
|  CS_F_(hox)->val  |  call field_get_val_s(isca(ihox), cvar_hox)  | Ox enthalpy | 
 Defined in ppincl.f90 and cs_field_pointer.h.
| C code | Fortran code | Description | 
|---|---|---|
|  CS_F_(e_tot)->val    |  call field_get_val_s(isca(ienerg), cvar_energ)    |  Total energy     | 
|  CS_F_(t_kelvin)->val    |  call field_get_val_s(isca(itempk), cvar_tempk)    |  Temperature, in Kelvin  | 
 Defined in ppincl.f90 and cs_field_pointer.h. Note, esp_id = iesp -1.
| C code | Fortran code | Description | 
|---|---|---|
| CS_F_(potr)->val    |  call field_get_val_s_by_name("elec_pot_r", cvar_potr)    |  Electric potential, real part     | 
|  CS_F_(poti)->val    |  call field_get_val_s_by_name("elec_pot_i", cvar_poti)    |  Electric potential, imaginary part     | 
|  CS_F_(potva)->val    |  call field_get_val_v_by_name("vec_potential", cvar_potva)    |  Vector potential     | 
|  CS_FI_(ycoel,esp_id)->val    |  call field_get_val_s_by_name("esl_fraction_01", cvar_ycoel_01)    |  Constituent mass fraction  | 
 Defined in ppincl.f90 and cs_field_pointer.h.
| C code | Fortran code | Description | 
|---|---|---|
|  CS_F_(fm)->val    |  call field_get_val_s(isca(ifm), cvar_fm)    |  Mixture fraction     | 
|  CS_F_(fp2m)->val    |  call field_get_val_s(isca(ifp2m), cvar_fp2m)    |  Mixture fraction variance     | 
|  CS_F_(fsm)->val    |  call field_get_val_s(isca(ifsm), cvar_fsm)    |  Soot mass fraction     | 
|  CS_F_(npm)->val    |  call field_get_val_s(isca(inpm), cvar_npm)    |  Soot precursor number     | 
|  CS_F_(ygfm)->val    |  call field_get_val_s(isca(iygfm), cvar_ygfm)    |  Fresh gas fraction     | 
|  CS_F_(yfm)->val    |  call field_get_val_s(isca(iyfm), cvar_yfm)    |  Mass fraction     | 
|  CS_F_(yfp2m)->val    |  call field_get_val_s(isca(iyfp2m), cvar_yfp2m)    |  Mass fraction variance     | 
|  CS_F_(coyfp)->val    |  call field_get_val_s(isca(icoyfp), cvar_coyfp)    |  Mass fraction covariance  | 
 Defined in cs_field_pointer.h. Note, esp_id = iesp -1.
| C code | Description | 
|---|---|
|  CS_F_(rad_energy)->val  | Radiative luminance | 
|  CS_F_(rad_q)->val  | Radiative flux | 
|  CS_FI_(rad_ets,esp_id)->val  | Radiative flux explicit source term | 
|  CS_FI_(rad_its,esp_id)->val  | Radiative flux implicit source term | 
|  CS_FI_(rad_abs,esp_id)->val  | Radiative absorption | 
|  CS_FI_(rad_emi,esp_id)->val  | Radiative emission | 
|  CS_FI_(rad_cak,esp_id)->val  | Radiative absorption coefficient | 
|  CS_F_(qinci)->val  | Radiative incident radiative flux density | 
|  CS_F_(xlam)->val  | Wall thermal conductivity | 
|  CS_F_(epa)->val  | Wall thickness | 
|  CS_F_(emissivity)->val  | Wall emissivity | 
|  CS_F_(fnet)->val  | Boundary radiative flux | 
|  CS_F_(fconv)->val  | Boundary radiative convective flux | 
|  CS_F_(hconv)->val  | Radiative exchange coefficient | 
 Defined in cs_field_pointer.h.
| C code | Description | 
|---|---|
|  CS_FI_(yf_ncond,inc)->val  | Non-condensable gas mass fractions | 
|  CS_FI_(qp,ip)->val  | Particles turbulent kinetic energy Q2 | 
|  CS_FI_(qfp,ip)->val  | Covariance of the turbulent Q12 | 
|  CS_FI_(qfpxx,ip)->val  | XX component of qfp | 
|  CS_FI_(qfpxy,ip)->val  | XY component of qfp | 
|  CS_FI_(qfpxz,ip)->val  | XZ component of qfp | 
|  CS_FI_(qfpyx,ip)->val  | YX component of qfp | 
|  CS_FI_(qfpyy,ip)->val  | YY component of qfp | 
|  CS_FI_(qfpyz,ip)->val  | YZ component of qfp | 
|  CS_FI_(qfpzx,ip)->val  | ZX component of qfp | 
|  CS_FI_(qfpzy,ip)->val  | ZY component of qfp | 
|  CS_FI_(qfpzz,ip)->val  | ZZ component of qfp | 
|  CS_FI_(gamma,ip)->val  | Interfacial mass transfer | 
|  CS_FI_(ia,ip)->val  | Interfacial area | 
|  CS_FI_(x2,ip)->val  | Droplets x2 | 
|  CS_FI_(d32,ip)->val  | Droplets Sauter mean diameter | 
|  CS_FI_(drag,ipcpl)->val  | Drag between phases | 
|  CS_FI_(ad_mass,ip)->val  | Added mass | 
|  CS_FI_(th_diff,ip)->val  | Thermal dynamic diffusivity (  ) | 
|  CS_FI_(th_diff_t,ip)->val  | Turbulent thermal dynamic diffusivity (  ) | 
|  CS_FI_(drho_dp,ip)->val  | dRho over dP | 
|  CS_FI_(drho_dh,ip)->val  | dRho over dH | 
|  CS_FI_(tau12_t,ip)->val  | Turbulent tau12 for particles | 
|  CS_FI_(lift,ip)->val  | Particles lift | 
|  CS_FI_(disp_t,ip)->val  | Particles turbulent dispersion | 
|  CS_FI_(drift_vel,ip)->val  | Particles drift velocity | 
 A list can be found in liste of predefined fields.