39 character(len=LINELENGTH),
dimension(:),
allocatable :: param_names
41 integer(I4B),
dimension(:, :),
allocatable :: varids_param
42 integer(I4B),
dimension(:, :),
allocatable :: varids_aux
43 integer(I4B),
dimension(:),
pointer,
contiguous :: mshape => null()
44 integer(I4B),
pointer :: iper
45 integer(I4B) :: iper_export
46 integer(I4B) :: nparam
56 character(len=LINELENGTH) :: title
57 character(len=LINELENGTH) :: model
58 character(len=LINELENGTH) :: mesh
59 character(len=LINELENGTH) :: grid
60 character(len=LINELENGTH) :: history
61 character(len=LINELENGTH) :: source
62 character(len=LINELENGTH) :: conventions
63 character(len=LINELENGTH) :: stdname
64 character(len=LINELENGTH) :: longname
73 character(len=LENMODELNAME) :: modelname
74 character(len=LENCOMPONENTNAME) :: modeltype
75 character(len=LINELENGTH) :: modelfname
76 character(len=LINELENGTH) :: nc_fname
77 character(len=LINELENGTH) :: gridmap_name
78 character(len=LINELENGTH) :: mesh_name =
'mesh'
79 character(len=LENMEMPATH) :: dis_mempath
80 character(len=LENMEMPATH) :: ncf_mempath
81 character(len=LENBIGLINE) :: wkt
82 character(len=LINELENGTH) :: datetime
83 character(len=LINELENGTH) :: xname
84 character(len=LINELENGTH) :: lenunits
86 real(dp),
dimension(:),
pointer,
contiguous :: x
87 integer(I4B) :: disenum
89 integer(I4B) :: totnstp
90 integer(I4B),
pointer :: deflate
91 integer(I4B),
pointer :: shuffle
92 integer(I4B),
pointer :: input_attr
93 integer(I4B),
pointer :: chunk_time
95 logical(LGP) :: chunking_active
135 character(len=*),
intent(in) :: ilayer_varname
136 integer(I4B),
intent(in) :: ilayer
144 subroutine epkg_init(this, mf6_input, mshape, naux, param_names, &
152 integer(I4B),
dimension(:),
pointer,
contiguous,
intent(in) :: mshape
153 integer(I4B),
intent(in) :: naux
154 character(len=LINELENGTH),
dimension(:),
allocatable, &
155 intent(in) :: param_names
156 integer(I4B),
intent(in) :: nparam
158 character(len=LENVARNAME) :: rs_varname
159 character(len=LENMEMPATH) :: input_mempath
160 integer(I4B),
pointer :: rsvar
162 this%mf6_input = mf6_input
163 this%mshape => mshape
169 subcomponent=mf6_input%subcomponent_name, &
173 allocate (this%param_names(nparam))
174 allocate (this%param_reads(nparam))
175 allocate (this%varids_param(nparam, mshape(1)))
176 allocate (this%varids_aux(naux, mshape(1)))
180 this%param_names(n) = param_names(n)
181 rs_varname =
rsv_name(param_names(n))
182 call mem_setptr(rsvar, rs_varname, mf6_input%mempath)
183 this%param_reads(n)%invar => rsvar
187 call mem_setptr(this%iper,
'IPER', mf6_input%mempath)
195 if (
allocated(this%param_names))
deallocate (this%param_names)
200 subroutine set(this, modelname, modeltype, modelfname, nctype, disenum)
203 character(len=*),
intent(in) :: modelname
204 character(len=*),
intent(in) :: modeltype
205 character(len=*),
intent(in) :: modelfname
206 integer(I4B),
intent(in) :: nctype
207 integer(I4B),
intent(in) :: disenum
216 this%conventions =
''
221 this%conventions =
'CF-1.11'
223 trim(this%conventions)//
' UGRID-1.0'
226 select case (modeltype)
228 this%title = trim(modelname)//
' hydraulic head'
229 this%longname =
'head'
231 this%title = trim(modelname)//
' concentration'
232 this%longname =
'concentration'
234 this%title = trim(modelname)//
' temperature'
235 this%longname =
'temperature'
237 errmsg = trim(modeltype)//
' models not supported for NetCDF export.'
243 this%title = trim(this%title)//
' array input'
248 this%mesh =
'LAYERED'
252 if (disenum ==
dis)
then
253 this%grid =
'STRUCTURED'
254 else if (disenum ==
disv)
then
259 this%model = trim(modeltype)//
'6: '//trim(modelname)
262 this%source =
'MODFLOW 6 '//trim(adjustl(
version))
265 call date_and_time(values=values)
266 write (this%history,
'(a,i0,a,i0,a,i0,a,i0,a,i0,a,i0,a,i0)') &
267 'first created ', values(1),
'/', values(2),
'/', values(3),
' ', &
268 values(5),
':', values(6),
':', values(7),
'.', values(8)
273 subroutine export_init(this, modelname, modeltype, modelfname, nc_fname, &
274 disenum, nctype, iout)
282 character(len=*),
intent(in) :: modelname
283 character(len=*),
intent(in) :: modeltype
284 character(len=*),
intent(in) :: modelfname
285 character(len=*),
intent(in) :: nc_fname
286 integer(I4B),
intent(in) :: disenum
287 integer(I4B),
intent(in) :: nctype
288 integer(I4B),
intent(in) :: iout
289 character(len=LENMEMPATH) :: model_mempath
291 logical(LGP) :: found_mempath
294 allocate (this%deflate)
295 allocate (this%shuffle)
296 allocate (this%input_attr)
297 allocate (this%chunk_time)
300 this%modelname = modelname
301 this%modeltype = modeltype
302 this%modelfname = modelfname
303 this%nc_fname = nc_fname
304 this%gridmap_name =
''
305 this%ncf_mempath =
''
310 this%disenum = disenum
318 this%chunking_active = .false.
321 call this%annotation%set(modelname, modeltype, modelfname, nctype, disenum)
324 select case (modeltype)
328 this%xname =
'concentration'
330 this%xname =
'temperature'
332 errmsg = trim(modeltype)//
' models not supported for NetCDF export.'
338 if (disenum ==
dis)
then
340 else if (disenum ==
disu)
then
342 else if (disenum ==
disv)
then
351 call mem_set_value(this%ncf_mempath,
'NCF6_MEMPATH', this%dis_mempath, &
354 if (found_mempath)
then
357 call mem_set_value(this%deflate,
'DEFLATE', this%ncf_mempath, &
359 call mem_set_value(this%shuffle,
'SHUFFLE', this%ncf_mempath, &
361 call mem_set_value(this%input_attr,
'ATTR_OFF', this%ncf_mempath, &
363 call mem_set_value(this%chunk_time,
'CHUNK_TIME', this%ncf_mempath, &
364 ncf_found%chunk_time)
367 if (ncf_found%wkt)
then
368 this%gridmap_name =
'projection'
372 if (ncf_found%attr_off)
then
378 this%datetime =
'days since '//trim(
datetime0)
381 this%datetime =
'days since 1970-01-01T00:00:00'
386 errmsg =
'Adaptive time stepping not currently supported &
387 &with NetCDF exports.'
393 this%totnstp = sum(
nstp)
401 integer(I4B),
intent(in) :: idx
403 class(*),
pointer :: obj
405 obj => this%pkglist%GetItem(idx)
406 if (
associated(obj))
then
421 character(len=*),
intent(in) :: pkgname
423 character(len=LINELENGTH) :: attr
425 if (this%input_attr > 0)
then
438 character(len=*),
intent(in) :: pkgname
439 character(len=*),
intent(in) :: tagname
440 character(len=*),
intent(in) :: mempath
441 integer(I4B),
optional,
intent(in) :: layer
442 integer(I4B),
optional,
intent(in) :: iaux
443 character(len=LINELENGTH) :: varname
445 contiguous :: auxnames
446 character(len=LINELENGTH) :: pname, vname
450 if (
present(iaux))
then
452 if (tagname ==
'AUX')
then
454 call mem_setptr(auxnames,
'AUXILIARY', mempath)
455 vname = auxnames(iaux)
462 varname = trim(pname)//
'_'//trim(vname)
464 if (
present(layer))
then
467 write (varname,
'(a,i0)') trim(varname)//
'_l', layer
479 character(len=*),
intent(in) :: longname
480 character(len=*),
intent(in) :: pkgname
481 character(len=*),
intent(in) :: tagname
482 character(len=*),
intent(in) :: mempath
483 integer(I4B),
optional,
intent(in) :: layer
484 integer(I4B),
optional,
intent(in) :: iaux
485 character(len=LINELENGTH) :: lname
487 contiguous :: auxnames
488 character(len=LINELENGTH) :: pname, vname, auxname
493 if (longname ==
'')
then
494 lname = trim(pname)//
' '//trim(vname)
499 if (
present(iaux))
then
501 if (tagname ==
'AUX')
then
503 call mem_setptr(auxnames,
'AUXILIARY', mempath)
504 auxname = auxnames(iaux)
506 lname = trim(lname)//
' '//trim(auxname)
511 if (
present(layer))
then
513 write (lname,
'(a,i0)') trim(lname)//
' layer ', layer
525 do idx = 1, this%pkglist%Count()
526 export_pkg => this%get(idx)
528 if (export_pkg%iper /=
kper) cycle
530 if (export_pkg%iper_export >= export_pkg%iper) cycle
532 export_pkg%iper_export = export_pkg%iper
534 call this%package_step(export_pkg)
545 deallocate (this%deflate)
546 deallocate (this%shuffle)
547 deallocate (this%input_attr)
548 deallocate (this%chunk_time)
550 if (this%ncf_mempath /=
'')
then
abstract interfaces for model netcdf export type
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.
This module contains the LoadContextModule.
character(len=lenvarname) function, public rsv_name(mf6varname)
create read state variable name
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
character(len=linelength) function, public export_varname(pkgname, tagname, mempath, layer, iaux)
build netcdf variable name
subroutine epkg_init(this, mf6_input, mshape, naux, param_names, nparam)
initialize dynamic package export object
@, public netcdf_structured
netcdf structrured export
subroutine export_destroy(this)
destroy model netcdf export object
character(len=linelength) function, public export_longname(longname, pkgname, tagname, mempath, layer, iaux)
build netcdf variable longname
subroutine export_init(this, modelname, modeltype, modelfname, nc_fname, disenum, nctype, iout)
initialization of model netcdf export
@, public netcdf_mesh2d
netcdf ugrid layered mesh export
@, public netcdf_undef
undefined netcdf export type
subroutine set(this, modelname, modeltype, modelfname, nctype, disenum)
set netcdf file scoped attributes
character(len=linelength) function input_attribute(this, pkgname, idt)
build modflow_input attribute string
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 inats
flag indicating ats active for simulation
integer(i4b), pointer, public kper
current stress period number
This module contains version information.
character(len=40), parameter version
This class is used to store a single deferred-length character string. It was designed to work in an ...
A generic heterogeneous doubly-linked list.
Pointer type for read state variable.
abstract type for model netcdf export type
netcdf export attribute annotations
base class for an export model