38 character(len=LINELENGTH),
dimension(:),
allocatable :: param_names
40 integer(I4B),
dimension(:),
pointer,
contiguous :: mshape => null()
41 integer(I4B),
pointer :: iper
42 integer(I4B) :: iper_export
43 integer(I4B) :: nparam
52 character(len=LINELENGTH) :: title
53 character(len=LINELENGTH) :: model
54 character(len=LINELENGTH) :: grid
55 character(len=LINELENGTH) :: history
56 character(len=LINELENGTH) :: source
57 character(len=LINELENGTH) :: conventions
58 character(len=LINELENGTH) :: stdname
59 character(len=LINELENGTH) :: longname
68 character(len=LENMODELNAME) :: modelname
69 character(len=LENCOMPONENTNAME) :: modeltype
70 character(len=LINELENGTH) :: modelfname
71 character(len=LINELENGTH) :: nc_fname
72 character(len=LINELENGTH) :: gridmap_name
73 character(len=LINELENGTH) :: mesh_name =
'mesh'
74 character(len=LENMEMPATH) :: dis_mempath
75 character(len=LENMEMPATH) :: ncf_mempath
76 character(len=LENBIGLINE) :: ogc_wkt
77 character(len=LINELENGTH) :: datetime
78 character(len=LINELENGTH) :: xname
80 real(dp),
dimension(:),
pointer,
contiguous :: x
81 integer(I4B) :: disenum
83 integer(I4B) :: stepcnt
84 integer(I4B) :: totnstp
85 integer(I4B),
pointer :: deflate
86 integer(I4B),
pointer :: shuffle
87 integer(I4B),
pointer :: input_attr
88 integer(I4B),
pointer :: chunk_time
90 logical(LGP) :: chunking_active
130 character(len=*),
intent(in) :: ilayer_varname
131 integer(I4B),
intent(in) :: ilayer
139 subroutine epkg_init(this, mf6_input, mshape, param_names, &
148 integer(I4B),
dimension(:),
pointer,
contiguous,
intent(in) :: mshape
149 character(len=LINELENGTH),
dimension(:),
allocatable, &
150 intent(in) :: param_names
151 integer(I4B),
intent(in) :: nparam
153 character(len=LENVARNAME) :: rs_varname
154 character(len=LENMEMPATH) :: input_mempath
155 integer(I4B),
pointer :: rsvar
157 this%mf6_input = mf6_input
158 this%mshape => mshape
163 subcomponent=mf6_input%subcomponent_name, &
167 allocate (this%param_names(nparam))
168 allocate (this%param_reads(nparam))
172 this%param_names(n) = param_names(n)
173 rs_varname =
rsv_name(param_names(n))
174 call mem_setptr(rsvar, rs_varname, mf6_input%mempath)
175 this%param_reads(n)%invar => rsvar
179 call mem_setptr(this%iper,
'IPER', mf6_input%mempath)
188 if (
allocated(this%param_names))
deallocate (this%param_names)
193 subroutine set(this, modelname, modeltype, modelfname, nctype)
196 character(len=*),
intent(in) :: modelname
197 character(len=*),
intent(in) :: modeltype
198 character(len=*),
intent(in) :: modelfname
199 integer(I4B),
intent(in) :: nctype
200 character(len=LINELENGTH) :: fullname
208 this%conventions =
''
213 this%conventions =
'CF-1.11'
215 trim(this%conventions)//
' UGRID-1.0'
218 select case (modeltype)
220 fullname =
'Groundwater Flow'
221 this%title = trim(modelname)//
' hydraulic head'
222 this%longname =
'head'
224 fullname =
'Groundwater Transport'
225 this%title = trim(modelname)//
' concentration'
226 this%longname =
'concentration'
228 fullname =
'Groundwater Energy'
229 this%title = trim(modelname)//
' temperature'
230 this%longname =
'temperature'
232 errmsg = trim(modeltype)//
' models not supported for NetCDF export.'
239 this%grid =
'LAYERED MESH'
241 this%grid =
'STRUCTURED'
245 this%model = trim(modelname)//
': MODFLOW 6 '//trim(fullname)// &
246 ' ('//trim(modeltype)//
') model'
249 this%source =
'MODFLOW 6 '//trim(adjustl(
version))
252 call date_and_time(values=values)
253 write (this%history,
'(a,i0,a,i0,a,i0,a,i0,a,i0,a,i0,a,i0)') &
254 'first created ', values(1),
'/', values(2),
'/', values(3),
' ', &
255 values(5),
':', values(6),
':', values(7),
'.', values(8)
260 subroutine export_init(this, modelname, modeltype, modelfname, disenum, &
271 character(len=*),
intent(in) :: modelname
272 character(len=*),
intent(in) :: modeltype
273 character(len=*),
intent(in) :: modelfname
274 integer(I4B),
intent(in) :: disenum
275 integer(I4B),
intent(in) :: nctype
276 integer(I4B),
intent(in) :: iout
277 character(len=LENMEMPATH) :: model_mempath
279 logical(LGP) :: found_mempath
282 allocate (this%deflate)
283 allocate (this%shuffle)
284 allocate (this%input_attr)
285 allocate (this%chunk_time)
288 this%modelname = modelname
289 this%modeltype = modeltype
290 this%modelfname = modelfname
291 this%nc_fname = trim(modelname)//
'.nc'
292 this%gridmap_name =
''
293 this%ncf_mempath =
''
297 this%disenum = disenum
306 this%chunking_active = .false.
311 call this%annotation%set(modelname, modeltype, modelfname, nctype)
314 select case (modeltype)
318 this%xname =
'concentration'
320 this%xname =
'temperature'
322 errmsg = trim(modeltype)//
' models not supported for NetCDF export.'
328 if (disenum == dis)
then
330 else if (disenum == disu)
then
332 else if (disenum == disv)
then
341 call mem_set_value(this%ncf_mempath,
'NCF6_MEMPATH', this%dis_mempath, &
344 if (found_mempath)
then
345 call mem_set_value(this%ogc_wkt,
'OGC_WKT', this%ncf_mempath, &
347 call mem_set_value(this%deflate,
'DEFLATE', this%ncf_mempath, &
349 call mem_set_value(this%shuffle,
'SHUFFLE', this%ncf_mempath, &
351 call mem_set_value(this%input_attr,
'ATTR_OFF', this%ncf_mempath, &
353 call mem_set_value(this%chunk_time,
'CHUNK_TIME', this%ncf_mempath, &
357 if (found%ogc_wkt)
then
358 this%gridmap_name =
'projection'
362 if (found%attr_off)
then
368 errmsg =
'TDIS parameter START_DATE_TIME required for NetCDF export.'
372 this%datetime =
'days since '//trim(
datetime0)
376 this%totnstp = sum(
nstp)
384 integer(I4B),
intent(in) :: idx
386 class(*),
pointer :: obj
389 obj => this%pkglist%GetItem(idx)
390 if (
associated(obj))
then
405 character(len=*),
intent(in) :: pkgname
407 character(len=LINELENGTH) :: attr
411 if (this%input_attr > 0)
then
421 character(len=*),
intent(in) :: longname
422 character(len=*),
intent(in) :: pkgname
423 character(len=*),
intent(in) :: tagname
424 integer(I4B),
intent(in) :: layer
425 integer(I4B),
optional,
intent(in) :: iper
426 character(len=LINELENGTH) :: lname
427 character(len=LINELENGTH) :: pname, vname
433 if (longname ==
'')
then
434 lname = trim(pname)//
' '//trim(vname)
439 write (lname,
'(a,i0)') trim(lname)//
' layer=', layer
441 if (
present(iper))
then
443 write (lname,
'(a,i0)') trim(lname)//
' period=', iper
454 integer(I4B) :: idx, ilayer
456 character(len=LENVARNAME) :: ilayer_varname
458 do idx = 1, this%pkglist%Count()
460 export_pkg => this%get(idx)
462 if (export_pkg%iper /=
kper) cycle
464 if (export_pkg%iper_export >= export_pkg%iper) cycle
466 export_pkg%iper_export = export_pkg%iper
472 ilayer_varname =
'I'//trim(export_pkg%mf6_input%subcomponent_type(1:3))
475 ilayer =
ifind(export_pkg%param_names, ilayer_varname)
478 if (ilayer == 1)
then
479 call this%package_step_ilayer(export_pkg, ilayer_varname, ilayer)
481 call this%package_step(export_pkg)
495 deallocate (this%deflate)
496 deallocate (this%shuffle)
497 deallocate (this%input_attr)
498 deallocate (this%chunk_time)
501 if (this%ncf_mempath /=
'')
then
abstract interfaces for model netcdf export type
This module contains the BoundInputContextModule.
character(len=lenvarname) function, public rsv_name(mf6varname)
create read state variable name
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
@ mvalidate
validation mode - do not run time steps
integer(i4b), parameter lenmodelname
maximum length of the model name
integer(i4b), parameter lenbigline
maximum length of a big line
@ disu
DISV6 discretization.
@ dis
DIS6 discretization.
@ disv
DISU6 discretization.
integer(i4b), parameter lenvarname
maximum length of a variable name
integer(i4b), parameter lenmempath
maximum length of the memory path
This module defines variable data types.
character(len=lenmemseparator), parameter mempathseparator
used to build up the memory address for the stored variables
character(len=lenmempath) function create_mem_path(component, subcomponent, context)
returns the path to the memory object
subroutine, public memorystore_remove(component, subcomponent, context)
This module contains the NCModelExportModule.
class(exportpackagetype) function, pointer export_get(this, idx)
retrieve dynamic export object from package list
subroutine epkg_init(this, mf6_input, mshape, param_names, nparam)
initialize dynamic package export object
subroutine export_init(this, modelname, modeltype, modelfname, disenum, nctype, iout)
initialization of model netcdf export
@, public netcdf_structured
netcdf structrured export
character(len=linelength) function, public export_longname(longname, pkgname, tagname, layer, iper)
build netcdf variable longname
subroutine export_destroy(this)
destroy model netcdf export object
subroutine set(this, modelname, modeltype, modelfname, nctype)
set netcdf file scoped attributes
@, public netcdf_undef
undefined netcdf export type
character(len=linelength) function input_attribute(this, pkgname, idt)
build modflow6_input attribute string
@, public netcdf_ugrid
netcdf mesh export
subroutine epkg_destroy(this)
destroy dynamic package export object
subroutine export_input(this)
netcdf dynamic package period export
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
integer(i4b) isim_mode
simulation mode
integer(i4b), dimension(:), pointer, public, contiguous nstp
number of time steps in each stress period
character(len=lendatetime), pointer, public datetime0
starting date and time for the simulation
integer(i4b), pointer, public kper
current stress period number
This module contains version information.
character(len=40), parameter version
Pointer type for read state variable.
A generic heterogeneous doubly-linked list.
abstract type for model netcdf export type
netcdf export attribute annotations
base class for an export model