Provides some convenience wrappers around netCDF procedures, mostly for handling netCDF errors in a consistent manner, removing the need to manually check the returned status code.
This module requires the preprocessor macro 1
to be
defined. If it is not defined, you won't be able to use
this module!
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
integer, | public, | parameter | :: | kind_nf | = | kind(NF90_NOERR) |
Kind of netCDF types and constants |
integer(kind=kind_nf), | public, | parameter | :: | netcdf_real | = | NF90_DOUBLE |
netCDF type of default |
integer(kind=kind_nf), | public, | parameter | :: | netcdf_int | = | NF90_INT |
netCDF type of default |
logical, | private, | parameter | :: | test | = | .false. | |
logical, | private | :: | use_compression_default | = | .true. | ||
integer(kind=kind_nf), | private | :: | deflate_level_default | = | 1 |
Get the netCDF ID for a variable, creating it if it doesn't exist already
Get the netCDF ID for a variable, creating it if it doesn't exist already. Aborts if any errors are detected.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=kind_nf), | intent(in) | :: | file_id |
ID of the file or group to look for or create the variable under |
||
character(len=*), | intent(in) | :: | var_name |
Name of the variable |
||
integer(kind=kind_nf), | intent(in) | :: | var_type |
The netCDF type of the variable |
||
integer(kind=kind_nf), | intent(out) | :: | var_id |
The netCDF ID of the variable under |
Get the netCDF ID for a variable, creating it if it doesn't exist already. Aborts if any errors are detected.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=kind_nf), | intent(in) | :: | file_id |
ID of the file or group to look for or create the variable under |
||
character(len=*), | intent(in) | :: | var_name |
Name of the variable |
||
integer(kind=kind_nf), | intent(in) | :: | var_type |
The netCDF type of the variable |
||
integer(kind=kind_nf), | intent(in) | :: | dim_id |
Array of dimension IDs |
||
integer(kind=kind_nf), | intent(out) | :: | var_id |
The netCDF ID of the variable under |
||
logical, | intent(in), | optional | :: | compress |
Do we want to use compression for this variable |
|
integer(kind=kind_nf), | intent(in), | optional | :: | deflate_level |
The compression level to use for this variable |
Get the netCDF ID for a variable, creating it if it doesn't exist already. Aborts if any errors are detected.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=kind_nf), | intent(in) | :: | file_id |
ID of the file or group to look for or create the variable under |
||
character(len=*), | intent(in) | :: | var_name |
Name of the variable |
||
integer(kind=kind_nf), | intent(in) | :: | var_type |
The netCDF type of the variable |
||
integer(kind=kind_nf), | intent(in), | dimension(:) | :: | dim_id |
Array of dimension IDs |
|
integer(kind=kind_nf), | intent(out) | :: | var_id |
The netCDF ID of the variable under |
||
logical, | intent(in), | optional | :: | compress |
Do we want to use compression for this variable |
|
integer(kind=kind_nf), | intent(in), | optional | :: | deflate_level |
The compression level to use for this variable |
Add an attribute to an existing netCDF variable
Add an attribute to an existing netCDF variable. Aborts if any errors are detected.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=kind_nf), | intent(in) | :: | file_id |
ID of the file or group to look for or create the variable under |
||
integer(kind=kind_nf), | intent(in) | :: | var_id |
The netCDF ID of the variable under |
||
character(len=*), | intent(in) | :: | att_name |
Name of the attribute |
||
character(len=*), | intent(in) | :: | att_text |
Attribute text to store |
Returns the correct netCDF constant for the real
kind in use
Wrapper around nf90_inquire_dimension
. Aborts if any errors are
detected.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=kind_nf), | intent(in) | :: | file_id |
NetCDF ID of the file |
||
integer(kind=kind_nf), | intent(in) | :: | dim_id |
NetCDF ID of the dimension |
Returns the current value of use_compression_default
Returns the current value of deflate_level_default
Check that an existing netCDF file uses the same real
kind as
the current simulation. Only prints a warning!
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=kind_nf), | intent(in), | optional | :: | ncid | ||
character(len=*), | intent(in), | optional | :: | filename |
Convert a netCDF error code to a nice error message. Writes to error_unit
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=kind_nf), | intent(in) | :: | istatus |
The netCDF error code to convert to a message |
||
integer(kind=kind_nf), | intent(in), | optional | :: | ncid |
netCDF ID of the file |
|
integer(kind=kind_nf), | intent(in), | optional | :: | varid |
netCDF ID of the variable |
|
integer(kind=kind_nf), | intent(in), | optional | :: | dimid |
netCDF ID of the dimension |
|
character(len=*), | intent(in), | optional | :: | file |
Name of the file |
|
character(len=*), | intent(in), | optional | :: | dim |
Name of the dimension |
|
character(len=*), | intent(in), | optional | :: | var |
Name of the variable |
|
character(len=*), | intent(in), | optional | :: | att |
Name of the attribute |
|
character(len=*), | intent(in), | optional | :: | message |
Custom text to append to the error message |
|
logical, | intent(in), | optional | :: | abort |
Immediately abort the program if present and true |
Get the netCDF ID for a variable, creating it if it doesn't exist already. Aborts if any errors are detected.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=kind_nf), | intent(in) | :: | file_id |
ID of the file or group to look for or create the variable under |
||
character(len=*), | intent(in) | :: | var_name |
Name of the variable |
||
integer(kind=kind_nf), | intent(in) | :: | var_type |
The netCDF type of the variable |
||
integer(kind=kind_nf), | intent(out) | :: | var_id |
The netCDF ID of the variable under |
Get the netCDF ID for a variable, creating it if it doesn't exist already. Aborts if any errors are detected.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=kind_nf), | intent(in) | :: | file_id |
ID of the file or group to look for or create the variable under |
||
character(len=*), | intent(in) | :: | var_name |
Name of the variable |
||
integer(kind=kind_nf), | intent(in) | :: | var_type |
The netCDF type of the variable |
||
integer(kind=kind_nf), | intent(in) | :: | dim_id |
Array of dimension IDs |
||
integer(kind=kind_nf), | intent(out) | :: | var_id |
The netCDF ID of the variable under |
||
logical, | intent(in), | optional | :: | compress |
Do we want to use compression for this variable |
|
integer(kind=kind_nf), | intent(in), | optional | :: | deflate_level |
The compression level to use for this variable |
Get the netCDF ID for a variable, creating it if it doesn't exist already. Aborts if any errors are detected.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=kind_nf), | intent(in) | :: | file_id |
ID of the file or group to look for or create the variable under |
||
character(len=*), | intent(in) | :: | var_name |
Name of the variable |
||
integer(kind=kind_nf), | intent(in) | :: | var_type |
The netCDF type of the variable |
||
integer(kind=kind_nf), | intent(in), | dimension(:) | :: | dim_id |
Array of dimension IDs |
|
integer(kind=kind_nf), | intent(out) | :: | var_id |
The netCDF ID of the variable under |
||
logical, | intent(in), | optional | :: | compress |
Do we want to use compression for this variable |
|
integer(kind=kind_nf), | intent(in), | optional | :: | deflate_level |
The compression level to use for this variable |
Add an attribute to an existing netCDF variable. Aborts if any errors are detected.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=kind_nf), | intent(in) | :: | file_id |
ID of the file or group to look for or create the variable under |
||
integer(kind=kind_nf), | intent(in) | :: | var_id |
The netCDF ID of the variable under |
||
character(len=*), | intent(in) | :: | att_name |
Name of the attribute |
||
character(len=*), | intent(in) | :: | att_text |
Attribute text to store |
Get the netCDF ID for a dimension, creating it if it doesn't exist already. Aborts if any errors are detected.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=kind_nf), | intent(in) | :: | file_id |
ID of the file or group to look for or create the dimension under |
||
character(len=*), | intent(in) | :: | dim_name |
Name of the dimension |
||
integer(kind=kind_nf), | intent(in) | :: | dim_size |
The size of the dimension |
||
integer(kind=kind_nf), | intent(out) | :: | dim_id |
The netCDF ID of the dimension under |
Set the value of use_compression_default
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
logical, | intent(in) | :: | compression_flag |
Set the value of deflate_level_default
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=kind_nf), | intent(in) | :: | compression_level |