| 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 |
open netcdf file
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(t_ncfile), | intent(inout) | :: | sf |
self |
close netcdf file
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(t_ncfile), | intent(inout) | :: | sf |
self |
check if variable name exists (also including groups separated with "/")
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(t_ncfile), | intent(inout) | :: | sf |
self |
||
| character(len=*), | intent(in) | :: | varname_in |
name of the variable (can include "/" for groups) |
get the number of dimensions of a variable
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(t_ncfile), | intent(inout) | :: | sf |
self |
||
| character(len=*), | intent(in) | :: | varname_in |
name of the variable (can include "/" for groups) |
get the size of a ulti-dimensional array for all dimensions ndims
| Type | Intent | Optional | 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 |
size of each dimension of the array
get integer or real scalar (depends on optional argument) abort if variable does not exist. USE var_exists for checking
| Type | Intent | Optional | 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) |
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
| Type | Intent | Optional | 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 |
define a dimension to the netCDF file
| Type | Intent | Optional | 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 |
after creating a new file and making all definitions, one has to call end_def_mode
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(t_ncfile), | intent(inout) | :: | sf |
self |
define and put a scalar value to the netCDF file
| Type | Intent | Optional | 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 |
| Type | Intent | Optional | 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 |
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
| Type | Intent | Optional | 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 |
define and put an array value to the netCDF file
| Type | Intent | Optional | 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 |
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.
| Type | Intent | Optional | 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 |
netcdf error handling via sf%ioError variable
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(t_ncfile), | intent(inout) | :: | sf |
self |
||
| character(len=*), | intent(in) | :: | errmsg |
closes file and frees variable
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(t_ncfile), | intent(inout) | :: | sf |
self |
TYPE :: t_ncfile INTEGER :: nc_id INTEGER :: ioError LOGICAL :: isopen CHARACTER(LEN=1) :: rwo_mode CHARACTER(LEN=255) :: Filename CONTAINS PROCEDURE :: openfile => ncfile_openfile PROCEDURE :: closefile => ncfile_closefile PROCEDURE :: var_exists => ncfile_var_exists PROCEDURE :: get_var_ndims => ncfile_get_var_ndims PROCEDURE :: get_var_dims => ncfile_get_var_dims PROCEDURE :: get_scalar => ncfile_get_scalar PROCEDURE :: get_array => ncfile_get_array PROCEDURE :: def_dim => ncfile_def_dim PROCEDURE :: end_def_mode => ncfile_end_def_mode PROCEDURE :: put_scalar => ncfile_put_scalar PROCEDURE :: put_attr_char => ncfile_put_attributes_char PROCEDURE :: put_char => ncfile_put_char PROCEDURE :: put_array => ncfile_put_array PROCEDURE :: enter_groups => ncfile_enter_groups PROCEDURE :: handle_error => ncfile_handle_error PROCEDURE :: free => ncfile_free END TYPE t_ncfile