11 use grdvars, only: ni,nj,nv,nverts,ncoord
12 use grdvars, only: lonct,latct,lonct_vert,latct_vert
13 use grdvars, only: loncu,latcu,loncu_vert,latcu_vert
14 use grdvars, only: loncv,latcv,loncv_vert,latcv_vert
15 use grdvars, only: lonbu,latbu,lonbu_vert,latbu_vert
16 use grdvars, only: wet4,areact,anglet,dp4
35 character(len=*),
intent(in) :: fname
38 integer :: ii,id,rc, ncid, dim2(2),dim3(3)
39 integer :: idimid,jdimid,kdimid
51 rc = nf90_create(trim(fname), nf90_64bit_offset, ncid)
52 logmsg =
'==> writing tripole grid to '//trim(fname)
53 print
'(a)', trim(logmsg)
54 if(rc .ne. 0)print
'(a)',
'nf90_create = '//trim(nf90_strerror(rc))
56 rc = nf90_def_dim(ncid,
'ni', ni, idimid)
57 rc = nf90_def_dim(ncid,
'nj', nj, jdimid)
58 rc = nf90_def_dim(ncid,
'nv', nv, kdimid)
61 dim2(:) = (/idimid, jdimid/)
62 rc = nf90_def_var(ncid,
'wet', nf90_int, dim2, id)
63 rc = nf90_put_att(ncid, id,
'units',
'nd')
65 rc = nf90_def_var(ncid,
'area', nf90_double, dim2, id)
66 rc = nf90_put_att(ncid, id,
'units',
'm2')
68 rc = nf90_def_var(ncid,
'anglet', nf90_double, dim2, id)
69 rc = nf90_put_att(ncid, id,
'units',
'radians')
71 rc = nf90_def_var(ncid,
'depth', nf90_float, dim2, id)
72 rc = nf90_put_att(ncid, id,
'units',
'm')
74 dim2(:) = (/idimid, jdimid/)
76 rc = nf90_def_var(ncid, trim(fixvars(ii)%var_name), nf90_double, dim2, id)
77 rc = nf90_put_att(ncid, id,
'units', trim(fixvars(ii)%unit_name))
78 rc = nf90_put_att(ncid, id,
'long_name', trim(fixvars(ii)%long_name))
79 if(trim(fixvars(ii)%var_name(1:3)) .eq.
"lon")
then
80 rc = nf90_put_att(ncid, id,
'lon_bounds', trim(fixvars(ii)%vertices))
82 rc = nf90_put_att(ncid, id,
'lat_bounds', trim(fixvars(ii)%vertices))
86 dim3(:) = (/idimid, jdimid, kdimid/)
87 do ii = ncoord+1,ncoord+nverts
88 rc = nf90_def_var(ncid, trim(fixvars(ii)%var_name), nf90_double, dim3, id)
89 rc = nf90_put_att(ncid, id,
'units', trim(fixvars(ii)%unit_name))
90 rc = nf90_put_att(ncid, id,
'long_name', trim(fixvars(ii)%long_name))
93 rc = nf90_put_att(ncid, nf90_global,
'history', trim(history))
94 rc = nf90_enddef(ncid)
96 rc = nf90_inq_varid(ncid,
'wet', id)
97 rc = nf90_put_var(ncid, id, int(wet4))
99 rc = nf90_inq_varid(ncid,
'area', id)
100 rc = nf90_put_var(ncid, id, areact)
102 rc = nf90_inq_varid(ncid,
'anglet', id)
103 rc = nf90_put_var(ncid, id, anglet)
105 rc = nf90_inq_varid(ncid,
'depth', id)
106 rc = nf90_put_var(ncid, id, dp4)
108 rc = nf90_inq_varid(ncid,
'lonCt', id)
109 rc = nf90_put_var(ncid, id, lonct)
111 rc = nf90_inq_varid(ncid,
'latCt', id)
112 rc = nf90_put_var(ncid, id, latct)
114 rc = nf90_inq_varid(ncid,
'lonCv', id)
115 rc = nf90_put_var(ncid, id, loncv)
117 rc = nf90_inq_varid(ncid,
'latCv', id)
118 rc = nf90_put_var(ncid, id, latcv)
120 rc = nf90_inq_varid(ncid,
'lonCu', id)
121 rc = nf90_put_var(ncid, id, loncu)
123 rc = nf90_inq_varid(ncid,
'latCu', id)
124 rc = nf90_put_var(ncid, id, latcu)
126 rc = nf90_inq_varid(ncid,
'lonBu', id)
127 rc = nf90_put_var(ncid, id, lonbu)
129 rc = nf90_inq_varid(ncid,
'latBu', id)
130 rc = nf90_put_var(ncid, id, latbu)
133 rc = nf90_inq_varid(ncid,
'lonCt_vert', id)
134 rc = nf90_put_var(ncid, id, lonct_vert)
136 rc = nf90_inq_varid(ncid,
'latCt_vert', id)
137 rc = nf90_put_var(ncid, id, latct_vert)
139 rc = nf90_inq_varid(ncid,
'lonCv_vert', id)
140 rc = nf90_put_var(ncid, id, loncv_vert)
142 rc = nf90_inq_varid(ncid,
'latCv_vert', id)
143 rc = nf90_put_var(ncid, id, latcv_vert)
145 rc = nf90_inq_varid(ncid,
'lonCu_vert', id)
146 rc = nf90_put_var(ncid, id, loncu_vert)
148 rc = nf90_inq_varid(ncid,
'latCu_vert', id)
149 rc = nf90_put_var(ncid, id, latcu_vert)
151 rc = nf90_inq_varid(ncid,
'lonBu_vert', id)
152 rc = nf90_put_var(ncid, id, lonbu_vert)
154 rc = nf90_inq_varid(ncid,
'latBu_vert', id)
155 rc = nf90_put_var(ncid, id, latbu_vert)
157 rc = nf90_close(ncid)
subroutine, public write_tripolegrid(fname)
Write the tripole grid file.
subroutine fixvars_typedefine
Define the variables written to the tripole grid file.