-
Notifications
You must be signed in to change notification settings - Fork 0
/
nc_putAxisIntAttr.F90
113 lines (94 loc) · 4.2 KB
/
nc_putAxisIntAttr.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! svn propset svn:keywords "URL Rev Author Date Id"
! $URL: file:///neem/users/huangwei/.vdras_source_code/SVN_REPOSITORY/trunk/vdras/io/netcdf4/nc_putAttr.F90 $
! $Rev: 144 $
! $Author: huangwei $
! $Date: 2010-11-15 10:33:52 -0700 (Mon, 15 Nov 2010) $
! $Id: nc_putAttr.F90 144 2010-11-15 17:33:52Z huangwei $
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
subroutine nc_putAxisIntAttr(ncid, nd, dimid, var_name, &
desc, units, coordinates)
use netcdf
implicit none
integer, intent(in) :: ncid, nd
integer, dimension(6), intent(in) :: dimid
character(len=*), intent(in) :: var_name, desc, units, coordinates
! real, intent(in) :: missing_real
! real, intent(in), optional :: missing_real
! integer, intent(in), optional :: missing_int
!--Variable id
integer :: varid, md
!--Return status
integer :: status
md = nd
if(md > 6) then
write(unit=0, fmt='(a, i6)') "We can only handle data up to 5d. but here nd = ", nd
endif
!--Always set the extra dimension unlimited.
! dimid(nd+1) = nf90_unlimited
status = nf90_def_var(ncid, trim(var_name), NF90_INT, dimid(1:md), varid)
if(status /= nf90_noerr) then
write(unit=0, fmt='(a, i6)') "ncid: ", ncid
write(unit=0, fmt='(a, 6i6)') "dimid: ", dimid(1:md)
write(unit=0, fmt='(3a)') "Problem to def varid for: <", trim(var_name), ">.", &
"Error status: ", trim(nf90_strerror(status))
write(unit=0, fmt='(3a, i4)') &
"Stop in file: <", __FILE__, ">, line: ", __LINE__
stop
endif
! status = nf90_put_att(ncid, varid, "description", trim(desc))
status = nf90_put_att(ncid, varid, "long_name", trim(desc))
if(status /= nf90_noerr) then
write(unit=0, fmt='(3a)') "Problem to write attribute description: <", trim(desc), ">.", &
"Error status: ", trim(nf90_strerror(status))
write(unit=0, fmt='(3a, i4)') &
"Stop in file: <", __FILE__, ">, line: ", __LINE__
stop
endif
! status = nf90_put_att(ncid, varid, "long_name", trim(var_name))
! if(status /= nf90_noerr) then
! write(unit=0, fmt='(3a)') "Problem to write attribute long_name: <", trim(var_name), ">.", &
! "Error status: ", trim(nf90_strerror(status))
! write(unit=0, fmt='(3a, i4)') &
! "Stop in file: <", __FILE__, ">, line: ", __LINE__
! stop
! endif
status = nf90_put_att(ncid, varid, "units", trim(units))
if(status /= nf90_noerr) then
write(unit=0, fmt='(3a)') "Problem to write attribute units: <", trim(units), ">.", &
"Error status: ", trim(nf90_strerror(status))
write(unit=0, fmt='(3a, i4)') &
"Stop in file: <", __FILE__, ">, line: ", __LINE__
stop
endif
status = nf90_put_att(ncid, varid, "_CoordinateAxisType", trim(coordinates))
if(status /= nf90_noerr) then
write(unit=0, fmt='(3a)') "Problem to write attribute coordinates: <", trim(coordinates), ">.", &
"Error status: ", trim(nf90_strerror(status))
write(unit=0, fmt='(3a, i4)') &
"Stop in file: <", __FILE__, ">, line: ", __LINE__
stop
endif
! if(present(missing_real)) then
! status = nf90_put_att(ncid, varid, "_FillValue", missing_real)
! if(status /= nf90_noerr) then
! write(unit=0, fmt='(a, f12.2)') "Problem to write attribute missing_real: ", missing_real
! write(unit=0, fmt='(3a)') "Error status: ", trim(nf90_strerror(status))
! write(unit=0, fmt='(3a, i4)') &
! "Stop in file: <", __FILE__, ">, line: ", __LINE__
! stop
! endif
! endif
#if 0
! if(present(missing_int)) then
! status = nf90_put_att(ncid, varid, "_FillValue", missing_int)
! if(status /= nf90_noerr) then
! write(unit=0, fmt='(a, f12.2)') "Problem to write attribute missing_int: ", missing_int
! write(unit=0, fmt='(3a)') "Error status: ", trim(nf90_strerror(status))
! write(unit=0, fmt='(3a, i4)') &
! "Stop in file: <", __FILE__, ">, line: ", __LINE__
! stop
! endif
! endif
#endif
end subroutine nc_putAxisIntAttr