28 character(len=*),
intent(in) :: src, wgt
31 integer,
parameter :: ntile = 6
32 integer(int_kind) :: n_a, n_b, n_s
34 integer(int_kind),
allocatable,
dimension(:) :: col, row
35 real(dbl_kind),
allocatable,
dimension(:) :: s
36 real(dbl_kind),
allocatable,
dimension(:) :: lat1d, lon1d
38 integer(int_kind),
allocatable,
dimension(:) :: src_field
39 real(dbl_kind),
allocatable,
dimension(:) :: dst_field
41 real(dbl_kind),
allocatable,
dimension(:,:) :: dst2d
42 real(dbl_kind),
allocatable,
dimension(:,:) :: lat2d,lon2d
44 character(len=CS) :: ctile
45 character(len=CL) :: fdst
46 integer :: i,ii,jj,id,rc,ncid, dim2(2)
48 integer :: idimid,jdimid
50 character(len=CM) :: vname
55 rc = nf90_open(trim(wgt), nf90_nowrite, ncid)
56 rc = nf90_inq_dimid(ncid,
'n_s', id)
57 rc = nf90_inquire_dimension(ncid, id, len=n_s)
58 rc = nf90_inq_dimid(ncid,
'n_a', id)
59 rc = nf90_inquire_dimension(ncid, id, len=n_a)
60 rc = nf90_inq_dimid(ncid,
'n_b', id)
61 rc = nf90_inquire_dimension(ncid, id, len=n_b)
67 allocate(lat1d(1:n_b))
68 allocate(lon1d(1:n_b))
70 rc = nf90_inq_varid(ncid,
'col', id)
71 rc = nf90_get_var(ncid, id, col)
72 rc = nf90_inq_varid(ncid,
'row', id)
73 rc = nf90_get_var(ncid, id, row)
74 rc = nf90_inq_varid(ncid,
'S', id)
75 rc = nf90_get_var(ncid, id, s)
78 rc = nf90_inq_varid(ncid,
'yc_b', id)
79 rc = nf90_get_var(ncid, id, lat1d)
80 rc = nf90_inq_varid(ncid,
'xc_b', id)
81 rc = nf90_get_var(ncid, id, lon1d)
88 allocate(src_field(1:n_a))
89 allocate(dst_field(1:n_b))
91 rc = nf90_open(trim(src), nf90_nowrite, ncid)
94 rc = nf90_inq_varid(ncid,
'grid_imask', id)
95 rc = nf90_get_var(ncid, id, src_field)
100 ii = row(i); jj = col(i)
101 dst_field(ii) = dst_field(ii) + s(i)*
real(src_field(jj),dbl_kind)
108 allocate(dst2d(npx,npx))
109 allocate(lon2d(npx,npx));
allocate(lat2d(npx,npx))
113 iend = istr+npx*npx-1
116 write(ctile,
'(a5,i1)')
'.tile',i+1
117 fdst = trim(dirout)//
'/'//trim(atmres)//
'.mx'//trim(res)//trim(ctile)//
'.nc'
118 logmsg =
'creating mapped ocean mask file '//trim(fdst)
119 print
'(a)',trim(logmsg)
121 dst2d(:,:) = reshape(dst_field(istr:iend), (/npx,npx/))
122 lat2d(:,:) = reshape( lat1d(istr:iend), (/npx,npx/))
123 lon2d(:,:) = reshape( lon1d(istr:iend), (/npx,npx/))
125 rc = nf90_create(trim(fdst), nf90_64bit_offset, ncid)
126 rc = nf90_def_dim(ncid,
'grid_xt', npx, idimid)
127 rc = nf90_def_dim(ncid,
'grid_yt', npx, jdimid)
129 dim2(:) = (/idimid, jdimid/)
131 rc = nf90_def_var(ncid, vname, nf90_double, dim2, id)
133 rc = nf90_def_var(ncid, vname, nf90_double, dim2, id)
135 rc = nf90_def_var(ncid, vname, nf90_double, dim2, id)
136 rc = nf90_enddef(ncid)
138 rc = nf90_inq_varid(ncid,
'grid_xt', id)
139 rc = nf90_put_var(ncid, id, lon2d)
140 rc = nf90_inq_varid(ncid,
'grid_yt', id)
141 rc = nf90_put_var(ncid, id, lat2d)
142 rc = nf90_inq_varid(ncid,
'land_frac', id)
143 rc = nf90_put_var(ncid, id, dst2d)
144 rc = nf90_close(ncid)
151 deallocate(col, row, s, lat1d, lon1d, src_field, dst_field)
152 deallocate(dst2d,lon2d,lat2d)
subroutine make_frac_land(src, wgt)
Use ESMF weights to map the ocean land mask to the FV3 tiles and write the mapped mask to 6 tile file...