MODgvec_IO_NETCDF Module

Module IO_NETCDF: SIMPLE NETCDF INTERFACE

Provides simplified read routines for netcdf files, via a class "t_ncfile" start with defining a variable as CLASS(t_ncfile),ALLOCATABLE :: nc and to allocate and initialize CALL ncfile_init(nc,Filename,rwo_mode)


Uses

  • module~~modgvec_io_netcdf~~UsesGraph module~modgvec_io_netcdf MODgvec_IO_NETCDF module~modgvec_globals MODgvec_Globals module~modgvec_io_netcdf->module~modgvec_globals iso_fortran_env iso_fortran_env module~modgvec_globals->iso_fortran_env

Used by

  • module~~modgvec_io_netcdf~~UsedByGraph module~modgvec_io_netcdf MODgvec_IO_NETCDF module~modgvec_boundaryfromfile MODgvec_boundaryFromFile module~modgvec_boundaryfromfile->module~modgvec_io_netcdf module~modgvec_hmap_axisnb MODgvec_hmap_axisNB module~modgvec_hmap_axisnb->module~modgvec_io_netcdf proc~bff_init t_boundaryFromFile%bff_init proc~bff_init->module~modgvec_io_netcdf proc~hmap_axisnb_init_params hmap_axisNB_init_params proc~hmap_axisnb_init_params->module~modgvec_io_netcdf proc~readnetcdf ReadNETCDF proc~readnetcdf->module~modgvec_io_netcdf proc~readnetcdf~2 ReadNETCDF proc~readnetcdf~2->module~modgvec_io_netcdf proc~writedatatonetcdf WriteDataToNETCDF proc~writedatatonetcdf->module~modgvec_io_netcdf module~modgvec_hmap MODgvec_hmap module~modgvec_hmap->module~modgvec_hmap_axisnb module~modgvec_mhd3d_vars MODgvec_MHD3D_Vars module~modgvec_mhd3d_vars->module~modgvec_boundaryfromfile module~modgvec_mhd3d_vars->module~modgvec_hmap proc~initmhd3d t_functional_mhd3d%InitMHD3D proc~initmhd3d->module~modgvec_boundaryfromfile proc~initmhd3d->module~modgvec_hmap proc~initmhd3d->module~modgvec_mhd3d_vars module~modgvec_readstate_vars MODgvec_ReadState_Vars module~modgvec_readstate_vars->module~modgvec_hmap module~modgvec_sfl_boozer MODgvec_SFL_Boozer module~modgvec_sfl_boozer->module~modgvec_hmap module~modgvec_transform_sfl MODgvec_Transform_SFL module~modgvec_transform_sfl->module~modgvec_hmap module~modgvec_transform_sfl->module~modgvec_sfl_boozer proc~addboundaryperturbation AddBoundaryPerturbation proc~addboundaryperturbation->module~modgvec_mhd3d_vars proc~analyze Analyze proc~analyze->module~modgvec_mhd3d_vars proc~applybc_fstrong ApplyBC_Fstrong proc~applybc_fstrong->module~modgvec_mhd3d_vars proc~buildprecond BuildPrecond proc~buildprecond->module~modgvec_mhd3d_vars proc~evalaux EvalAux proc~evalaux->module~modgvec_mhd3d_vars proc~evalenergy EvalEnergy proc~evalenergy->module~modgvec_mhd3d_vars proc~evalforce EvalForce proc~evalforce->module~modgvec_mhd3d_vars proc~evaluate_hmap evaluate_hmap proc~evaluate_hmap->module~modgvec_hmap proc~evaluate_hmap->module~modgvec_mhd3d_vars proc~evaluate_hmap_derivs evaluate_hmap_derivs proc~evaluate_hmap_derivs->module~modgvec_hmap proc~evaluate_hmap_derivs->module~modgvec_mhd3d_vars proc~evaluate_hmap_only evaluate_hmap_only proc~evaluate_hmap_only->module~modgvec_hmap proc~evaluate_hmap_only->module~modgvec_mhd3d_vars proc~evaluate_hmap_only_pw evaluate_hmap_only_pw proc~evaluate_hmap_only_pw->module~modgvec_mhd3d_vars proc~evaluate_hmap_pw evaluate_hmap_pw proc~evaluate_hmap_pw->module~modgvec_mhd3d_vars proc~evaluate_jac_h_derivs evaluate_jac_h_derivs proc~evaluate_jac_h_derivs->module~modgvec_hmap proc~evaluate_jac_h_derivs->module~modgvec_mhd3d_vars proc~evaluate_jac_h_derivs_pw evaluate_jac_h_derivs_pw proc~evaluate_jac_h_derivs_pw->module~modgvec_mhd3d_vars proc~evaluate_metric_derivs evaluate_metric_derivs proc~evaluate_metric_derivs->module~modgvec_hmap proc~evaluate_metric_derivs->module~modgvec_mhd3d_vars proc~evaluate_profile evaluate_profile proc~evaluate_profile->module~modgvec_mhd3d_vars proc~evaluate_rho2_profile evaluate_rho2_profile proc~evaluate_rho2_profile->module~modgvec_mhd3d_vars proc~finalizemhd3d t_functional_mhd3d%FinalizeMHD3D proc~finalizemhd3d->module~modgvec_mhd3d_vars proc~finalizemhd3d_evalfunc FinalizeMHD3D_EvalFunc proc~finalizemhd3d_evalfunc->module~modgvec_mhd3d_vars proc~find_pest_angles_2d find_pest_angles_2D proc~find_pest_angles_2d->module~modgvec_mhd3d_vars proc~find_pest_angles_2d->module~modgvec_transform_sfl proc~get_boozer get_boozer proc~get_boozer->module~modgvec_mhd3d_vars proc~get_boozer->module~modgvec_sfl_boozer proc~init Init proc~init->module~modgvec_mhd3d_vars proc~init_boozer init_boozer proc~init_boozer->module~modgvec_mhd3d_vars proc~init_boozer->module~modgvec_sfl_boozer proc~init_la_from_solution Init_LA_from_Solution proc~init_la_from_solution->module~modgvec_hmap proc~init_la_from_solution->module~modgvec_mhd3d_vars proc~initaverageaxis InitAverageAxis proc~initaverageaxis->module~modgvec_mhd3d_vars proc~initializemhd3d_evalfunc InitializeMHD3D_evalFunc proc~initializemhd3d_evalfunc->module~modgvec_mhd3d_vars proc~initprofilesgp InitProfilesGP proc~initprofilesgp->module~modgvec_mhd3d_vars proc~initsolution InitSolution proc~initsolution->module~modgvec_mhd3d_vars proc~initsolutionmhd3d t_functional_mhd3d%InitSolutionMHD3D proc~initsolutionmhd3d->module~modgvec_mhd3d_vars proc~lambda_solve Lambda_solve proc~lambda_solve->module~modgvec_hmap proc~minimize minimize proc~minimize->module~modgvec_mhd3d_vars proc~minimizemhd3d t_functional_mhd3d%MinimizeMHD3D proc~minimizemhd3d->module~modgvec_mhd3d_vars proc~readstatefilefromascii ReadStateFileFromASCII proc~readstatefilefromascii->module~modgvec_hmap proc~readstatefilefromascii->module~modgvec_readstate_vars proc~restartfromstate RestartFromState proc~restartfromstate->module~modgvec_mhd3d_vars proc~restartfromstate->module~modgvec_readstate_vars proc~select_base select_base proc~select_base->module~modgvec_mhd3d_vars proc~select_base_dofs select_base_dofs proc~select_base_dofs->module~modgvec_mhd3d_vars proc~sfl_boozer_new sfl_boozer_new proc~sfl_boozer_new->module~modgvec_hmap proc~writestatetoascii WriteStateToASCII proc~writestatetoascii->module~modgvec_mhd3d_vars module~modgvec_gvec_to_castor3d_vars MODgvec_gvec_to_castor3d_Vars module~modgvec_gvec_to_castor3d_vars->module~modgvec_transform_sfl module~modgvec_gvec_to_gene_vars MODgvec_gvec_to_gene_Vars module~modgvec_gvec_to_gene_vars->module~modgvec_transform_sfl module~modgvec_gvec_to_hopr_vars MODgvec_gvec_to_hopr_vars module~modgvec_gvec_to_hopr_vars->module~modgvec_transform_sfl proc~buildtransform_sfl t_transform_sfl%BuildTransform_SFL proc~buildtransform_sfl->module~modgvec_sfl_boozer proc~eval_prof_r eval_prof_r proc~eval_prof_r->module~modgvec_readstate_vars proc~evaluate_boozer_list_tz_all evaluate_boozer_list_tz_all proc~evaluate_boozer_list_tz_all->module~modgvec_sfl_boozer proc~finalize_readstate Finalize_ReadState proc~finalize_readstate->module~modgvec_readstate_vars proc~get_field Get_Field proc~get_field->module~modgvec_readstate_vars proc~gvec_to_jorek_prepare gvec_to_jorek_prepare proc~gvec_to_jorek_prepare->module~modgvec_readstate_vars proc~init_base Init_Base proc~init_base->module~modgvec_readstate_vars proc~init_gvec_to_jorek init_gvec_to_jorek proc~init_gvec_to_jorek->module~modgvec_readstate_vars proc~readstate ReadState proc~readstate->module~modgvec_readstate_vars proc~transform_sfl_init t_transform_sfl%transform_SFL_init proc~transform_sfl_init->module~modgvec_sfl_boozer program~gvec_post GVEC_POST program~gvec_post->module~modgvec_readstate_vars

Derived Types

type, public ::  t_ncfile

Components

Type Visibility Attributes Name Initial
integer, public :: nc_id
integer, public :: ioError
logical, public :: isopen
character(len=1), public :: rwo_mode
character(len=255), public :: Filename

Type-Bound Procedures

procedure, public :: openfile => ncfile_openfile
procedure, public :: closefile => ncfile_closefile
procedure, public :: var_exists => ncfile_var_exists
procedure, public :: get_var_ndims => ncfile_get_var_ndims
procedure, public :: get_var_dims => ncfile_get_var_dims
procedure, public :: get_scalar => ncfile_get_scalar
procedure, public :: get_array => ncfile_get_array
procedure, public :: def_dim => ncfile_def_dim
procedure, public :: end_def_mode => ncfile_end_def_mode
procedure, public :: put_scalar => ncfile_put_scalar
procedure, public :: put_attr_char => ncfile_put_attributes_char
procedure, public :: put_char => ncfile_put_char
procedure, public :: put_array => ncfile_put_array
procedure, public :: enter_groups => ncfile_enter_groups
procedure, public :: handle_error => ncfile_handle_error
procedure, public :: free => ncfile_free

Functions

public function ncfile_var_exists(sf, varname_in) result(exists)

check if variable name exists (also including groups separated with "/")

Arguments

Type IntentOptional Attributes Name
class(t_ncfile), intent(inout) :: sf

self

character(len=*), intent(in) :: varname_in

name of the variable (can include "/" for groups)

Return Value logical

public function ncfile_get_var_ndims(sf, varname_in) result(ndims_out)

get the number of dimensions of a variable

Arguments

Type IntentOptional Attributes Name
class(t_ncfile), intent(inout) :: sf

self

character(len=*), intent(in) :: varname_in

name of the variable (can include "/" for groups)

Return Value integer

public function ncfile_get_var_dims(sf, varname_in, ndims_in, transpose_in) result(dims_out)

get the size of a ulti-dimensional array for all dimensions ndims

Arguments

Type IntentOptional Attributes Name
class(t_ncfile), intent(inout) :: sf

self

character(len=*), intent(in) :: varname_in

name of the multi-dimensional array (can include "/" for groups)

integer, intent(in) :: ndims_in

number of dimensions in the array

logical, intent(in), optional :: transpose_in

transpose the data array, default is true, because of fortran ordering

Return Value integer, (ndims_in)

size of each dimension of the array


Subroutines

public subroutine mpi_check_single_access()

Arguments

None

public subroutine ncfile_init(sf, Filename, rwo_mode)

allocate and initialize class and open/close the netcdf file and define read ("r") or write ("w" includes read) mode

Arguments

Type IntentOptional Attributes Name
class(t_ncfile), intent(inout), ALLOCATABLE :: sf

self

character(len=*), intent(in) :: Filename
character(len=1), intent(in) :: rwo_mode

public subroutine ncfile_openfile(sf)

open netcdf file

Arguments

Type IntentOptional Attributes Name
class(t_ncfile), intent(inout) :: sf

self

public subroutine ncfile_closefile(sf)

close netcdf file

Arguments

Type IntentOptional Attributes Name
class(t_ncfile), intent(inout) :: sf

self

public subroutine ncfile_enter_groups(sf, varname_in, grpid, varname, exists)

if variable name contains "/", these are interpreted as groups/subgroups. split the varname at first occurence of "/" to get the first group name on the file level. Then get the group id. repeat until no "/" is found anymore. output the final groupid and the variable name without the group names.

Arguments

Type IntentOptional Attributes Name
class(t_ncfile), intent(inout) :: sf

self

character(len=*), intent(in) :: varname_in

name of the variable (can include "/" for groups)

integer, intent(out) :: grpid

id of the last group found

character(len=255), intent(out) :: varname

name of the variable without groups

logical, intent(out) :: exists

public subroutine ncfile_get_scalar(sf, varname_in, intout, realout)

get integer or real scalar (depends on optional argument) abort if variable does not exist. USE var_exists for checking

Arguments

Type IntentOptional Attributes Name
class(t_ncfile), intent(inout) :: sf

self

character(len=*), intent(in) :: varname_in

name of the variable (can include "/" for groups)

integer, intent(out), optional :: intout

choose for integer out

real(kind=wp), intent(out), optional :: realout

choose for real(wp) out (double)

public subroutine ncfile_get_array(sf, varname_in, transpose_in, intout_1d, realout_1d, intout_2d, realout_2d, intout_3d, realout_3d, intout_4d, realout_4d)

get integer or real array of dimension 1d,2d,3d,4d (depends on optional argument) netcdf call get_var knows type and dimensions directly from argument abort if variable does not exist. USE var_exists for checking

Arguments

Type IntentOptional Attributes Name
class(t_ncfile), intent(inout) :: sf

self

character(len=*), intent(in) :: varname_in

name of the variable (can include "/" for groups)

logical, intent(in), optional :: transpose_in

transpose the data array, default is true, because of fortran ordering

integer, intent(out), optional :: intout_1d(:)

choose for integer out 1d array

real(kind=wp), intent(out), optional :: realout_1d(:)

choose for real(wp) out (double) 1d array

integer, intent(out), optional :: intout_2d(:,:)

choose for integer out 2d array

real(kind=wp), intent(out), optional :: realout_2d(:,:)

choose for real(wp) out (double) 2d array

integer, intent(out), optional :: intout_3d(:,:,:)

choose for integer out 3d array

real(kind=wp), intent(out), optional :: realout_3d(:,:,:)

choose for real(wp) out (double) 3d array

integer, intent(out), optional :: intout_4d(:,:,:,:)

choose for integer out 4d array

real(kind=wp), intent(out), optional :: realout_4d(:,:,:,:)

choose for real(wp) out (double) 4darray

public subroutine ncfile_def_dim(sf, dimname_in, dimlen, dimid)

define a dimension to the netCDF file

Arguments

Type IntentOptional Attributes Name
class(t_ncfile), intent(inout) :: sf

self

character(len=*), intent(in) :: dimname_in

name of the dimension

integer, intent(in) :: dimlen

length of the dimension

integer, intent(out) :: dimid

id of the dimension

public subroutine ncfile_end_def_mode(sf)

after creating a new file and making all definitions, one has to call end_def_mode

Arguments

Type IntentOptional Attributes Name
class(t_ncfile), intent(inout) :: sf

self

public subroutine ncfile_put_scalar(sf, varname_in, def_put_mode, int_in, real_in)

define and put a scalar value to the netCDF file

Arguments

Type IntentOptional Attributes Name
class(t_ncfile), intent(inout) :: sf

self

character(len=*), intent(in) :: varname_in

name of the variable

integer, intent(in) :: def_put_mode

1:"def" or 2:"put" mode

integer, intent(in), optional :: int_in

scalar integer input

real(kind=wp), intent(in), optional :: real_in

scalar double input

public subroutine ncfile_put_attributes_char(sf, varname_in, n_attr, attrs_names, attr_values)

Arguments

Type IntentOptional Attributes Name
class(t_ncfile), intent(inout) :: sf

self

character(len=*), intent(in) :: varname_in

name of the variable

integer, intent(in) :: n_attr

number of attributes

character(len=*), intent(in) :: attrs_names(:)

Array of attribute names

character(len=*), intent(in) :: attr_values(:)

double input

public subroutine ncfile_put_char(sf, varname_in, dimid, def_put_mode, char_in)

define and put a char to the netCDF file as a string NOTE: This is only used for naming coordinate directions with a single character

Arguments

Type IntentOptional Attributes Name
class(t_ncfile), intent(inout) :: sf

self

character(len=*), intent(in) :: varname_in

name of the variable

integer, intent(in) :: dimid

ids of dimensions, must be created before by put_dim

integer, intent(in) :: def_put_mode

1:"def" or 2:"put" mode

character(len=*), intent(in) :: char_in

double input

public subroutine ncfile_put_array(sf, varname_in, ndims_var, dims, dimids, def_put_mode, transpose_in, int_in, real_in)

define and put an array value to the netCDF file

Arguments

Type IntentOptional Attributes Name
class(t_ncfile), intent(inout) :: sf

self

character(len=*), intent(in) :: varname_in

name of the variable

integer, intent(in) :: ndims_var

number of dimensions

integer, intent(in) :: dims(1:ndims_var)

number of dimensions

integer, intent(in) :: dimids(1:ndims_var)

ids of dimensions, must be created before by put_dim

integer, intent(in) :: def_put_mode

1:"def" or 2:"put" mode

logical, intent(in), optional :: transpose_in

transpose the data array, default is true, because of fortran ordering

integer, intent(in), optional :: int_in(PRODUCT(dims))

integer input

real(kind=wp), intent(in), optional :: real_in(PRODUCT(dims))

double input

public subroutine ncfile_handle_error(sf, errmsg, TypeInfo)

netcdf error handling via sf%ioError variable

Arguments

Type IntentOptional Attributes Name
class(t_ncfile), intent(inout) :: sf

self

character(len=*), intent(in) :: errmsg
character(len=*), intent(in), optional :: TypeInfo

public subroutine ncfile_free(sf)

closes file and frees variable

Arguments

Type IntentOptional Attributes Name
class(t_ncfile), intent(inout) :: sf

self