WAVEWATCH III  beta 0.0.1
scrip_remap_read Module Reference

Functions/Subroutines

subroutine read_remap_ww3 (map_name, interp_file, errorCode)
 
subroutine read_remap_scrip_ww3
 

Function/Subroutine Documentation

◆ read_remap_scrip_ww3()

subroutine scrip_remap_read::read_remap_scrip_ww3

Definition at line 251 of file scrip_remap_read.f.

251 
252 !-----------------------------------------------------------------------
253 !
254 ! the routine reads a netCDF file to extract remapping info
255 ! in SCRIP format
256 !
257 ! Only read variables needed by WW3
258 !
259 !-----------------------------------------------------------------------
260 !-----------------------------------------------------------------------
261 !
262 ! local variables
263 !
264 !-----------------------------------------------------------------------
265 
266  character (SCRIP_charLength) ::
267  & grid1_name ! grid name for source grid
268  &, grid2_name ! grid name for dest grid
269 
270  integer (SCRIP_i4) ::
271  & n ! dummy index
272  &, errorCode ! error code for SCRIP routine
273 
274  integer (SCRIP_i4), dimension(:), allocatable ::
275  & grid1_mask_int, ! integer masks to determine
276  & grid2_mask_int ! cells that participate in map
277 
278  character (20), parameter ::
279  & rtnName = 'read_remap_scrip_ww3'
280 
281 !-----------------------------------------------------------------------
282 !
283 ! read some additional global attributes
284 !
285 !-----------------------------------------------------------------------
286 
287  !***
288  !*** source and destination grid names
289  !***
290 
291  grid1_name = ' '
292  grid2_name = ' '
293  errorcode = scrip_success
294  ncstat = nf90_get_att(nc_file_id, nf90_global, 'source_grid',
295  & grid1_name)
296  if (scrip_netcdferrorcheck(ncstat, errorcode, rtnname, 'error
297  & reading source grid name')) return
298 
299  ncstat = nf90_get_att(nc_file_id, nf90_global, 'dest_grid',
300  & grid2_name)
301  if (scrip_netcdferrorcheck(ncstat, errorcode, rtnname, 'error
302  & reading destination grid name')) return
303 
304 ! Let's not include routine write statements w/out check on improc, l_master, etc.
305 ! print *,' '
306 ! print *,'Remapping between:',trim(grid1_name)
307 ! print *,'and ',trim(grid2_name)
308 ! print *,' '
309 
310 !-----------------------------------------------------------------------
311 !
312 ! read dimension information
313 !
314 !-----------------------------------------------------------------------
315 
316  ncstat = nf90_inq_dimid(nc_file_id, 'dst_grid_size',
317  & nc_dstgrdsize_id)
318  if (scrip_netcdferrorcheck(ncstat, errorcode, rtnname, 'error
319  & reading destination grid id')) return
320 ! ncstat = nf90_inq_dimlen(nc_file_id, nc_dstgrdsize_id, grid2_size)
321  ncstat = nf90_inquire_dimension(nc_file_id, nc_dstgrdsize_id,
322  & len = grid2_size)
323  if (scrip_netcdferrorcheck(ncstat, errorcode, rtnname, 'error
324  & reading destination grid size')) return
325 
326  ncstat = nf90_inq_dimid(nc_file_id, 'num_links',
327  & nc_numlinks_id)
328  if (scrip_netcdferrorcheck(ncstat, errorcode, rtnname, 'error
329  & reading number of links id')) return
330 ! ncstat = nf90_inq_dimlen(nc_file_id, nc_numlinks_id,
331 ! & num_links_map1)
332  ncstat = nf90_inquire_dimension(nc_file_id, nc_numlinks_id,
333  & len = num_links_map1)
334  if (scrip_netcdferrorcheck(ncstat, errorcode, rtnname, 'error
335  & reading number of links')) return
337 
338  ncstat = nf90_inq_dimid(nc_file_id, 'num_wgts',
339  & nc_numwgts_id)
340  if (scrip_netcdferrorcheck(ncstat, errorcode, rtnname, 'error
341  & reading number of weights id')) return
342 ! ncstat = nf90_inq_dimlen(nc_file_id, nc_numwgts_id, num_wts)
343  ncstat = nf90_inquire_dimension(nc_file_id, nc_numwgts_id,
344  & len = num_wts)
345  if (scrip_netcdferrorcheck(ncstat, errorcode, rtnname, 'error
346  & reading number of weights')) return
347 
348 !-----------------------------------------------------------------------
349 !
350 ! allocate arrays
351 !
352 !-----------------------------------------------------------------------
353 
354 ! grid2_frac is allocated in grid_init
355  if(allocated(grid2_frac))deallocate(grid2_frac)
356  allocate( grid2_frac(grid2_size) )
357 
358 ! grid1_add_map1, grid2_add_map1, wts_map1 are allocated in init_remap_vars
359  if(allocated(grid1_add_map1))deallocate(grid1_add_map1)
360  if(allocated(grid2_add_map1))deallocate(grid2_add_map1)
361  if(allocated(wts_map1))deallocate(wts_map1)
362  allocate( grid1_add_map1(num_links_map1),
365 
366 !-----------------------------------------------------------------------
367 !
368 ! get variable ids
369 !
370 !-----------------------------------------------------------------------
371 
372  ncstat = nf90_inq_varid(nc_file_id, 'dst_grid_frac',
373  & nc_dstgrdfrac_id)
374  if (scrip_netcdferrorcheck(ncstat, errorcode, rtnname, 'error
375  & reading destination grid fraction id')) return
376 
377  ncstat = nf90_inq_varid(nc_file_id, 'src_address',
378  & nc_srcgrdadd_id)
379  if (scrip_netcdferrorcheck(ncstat, errorcode, rtnname, 'error
380  & reading source grid address id')) return
381 
382  ncstat = nf90_inq_varid(nc_file_id, 'dst_address',
383  & nc_dstgrdadd_id)
384  if (scrip_netcdferrorcheck(ncstat, errorcode, rtnname, 'error
385  & reading destination grid address id')) return
386 
387  ncstat = nf90_inq_varid(nc_file_id, 'remap_matrix',
388  & nc_rmpmatrix_id)
389  if (scrip_netcdferrorcheck(ncstat, errorcode, rtnname, 'error
390  & reading remap matrix id')) return
391 
392 !-----------------------------------------------------------------------
393 !
394 ! read all variables
395 !
396 !-----------------------------------------------------------------------
397 
398  ncstat = nf90_get_var(nc_file_id, nc_dstgrdfrac_id,
399  & grid2_frac)
400  if (scrip_netcdferrorcheck(ncstat, errorcode, rtnname, 'error
401  & reading destination grid fraction')) return
402 
403  ncstat = nf90_get_var(nc_file_id, nc_srcgrdadd_id,
404  & grid1_add_map1)
405  if (scrip_netcdferrorcheck(ncstat, errorcode, rtnname, 'error
406  & reading source grid address')) return
407 
408  ncstat = nf90_get_var(nc_file_id, nc_dstgrdadd_id,
409  & grid2_add_map1)
410  if (scrip_netcdferrorcheck(ncstat, errorcode, rtnname, 'error
411  & reading destination grid address')) return
412 
413  ncstat = nf90_get_var(nc_file_id, nc_rmpmatrix_id,
414  & wts_map1)
415  if (scrip_netcdferrorcheck(ncstat, errorcode, rtnname, 'error
416  & reading remap weights')) return
417 
418 
419  ncstat = nf90_close(nc_file_id)
420  if (scrip_netcdferrorcheck(ncstat, errorcode, rtnname, 'error
421  & closing netCDF file')) return
422 
423 !-----------------------------------------------------------------------
424 

References scrip_remap_vars::grid1_add_map1, scrip_remap_vars::grid2_add_map1, scrip_grids::grid2_frac, scrip_grids::grid2_size, scrip_remap_vars::max_links_map1, scrip_remap_vars::num_links_map1, scrip_remap_vars::num_wts, scrip_netcdfmod::scrip_netcdferrorcheck(), scrip_errormod::scrip_success, and scrip_remap_vars::wts_map1.

Referenced by read_remap_ww3().

◆ read_remap_ww3()

subroutine scrip_remap_read::read_remap_ww3 ( character(scrip_charlength), intent(out)  map_name,
character(scrip_charlength), intent(in)  interp_file,
integer (scrip_i4)  errorCode 
)

Definition at line 115 of file scrip_remap_read.f.

115 
116 !-----------------------------------------------------------------------
117 !
118 ! this driver routine reads some global attributes and then
119 ! calls a specific read routine based on file conventions
120 !
121 !-----------------------------------------------------------------------
122 
123 !-----------------------------------------------------------------------
124 !
125 ! input variables
126 !
127 !-----------------------------------------------------------------------
128 
129  character(SCRIP_CharLength), intent(in) ::
130  & interp_file ! filename for remap data
131 
132 !-----------------------------------------------------------------------
133 !
134 ! output variables
135 !
136 !-----------------------------------------------------------------------
137 
138  character(SCRIP_CharLength), intent(out) ::
139  & map_name ! name for mapping
140 
141 !-----------------------------------------------------------------------
142 !
143 ! local variables
144 !
145 !-----------------------------------------------------------------------
146 
147  integer (SCRIP_i4) ::
148  & errorCode ! error code for SCRIP routine
149 
150  character (14), parameter ::
151  & rtnName = 'read_remap_ww3'
152 
153 !-----------------------------------------------------------------------
154 !
155 ! open file and read some global information
156 !
157 !-----------------------------------------------------------------------
158 
159  ncstat = nf90_open(interp_file, nf90_noclobber, nc_file_id)
160  if (scrip_netcdferrorcheck(ncstat, errorcode, rtnname, 'error
161  & opening interpolation file')) return
162 
163  !***
164  !*** map name
165  !***
166  map_name = ' '
167  ncstat = nf90_get_att(nc_file_id, nf90_global, 'title',
168  & map_name)
169  if (scrip_netcdferrorcheck(ncstat, errorcode, rtnname, 'error
170  & reading map name')) return
171 
172 
173  !***
174  !*** normalization option
175  !***
176  normalize_opt = ' '
177  ncstat = nf90_get_att(nc_file_id, nf90_global, 'normalization',
178  & normalize_opt)
179  if (scrip_netcdferrorcheck(ncstat, errorcode, rtnname, 'error
180  & reading interpolation option')) return
181 
182  select case(normalize_opt)
183  case ('none')
185  case ('fracarea')
187  case ('destarea')
189  case default
190  print *,'normalize_opt = ',normalize_opt
191  stop 'Invalid normalization option'
192  end select
193 
194  !***
195  !*** map method
196  !***
197  map_method = ' '
198  ncstat = nf90_get_att(nc_file_id, nf90_global, 'map_method',
199  & map_method)
200  if (scrip_netcdferrorcheck(ncstat, errorcode, rtnname, 'error
201  & reading map method')) return
202 
203  select case(map_method)
204  case('Conservative remapping')
206  case('Bilinear remapping')
208  case('Distance weighted avg of nearest neighbors')
210  case('Bicubic remapping')
212  case default
213  print *,'map_type = ',map_method
214  stop 'Invalid Map Type'
215  end select
216 
217  !***
218  !*** file convention
219  !***
220  convention = ' '
221  ncstat = nf90_get_att(nc_file_id, nf90_global, 'conventions',
222  & convention)
223  if (scrip_netcdferrorcheck(ncstat, errorcode, rtnname, 'error
224  & reading file convention')) return
225 
226 !-----------------------------------------------------------------------
227 !
228 ! call appropriate read routine based on output convention
229 !
230 !-----------------------------------------------------------------------
231 
232  select case(convention)
233  case ('SCRIP')
235  case ('NCAR-CSM')
236  print *,'convention = NCAR-CSM not supported for WW3'
237  stop 'unsupported file convention'
238 ! call read_remap_csm
239  case default
240  print *,'convention = ',convention
241  stop 'unknown output file convention'
242  end select
243 
244 !-----------------------------------------------------------------------
245 

References scrip_remap_vars::map_type, scrip_remap_vars::map_type_bicubic, scrip_remap_vars::map_type_bilinear, scrip_remap_vars::map_type_conserv, scrip_remap_vars::map_type_distwgt, scrip_remap_vars::norm_opt, scrip_remap_vars::norm_opt_dstarea, scrip_remap_vars::norm_opt_frcarea, scrip_remap_vars::norm_opt_none, read_remap_scrip_ww3(), and scrip_netcdfmod::scrip_netcdferrorcheck().

Referenced by scrip_interface::scrip().

scrip_remap_vars::norm_opt_none
integer(scrip_i4), parameter norm_opt_none
Definition: scrip_remap_vars.f:54
scrip_remap_vars::grid1_add_map1
integer(scrip_i4), dimension(:), allocatable, save grid1_add_map1
Definition: scrip_remap_vars.f:77
scrip_remap_vars::map_type_bilinear
integer(scrip_i4), parameter map_type_bilinear
Definition: scrip_remap_vars.f:59
scrip_remap_vars::num_links_map1
integer(scrip_i4), save num_links_map1
Definition: scrip_remap_vars.f:66
scrip_remap_vars::norm_opt
integer(scrip_i4), save norm_opt
Definition: scrip_remap_vars.f:66
scrip_remap_vars::map_type
integer(scrip_i4), save map_type
Definition: scrip_remap_vars.f:66
scrip_remap_read::read_remap_scrip_ww3
subroutine read_remap_scrip_ww3
Definition: scrip_remap_read.f:251
scrip_remap_vars::norm_opt_frcarea
integer(scrip_i4), parameter norm_opt_frcarea
Definition: scrip_remap_vars.f:54
scrip_remap_vars::max_links_map1
integer(scrip_i4), save max_links_map1
Definition: scrip_remap_vars.f:66
scrip_errormod::scrip_success
integer(scrip_i4), parameter, public scrip_success
Definition: scrip_errormod.f90:42
scrip_grids::grid2_size
integer(scrip_i4), save grid2_size
Definition: scrip_grids.f:68
scrip_grids::grid1_name
character(scrip_charlength), save grid1_name
Definition: scrip_grids.f:77
scrip_grids::grid2_name
character(scrip_charlength), save grid2_name
Definition: scrip_grids.f:77
scrip_remap_vars::wts_map1
real(scrip_r8), dimension(:,:), allocatable, save wts_map1
Definition: scrip_remap_vars.f:83
scrip_remap_vars::map_type_distwgt
integer(scrip_i4), parameter map_type_distwgt
Definition: scrip_remap_vars.f:59
scrip_remap_vars::map_type_conserv
integer(scrip_i4), parameter map_type_conserv
Definition: scrip_remap_vars.f:59
scrip_remap_vars::grid2_add_map1
integer(scrip_i4), dimension(:), allocatable, save grid2_add_map1
Definition: scrip_remap_vars.f:77
scrip_remap_vars::map_type_bicubic
integer(scrip_i4), parameter map_type_bicubic
Definition: scrip_remap_vars.f:59
scrip_remap_vars::norm_opt_dstarea
integer(scrip_i4), parameter norm_opt_dstarea
Definition: scrip_remap_vars.f:54
scrip_remap_vars::num_wts
integer(scrip_i4), save num_wts
Definition: scrip_remap_vars.f:66
scrip_grids::grid2_frac
real(scrip_r8), dimension(:), allocatable, target, save grid2_frac
Definition: scrip_grids.f:103