12 use grdvars, only: ni,nj,mastertask
13 use grdvars, only: wet4,dp4,minimum_depth,maximum_depth,masking_depth
34 character(len=*),
intent(in) :: fsrc, fdst
37 integer :: rc,id,i,j,ii,jj,ncid,dimid,idimid,dim1(1)
38 integer :: cnt1=0, cnt2=0, icnt
39 integer(int_kind),
allocatable,
dimension(:) :: ieds1, jeds1, ieds2, jeds2
40 real(real_kind),
allocatable,
dimension(:) :: zeds1, zeds2
46 rc = nf90_open(trim(fsrc), nf90_nowrite, ncid)
47 print
'(a)',
'using topo edits file '//trim(fsrc)//
' to edit land mask '
49 rc = nf90_inq_dimid(ncid,
'nEdits', dimid)
50 rc = nf90_inquire_dimension(ncid, dimid, len=cnt1)
54 allocate(ieds1(cnt1)); ieds1 = 0
55 allocate(jeds1(cnt1)); jeds2 = 0
56 allocate(zeds1(cnt1)); zeds2 = 0.0
58 rc = nf90_open(fsrc, nf90_nowrite, ncid)
59 rc = nf90_inq_varid(ncid,
'iEdit', id)
60 rc = nf90_get_var(ncid, id, ieds1)
61 rc = nf90_inq_varid(ncid,
'jEdit', id)
62 rc = nf90_get_var(ncid, id, jeds1)
63 rc = nf90_inq_varid(ncid,
'zEdit', id)
64 rc = nf90_get_var(ncid, id, zeds1)
75 if(wet4(i,j) .eq. 1.0)icnt = icnt+1
78 print
'(a,i4,a,i4)',
'found ',icnt,
' open water points at j=1 , cnt2 = ',cnt2
82 allocate(ieds2(cnt2)); ieds2 = 0
83 allocate(jeds2(cnt2)); jeds2 = 0
84 allocate(zeds2(cnt2)); zeds2 = 0.0
86 ieds2(1:cnt1) = ieds1(1:cnt1)
87 jeds2(1:cnt1) = jeds1(1:cnt1)
88 zeds2(1:cnt1) = zeds1(1:cnt1)
97 if(wet4(i,j) .eq. 1.0)
then
110 rc = nf90_create(fdst, nf90_write, ncid)
111 print
'(a)',
'writing new topo edits to '//trim(fdst)
113 rc = nf90_def_dim(ncid,
'nEdits', cnt2, idimid)
115 rc = nf90_def_var(ncid,
'ni', nf90_int, id)
116 rc = nf90_def_var(ncid,
'nj', nf90_int, id)
119 rc = nf90_def_var(ncid,
'iEdit', nf90_int, dim1, id)
120 rc = nf90_def_var(ncid,
'jEdit', nf90_int, dim1, id)
121 rc = nf90_def_var(ncid,
'zEdit', nf90_float, dim1, id)
122 rc = nf90_put_att(ncid, nf90_global,
'history', trim(history))
123 rc = nf90_enddef(ncid)
125 rc = nf90_inq_varid(ncid,
'ni', id)
126 rc = nf90_put_var(ncid, id, ni)
127 rc = nf90_inq_varid(ncid,
'nj', id)
128 rc = nf90_put_var(ncid, id, nj)
130 rc = nf90_inq_varid(ncid,
'iEdit', id)
131 rc = nf90_put_var(ncid, id, ieds2)
132 rc = nf90_inq_varid(ncid,
'jEdit', id)
133 rc = nf90_put_var(ncid, id, jeds2)
134 rc = nf90_inq_varid(ncid,
'zEdit', id)
135 rc = nf90_put_var(ncid, id, zeds2)
137 rc = nf90_close(ncid)
144 ii = ieds2(i); jj = jeds2(i)
145 if(wet4(ii+1,jj+1) .eq. 0.0 .and. zeds2(i) .gt. 0.0)
then
146 wet4(ii+1,jj+1) = 1.0
147 print
'(a,2i4,a)',
'switch point ',ii+1,jj+1,
' from land->ocean at runtime'
149 if(wet4(ii+1,jj+1) .eq. 1.0 .and. zeds2(i) .eq. 0.0)
then
150 wet4(ii+1,jj+1) = 0.0
151 print
'(a,2i4,a)',
'switch point ',ii+1,jj+1,
' from ocean->land at runtime'
154 deallocate(ieds1, jeds1, zeds1)
155 deallocate(ieds2, jeds2, zeds2)
167 character(len=*),
intent(in) :: fsrc
170 integer :: rc,ncid,id,dimid,i,j,ii,jj,cnt1
171 integer(int_kind),
allocatable,
dimension(:) :: ieds1, jeds1
172 real(real_kind),
allocatable,
dimension(:) :: zeds1
174 logical :: file_exists
179 inquire(file=trim(fsrc),exist=file_exists)
180 if (file_exists)
then
181 rc = nf90_open(trim(fsrc), nf90_nowrite, ncid)
182 print
'(a)',
'using topo edits file '//trim(fsrc)//
' to adjust bathymetry '
184 rc = nf90_inq_dimid(ncid,
'nEdits', dimid)
185 rc = nf90_inquire_dimension(ncid, dimid, len=cnt1)
186 rc = nf90_close(ncid)
189 allocate(ieds1(cnt1))
190 allocate(jeds1(cnt1))
191 allocate(zeds1(cnt1))
193 rc = nf90_open(fsrc, nf90_nowrite, ncid)
194 rc = nf90_inq_varid(ncid,
'iEdit', id)
195 rc = nf90_get_var(ncid, id, ieds1)
196 rc = nf90_inq_varid(ncid,
'jEdit', id)
197 rc = nf90_get_var(ncid, id, jeds1)
198 rc = nf90_inq_varid(ncid,
'zEdit', id)
199 rc = nf90_get_var(ncid, id, zeds1)
200 rc = nf90_close(ncid)
204 ii = ieds1(i); jj = jeds1(i)
205 print
'(a,3i5,f8.2,a,f8.2)',
'Ocean topography edit: ', i, ii+1, jj+1 , dp4(ii+1,jj+1),
'->', abs(zeds1(i))
206 dp4(ii+1,jj+1) = abs(zeds1(i))
208 deallocate(ieds1, jeds1, zeds1)
215 print
'(a)',
'Applying topo limits to ensure that min_depth < D(x,y) < max_depth '
216 print
'(a, f8.2)',
'Using min_depth = ',minimum_depth
217 print
'(a, f8.2)',
'Using max_depth = ',maximum_depth
220 if(dp4(i,j) > min(minimum_depth,masking_depth))
then
221 dp4(i,j) = min( max(dp4(i,j), minimum_depth), maximum_depth)
subroutine, public apply_topoedits(fsrc)
Read the topoedits file and adjust the bathymetry.
subroutine, public add_topoedits(fsrc, fdst)
Read the existing topoedits file, append required topoedits and write a new topoedits file...