-
Notifications
You must be signed in to change notification settings - Fork 69
Expand file tree
/
Copy pathio_netcdf_attribute_module.F90
More file actions
74 lines (55 loc) · 1.86 KB
/
io_netcdf_attribute_module.F90
File metadata and controls
74 lines (55 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
module io_netcdf_attribute_module
implicit none
public att_type, att_type_text, att_type_int
private
type, abstract :: att_type
character(:), allocatable :: name
contains
procedure(define_in_var), deferred :: define_in_var
end type att_type
interface
subroutine define_in_var(this, fileid, varid)
import att_type
class(att_type), intent(inout) :: this
integer, intent(in) :: fileid
integer, intent(in) :: varid
end subroutine define_in_var
end interface
type, extends(att_type) :: att_type_text
character(:), allocatable :: text
contains
procedure :: define_in_var => define_in_var_text
end type att_type_text
type, extends(att_type) :: att_type_int
integer :: val
contains
procedure :: define_in_var => define_in_var_int
end type att_type_int
contains
subroutine define_in_var_text(this, fileid, varid)
class(att_type_text), intent(inout) :: this
integer, intent(in) :: fileid
integer, intent(in) :: varid
! EO parameters
include "netcdf.inc"
call assert_nc( nf_put_att_text(fileid, varid, this%name, len(this%text), this%text) , __LINE__)
end subroutine define_in_var_text
subroutine define_in_var_int(this, fileid, varid)
class(att_type_int), intent(inout) :: this
integer, intent(in) :: fileid
integer, intent(in) :: varid
! EO parameters
include "netcdf.inc"
call assert_nc( nf_put_att_int(fileid, varid, this%name, nf_int, 1, this%val) , __LINE__)
end subroutine define_in_var_int
subroutine assert_nc(status, line)
integer, intent(in) :: status
integer, intent(in) :: line
! EO parameters
include "netcdf.inc"
if(status /= nf_noerr) then
print *, "error in line ",line, __FILE__, ' ', trim(nf_strerror(status))
stop 1
endif
end subroutine assert_nc
end module io_netcdf_attribute_module