34 integer(I4B) :: nmesh_node
35 integer(I4B) :: nmesh_face
36 integer(I4B) :: max_nmesh_face_nodes
46 integer(I4B) :: mesh_node_x
47 integer(I4B) :: mesh_node_y
48 integer(I4B) :: mesh_face_x
49 integer(I4B) :: mesh_face_y
50 integer(I4B) :: mesh_face_xbnds
51 integer(I4B) :: mesh_face_ybnds
52 integer(I4B) :: mesh_face_nodes
54 integer(I4B),
dimension(:),
allocatable :: dependent
64 integer(I4B),
pointer :: chunk_face
82 character(len=*),
intent(in) :: pkgtype
83 character(len=*),
intent(in) :: pkgname
84 character(len=*),
intent(in) :: mempath
98 subroutine mesh_init(this, modelname, modeltype, modelfname, nc_fname, &
99 disenum, nctype, iout)
102 character(len=*),
intent(in) :: modelname
103 character(len=*),
intent(in) :: modeltype
104 character(len=*),
intent(in) :: modelfname
105 character(len=*),
intent(in) :: nc_fname
106 integer(I4B),
intent(in) :: disenum
107 integer(I4B),
intent(in) :: nctype
108 integer(I4B),
intent(in) :: iout
109 logical(LGP) :: found
112 call this%NCModelExportType%init(modelname, modeltype, modelfname, nc_fname, &
113 disenum, nctype, iout)
116 allocate (this%chunk_face)
120 if (this%ncf_mempath /=
'')
then
121 call mem_set_value(this%chunk_face,
'CHUNK_FACE', this%ncf_mempath, found)
124 if (this%chunk_time > 0 .and. this%chunk_face > 0)
then
125 this%chunking_active = .true.
129 call nf_verify(nf90_create(this%nc_fname, &
130 iand(nf90_clobber, nf90_netcdf4), this%ncid), &
139 call nf_verify(nf90_close(this%ncid), this%nc_fname)
140 deallocate (this%chunk_face)
141 nullify (this%chunk_face)
149 call nf_verify(nf90_put_att(this%ncid, nf90_global,
'title', &
150 this%annotation%title), this%nc_fname)
152 call nf_verify(nf90_put_att(this%ncid, nf90_global,
'source', &
153 this%annotation%source), this%nc_fname)
155 call nf_verify(nf90_put_att(this%ncid, nf90_global,
'modflow6_grid', &
156 this%annotation%grid), this%nc_fname)
158 call nf_verify(nf90_put_att(this%ncid, nf90_global,
'modflow6_model', &
159 this%annotation%model), this%nc_fname)
161 call nf_verify(nf90_put_att(this%ncid, nf90_global,
'history', &
162 this%annotation%history), this%nc_fname)
164 call nf_verify(nf90_put_att(this%ncid, nf90_global,
'Conventions', &
165 this%annotation%conventions), &
174 character(len=*),
intent(in) :: pkgtype
175 character(len=*),
intent(in) :: pkgname
176 character(len=*),
intent(in) :: mempath
178 intent(in) :: param_dfns
180 integer(I4B) :: iparam, isize
182 do iparam = 1,
size(param_dfns)
184 idt => param_dfns(iparam)
186 if (idt%blockname ==
'GRIDDATA')
then
188 call get_isize(idt%mf6varname, mempath, isize)
190 call this%export_input_array(pkgtype, pkgname, mempath, idt)
206 character(LENCOMPONENTNAME) :: ptype, pname, pkgtype
207 character(len=LENMEMPATH) :: input_mempath
209 pointer :: pkgtypes => null()
211 pointer :: pkgnames => null()
213 pointer :: mempaths => null()
215 character(len=LENMEMPATH) :: mempath
217 integer(I4B),
pointer :: export_arrays
218 logical(LGP) :: found
223 call mem_setptr(pkgtypes,
'PKGTYPES', input_mempath)
224 call mem_setptr(pkgnames,
'PKGNAMES', input_mempath)
225 call mem_setptr(mempaths,
'MEMPATHS', input_mempath)
227 allocate (export_arrays)
229 do n = 1,
size(mempaths)
234 mempath = mempaths(n)
239 if (mempath /=
'')
then
241 call mem_set_value(export_arrays,
'EXPORT_NC', mempath, found)
242 if (export_arrays > 0)
then
244 param_dfns => param_definitions(this%modeltype, pkgtype)
245 call this%export_input_arrays(ptype, pname, mempath, param_dfns)
251 deallocate (export_arrays)
258 character(len=LINELENGTH) :: varname, longname
268 write (varname,
'(a,i0)') trim(this%xname)//
'_l', k
269 write (longname,
'(a,i0,a)') trim(this%annotation%longname)// &
273 call nf_verify(nf90_def_var(this%ncid, varname, nf90_double, &
274 (/this%dim_ids%nmesh_face, &
275 this%dim_ids%time/), &
276 this%var_ids%dependent(k)), &
280 if (this%chunking_active)
then
281 call nf_verify(nf90_def_var_chunking(this%ncid, &
282 this%var_ids%dependent(k), &
285 this%chunk_time/)), &
290 call ncvar_deflate(this%ncid, this%var_ids%dependent(k), this%deflate, &
291 this%shuffle, this%nc_fname)
294 call nf_verify(nf90_put_att(this%ncid, this%var_ids%dependent(k), &
295 'units',
'm'), this%nc_fname)
296 call nf_verify(nf90_put_att(this%ncid, this%var_ids%dependent(k), &
297 'standard_name', this%annotation%stdname), &
299 call nf_verify(nf90_put_att(this%ncid, this%var_ids%dependent(k), &
300 'long_name', longname), this%nc_fname)
301 call nf_verify(nf90_put_att(this%ncid, this%var_ids%dependent(k), &
304 call nf_verify(nf90_put_att(this%ncid, this%var_ids%dependent(k), &
305 'mesh', this%mesh_name), this%nc_fname)
306 call nf_verify(nf90_put_att(this%ncid, this%var_ids%dependent(k), &
307 'location',
'face'), this%nc_fname)
311 this%gridmap_name, this%nc_fname)
319 integer(I4B) :: var_id
322 if (this%ogc_wkt /=
'')
then
324 call nf_verify(nf90_redef(this%ncid), this%nc_fname)
325 call nf_verify(nf90_def_var(this%ncid, this%gridmap_name, nf90_int, &
326 var_id), this%nc_fname)
331 call nf_verify(nf90_put_att(this%ncid, var_id,
'wkt', this%ogc_wkt), &
333 call nf_verify(nf90_enddef(this%ncid), this%nc_fname)
334 call nf_verify(nf90_put_var(this%ncid, var_id, 1), &
345 call nf_verify(nf90_def_var(this%ncid, this%mesh_name, nf90_int, &
346 this%var_ids%mesh), this%nc_fname)
349 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh,
'cf_role', &
350 'mesh_topology'), this%nc_fname)
351 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh,
'long_name', &
352 '2D mesh topology'), this%nc_fname)
353 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh, &
354 'topology_dimension', 2), this%nc_fname)
355 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh,
'face_dimension', &
356 'nmesh_face'), this%nc_fname)
357 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh, &
358 'node_coordinates',
'mesh_node_x mesh_node_y'), &
360 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh, &
361 'face_coordinates',
'mesh_face_x mesh_face_y'), &
363 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh, &
364 'face_node_connectivity',
'mesh_face_nodes'), &
368 call nf_verify(nf90_def_var(this%ncid,
'mesh_node_x', nf90_double, &
369 (/this%dim_ids%nmesh_node/), &
370 this%var_ids%mesh_node_x), this%nc_fname)
373 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_node_x, &
374 'units',
'm'), this%nc_fname)
375 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_node_x, &
376 'standard_name',
'projection_x_coordinate'), &
378 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_node_x, &
379 'long_name',
'Easting'), this%nc_fname)
381 if (this%ogc_wkt /=
'')
then
383 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_node_x, &
384 'grid_mapping', this%gridmap_name), &
389 call nf_verify(nf90_def_var(this%ncid,
'mesh_node_y', nf90_double, &
390 (/this%dim_ids%nmesh_node/), &
391 this%var_ids%mesh_node_y), this%nc_fname)
394 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_node_y, &
395 'units',
'm'), this%nc_fname)
396 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_node_y, &
397 'standard_name',
'projection_y_coordinate'), &
399 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_node_y, &
400 'long_name',
'Northing'), this%nc_fname)
402 if (this%ogc_wkt /=
'')
then
404 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_node_y, &
405 'grid_mapping', this%gridmap_name), &
410 call nf_verify(nf90_def_var(this%ncid,
'mesh_face_x', nf90_double, &
411 (/this%dim_ids%nmesh_face/), &
412 this%var_ids%mesh_face_x), this%nc_fname)
415 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_face_x, &
416 'units',
'm'), this%nc_fname)
417 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_face_x, &
418 'standard_name',
'projection_x_coordinate'), &
420 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_face_x, &
421 'long_name',
'Easting'), this%nc_fname)
422 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_face_x,
'bounds', &
423 'mesh_face_xbnds'), this%nc_fname)
424 if (this%ogc_wkt /=
'')
then
426 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_face_x, &
427 'grid_mapping', this%gridmap_name), &
432 call nf_verify(nf90_def_var(this%ncid,
'mesh_face_xbnds', nf90_double, &
433 (/this%dim_ids%max_nmesh_face_nodes, &
434 this%dim_ids%nmesh_face/), &
435 this%var_ids%mesh_face_xbnds), &
439 call nf_verify(nf90_def_var(this%ncid,
'mesh_face_y', nf90_double, &
440 (/this%dim_ids%nmesh_face/), &
441 this%var_ids%mesh_face_y), this%nc_fname)
444 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_face_y, &
445 'units',
'm'), this%nc_fname)
446 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_face_y, &
447 'standard_name',
'projection_y_coordinate'), &
449 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_face_y, &
450 'long_name',
'Northing'), this%nc_fname)
451 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_face_y,
'bounds', &
452 'mesh_face_ybnds'), this%nc_fname)
454 if (this%ogc_wkt /=
'')
then
456 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_face_y, &
457 'grid_mapping', this%gridmap_name), &
462 call nf_verify(nf90_def_var(this%ncid,
'mesh_face_ybnds', nf90_double, &
463 (/this%dim_ids%max_nmesh_face_nodes, &
464 this%dim_ids%nmesh_face/), &
465 this%var_ids%mesh_face_ybnds), &
469 call nf_verify(nf90_def_var(this%ncid,
'mesh_face_nodes', nf90_int, &
470 (/this%dim_ids%max_nmesh_face_nodes, &
471 this%dim_ids%nmesh_face/), &
472 this%var_ids%mesh_face_nodes), &
476 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_face_nodes, &
477 'cf_role',
'face_node_connectivity'), &
479 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_face_nodes, &
481 'Vertices bounding cell (counterclockwise)'), &
483 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_face_nodes, &
484 '_FillValue', (/nf90_fill_int/)), &
486 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_face_nodes, &
487 'start_index', 1), this%nc_fname)
493 integer(I4B),
intent(in) :: ncid
494 integer(I4B),
intent(in) :: varid
495 integer(I4B),
intent(in) :: chunk_face
496 character(len=*),
intent(in) :: nc_fname
497 if (chunk_face > 0)
then
498 call nf_verify(nf90_def_var_chunking(ncid, varid, nf90_chunked, &
499 (/chunk_face/)), nc_fname)
506 integer(I4B),
intent(in) :: ncid
507 integer(I4B),
intent(in) :: varid
508 integer(I4B),
intent(in) :: deflate
509 integer(I4B),
intent(in) :: shuffle
510 character(len=*),
intent(in) :: nc_fname
511 if (deflate >= 0)
then
512 call nf_verify(nf90_def_var_deflate(ncid, varid, shuffle=shuffle, &
513 deflate=1, deflate_level=deflate), &
521 integer(I4B),
intent(in) :: ncid
522 integer(I4B),
intent(in) :: varid
523 character(len=*),
intent(in) :: gridmap_name
524 character(len=*),
intent(in) :: nc_fname
525 if (gridmap_name /=
'')
then
526 call nf_verify(nf90_put_att(ncid, varid,
'coordinates', &
527 'mesh_face_x mesh_face_y'), nc_fname)
528 call nf_verify(nf90_put_att(ncid, varid,
'grid_mapping', &
529 gridmap_name), nc_fname)
536 integer(I4B),
intent(in) :: ncid
537 integer(I4B),
intent(in) :: varid
538 integer(I4B),
intent(in) :: layer
539 integer(I4B),
intent(in) :: iper
540 integer(I4B),
intent(in) :: iaux
541 character(len=*),
intent(in) :: nc_tag
542 character(len=*),
intent(in) :: nc_fname
543 if (nc_tag /=
'')
then
544 call nf_verify(nf90_put_att(ncid, varid,
'modflow6_input', &
547 call nf_verify(nf90_put_att(ncid, varid,
'modflow6_layer', &
551 call nf_verify(nf90_put_att(ncid, varid,
'modflow6_iper', &
555 call nf_verify(nf90_put_att(ncid, varid,
'modflow6_iaux', &
565 character(len=*),
intent(in) :: varname
566 integer(I4B),
optional,
intent(in) :: layer
567 integer(I4B),
optional,
intent(in) :: iper
568 integer(I4B),
optional,
intent(in) :: iaux
569 character(len=LINELENGTH) :: vname
571 if (varname /=
'')
then
574 if (
present(layer))
then
576 write (vname,
'(a,i0)') trim(vname)//
'_l', layer
579 if (
present(iper))
then
581 write (vname,
'(a,i0)') trim(vname)//
'_p', iper
584 if (
present(iaux))
then
586 write (vname,
'(a,i0)') trim(vname)//
'a', iaux
abstract interfaces for derived ugrid netcd export types
This module contains simulation constants.
integer(i4b), parameter linelength
maximum length of a standard line
integer(i4b), parameter lencomponentname
maximum length of a component name
real(dp), parameter dnodata
real no data constant
real(dp), parameter dhnoflo
real no flow constant
integer(i4b), parameter lenmempath
maximum length of the memory path
type(inputparamdefinitiontype) function, dimension(:), pointer, public param_definitions(component, subcomponent)
logical function, public idm_multi_package(component, subcomponent)
This module defines variable data types.
character(len=lenmempath) function create_mem_path(component, subcomponent, context)
returns the path to the memory object
subroutine, public get_isize(name, mem_path, isize)
@ brief Get the number of elements for this variable
This module contains the MeshModelModule.
subroutine define_gridmap(this)
create the file grid mapping container variable
character(len=linelength) function, public export_varname(varname, layer, iper, iaux)
build netcdf variable name
subroutine, public ncvar_gridmap(ncid, varid, gridmap_name, nc_fname)
put variable gridmap attributes
subroutine mesh_init(this, modelname, modeltype, modelfname, nc_fname, disenum, nctype, iout)
initialize
subroutine, public ncvar_chunk(ncid, varid, chunk_face, nc_fname)
define variable chunking
subroutine mesh_destroy(this)
initialize
subroutine add_global_att(this)
create file (group) attributes
subroutine add_pkg_data(this)
determine packages to write gridded input
subroutine export_input_arrays(this, pkgtype, pkgname, mempath, param_dfns)
write package gridded input data
subroutine define_dependent(this)
create the model layer dependent variables
subroutine, public ncvar_deflate(ncid, varid, deflate, shuffle, nc_fname)
define variable compression
subroutine, public ncvar_mf6attr(ncid, varid, layer, iper, iaux, nc_tag, nc_fname)
put variable internal attributes
subroutine create_mesh(this)
create the file mesh container variable
This module contains the NCModelExportModule.
This module contains the NetCDFCommonModule.
subroutine, public nf_verify(res, nc_fname)
error check a netcdf-fortran interface call
This module contains simulation methods.
subroutine, public store_error(msg, terminate)
Store an error message.
subroutine, public store_error_filename(filename, terminate)
Store the erroring file name.
This module contains simulation variables.
character(len=maxcharlen) errmsg
error message string
character(len=linelength) idm_context
This module contains the SourceCommonModule.
character(len=lencomponentname) function, public idm_subcomponent_type(component, subcomponent)
component from package or model type
This class is used to store a single deferred-length character string. It was designed to work in an ...
base ugrid netcdf export type
type for storing model export dimension ids
type for storing model export variable ids
abstract type for model netcdf export type