1 module netcdf_layer_base
6 type, abstract
:: NetCDF_layer_
7 procedure (nf90_open
), pointer, nopass
:: open_file
! => nf90_open
8 procedure (nf90_def_dim
), pointer, nopass
:: def_dim
!=> nf90_def_dim
9 procedure (nf90_inq_varid
), pointer, nopass
:: inq_varid
!=> nf90_inq_varid
10 procedure (nf90_close
), pointer, nopass
:: close_file
!=> nf90_close
12 procedure (integer), pointer, nopass
:: put_var
!=> nf_put_var
13 procedure (integer), pointer, nopass
:: get_var
!=> nf_get_var
14 procedure (integer), pointer, nopass
:: put_att
!=> nf_put_att
15 procedure (integer), pointer, nopass
:: def_var
!=> nf_def_var
17 procedure (create_file_signature
), pass(object
), deferred
:: create_file
18 end type NetCDF_layer_
20 integer, external :: nf_put_att
21 integer, external :: nf_def_var
22 integer, external :: nf_put_var
23 integer, external :: nf_get_var
27 function create_file_signature(object
, path
, cmode
, initialsize
, chunksize
, ncid
) result(res
)
29 class(NetCDF_layer_
), intent(in
) :: object
30 character (len
= *), intent(in
) :: path
31 integer, intent(in
) :: cmode
32 integer, optional
, intent(in
) :: initialsize
33 integer, optional
, intent(inout
) :: chunksize
34 integer, intent( out
) :: ncid
36 end function create_file_signature
40 type, extends(NetCDF_layer_
) :: NetCDF_serial_
42 procedure
, pass(object
) :: create_file
=> create_file_serial
43 end type NetCDF_serial_
45 type, extends(NetCDF_layer_
) :: NetCDF_parallel_
46 integer :: MPI_communicator
47 integer :: default_info
= MPI_INFO_NULL
49 procedure
, pass(object
) :: create_file
=> create_file_parallel
50 end type NetCDF_parallel_
54 function create_file_serial (object
, path
, cmode
, initialsize
, chunksize
, ncid
) result(res
)
55 class(NetCDF_serial_
), intent(in
) :: object
56 character (len
= *), intent(in
) :: path
57 integer, intent(in
) :: cmode
58 integer, optional
, intent(in
) :: initialsize
59 integer, optional
, intent(inout
) :: chunksize
60 integer, intent( out
) :: ncid
63 res
= nf90_create(path
= path
, cmode
= cmode
, ncid
= ncid
)
65 end function create_file_serial
67 function create_file_parallel(object
, path
, cmode
, initialsize
, chunksize
, ncid
) result(res
)
68 class(NetCDF_parallel_
),intent(in
) :: object
69 character (len
= *), intent(in
) :: path
70 integer, intent(in
) :: cmode
71 integer, optional
, intent(in
) :: initialsize
72 integer, optional
, intent(inout
) :: chunksize
73 integer, intent( out
) :: ncid
76 res
= nf90_create(path
= path
, cmode
= cmode
, ncid
= ncid
, &
77 & comm
= object
%mpi_communicator
, info
= object
%default_info
)
79 end function create_file_parallel
81 end module netcdf_layer_base