-
Notifications
You must be signed in to change notification settings - Fork 0
/
nc_put_single_int.F90
90 lines (64 loc) · 2.43 KB
/
nc_put_single_int.F90
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
subroutine nc_put_single_int(ncid, var_name, iv, nrec)
use netcdf
implicit none
integer, intent(in) :: ncid, nrec, iv
character(len=*), intent(in) :: var_name
!--Variable id
integer :: varid
!--Return status
integer :: status
integer, dimension(1) :: start, count, nv
nv(1) = iv
start(1) = nrec
count(1) = 1
status = nf90_inq_varid(ncid, trim(var_name), varid)
if(status /= nf90_noerr) then
write(unit=0, fmt='(3a)') "Problem to get varid for: <", trim(var_name), ">.", &
"Error status: ", trim(nf90_strerror(status))
write(unit=0, fmt='(3a, i4)') &
"Stop in file: <", __FILE__, ">, line: ", __LINE__
stop
end if
status = nf90_put_var(ncid, varid, nv, start=start, count=count)
if(status /= nf90_noerr) then
write(unit=0, fmt='(3a)') "Problem to write variable: <", trim(var_name), ">.", &
"Error status: ", trim(nf90_strerror(status))
write(unit=0, fmt='(3a, i4)') &
"Stop in file: <", __FILE__, ">, line: ", __LINE__
stop
end if
end subroutine nc_put_single_int
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
subroutine nc_put_single_double(ncid, var_name, dv, nrec)
use netcdf
implicit none
integer, intent(in) :: ncid, nrec
real(kind=8), intent(in) :: dv
character(len=*), intent(in) :: var_name
!--Variable id
integer :: varid
!--Return status
integer :: status
integer, dimension(1) :: start, count
real(kind=8), dimension(1) :: nv
nv(1) = dv
start(1) = nrec
count(1) = 1
status = nf90_inq_varid(ncid, trim(var_name), varid)
if(status /= nf90_noerr) then
write(unit=0, fmt='(3a)') "Problem to get varid for: <", trim(var_name), ">.", &
"Error status: ", trim(nf90_strerror(status))
write(unit=0, fmt='(3a, i4)') &
"Stop in file: <", __FILE__, ">, line: ", __LINE__
stop
end if
status = nf90_put_var(ncid, varid, nv, start=start, count=count)
if(status /= nf90_noerr) then
write(unit=0, fmt='(3a)') "Problem to write variable: <", trim(var_name), ">.", &
"Error status: ", trim(nf90_strerror(status))
write(unit=0, fmt='(3a, i4)') &
"Stop in file: <", __FILE__, ">, line: ", __LINE__
stop
end if
end subroutine nc_put_single_double