MODFLOW 6 version 6.9.0.dev0
USGS Modular Hydrologic Model
Loading...
Searching...
No Matches
NCModel.f90
Go to the documentation of this file.
1!> @brief This module contains the NCModelExportModule
2!!
3!! This module defines a model export and base type for
4!! supported netcdf files and is not dependent on
5!! netcdf libraries.
6!!
7!<
9
10 use kindmodule, only: dp, i4b, lgp
20 use listmodule, only: listtype
21
22 implicit none
23 private
25 public :: ncexportannotation
26 public :: exportpackagetype
33
34 !> @brief netcdf export types enumerator
35 !<
36 ENUM, BIND(C)
37 ENUMERATOR :: netcdf_undef = 0 !< undefined netcdf export type
38 ENUMERATOR :: netcdf_structured = 1 !< netcdf structrured export
39 ENUMERATOR :: netcdf_mesh2d = 2 !< netcdf ugrid layered mesh export
40 END ENUM
41
43 type(modflowinputtype) :: mf6_input !< description of modflow6 input
44 character(len=LINELENGTH), dimension(:), allocatable :: param_names !< dynamic param tagnames
45 type(readstatevartype), dimension(:), allocatable :: param_reads !< param read states
46 integer(I4B), dimension(:, :), allocatable :: varids_param
47 integer(I4B), dimension(:, :), allocatable :: varids_aux
48 integer(I4B), dimension(:), pointer, contiguous :: mshape => null() !< model shape
49 integer(I4B), pointer :: iper !< most recent package rp load
50 integer(I4B) :: eper !< most recent period of netcdf package export
51 integer(I4B) :: nparam !< number of in scope params
52 integer(I4B) :: naux !< number of auxiliary variables
53 integer(I4B), dimension(:), pointer, &
54 contiguous :: aux_reads => null() !< read state of each auxiliary variable
55 logical(LGP), dimension(:), allocatable :: param_value !< param has input in effect
56 logical(LGP), dimension(:), allocatable :: aux_value !< aux has input in effect
57 contains
58 procedure :: init => epkg_init
59 procedure :: destroy => epkg_destroy
60 procedure :: update_state
61 procedure :: param_state
62 procedure :: aux_state
63 procedure :: user_nodes
64 end type exportpackagetype
65
66 !> @brief netcdf export attribute annotations
67 !<
69 character(len=LINELENGTH) :: title !< file scoped title attribute
70 character(len=LINELENGTH) :: model !< file scoped model attribute
71 character(len=LINELENGTH) :: mesh !< mesh type
72 character(len=LINELENGTH) :: grid !< grid type
73 character(len=LINELENGTH) :: history !< file scoped history attribute
74 character(len=LINELENGTH) :: source !< file scoped source attribute
75 character(len=LINELENGTH) :: conventions !< file scoped conventions attribute
76 character(len=LINELENGTH) :: stdname !< dependent variable standard name
77 character(len=LINELENGTH) :: longname !< dependent variable long name
78 contains
79 procedure :: set
80 end type ncexportannotation
81
82 !> @brief base class for an export model
83 !<
85 type(listtype) :: pkglist
86 character(len=LENMODELNAME) :: modelname !< name of model
87 character(len=LENCOMPONENTNAME) :: modeltype !< type of model
88 character(len=LINELENGTH) :: modelfname !< name of model input file
89 character(len=LINELENGTH) :: nc_fname !< name of netcdf export file
90 character(len=LINELENGTH) :: gridmap_name !< name of grid mapping variable
91 character(len=LINELENGTH) :: mesh_name = 'mesh' !< name of mesh container variable
92 character(len=LENMEMPATH) :: dis_mempath !< discretization input mempath
93 character(len=LENMEMPATH) :: ncf_mempath !< netcdf utility package input mempath
94 character(len=LENBIGLINE) :: wkt !< WKT1 (OGC 01-009) user string
95 character(len=LENBIGLINE) :: crs_wkt !< WKT2 (ISO 19162:2019) user string; falls back to wkt if empty
96 character(len=LINELENGTH) :: datetime !< export file creation time
97 character(len=LINELENGTH) :: xname !< dependent variable name
98 character(len=LINELENGTH) :: lenunits !< unidata udunits length units
99 type(ncexportannotation) :: annotation !< export file annotation
100 real(dp), dimension(:), pointer, contiguous :: x !< dependent variable pointer
101 integer(I4B) :: disenum !< type of discretization
102 integer(I4B) :: ncid !< netcdf file descriptor
103 integer(I4B) :: totnstp !< simulation total number of steps
104 integer(I4B), pointer :: deflate !< variable deflate level
105 integer(I4B), pointer :: shuffle !< variable shuffle filter
106 integer(I4B), pointer :: input_attr !< assign variable input attr
107 integer(I4B), pointer :: chunk_time !< chunking parameter for time dimension
108 integer(I4B) :: iout !< lst file descriptor
109 logical(LGP) :: chunking_active !< have chunking parameters been provided
110 contains
111 procedure :: init => export_init
112 procedure :: get => export_get
113 procedure :: input_attribute
114 procedure :: istp
115 procedure :: destroy => export_destroy
116 end type ncmodelexporttype
117
118 !> @brief abstract type for model netcdf export type
119 !<
120 type, abstract, extends(ncmodelexporttype) :: ncbasemodelexporttype
121 contains
122 procedure :: export_input
123 procedure(model_define), deferred :: df
124 procedure(package_export), deferred :: export_df
125 procedure(model_step), deferred :: step
126 procedure(package_export), deferred :: package_step
127 end type ncbasemodelexporttype
128
129 !> @brief abstract interfaces for model netcdf export type
130 !<
131 abstract interface
132 subroutine model_define(this)
134 class(ncbasemodelexporttype), intent(inout) :: this
135 end subroutine
136 subroutine model_step(this)
138 class(ncbasemodelexporttype), intent(inout) :: this
139 end subroutine
140 subroutine package_export(this, export_pkg)
142 class(ncbasemodelexporttype), intent(inout) :: this
143 class(exportpackagetype), pointer, intent(in) :: export_pkg
144 end subroutine
145 subroutine package_export_ilayer(this, export_pkg, ilayer_varname, &
146 ilayer)
148 class(ncbasemodelexporttype), intent(inout) :: this
149 class(exportpackagetype), pointer, intent(in) :: export_pkg
150 character(len=*), intent(in) :: ilayer_varname
151 integer(I4B), intent(in) :: ilayer
152 end subroutine
153 end interface
154
155contains
156
157 !> @brief initialize dynamic package export object
158 !<
159 subroutine epkg_init(this, mf6_input, mshape, naux, param_names, &
160 nparam)
165 class(exportpackagetype), intent(inout) :: this
166 type(modflowinputtype), intent(in) :: mf6_input
167 integer(I4B), dimension(:), pointer, contiguous, intent(in) :: mshape !< model shape
168 integer(I4B), intent(in) :: naux
169 character(len=LINELENGTH), dimension(:), allocatable, &
170 intent(in) :: param_names
171 integer(I4B), intent(in) :: nparam
172 integer(I4B) :: n
173 character(len=LENVARNAME) :: rs_varname
174 character(len=LENMEMPATH) :: input_mempath
175 integer(I4B), pointer :: rsvar
176
177 this%mf6_input = mf6_input
178 this%mshape => mshape
179 this%nparam = nparam
180 this%naux = naux
181 this%eper = 0
182
183 input_mempath = create_mem_path(component=mf6_input%component_name, &
184 subcomponent=mf6_input%subcomponent_name, &
185 context=idm_context)
186
187 ! allocate param arrays
188 allocate (this%param_names(nparam))
189 allocate (this%param_reads(nparam))
190 allocate (this%varids_param(nparam, mshape(1)))
191 allocate (this%varids_aux(naux, mshape(1)))
192
193 ! set param arrays
194 do n = 1, nparam
195 this%param_names(n) = param_names(n)
196 rs_varname = rsv_name(param_names(n))
197 call mem_setptr(rsvar, rs_varname, mf6_input%mempath)
198 this%param_reads(n)%invar => rsvar
199 end do
200
201 ! set pointer to loaded input period
202 call mem_setptr(this%iper, 'IPER', mf6_input%mempath)
203
204 ! read state of each auxiliary variable
205 call mem_setptr(this%aux_reads, 'INAUXVARS', mf6_input%mempath)
206
207 ! input in effect before the first period: the layer index array
208 ! (e.g. IRCH, IEVT) is 1, other arrays have no input
209 allocate (this%param_value(nparam))
210 allocate (this%aux_value(naux))
211 this%param_value = .false.
212 this%aux_value = .false.
213 do n = 1, nparam
214 if (param_names(n) == 'I'//trim(mf6_input%subcomponent_type(1:3))) &
215 this%param_value(n) = .true.
216 end do
217 end subroutine epkg_init
218
219 !> @brief Update input in effect from the period block read states
220 !!
221 !! A block gives an array as values or as a time-array series. Arrays
222 !! not given keep their input. An array linked to a series has no input
223 !! to export, and none after the link until it is given values.
224 !<
225 subroutine update_state(this)
226 use tdismodule, only: kper
227 class(exportpackagetype), intent(inout) :: this
228 integer(I4B) :: n
229 if (this%iper /= kper) return
230 do n = 1, this%nparam
231 call set_state(this%param_reads(n)%invar, this%param_value(n))
232 end do
233 do n = 1, this%naux
234 call set_state(this%aux_reads(n), this%aux_value(n))
235 end do
236 end subroutine update_state
237
238 !> @brief Set input in effect from a read state
239 !<
240 subroutine set_state(invar, has_value)
241 integer(I4B), intent(in) :: invar
242 logical(LGP), intent(inout) :: has_value
243 select case (invar)
244 case (rs_values, rs_netcdf)
245 has_value = .true.
246 case (rs_series)
247 has_value = .false.
248 end select
249 end subroutine set_state
250
251 !> @brief .true. if a param has input in effect to export
252 !!
253 !! The auxiliary variable param has input if any auxiliary variable has.
254 !<
255 function param_state(this, iparam) result(exported)
256 class(exportpackagetype), intent(in) :: this
257 integer(I4B), intent(in) :: iparam
258 logical(LGP) :: exported
259 if (this%param_names(iparam) == 'AUX') then
260 exported = any(this%aux_value)
261 else
262 exported = this%param_value(iparam)
263 end if
264 end function param_state
265
266 !> @brief .true. if an auxiliary variable has input in effect to export
267 !<
268 function aux_state(this, iaux) result(exported)
269 class(exportpackagetype), intent(in) :: this
270 integer(I4B), intent(in) :: iaux
271 logical(LGP) :: exported
272 exported = this%aux_value(iaux)
273 end function aux_state
274
275 !> @brief Set user node values from a loaded period array
276 !!
277 !! Grid array input is indexed by boundary (NODEULIST, NBOUND), or by
278 !! user node when NODEULIST is empty. Other user nodes keep their value
279 !! in nodes.
280 !<
281 subroutine user_nodes(this, vals, nodes)
283 class(exportpackagetype), intent(in) :: this
284 real(DP), dimension(:), intent(in) :: vals !< loaded period array
285 real(DP), dimension(:), intent(inout) :: nodes !< user node values
286 integer(I4B), dimension(:), pointer, contiguous :: nodeulist
287 integer(I4B), pointer :: nbound
288 integer(I4B) :: n
289 call mem_setptr(nodeulist, 'NODEULIST', this%mf6_input%mempath)
290 if (size(nodeulist) == 0) then
291 nodes(1:size(vals)) = vals
292 else
293 call mem_setptr(nbound, 'NBOUND', this%mf6_input%mempath)
294 do n = 1, nbound
295 nodes(nodeulist(n)) = vals(n)
296 end do
297 end if
298 end subroutine user_nodes
299
300 !> @brief destroy dynamic package export object
301 !<
302 subroutine epkg_destroy(this)
304 class(exportpackagetype), intent(inout) :: this
305 if (allocated(this%param_names)) deallocate (this%param_names)
306 if (allocated(this%param_value)) deallocate (this%param_value)
307 if (allocated(this%aux_value)) deallocate (this%aux_value)
308 nullify (this%aux_reads)
309 end subroutine epkg_destroy
310
311 !> @brief set netcdf file scoped attributes
312 !<
313 subroutine set(this, modelname, modeltype, modelfname, nctype, disenum)
314 use versionmodule, only: fullversion
315 use inputoutputmodule, only: lowcase
316 class(ncexportannotation), intent(inout) :: this
317 character(len=*), intent(in) :: modelname
318 character(len=*), intent(in) :: modeltype
319 character(len=*), intent(in) :: modelfname
320 integer(I4B), intent(in) :: nctype
321 integer(I4B), intent(in) :: disenum
322 integer :: values(8)
323
324 this%title = ''
325 this%model = ''
326 this%mesh = ''
327 this%grid = ''
328 this%history = ''
329 this%source = ''
330 this%conventions = ''
331 this%stdname = ''
332 this%longname = ''
333
334 ! set file conventions
335 this%conventions = 'CF-1.13'
336 if (nctype == netcdf_mesh2d) this%conventions = &
337 trim(this%conventions)//' UGRID-1.0'
338
339 ! set model specific attributes
340 select case (modeltype)
341 case ('GWF')
342 this%title = trim(modelname)//' hydraulic head'
343 this%longname = 'head'
344 case ('GWT')
345 this%title = trim(modelname)//' concentration'
346 this%longname = 'concentration'
347 case ('GWE')
348 this%title = trim(modelname)//' temperature'
349 this%longname = 'temperature'
350 case default
351 errmsg = trim(modeltype)//' models not supported for NetCDF export.'
352 call store_error(errmsg)
353 call store_error_filename(modelfname)
354 end select
355
356 if (isim_mode == mvalidate) then
357 this%title = trim(this%title)//' array input'
358 end if
359
360 ! set mesh type
361 if (nctype == netcdf_mesh2d) then
362 this%mesh = 'layered'
363 end if
364
365 ! set grid type
366 if (disenum == dis) then
367 this%grid = 'structured'
368 else if (disenum == disv) then
369 this%grid = 'vertex'
370 end if
371
372 ! model description string (lowercase, no version suffix, matching CF convention)
373 this%model = trim(modeltype)//': '//trim(modelname)
374 call lowcase(this%model)
375
376 ! modflow6 version string
377 this%source = 'MODFLOW 6 '//trim(adjustl(fullversion))
378
379 ! create timestamp
380 call date_and_time(values=values)
381 write (this%history, '(a,i0,a,i0,a,i0,a,i0,a,i0,a,i0,a,i0)') &
382 'first created ', values(1), '/', values(2), '/', values(3), ' ', &
383 values(5), ':', values(6), ':', values(7), '.', values(8)
384 end subroutine set
385
386 !> @brief initialization of model netcdf export
387 !<
388 subroutine export_init(this, modelname, modeltype, modelfname, nc_fname, &
389 disenum, nctype, iout)
390 use tdismodule, only: datetime0, nper, nstp
394 use inputoutputmodule, only: lowcase
397 class(ncmodelexporttype), intent(inout) :: this
398 character(len=*), intent(in) :: modelname
399 character(len=*), intent(in) :: modeltype
400 character(len=*), intent(in) :: modelfname
401 character(len=*), intent(in) :: nc_fname
402 integer(I4B), intent(in) :: disenum
403 integer(I4B), intent(in) :: nctype
404 integer(I4B), intent(in) :: iout
405 character(len=LENMEMPATH) :: model_mempath
406 type(utlncfparamfoundtype) :: ncf_found
407
408 ! allocate
409 allocate (this%deflate)
410 allocate (this%shuffle)
411 allocate (this%input_attr)
412 allocate (this%chunk_time)
413
414 ! initialize
415 this%modelname = modelname
416 this%modeltype = modeltype
417 this%modelfname = modelfname
418 this%nc_fname = nc_fname
419 this%gridmap_name = ''
420 this%ncf_mempath = ''
421 this%wkt = ''
422 this%crs_wkt = ''
423 this%datetime = ''
424 this%xname = ''
425 this%lenunits = ''
426 this%disenum = disenum
427 this%ncid = 0
428 this%totnstp = 0
429 this%deflate = -1
430 this%shuffle = 0
431 this%input_attr = 1
432 this%chunk_time = -1
433 this%iout = iout
434 this%chunking_active = .false.
435
436 ! set file scoped attributes
437 call this%annotation%set(modelname, modeltype, modelfname, nctype, disenum)
438
439 ! set dependent variable basename
440 select case (modeltype)
441 case ('GWF')
442 this%xname = 'head'
443 case ('GWT')
444 this%xname = 'concentration'
445 case ('GWE')
446 this%xname = 'temperature'
447 case default
448 errmsg = trim(modeltype)//' models not supported for NetCDF export.'
449 call store_error(errmsg)
450 call store_error_filename(modelfname)
451 end select
452
453 ! set discretization input mempath
454 if (disenum == dis) then
455 this%dis_mempath = create_mem_path(modelname, 'DIS', idm_context)
456 else if (disenum == disu) then
457 this%dis_mempath = create_mem_path(modelname, 'DISU', idm_context)
458 else if (disenum == disv) then
459 this%dis_mempath = create_mem_path(modelname, 'DISV', idm_context)
460 end if
461
462 ! set dependent variable pointer
463 model_mempath = create_mem_path(component=modelname)
464 call mem_setptr(this%x, 'X', model_mempath)
465
466 ! set ncf_mempath if provided
467 if (filein_fname(this%ncf_mempath, 'NCF6_MEMPATH', this%dis_mempath, &
468 modelfname)) then
469 call mem_set_value(this%wkt, 'WKT', this%ncf_mempath, &
470 ncf_found%wkt)
471 call mem_set_value(this%crs_wkt, 'CRS_WKT', this%ncf_mempath, &
472 ncf_found%crs_wkt)
473 call mem_set_value(this%deflate, 'DEFLATE', this%ncf_mempath, &
474 ncf_found%deflate)
475 call mem_set_value(this%shuffle, 'SHUFFLE', this%ncf_mempath, &
476 ncf_found%shuffle)
477 call mem_set_value(this%input_attr, 'ATTR_OFF', this%ncf_mempath, &
478 ncf_found%attr_off)
479 call mem_set_value(this%chunk_time, 'CHUNK_TIME', this%ncf_mempath, &
480 ncf_found%chunk_time)
481 end if
482
483 if (ncf_found%wkt .or. ncf_found%crs_wkt) then
484 this%gridmap_name = 'projection'
485 end if
486
487 ! ATTR_OFF turns off modflow 6 input attributes
488 if (ncf_found%attr_off) then
489 this%input_attr = 0
490 end if
491
492 ! set datetime string
493 if (datetime0 /= '') then
494 this%datetime = 'days since '//trim(datetime0)
495 else
496 ! January 1, 1970 at 00:00:00 UTC
497 this%datetime = 'days since 1970-01-01T00:00:00'
498 end if
499
500 ! set total nstp
501 if (isim_mode == mvalidate) then
502 this%totnstp = nper
503 else
504 this%totnstp = sum(nstp)
505 end if
506 end subroutine export_init
507
508 !> @brief retrieve dynamic export object from package list
509 !<
510 function export_get(this, idx) result(res)
511 use listmodule, only: listtype
512 class(ncmodelexporttype), intent(inout) :: this
513 integer(I4B), intent(in) :: idx
514 class(exportpackagetype), pointer :: res
515 class(*), pointer :: obj
516 nullify (res)
517 obj => this%pkglist%GetItem(idx)
518 if (associated(obj)) then
519 select type (obj)
520 class is (exportpackagetype)
521 res => obj
522 end select
523 end if
524 end function export_get
525
526 !> @brief build modflow_input attribute string
527 !<
528 function input_attribute(this, pkgname, idt) result(attr)
529 use inputoutputmodule, only: lowcase
532 class(ncmodelexporttype), intent(inout) :: this
533 character(len=*), intent(in) :: pkgname
534 type(inputparamdefinitiontype), pointer, intent(in) :: idt
535 character(len=LINELENGTH) :: attr
536 attr = ''
537 if (this%input_attr > 0) then
538 attr = trim(this%modelname)//mempathseparator//trim(pkgname)// &
539 mempathseparator//trim(idt%tagname)
540 call lowcase(attr)
541 end if
542 end function input_attribute
543
544 !> @brief step index for timeseries data
545 !<
546 function istp(this)
547 use tdismodule, only: kstp, kper, nstp
548 class(ncmodelexporttype), intent(inout) :: this
549 integer(I4B) :: n, istp
550 istp = kstp
551 if (kper > 1) then
552 do n = 1, kper - 1
553 istp = istp + nstp(n)
554 end do
555 end if
556 end function istp
557
558 !> @brief build netcdf variable name
559 !<
560 function export_varname(pkgname, tagname, mempath, layer, iaux) &
561 result(varname)
564 use inputoutputmodule, only: lowcase
565 character(len=*), intent(in) :: pkgname
566 character(len=*), intent(in) :: tagname
567 character(len=*), intent(in) :: mempath
568 integer(I4B), optional, intent(in) :: layer
569 integer(I4B), optional, intent(in) :: iaux
570 character(len=LINELENGTH) :: varname
571 type(characterstringtype), dimension(:), pointer, &
572 contiguous :: auxnames
573 character(len=LINELENGTH) :: pname, vname
574 vname = tagname
575 pname = pkgname
576
577 if (present(iaux)) then
578 if (iaux > 0) then
579 if (tagname == 'AUX') then
580 ! reset vname to auxiliary variable name
581 call mem_setptr(auxnames, 'AUXILIARY', mempath)
582 vname = auxnames(iaux)
583 end if
584 end if
585 end if
586
587 call lowcase(vname)
588 call lowcase(pname)
589 varname = trim(pname)//'_'//trim(vname)
590
591 if (present(layer)) then
592 if (layer > 0) then
593 !write (varname, '(a,i0)') trim(varname)//'_L', layer
594 write (varname, '(a,i0)') trim(varname)//'_l', layer
595 end if
596 end if
597 end function export_varname
598
599 !> @brief build netcdf variable longname
600 !<
601 function export_longname(longname, pkgname, tagname, mempath, layer, iaux, &
602 component_type, subcomponent_type) result(lname)
605 use inputoutputmodule, only: lowcase
607 character(len=*), intent(in) :: longname
608 character(len=*), intent(in) :: pkgname
609 character(len=*), intent(in) :: tagname
610 character(len=*), intent(in) :: mempath
611 integer(I4B), optional, intent(in) :: layer
612 integer(I4B), optional, intent(in) :: iaux
613 character(len=*), optional, intent(in) :: component_type
614 character(len=*), optional, intent(in) :: subcomponent_type
615 character(len=LINELENGTH) :: lname
616 type(characterstringtype), dimension(:), pointer, &
617 contiguous :: auxnames
618 character(len=LINELENGTH) :: pname, vname, auxname
619 pname = pkgname
620 vname = tagname
621 call lowcase(pname)
622 call lowcase(vname)
623 if (longname == '') then
624 lname = trim(pname)//' '//trim(vname)
625 else
626 lname = longname
627 if (present(component_type) .and. present(subcomponent_type)) then
628 if (idm_multi_package(component_type, subcomponent_type)) then
629 lname = trim(pname)//' '//trim(lname)
630 end if
631 end if
632 end if
633
634 if (present(iaux)) then
635 if (iaux > 0) then
636 if (tagname == 'AUX') then
637 ! reset vname to auxiliary variable name
638 call mem_setptr(auxnames, 'AUXILIARY', mempath)
639 auxname = auxnames(iaux)
640 call lowcase(auxname)
641 lname = trim(lname)//' '//trim(auxname)
642 end if
643 end if
644 end if
645
646 if (present(layer)) then
647 if (layer > 0) then
648 write (lname, '(a,i0)') trim(lname)//' layer ', layer
649 end if
650 end if
651 end function export_longname
652
653 !> @brief netcdf dynamic package period export
654 !<
655 subroutine export_input(this)
656 use tdismodule, only: kper
657 class(ncbasemodelexporttype), intent(inout) :: this
658 integer(I4B) :: idx
659 class(exportpackagetype), pointer :: export_pkg
660 do idx = 1, this%pkglist%Count()
661 export_pkg => this%get(idx)
662 ! period input already exported
663 if (export_pkg%eper >= kper) cycle
664 ! update export package
665 call this%package_step(export_pkg)
666 ! update exported iper
667 export_pkg%eper = kper
668 end do
669 end subroutine export_input
670
671 !> @brief map a WKT string to a CF-1.13 grid_mapping_name
672 !!
673 !! Accepts either WKT1 (OGC 01-009, PROJECTION["name"]) or WKT2
674 !! (ISO 19162:2019, METHOD["name"]) format. WKT1 is tried first;
675 !! if PROJECTION[ is absent the WKT2 METHOD[ path is attempted.
676 !! Returns '' for geographic CRS or unrecognised projection names.
677 !! Only common groundwater projections included. Matching is
678 !! case-insensitive.
679 !<
680 function wkt_to_cf_gridmapping(wkt) result(gmname)
681 use inputoutputmodule, only: upcase
682 character(len=*), intent(in) :: wkt
683 character(len=LINELENGTH) :: gmname
684 character(len=LINELENGTH) :: proj_name
685 character(len=LENBIGLINE) :: wkt_upper
686 integer :: istart, iend
687
688 gmname = ''
689 proj_name = ''
690
691 ! uppercase copy for case-insensitive keyword search
692 wkt_upper = wkt
693 call upcase(wkt_upper)
694
695 ! --- WKT1 path: PROJECTION["name"] ---
696 istart = index(wkt_upper, 'PROJECTION[')
697 if (istart /= 0) then
698 istart = istart + len('PROJECTION[')
699 do while (istart <= len(wkt))
700 if (wkt(istart:istart) == '"') exit
701 istart = istart + 1
702 end do
703 if (istart > len(wkt)) return
704 istart = istart + 1
705 iend = index(wkt(istart:), '"')
706 if (iend == 0) return
707 iend = istart + iend - 2
708 if (iend < istart) return
709 proj_name = wkt(istart:iend)
710 call upcase(proj_name)
711 select case (trim(proj_name))
712 case ('TRANSVERSE_MERCATOR')
713 gmname = 'transverse_mercator'
714 case ('LAMBERT_CONFORMAL_CONIC_2SP', 'LAMBERT_CONFORMAL_CONIC_1SP')
715 gmname = 'lambert_conformal_conic'
716 case ('ALBERS_CONIC_EQUAL_AREA')
717 gmname = 'albers_conical_equal_area'
718 case ('MERCATOR_1SP', 'MERCATOR_2SP')
719 gmname = 'mercator'
720 case ('POLAR_STEREOGRAPHIC')
721 gmname = 'polar_stereographic'
722 end select
723 return
724 end if
725
726 ! --- WKT2 path: METHOD["name"] ---
727 istart = index(wkt_upper, 'METHOD[')
728 if (istart == 0) return
729 istart = istart + len('METHOD[')
730 do while (istart <= len(wkt))
731 if (wkt(istart:istart) == '"') exit
732 istart = istart + 1
733 end do
734 if (istart > len(wkt)) return
735 istart = istart + 1
736 iend = index(wkt(istart:), '"')
737 if (iend == 0) return
738 iend = istart + iend - 2
739 if (iend < istart) return
740 proj_name = wkt(istart:iend)
741 call upcase(proj_name)
742 select case (trim(proj_name))
743 case ('TRANSVERSE MERCATOR')
744 gmname = 'transverse_mercator'
745 case ('LAMBERT CONIC CONFORMAL (2SP)', 'LAMBERT CONIC CONFORMAL (1SP)')
746 gmname = 'lambert_conformal_conic'
747 case ('ALBERS EQUAL AREA')
748 gmname = 'albers_conical_equal_area'
749 case ('MERCATOR (VARIANT A)', 'MERCATOR (VARIANT B)')
750 gmname = 'mercator'
751 case ('POLAR STEREOGRAPHIC (VARIANT A)', 'POLAR STEREOGRAPHIC (VARIANT B)')
752 gmname = 'polar_stereographic'
753 end select
754 end function wkt_to_cf_gridmapping
755
756 !> @brief find the first number following a quoted parameter name
757 !!
758 !! Matches e.g. PARAMETER["central_meridian",-117] (WKT1) or
759 !! PARAMETER["Longitude of natural origin",-117,...] (WKT2).
760 !! Best-effort only -- MF6 has no CRS parsing library. found=.false.
761 !! if name is not present or no number follows it.
762 !<
763 function wkt_find_param(wkt, name, found) result(value)
764 use inputoutputmodule, only: upcase
765 character(len=*), intent(in) :: wkt
766 character(len=*), intent(in) :: name
767 logical(LGP), intent(out) :: found
768 real(dp) :: value
769 character(len=LENBIGLINE) :: wkt_upper
770 character(len=LINELENGTH) :: target_upper
771 integer :: ipos, istart, iend, ios, wkt_len
772
773 found = .false.
774 value = dzero
775 wkt_len = len_trim(wkt)
776 target_upper = '"'//trim(name)//'"'
777 wkt_upper = wkt
778 call upcase(wkt_upper)
779 call upcase(target_upper)
780 ipos = index(wkt_upper(1:wkt_len), trim(target_upper))
781 if (ipos == 0) return
782
783 istart = ipos + len_trim(target_upper)
784 do while (istart <= wkt_len)
785 if (wkt(istart:istart) == ',') exit
786 istart = istart + 1
787 end do
788 istart = istart + 1
789 iend = istart
790 do while (iend <= wkt_len)
791 if (wkt(iend:iend) == ',' .or. wkt(iend:iend) == ']') exit
792 iend = iend + 1
793 end do
794 if (iend <= istart) return
795 read (wkt(istart:iend - 1), *, iostat=ios) value
796 if (ios == 0) found = .true.
797 end function wkt_find_param
798
799 !> @brief find semi-major axis and inverse flattening from a WKT string
800 !!
801 !! Matches SPHEROID["name",A,B,...] (WKT1) or ELLIPSOID["name",A,B,...]
802 !! (WKT2). Best-effort only. found=.false. if neither keyword is
803 !! present or the two numbers cannot be read.
804 !<
805 subroutine wkt_find_ellipsoid(wkt, semi_major_axis, inverse_flattening, found)
806 use inputoutputmodule, only: upcase
807 character(len=*), intent(in) :: wkt
808 real(DP), intent(out) :: semi_major_axis
809 real(DP), intent(out) :: inverse_flattening
810 logical(LGP), intent(out) :: found
811 character(len=LENBIGLINE) :: wkt_upper
812 integer :: ipos, i, iend, ios, wkt_len, nquote
813
814 found = .false.
815 semi_major_axis = dzero
816 inverse_flattening = dzero
817 wkt_len = len_trim(wkt)
818 wkt_upper = wkt
819 call upcase(wkt_upper)
820
821 ipos = index(wkt_upper(1:wkt_len), 'SPHEROID[')
822 if (ipos == 0) ipos = index(wkt_upper(1:wkt_len), 'ELLIPSOID[')
823 if (ipos == 0) return
824
825 ! skip past the quoted ellipsoid name (its closing quote)
826 i = ipos
827 nquote = 0
828 do while (i <= wkt_len)
829 if (wkt(i:i) == '"') nquote = nquote + 1
830 if (nquote == 2) exit
831 i = i + 1
832 end do
833 if (nquote < 2) return
834 i = i + 1
835 if (wkt(i:i) == ',') i = i + 1
836
837 iend = i
838 do while (iend <= wkt_len)
839 if (wkt(iend:iend) == ',') exit
840 iend = iend + 1
841 end do
842 if (iend <= i) return
843 read (wkt(i:iend - 1), *, iostat=ios) semi_major_axis
844 if (ios /= 0) return
845
846 i = iend + 1
847 iend = i
848 do while (iend <= wkt_len)
849 if (wkt(iend:iend) == ',' .or. wkt(iend:iend) == ']') exit
850 iend = iend + 1
851 end do
852 if (iend <= i) return
853 read (wkt(i:iend - 1), *, iostat=ios) inverse_flattening
854 if (ios == 0) found = .true.
855 end subroutine wkt_find_ellipsoid
856
857 !> @brief extract CF transverse_mercator grid_mapping parameters
858 !!
859 !! Best-effort extraction from a WKT1 or WKT2 string -- MF6 has no
860 !! CRS parsing library. Tries WKT1 parameter names first, falling
861 !! back to WKT2 names. found=.false. if any parameter cannot be
862 !! located.
863 !<
864 subroutine wkt_transverse_mercator_params(wkt, longitude_of_central_meridian, &
865 latitude_of_projection_origin, &
866 scale_factor_at_central_meridian, &
867 false_easting, false_northing, &
868 semi_major_axis, inverse_flattening, &
869 found)
870 character(len=*), intent(in) :: wkt
871 real(dp), intent(out) :: longitude_of_central_meridian
872 real(dp), intent(out) :: latitude_of_projection_origin
873 real(dp), intent(out) :: scale_factor_at_central_meridian
874 real(dp), intent(out) :: false_easting
875 real(dp), intent(out) :: false_northing
876 real(dp), intent(out) :: semi_major_axis
877 real(dp), intent(out) :: inverse_flattening
878 logical(LGP), intent(out) :: found
879 logical(LGP) :: f1, f2, f3, f4, f5, f6
880
881 longitude_of_central_meridian = wkt_find_param(wkt, 'central_meridian', f1)
882 if (.not. f1) longitude_of_central_meridian = &
883 wkt_find_param(wkt, 'Longitude of natural origin', f1)
884
885 latitude_of_projection_origin = wkt_find_param(wkt, 'latitude_of_origin', f2)
886 if (.not. f2) latitude_of_projection_origin = &
887 wkt_find_param(wkt, 'Latitude of natural origin', f2)
888
889 scale_factor_at_central_meridian = wkt_find_param(wkt, 'scale_factor', f3)
890 if (.not. f3) scale_factor_at_central_meridian = &
891 wkt_find_param(wkt, 'Scale factor at natural origin', f3)
892
893 false_easting = wkt_find_param(wkt, 'false_easting', f4)
894 if (.not. f4) false_easting = wkt_find_param(wkt, 'False easting', f4)
895
896 false_northing = wkt_find_param(wkt, 'false_northing', f5)
897 if (.not. f5) false_northing = wkt_find_param(wkt, 'False northing', f5)
898
899 call wkt_find_ellipsoid(wkt, semi_major_axis, inverse_flattening, f6)
900
901 found = f1 .and. f2 .and. f3 .and. f4 .and. f5 .and. f6
902 end subroutine wkt_transverse_mercator_params
903
904 !> @brief extract CF lambert_conformal_conic grid_mapping parameters
905 !!
906 !! Best-effort extraction from a WKT1 or WKT2 string -- MF6 has no
907 !! CRS parsing library. 2SP (two standard parallels) only: CF's
908 !! lambert_conformal_conic has no scale_factor attribute, so a 1SP
909 !! (scale-factor-based) WKT cannot be exactly represented without
910 !! trigonometric conversion MF6 has no library for. is_2sp=.false.
911 !! if a second standard parallel is not present (i.e. likely 1SP);
912 !! found=.false. if is_2sp but any other parameter cannot be located.
913 !<
914 subroutine wkt_lambert_conformal_conic_params(wkt, standard_parallel_1, &
915 standard_parallel_2, &
916 longitude_of_central_meridian, &
917 latitude_of_projection_origin, &
918 false_easting, false_northing, &
919 semi_major_axis, &
920 inverse_flattening, is_2sp, found)
921 character(len=*), intent(in) :: wkt
922 real(dp), intent(out) :: standard_parallel_1
923 real(dp), intent(out) :: standard_parallel_2
924 real(dp), intent(out) :: longitude_of_central_meridian
925 real(dp), intent(out) :: latitude_of_projection_origin
926 real(dp), intent(out) :: false_easting
927 real(dp), intent(out) :: false_northing
928 real(dp), intent(out) :: semi_major_axis
929 real(dp), intent(out) :: inverse_flattening
930 logical(LGP), intent(out) :: is_2sp
931 logical(LGP), intent(out) :: found
932 logical(LGP) :: f1, f2, f3, f4, f5, f6, f7
933
934 standard_parallel_2 = wkt_find_param(wkt, 'standard_parallel_2', f2)
935 if (.not. f2) standard_parallel_2 = &
936 wkt_find_param(wkt, 'Latitude of 2nd standard parallel', f2)
937 is_2sp = f2
938 if (.not. is_2sp) then
939 found = .false.
940 return
941 end if
942
943 standard_parallel_1 = wkt_find_param(wkt, 'standard_parallel_1', f1)
944 if (.not. f1) standard_parallel_1 = &
945 wkt_find_param(wkt, 'Latitude of 1st standard parallel', f1)
946
947 longitude_of_central_meridian = wkt_find_param(wkt, 'central_meridian', f3)
948 if (.not. f3) longitude_of_central_meridian = &
949 wkt_find_param(wkt, 'Longitude of false origin', f3)
950
951 latitude_of_projection_origin = wkt_find_param(wkt, 'latitude_of_origin', f4)
952 if (.not. f4) latitude_of_projection_origin = &
953 wkt_find_param(wkt, 'Latitude of false origin', f4)
954
955 false_easting = wkt_find_param(wkt, 'false_easting', f5)
956 if (.not. f5) false_easting = &
957 wkt_find_param(wkt, 'Easting at false origin', f5)
958
959 false_northing = wkt_find_param(wkt, 'false_northing', f6)
960 if (.not. f6) false_northing = &
961 wkt_find_param(wkt, 'Northing at false origin', f6)
962
963 call wkt_find_ellipsoid(wkt, semi_major_axis, inverse_flattening, f7)
964
965 found = f1 .and. f3 .and. f4 .and. f5 .and. f6 .and. f7
967
968 !> @brief extract CF albers_conical_equal_area grid_mapping parameters
969 !!
970 !! Best-effort extraction from a WKT1 or WKT2 string -- MF6 has no
971 !! CRS parsing library. found=.false. if any parameter cannot be
972 !! located.
973 !<
974 subroutine wkt_albers_conical_equal_area_params(wkt, standard_parallel_1, &
975 standard_parallel_2, &
976 longitude_of_central_meridian, &
977 latitude_of_projection_origin, &
978 false_easting, &
979 false_northing, &
980 semi_major_axis, &
981 inverse_flattening, found)
982 character(len=*), intent(in) :: wkt
983 real(dp), intent(out) :: standard_parallel_1
984 real(dp), intent(out) :: standard_parallel_2
985 real(dp), intent(out) :: longitude_of_central_meridian
986 real(dp), intent(out) :: latitude_of_projection_origin
987 real(dp), intent(out) :: false_easting
988 real(dp), intent(out) :: false_northing
989 real(dp), intent(out) :: semi_major_axis
990 real(dp), intent(out) :: inverse_flattening
991 logical(LGP), intent(out) :: found
992 logical(LGP) :: f1, f2, f3, f4, f5, f6, f7
993
994 standard_parallel_1 = wkt_find_param(wkt, 'standard_parallel_1', f1)
995 if (.not. f1) standard_parallel_1 = &
996 wkt_find_param(wkt, 'Latitude of 1st standard parallel', f1)
997
998 standard_parallel_2 = wkt_find_param(wkt, 'standard_parallel_2', f2)
999 if (.not. f2) standard_parallel_2 = &
1000 wkt_find_param(wkt, 'Latitude of 2nd standard parallel', f2)
1001
1002 longitude_of_central_meridian = wkt_find_param(wkt, 'longitude_of_center', f3)
1003 if (.not. f3) longitude_of_central_meridian = &
1004 wkt_find_param(wkt, 'Longitude of false origin', f3)
1005
1006 latitude_of_projection_origin = wkt_find_param(wkt, 'latitude_of_center', f4)
1007 if (.not. f4) latitude_of_projection_origin = &
1008 wkt_find_param(wkt, 'Latitude of false origin', f4)
1009
1010 false_easting = wkt_find_param(wkt, 'false_easting', f5)
1011 if (.not. f5) false_easting = &
1012 wkt_find_param(wkt, 'Easting at false origin', f5)
1013
1014 false_northing = wkt_find_param(wkt, 'false_northing', f6)
1015 if (.not. f6) false_northing = &
1016 wkt_find_param(wkt, 'Northing at false origin', f6)
1017
1018 call wkt_find_ellipsoid(wkt, semi_major_axis, inverse_flattening, f7)
1019
1020 found = f1 .and. f2 .and. f3 .and. f4 .and. f5 .and. f6 .and. f7
1022
1023 !> @brief wrap a WKT2 PROJCRS in a derived CRS encoding grid rotation
1024 !!
1025 !! Builds a DerivedProjectedCRS wrapping the given WKT2 PROJCRS in an
1026 !! EPSG:9624 (affine parametric transformation) deriving conversion
1027 !! parameterized from xorigin/yorigin/angrot (degrees). Per ISO 19111,
1028 !! a deriving conversion is directed base->derived, so the parameters
1029 !! encode the world->local (inverse) rotation; a CRS-aware consumer
1030 !! applies the inverse to resolve true position from local coordinates.
1031 !! Returns '' if wkt is not recognized as a WKT2 PROJCRS -- a
1032 !! best-effort structural check only, as MF6 has no CRS parsing
1033 !! library and does not validate the WKT beyond this.
1034 !<
1035 function wrap_rotated_crs(wkt, xorigin, yorigin, angrot) result(derived_wkt)
1036 use inputoutputmodule, only: upcase
1037 character(len=*), intent(in) :: wkt
1038 real(dp), intent(in) :: xorigin, yorigin, angrot
1039 character(len=LENBIGLINE) :: derived_wkt
1040 character(len=LENBIGLINE) :: wkt_trim, wkt_upper, base_body, conversion
1041 character(len=30) :: a0s, a1s, a2s, b0s, b1s, b2s
1042 integer :: nstart, i, depth, closures, iend, wkt_len
1043 real(dp) :: ang, a0, a1, a2, b0, b1, b2
1044
1045 derived_wkt = ''
1046
1047 ! best-effort check that wkt is a WKT2 PROJCRS
1048 wkt_trim = trim(adjustl(wkt))
1049 wkt_len = len_trim(wkt_trim)
1050 wkt_upper = wkt_trim
1051 call upcase(wkt_upper)
1052 if (wkt_len < 9 .or. wkt_upper(1:8) /= 'PROJCRS[') return
1053
1054 ! locate the end of PROJCRS's 2nd top-level child (the mandatory
1055 ! BASEGEOGCRS/BASEGEODCRS and CONVERSION elements, in that order),
1056 ! by tracking bracket depth from just inside the opening '['
1057 nstart = 9
1058 depth = 0
1059 closures = 0
1060 iend = 0
1061 do i = nstart, wkt_len
1062 if (wkt_trim(i:i) == '[') then
1063 depth = depth + 1
1064 else if (wkt_trim(i:i) == ']') then
1065 depth = depth - 1
1066 if (depth == 0) then
1067 closures = closures + 1
1068 if (closures == 2) then
1069 iend = i
1070 exit
1071 end if
1072 end if
1073 end if
1074 end do
1075 if (iend == 0) return
1076 base_body = wkt_trim(nstart:iend)
1077
1078 ! EPSG:9624 affine parameters, base(world) -> derived(local grid)
1079 ang = angrot * dpio180
1080 a0 = -(xorigin * cos(ang) + yorigin * sin(ang))
1081 a1 = cos(ang)
1082 a2 = sin(ang)
1083 b0 = xorigin * sin(ang) - yorigin * cos(ang)
1084 b1 = -sin(ang)
1085 b2 = cos(ang)
1086 write (a0s, '(es22.15)') a0
1087 write (a1s, '(es22.15)') a1
1088 write (a2s, '(es22.15)') a2
1089 write (b0s, '(es22.15)') b0
1090 write (b1s, '(es22.15)') b1
1091 write (b2s, '(es22.15)') b2
1092
1093 conversion = 'DERIVINGCONVERSION["MODFLOW 6 grid rotation",'// &
1094 'METHOD["Affine parametric transformation",'// &
1095 'ID["EPSG",9624]],'// &
1096 'PARAMETER["A0",'//trim(adjustl(a0s))// &
1097 ',LENGTHUNIT["metre",1]],'// &
1098 'PARAMETER["A1",'//trim(adjustl(a1s))// &
1099 ',SCALEUNIT["unity",1]],'// &
1100 'PARAMETER["A2",'//trim(adjustl(a2s))// &
1101 ',SCALEUNIT["unity",1]],'// &
1102 'PARAMETER["B0",'//trim(adjustl(b0s))// &
1103 ',LENGTHUNIT["metre",1]],'// &
1104 'PARAMETER["B1",'//trim(adjustl(b1s))// &
1105 ',SCALEUNIT["unity",1]],'// &
1106 'PARAMETER["B2",'//trim(adjustl(b2s))// &
1107 ',SCALEUNIT["unity",1]]]'
1108
1109 derived_wkt = 'DERIVEDPROJCRS["MODFLOW 6 rotated grid CRS",'// &
1110 'BASEPROJCRS['//trim(base_body)//'],'// &
1111 trim(conversion)//','// &
1112 'CS[Cartesian,2],'// &
1113 'AXIS["easting (X)",east,ORDER[1],LENGTHUNIT["metre",1]],'// &
1114 'AXIS["northing (Y)",north,ORDER[2],LENGTHUNIT["metre",1]]]'
1115 end function wrap_rotated_crs
1116
1117 !> @brief destroy model netcdf export object
1118 !<
1119 subroutine export_destroy(this)
1122 class(ncmodelexporttype), intent(inout) :: this
1123 ! override in derived class
1124 deallocate (this%deflate)
1125 deallocate (this%shuffle)
1126 deallocate (this%input_attr)
1127 deallocate (this%chunk_time)
1128 ! Deallocate idm memory
1129 if (this%ncf_mempath /= '') then
1130 call memorystore_remove(this%modelname, 'NCF', idm_context)
1131 end if
1132 end subroutine export_destroy
1133
1134end module ncmodelexportmodule
abstract interfaces for model netcdf export type
Definition NCModel.f90:132
This module contains simulation constants.
Definition Constants.f90:9
integer(i4b), parameter linelength
maximum length of a standard line
Definition Constants.f90:45
integer(i4b), parameter lencomponentname
maximum length of a component name
Definition Constants.f90:18
@ mvalidate
validation mode - do not run time steps
integer(i4b), parameter lenmodelname
maximum length of the model name
Definition Constants.f90:22
integer(i4b), parameter lenbigline
maximum length of a big line
Definition Constants.f90:15
@ disu
DISV6 discretization.
@ dis
DIS6 discretization.
@ disv
DISU6 discretization.
integer(i4b), parameter lenvarname
maximum length of a variable name
Definition Constants.f90:17
real(dp), parameter dpio180
real constant
real(dp), parameter dzero
real constant zero
Definition Constants.f90:65
integer(i4b), parameter lenmempath
maximum length of the memory path
Definition Constants.f90:27
logical function, public idm_multi_package(component, subcomponent)
Input definition module.
This module contains the InputLoadTypeModule.
subroutine, public lowcase(word)
Convert to lower case.
subroutine, public upcase(word)
Convert to upper case.
This module defines variable data types.
Definition kind.f90:8
Load context for IDM generic dynamic loaders.
@ rs_series
time-array series given in the most recent period block
@ rs_netcdf
values read from NetCDF in the most recent period block
@ rs_values
values given in the most recent period block
subroutine init(this, mf6_input, blockname, named_bound)
Initialize the load context.
subroutine destroy(this)
destroy input context object
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 ModflowInputModule.
This module contains the NCModelExportModule.
Definition NCModel.f90:8
character(len=lenbigline) function, public wrap_rotated_crs(wkt, xorigin, yorigin, angrot)
wrap a WKT2 PROJCRS in a derived CRS encoding grid rotation
Definition NCModel.f90:1036
class(exportpackagetype) function, pointer export_get(this, idx)
retrieve dynamic export object from package list
Definition NCModel.f90:511
@ netcdf_undef
undefined netcdf export type
Definition NCModel.f90:37
@ netcdf_mesh2d
netcdf ugrid layered mesh export
Definition NCModel.f90:39
@ netcdf_structured
netcdf structrured export
Definition NCModel.f90:38
logical(lgp) function param_state(this, iparam)
.true. if a param has input in effect to export
Definition NCModel.f90:256
character(len=linelength) function, public wkt_to_cf_gridmapping(wkt)
map a WKT string to a CF-1.13 grid_mapping_name
Definition NCModel.f90:681
character(len=linelength) function, public export_varname(pkgname, tagname, mempath, layer, iaux)
build netcdf variable name
Definition NCModel.f90:562
integer(i4b) function istp(this)
step index for timeseries data
Definition NCModel.f90:547
subroutine epkg_init(this, mf6_input, mshape, naux, param_names, nparam)
initialize dynamic package export object
Definition NCModel.f90:161
subroutine update_state(this)
Update input in effect from the period block read states.
Definition NCModel.f90:226
logical(lgp) function aux_state(this, iaux)
.true. if an auxiliary variable has input in effect to export
Definition NCModel.f90:269
subroutine set_state(invar, has_value)
Set input in effect from a read state.
Definition NCModel.f90:241
subroutine export_destroy(this)
destroy model netcdf export object
Definition NCModel.f90:1120
subroutine export_init(this, modelname, modeltype, modelfname, nc_fname, disenum, nctype, iout)
initialization of model netcdf export
Definition NCModel.f90:390
subroutine user_nodes(this, vals, nodes)
Set user node values from a loaded period array.
Definition NCModel.f90:282
subroutine, public wkt_lambert_conformal_conic_params(wkt, standard_parallel_1, standard_parallel_2, longitude_of_central_meridian, latitude_of_projection_origin, false_easting, false_northing, semi_major_axis, inverse_flattening, is_2sp, found)
extract CF lambert_conformal_conic grid_mapping parameters
Definition NCModel.f90:921
subroutine, public wkt_transverse_mercator_params(wkt, longitude_of_central_meridian, latitude_of_projection_origin, scale_factor_at_central_meridian, false_easting, false_northing, semi_major_axis, inverse_flattening, found)
extract CF transverse_mercator grid_mapping parameters
Definition NCModel.f90:870
real(dp) function wkt_find_param(wkt, name, found)
find the first number following a quoted parameter name
Definition NCModel.f90:764
subroutine set(this, modelname, modeltype, modelfname, nctype, disenum)
set netcdf file scoped attributes
Definition NCModel.f90:314
character(len=linelength) function input_attribute(this, pkgname, idt)
build modflow_input attribute string
Definition NCModel.f90:529
subroutine epkg_destroy(this)
destroy dynamic package export object
Definition NCModel.f90:303
subroutine wkt_find_ellipsoid(wkt, semi_major_axis, inverse_flattening, found)
find semi-major axis and inverse flattening from a WKT string
Definition NCModel.f90:806
character(len=linelength) function, public export_longname(longname, pkgname, tagname, mempath, layer, iaux, component_type, subcomponent_type)
build netcdf variable longname
Definition NCModel.f90:603
subroutine export_input(this)
netcdf dynamic package period export
Definition NCModel.f90:656
subroutine, public wkt_albers_conical_equal_area_params(wkt, standard_parallel_1, standard_parallel_2, longitude_of_central_meridian, latitude_of_projection_origin, false_easting, false_northing, semi_major_axis, inverse_flattening, found)
extract CF albers_conical_equal_area grid_mapping parameters
Definition NCModel.f90:982
This module contains simulation methods.
Definition Sim.f90:10
subroutine, public store_error(msg, terminate)
Store an error message.
Definition Sim.f90:94
subroutine, public store_error_filename(filename, terminate)
Store the erroring file name.
Definition Sim.f90:208
This module contains simulation variables.
character(len=maxcharlen) errmsg
error message string
character(len=linelength) idm_context
integer(i4b) iout
file unit number for simulation output
integer(i4b) isim_mode
simulation mode
This module contains the SourceCommonModule.
logical(lgp) function, public filein_fname(filename, tagname, input_mempath, input_fname)
enforce and set a single input filename provided via FILEIN keyword
integer(i4b), dimension(:), pointer, public, contiguous nstp
number of time steps in each stress period
Definition tdis.f90:42
character(len=lendatetime), pointer, public datetime0
starting date and time for the simulation
Definition tdis.f90:44
integer(i4b), pointer, public kstp
current time step number
Definition tdis.f90:27
integer(i4b), pointer, public kper
current stress period number
Definition tdis.f90:26
integer(i4b), pointer, public nper
number of stress period
Definition tdis.f90:24
This module contains version information.
Definition version.f90:7
character(len= *), parameter fullversion
Definition version.f90:24
This class is used to store a single deferred-length character string. It was designed to work in an ...
Input parameter definition. Describes an input parameter.
type for storing a dynamic package load list
A generic heterogeneous doubly-linked list.
Definition List.f90:14
Pointer type for read state variable.
derived type for storing input definition for a file
abstract type for model netcdf export type
Definition NCModel.f90:120
netcdf export attribute annotations
Definition NCModel.f90:68
base class for an export model
Definition NCModel.f90:84