45 integer(I4B) :: elevation
47 integer(I4B) :: time_bnds
48 integer(I4B) :: dependent
49 integer(I4B) :: x_bnds
50 integer(I4B) :: y_bnds
51 integer(I4B) :: latitude
52 integer(I4B) :: longitude
53 integer(I4B) :: export
62 real(dp),
dimension(:),
pointer,
contiguous :: latitude => null()
63 real(dp),
dimension(:),
pointer,
contiguous :: longitude => null()
64 integer(I4B),
pointer :: chunk_z
65 integer(I4B),
pointer :: chunk_y
66 integer(I4B),
pointer :: chunk_x
67 integer(I4B),
dimension(:),
allocatable :: layers
68 logical(LGP) :: latlon
101 disenum, nctype, iout)
105 character(len=*),
intent(in) :: modelname
106 character(len=*),
intent(in) :: modeltype
107 character(len=*),
intent(in) :: modelfname
108 character(len=*),
intent(in) :: nc_fname
109 integer(I4B),
intent(in) :: disenum
110 integer(I4B),
intent(in) :: nctype
111 integer(I4B),
intent(in) :: iout
112 integer(I4B) :: k, latsz, lonsz
113 logical(LGP) :: found
116 this%nlay = this%dis%nlay
119 allocate (this%chunk_z)
120 allocate (this%chunk_y)
121 allocate (this%chunk_x)
122 allocate (this%layers(this%nlay))
132 this%latlon = .false.
135 call this%NCModelExportType%init(modelname, modeltype, modelfname, nc_fname, &
136 disenum, nctype, iout)
139 if (this%ncf_mempath /=
'')
then
140 call mem_set_value(this%chunk_z,
'CHUNK_Z', this%ncf_mempath, found)
141 call mem_set_value(this%chunk_y,
'CHUNK_Y', this%ncf_mempath, found)
142 call mem_set_value(this%chunk_x,
'CHUNK_X', this%ncf_mempath, found)
144 if (this%chunk_time > 0 .and. this%chunk_z > 0 .and. &
145 this%chunk_y > 0 .and. this%chunk_x > 0)
then
146 this%chunking_active = .true.
147 else if (this%chunk_time > 0 .or. this%chunk_z > 0 .or. &
148 this%chunk_y > 0 .or. this%chunk_x > 0)
then
153 write (
warnmsg,
'(a)')
'Ignoring user provided NetCDF chunking &
154 ¶meters. Define chunk_time, chunk_x, chunk_y and chunk_z input &
155 ¶meters to see an effect in file "'//trim(nc_fname)//
'".'
159 call get_isize(
'LATITUDE', this%ncf_mempath, latsz)
160 call get_isize(
'LONGITUDE', this%ncf_mempath, lonsz)
162 if (latsz > 0 .and. lonsz > 0)
then
164 if (this%wkt /=
'' .or. this%crs_wkt /=
'')
then
165 write (
warnmsg,
'(a)')
'Ignoring user provided NetCDF wkt/crs_wkt &
166 ¶meter(s) as longitude and latitude arrays have been provided. &
167 &Applies to file "'//trim(nc_fname)//
'".'
171 this%gridmap_name =
''
173 call mem_setptr(this%latitude,
'LATITUDE', this%ncf_mempath)
174 call mem_setptr(this%longitude,
'LONGITUDE', this%ncf_mempath)
175 if (this%dis%angrot /=
dzero)
then
176 write (
warnmsg,
'(a)')
'Structured rotated grid with &
177 &user-provided latitude/longitude: MF6 cannot verify these &
178 &values correctly account for grid rotation (angrot). They &
179 &must be computed from each cell''s true rotated position, &
180 ¬ from grid-local x/y. Applies to file "'// &
186 if (this%gridmap_name /=
'')
then
187 if (this%dis%angrot /=
dzero)
then
188 write (
warnmsg,
'(a)')
'CRS parameter set with structured rotated &
189 &grid. The x/y coordinate variables have grid-local, not &
190 &real-world, values. A CRS-aware consumer must apply the full &
191 &crs_wkt (which encodes rotation when a valid WKT2 PROJCRS was &
192 &supplied) via proper reprojection to resolve the true &
193 &position; deriving real longitude/latitude directly from x/y &
194 &and the flat/numeric CF grid_mapping parameters alone will be &
195 &incorrect, since those parameters never encode grid rotation. &
196 &Applies to file "'//trim(nc_fname)//
'".'
202 if (this%dis%lenuni == 1)
then
204 else if (this%dis%lenuni == 3)
then
211 call nf_verify(nf90_create(this%nc_fname, &
212 ior(nf90_clobber, nf90_netcdf4), this%ncid), &
220 call nf_verify(nf90_close(this%ncid), this%nc_fname)
221 deallocate (this%chunk_z)
222 deallocate (this%chunk_y)
223 deallocate (this%chunk_x)
224 deallocate (this%layers)
225 nullify (this%chunk_z)
226 nullify (this%chunk_y)
227 nullify (this%chunk_x)
229 call this%NCModelExportType%destroy()
239 call this%add_global_att()
241 call this%define_dim()
243 call this%define_geocoords()
246 call this%df_export()
249 call this%define_dependent()
252 call nf_verify(nf90_enddef(this%ncid), this%nc_fname)
254 call this%add_grid_data()
256 call this%add_proj_data()
259 call this%add_pkg_data()
262 call this%define_gridmap()
264 call nf_verify(nf90_sync(this%ncid), this%nc_fname)
274 do idx = 1, this%pkglist%Count()
275 export_pkg => this%get(idx)
276 call this%export_df(export_pkg)
286 real(DP),
dimension(:),
pointer,
contiguous :: dbl1d
287 integer(I4B) :: n, istp
292 if (
size(this%dis%nodeuser) < &
293 size(this%dis%nodereduced))
then
294 allocate (dbl1d(
size(this%dis%nodereduced)))
296 do n = 1,
size(this%dis%nodereduced)
297 if (this%dis%nodereduced(n) > 0)
then
298 dbl1d(n) = this%x(this%dis%nodereduced(n))
303 this%var_ids%dependent, dbl1d, &
304 start=(/1, 1, 1, istp/), &
305 count=(/this%dis%ncol, &
307 this%dis%nlay, 1/)), &
313 this%var_ids%dependent, this%x, &
314 start=(/1, 1, 1, istp/), &
315 count=(/this%dis%ncol, &
317 this%dis%nlay, 1/)), &
322 call nf_verify(nf90_put_var(this%ncid, this%var_ids%time, &
323 totim, start=(/istp/)), &
327 call nf_verify(nf90_sync(this%ncid), this%nc_fname)
334 character(len=*),
intent(in) :: pkgtype
335 character(len=*),
intent(in) :: pkgname
336 character(len=*),
intent(in) :: mempath
338 integer(I4B),
dimension(:),
pointer,
contiguous :: int1d
339 integer(I4B),
dimension(:, :),
pointer,
contiguous :: int2d
340 integer(I4B),
dimension(:, :, :),
pointer,
contiguous :: int3d
341 real(DP),
dimension(:),
pointer,
contiguous :: dbl1d
342 real(DP),
dimension(:, :),
pointer,
contiguous :: dbl2d
343 real(DP),
dimension(:, :, :),
pointer,
contiguous :: dbl3d
344 character(len=LINELENGTH) :: nc_tag
345 integer(I4B) :: iper, iaux
352 nc_tag = this%input_attribute(pkgname, idt)
354 select case (idt%datatype)
356 call mem_setptr(int1d, idt%mf6varname, mempath)
358 this%dis, idt, mempath, nc_tag, pkgname, &
359 this%gridmap_name, this%latlon, this%deflate, &
360 this%shuffle, this%chunk_z, this%chunk_y, &
361 this%chunk_x, iper, this%nc_fname)
363 call mem_setptr(int2d, idt%mf6varname, mempath)
365 this%dis, idt, mempath, nc_tag, pkgname, &
366 this%gridmap_name, this%latlon, this%deflate, &
367 this%shuffle, this%chunk_z, this%chunk_y, &
368 this%chunk_x, this%nc_fname)
370 call mem_setptr(int3d, idt%mf6varname, mempath)
372 this%dis, idt, mempath, nc_tag, pkgname, &
373 this%gridmap_name, this%latlon, this%deflate, &
374 this%shuffle, this%chunk_z, this%chunk_y, &
375 this%chunk_x, this%nc_fname)
377 call mem_setptr(dbl1d, idt%mf6varname, mempath)
379 this%dis, idt, mempath, nc_tag, pkgname, &
380 this%gridmap_name, this%latlon, this%deflate, &
381 this%shuffle, this%chunk_z, this%chunk_y, &
382 this%chunk_x, iper, iaux, this%nc_fname)
384 call mem_setptr(dbl2d, idt%mf6varname, mempath)
386 this%dis, idt, mempath, nc_tag, pkgname, &
387 this%gridmap_name, this%latlon, this%deflate, &
388 this%shuffle, this%chunk_z, this%chunk_y, &
389 this%chunk_x, this%nc_fname)
391 call mem_setptr(dbl3d, idt%mf6varname, mempath)
393 this%dis, idt, mempath, nc_tag, pkgname, &
394 this%gridmap_name, this%latlon, this%deflate, &
395 this%shuffle, this%chunk_z, this%chunk_y, &
396 this%chunk_x, this%nc_fname)
410 integer(I4B) :: iparam, iaux
413 do iparam = 1, export_pkg%nparam
419 export_pkg%mf6_input%component_type, &
420 export_pkg%mf6_input%subcomponent_type, &
421 'PERIOD', export_pkg%param_names(iparam),
'')
422 select case (idt%shape)
423 case (
'NCPL',
'NODES')
424 call this%create_timeseries(idt, iparam, iaux, export_pkg)
425 case (
'NAUX NCPL',
'NAUX NODES')
426 do iaux = 1, export_pkg%naux
427 call this%create_timeseries(idt, iparam, iaux, export_pkg)
440 integer(I4B),
intent(in) :: iparam
441 integer(I4B),
intent(in) :: iaux
443 character(len=LINELENGTH) :: varname, longname, nc_tag
444 integer(I4B) :: varid
445 logical(LGP) :: has_layer
447 has_layer = .not. (idt%shape ==
'NCPL' .or. idt%shape ==
'NAUX NCPL')
450 nc_tag = this%input_attribute(export_pkg%mf6_input%subcomponent_name, &
454 varname =
export_varname(export_pkg%mf6_input%subcomponent_name, &
455 idt%tagname, export_pkg%mf6_input%mempath, &
458 export_pkg%mf6_input%subcomponent_name, &
459 idt%tagname, export_pkg%mf6_input%mempath, &
461 component_type=idt%component_type, &
462 subcomponent_type=idt%subcomponent_type)
465 select case (idt%datatype)
466 case (
'DOUBLE1D',
'DOUBLE2D')
467 if (idt%shape ==
'NCPL' .or. &
468 idt%shape ==
'NAUX NCPL')
then
469 call nf_verify(nf90_def_var(this%ncid, varname, nf90_double, &
472 this%dim_ids%time/), varid), &
475 call nf_verify(nf90_def_var(this%ncid, varname, nf90_double, &
478 this%dim_ids%layer, &
479 this%dim_ids%time/), varid), &
482 call nf_verify(nf90_put_att(this%ncid, varid, &
483 '_FillValue', (/dnodata/)), &
486 call nf_verify(nf90_put_att(this%ncid, varid,
'cell_methods', &
487 'time: mean'), this%nc_fname)
489 if (idt%shape ==
'NCPL' .or. &
490 idt%shape ==
'NAUX NCPL')
then
491 call nf_verify(nf90_def_var(this%ncid, varname, nf90_int, &
494 this%dim_ids%time/), varid), &
497 call nf_verify(nf90_def_var(this%ncid, varname, nf90_int, &
500 this%dim_ids%layer, &
501 this%dim_ids%time/), varid), &
504 call nf_verify(nf90_put_att(this%ncid, varid, &
505 '_FillValue', (/nf90_fill_int/)), &
510 if (this%chunking_active)
then
511 call nf_verify(nf90_def_var_chunking(this%ncid, &
514 (/this%chunk_x, this%chunk_y, &
515 this%chunk_z, this%chunk_time/)), &
521 this%shuffle, this%nc_fname)
524 call nf_verify(nf90_put_att(this%ncid, varid, &
525 'long_name', longname), this%nc_fname)
528 call ncvar_gridmap(this%ncid, varid, this%gridmap_name, this%latlon, &
529 has_layer, this%nc_fname)
530 call ncvar_mf6attr(this%ncid, varid, iaux, nc_tag, this%nc_fname)
533 if (idt%tagname ==
'AUX')
then
534 export_pkg%varids_aux(iaux, 1) = varid
536 export_pkg%varids_param(iparam, 1) = varid
545 character(len=*),
intent(in) :: pkgtype
546 character(len=*),
intent(in) :: pkgname
547 character(len=*),
intent(in) :: mempath
549 intent(in) :: param_dfns
551 integer(I4B) :: iparam, isize
552 do iparam = 1,
size(param_dfns)
554 idt => param_dfns(iparam)
556 if (idt%blockname ==
'GRIDDATA')
then
558 call get_isize(idt%mf6varname, mempath, isize)
560 call this%export_input_array(pkgtype, pkgname, mempath, idt)
575 integer(I4B),
dimension(:),
pointer,
contiguous :: int1d
576 real(DP),
dimension(:),
pointer,
contiguous :: dbl1d, nodes
577 real(DP),
dimension(:, :),
pointer,
contiguous :: dbl2d
578 character(len=LINELENGTH) :: nc_tag
579 integer(I4B) :: iaux, iparam, nvals, n
585 call export_pkg%update_state()
588 do iparam = 1, export_pkg%nparam
590 if (.not. export_pkg%param_state(iparam)) cycle
595 export_pkg%mf6_input%component_type, &
596 export_pkg%mf6_input%subcomponent_type, &
597 'PERIOD', export_pkg%param_names(iparam),
'')
600 nc_tag = this%input_attribute(export_pkg%mf6_input%subcomponent_name, &
604 select case (idt%datatype)
606 call mem_setptr(int1d, idt%mf6varname, export_pkg%mf6_input%mempath)
607 this%var_ids%export = export_pkg%varids_param(iparam, 1)
609 this%dis, idt, export_pkg%mf6_input%mempath, &
610 nc_tag, export_pkg%mf6_input%subcomponent_name, &
611 this%gridmap_name, this%latlon, this%deflate, &
612 this%shuffle, this%chunk_z, this%chunk_y, &
613 this%chunk_x,
kper, this%nc_fname)
615 call mem_setptr(dbl1d, idt%mf6varname, export_pkg%mf6_input%mempath)
616 this%var_ids%export = export_pkg%varids_param(iparam, 1)
617 select case (idt%shape)
620 this%dis, idt, export_pkg%mf6_input%mempath, &
621 nc_tag, export_pkg%mf6_input%subcomponent_name, &
622 this%gridmap_name, this%latlon, this%deflate, &
623 this%shuffle, this%chunk_z, this%chunk_y, &
624 this%chunk_x,
kper, iaux, this%nc_fname)
626 nvals = this%dis%nodesuser
627 allocate (nodes(nvals))
629 call mem_setptr(dbl1d, idt%mf6varname, export_pkg%mf6_input%mempath)
630 call export_pkg%user_nodes(dbl1d, nodes)
632 this%dis, idt, export_pkg%mf6_input%mempath, &
633 nc_tag, export_pkg%mf6_input%subcomponent_name, &
634 this%gridmap_name, this%latlon, this%deflate, &
635 this%shuffle, this%chunk_z, this%chunk_y, &
636 this%chunk_x,
kper, iaux, this%nc_fname)
641 call mem_setptr(dbl2d, idt%mf6varname, export_pkg%mf6_input%mempath)
642 select case (idt%shape)
644 nvals = this%dis%nrow * this%dis%ncol
645 allocate (nodes(nvals))
646 do iaux = 1,
size(dbl2d, dim=1)
647 if (.not. export_pkg%aux_state(iaux)) cycle
648 this%var_ids%export = export_pkg%varids_aux(iaux, 1)
650 nodes(n) = dbl2d(iaux, n)
653 this%dis, idt, export_pkg%mf6_input%mempath, &
654 nc_tag, export_pkg%mf6_input%subcomponent_name, &
655 this%gridmap_name, this%latlon, this%deflate, &
656 this%shuffle, this%chunk_z, this%chunk_y, &
657 this%chunk_x,
kper, iaux, this%nc_fname)
661 nvals = this%dis%nodesuser
662 allocate (nodes(nvals))
663 do iaux = 1,
size(dbl2d, dim=1)
664 if (.not. export_pkg%aux_state(iaux)) cycle
666 this%var_ids%export = export_pkg%varids_aux(iaux, 1)
667 call export_pkg%user_nodes(dbl2d(iaux, :), nodes)
669 this%dis, idt, export_pkg%mf6_input%mempath, &
670 nc_tag, export_pkg%mf6_input%subcomponent_name, &
671 this%gridmap_name, this%latlon, this%deflate, &
672 this%shuffle, this%chunk_z, this%chunk_y, &
673 this%chunk_x,
kper, iaux, this%nc_fname)
685 call nf_verify(nf90_put_var(this%ncid, this%var_ids%time, &
691 call nf_verify(nf90_put_var(this%ncid, this%var_ids%time_bnds, &
693 start=(/1,
kper/), count=(/2, 1/)), &
696 call nf_verify(nf90_put_var(this%ncid, this%var_ids%time_bnds, &
702 call nf_verify(nf90_sync(this%ncid), this%nc_fname)
715 character(LENCOMPONENTNAME) :: ptype, pname, pkgtype
717 pointer :: pkgtypes => null()
719 pointer :: pkgnames => null()
721 pointer :: mempaths => null()
723 character(len=LENMEMPATH) :: input_mempath, mempath
725 integer(I4B),
pointer :: export_arrays
726 logical(LGP) :: found
731 call mem_setptr(pkgtypes,
'PKGTYPES', input_mempath)
732 call mem_setptr(pkgnames,
'PKGNAMES', input_mempath)
733 call mem_setptr(mempaths,
'MEMPATHS', input_mempath)
735 do n = 1,
size(mempaths)
737 allocate (export_arrays)
741 mempath = mempaths(n)
746 if (mempath /=
'')
then
748 call mem_set_value(export_arrays,
'EXPORT_NC', mempath, found, &
751 if (export_arrays > 0)
then
756 call this%export_input_arrays(ptype, pname, mempath, param_dfns)
761 deallocate (export_arrays)
770 call nf_verify(nf90_put_att(this%ncid, nf90_global,
'title', &
771 this%annotation%title), this%nc_fname)
773 call nf_verify(nf90_put_att(this%ncid, nf90_global,
'source', &
774 this%annotation%source), this%nc_fname)
776 call nf_verify(nf90_put_att(this%ncid, nf90_global,
'modflow_grid', &
777 this%annotation%grid), this%nc_fname)
779 call nf_verify(nf90_put_att(this%ncid, nf90_global,
'modflow_model', &
780 this%annotation%model), this%nc_fname)
782 call nf_verify(nf90_put_att(this%ncid, nf90_global,
'history', &
783 this%annotation%history), this%nc_fname)
785 call nf_verify(nf90_put_att(this%ncid, nf90_global,
'Conventions', &
786 this%annotation%conventions), &
798 call nf_verify(nf90_def_dim(this%ncid,
'bnd', 2, this%dim_ids%bnd), &
803 call nf_verify(nf90_def_dim(this%ncid,
'time', this%totnstp, &
804 this%dim_ids%time), this%nc_fname)
805 call nf_verify(nf90_def_var(this%ncid,
'time', nf90_double, &
806 this%dim_ids%time, this%var_ids%time), &
808 call nf_verify(nf90_put_att(this%ncid, this%var_ids%time,
'calendar', &
809 'standard'), this%nc_fname)
810 call nf_verify(nf90_put_att(this%ncid, this%var_ids%time,
'units', &
811 this%datetime), this%nc_fname)
812 call nf_verify(nf90_put_att(this%ncid, this%var_ids%time,
'axis',
'T'), &
814 call nf_verify(nf90_put_att(this%ncid, this%var_ids%time,
'standard_name', &
815 'time'), this%nc_fname)
816 call nf_verify(nf90_put_att(this%ncid, this%var_ids%time,
'long_name', &
817 'time'), this%nc_fname)
820 call nf_verify(nf90_put_att(this%ncid, this%var_ids%time,
'bounds', &
821 'time_bnds'), this%nc_fname)
822 call nf_verify(nf90_def_var(this%ncid,
'time_bnds', nf90_double, &
823 (/this%dim_ids%bnd, this%dim_ids%time/), &
824 this%var_ids%time_bnds), this%nc_fname)
829 call nf_verify(nf90_def_dim(this%ncid,
'layer', this%dis%nlay, &
830 this%dim_ids%layer), this%nc_fname)
831 call nf_verify(nf90_def_var(this%ncid,
'layer', nf90_int, &
832 this%dim_ids%layer, this%var_ids%layer), &
834 call nf_verify(nf90_put_att(this%ncid, this%var_ids%layer,
'units',
'1'), &
836 call nf_verify(nf90_put_att(this%ncid, this%var_ids%layer,
'axis',
'Z'), &
838 call nf_verify(nf90_put_att(this%ncid, this%var_ids%layer,
'positive', &
839 'down'), this%nc_fname)
840 call nf_verify(nf90_put_att(this%ncid, this%var_ids%layer,
'long_name', &
841 'model layer'), this%nc_fname)
844 call nf_verify(nf90_def_dim(this%ncid,
'y', this%dis%nrow, this%dim_ids%y), &
846 call nf_verify(nf90_def_var(this%ncid,
'y', nf90_double, this%dim_ids%y, &
847 this%var_ids%y), this%nc_fname)
848 call nf_verify(nf90_put_att(this%ncid, this%var_ids%y,
'units', &
849 this%lenunits), this%nc_fname)
850 if (this%dis%angrot ==
dzero .or. &
851 wrap_rotated_crs(this%crs_wkt, this%dis%xorigin, this%dis%yorigin, &
852 this%dis%angrot) /=
'')
then
859 call nf_verify(nf90_put_att(this%ncid, this%var_ids%y,
'axis',
'Y'), &
861 call nf_verify(nf90_put_att(this%ncid, this%var_ids%y,
'standard_name', &
862 'projection_y_coordinate'), this%nc_fname)
864 call nf_verify(nf90_put_att(this%ncid, this%var_ids%y,
'long_name', &
865 'Northing'), this%nc_fname)
866 if (this%gridmap_name /=
'')
then
867 call nf_verify(nf90_put_att(this%ncid, this%var_ids%y,
'grid_mapping', &
868 this%gridmap_name), this%nc_fname)
870 call nf_verify(nf90_put_att(this%ncid, this%var_ids%y,
'bounds',
'y_bnds'), &
872 call nf_verify(nf90_def_var(this%ncid,
'y_bnds', nf90_double, &
873 (/this%dim_ids%bnd, this%dim_ids%y/), &
874 this%var_ids%y_bnds), this%nc_fname)
877 call nf_verify(nf90_def_dim(this%ncid,
'x', this%dis%ncol, this%dim_ids%x), &
879 call nf_verify(nf90_def_var(this%ncid,
'x', nf90_double, this%dim_ids%x, &
880 this%var_ids%x), this%nc_fname)
881 call nf_verify(nf90_put_att(this%ncid, this%var_ids%x,
'units', &
882 this%lenunits), this%nc_fname)
883 if (this%dis%angrot ==
dzero .or. &
884 wrap_rotated_crs(this%crs_wkt, this%dis%xorigin, this%dis%yorigin, &
885 this%dis%angrot) /=
'')
then
887 call nf_verify(nf90_put_att(this%ncid, this%var_ids%x,
'axis',
'X'), &
889 call nf_verify(nf90_put_att(this%ncid, this%var_ids%x,
'standard_name', &
890 'projection_x_coordinate'), this%nc_fname)
892 call nf_verify(nf90_put_att(this%ncid, this%var_ids%x,
'long_name', &
893 'Easting'), this%nc_fname)
894 if (this%gridmap_name /=
'')
then
895 call nf_verify(nf90_put_att(this%ncid, this%var_ids%x,
'grid_mapping', &
896 this%gridmap_name), this%nc_fname)
898 call nf_verify(nf90_put_att(this%ncid, this%var_ids%x,
'bounds',
'x_bnds'), &
900 call nf_verify(nf90_def_var(this%ncid,
'x_bnds', nf90_double, &
901 (/this%dim_ids%bnd, this%dim_ids%x/), &
902 this%var_ids%x_bnds), this%nc_fname)
907 call nf_verify(nf90_def_var(this%ncid,
'z', nf90_double, &
908 (/this%dim_ids%x, this%dim_ids%y, &
909 this%dim_ids%layer/), &
910 this%var_ids%elevation), this%nc_fname)
911 call ncvar_chunk3d(this%ncid, this%var_ids%elevation, this%chunk_x, &
912 this%chunk_y, this%chunk_z, this%nc_fname)
913 call ncvar_deflate(this%ncid, this%var_ids%elevation, this%deflate, &
914 this%shuffle, this%nc_fname)
915 call nf_verify(nf90_put_att(this%ncid, this%var_ids%elevation,
'units', &
916 this%lenunits), this%nc_fname)
917 call nf_verify(nf90_put_att(this%ncid, this%var_ids%elevation, &
918 'standard_name',
'altitude'), this%nc_fname)
919 call nf_verify(nf90_put_att(this%ncid, this%var_ids%elevation, &
920 'positive',
'up'), this%nc_fname)
921 call nf_verify(nf90_put_att(this%ncid, this%var_ids%elevation, &
922 'long_name',
'cell center elevation'), &
932 call nf_verify(nf90_def_var(this%ncid, this%xname, nf90_double, &
933 (/this%dim_ids%x, this%dim_ids%y, &
934 this%dim_ids%layer, this%dim_ids%time/), &
935 this%var_ids%dependent), &
939 if (this%chunking_active)
then
940 call nf_verify(nf90_def_var_chunking(this%ncid, &
941 this%var_ids%dependent, &
943 (/this%chunk_x, this%chunk_y, &
944 this%chunk_z, this%chunk_time/)), &
949 call ncvar_deflate(this%ncid, this%var_ids%dependent, this%deflate, &
950 this%shuffle, this%nc_fname)
954 if (this%modeltype ==
'GWF')
then
955 call nf_verify(nf90_put_att(this%ncid, this%var_ids%dependent, &
956 'units', this%lenunits), this%nc_fname)
958 call nf_verify(nf90_put_att(this%ncid, this%var_ids%dependent,
'long_name', &
959 this%annotation%longname), this%nc_fname)
960 call nf_verify(nf90_put_att(this%ncid, this%var_ids%dependent,
'_FillValue', &
968 call nf_verify(nf90_put_att(this%ncid, this%var_ids%dependent, &
969 'cell_methods',
'time: point'), this%nc_fname)
972 call ncvar_gridmap(this%ncid, this%var_ids%dependent, this%gridmap_name, &
973 this%latlon, .true., this%nc_fname)
980 integer(I4B) :: var_id
981 character(len=LINELENGTH) :: gmname
982 character(len=LENBIGLINE) :: effective_crs_wkt, derived_wkt
983 character(len=100) :: rotinfo
984 real(DP) :: longitude_of_central_meridian, latitude_of_projection_origin
985 real(DP) :: scale_factor_at_central_meridian, false_easting, false_northing
986 real(DP) :: semi_major_axis, inverse_flattening
987 real(DP) :: standard_parallel_1, standard_parallel_2
988 logical(LGP) :: params_found, is_2sp
990 if (this%wkt /=
'' .or. this%crs_wkt /=
'')
then
991 call nf_verify(nf90_redef(this%ncid), this%nc_fname)
992 call nf_verify(nf90_def_var(this%ncid, this%gridmap_name, nf90_int, &
993 var_id), this%nc_fname)
997 if (this%wkt /=
'')
then
998 call nf_verify(nf90_put_att(this%ncid, var_id,
'wkt', this%wkt), &
1002 if (this%crs_wkt /=
'')
then
1003 effective_crs_wkt = this%crs_wkt
1005 effective_crs_wkt = this%wkt
1013 if (this%dis%angrot /= dzero)
then
1014 if (this%crs_wkt ==
'')
then
1015 write (warnmsg,
'(a)')
'Structured rotated grid with no CRS_WKT &
1016 &input: no rotation-positioning information will be written &
1017 &to the output CRS; x/y coordinate values will not reflect &
1018 &the true rotated position. Applies to file "'// &
1019 trim(this%nc_fname)//
'".'
1022 derived_wkt = wrap_rotated_crs(this%crs_wkt, this%dis%xorigin, &
1023 this%dis%yorigin, this%dis%angrot)
1024 if (derived_wkt /=
'')
then
1025 write (rotinfo,
'(a,g0,a,g0,a,g0,a)')
'xorigin=', &
1026 this%dis%xorigin,
', yorigin=', this%dis%yorigin, &
1027 ', angrot=', this%dis%angrot,
' deg'
1028 write (warnmsg,
'(a)')
'Structured rotated grid: wrapped &
1029 &CRS_WKT in a derived CRS to encode grid rotation ('// &
1030 trim(rotinfo)//
'). Applies to file "'// &
1031 trim(this%nc_fname)//
'".'
1033 effective_crs_wkt = derived_wkt
1035 write (warnmsg,
'(a)')
'Structured rotated grid: CRS_WKT is &
1036 ¬ a recognized WKT2 PROJCRS; no rotation-positioning &
1037 &information will be written to the output CRS; x/y &
1038 &coordinate values will not reflect the true rotated &
1039 &position. Applies to file "'//trim(this%nc_fname)//
'".'
1044 call nf_verify(nf90_put_att(this%ncid, var_id,
'crs_wkt', &
1045 trim(effective_crs_wkt)), this%nc_fname)
1047 gmname = wkt_to_cf_gridmapping(trim(effective_crs_wkt))
1048 if (gmname /=
'')
then
1049 call nf_verify(nf90_put_att(this%ncid, var_id,
'grid_mapping_name', &
1050 trim(gmname)), this%nc_fname)
1063 if (trim(gmname) ==
'transverse_mercator')
then
1064 call wkt_transverse_mercator_params(trim(effective_crs_wkt), &
1065 longitude_of_central_meridian, &
1066 latitude_of_projection_origin, &
1067 scale_factor_at_central_meridian, &
1068 false_easting, false_northing, &
1069 semi_major_axis, inverse_flattening, &
1071 if (params_found)
then
1072 call nf_verify(nf90_put_att(this%ncid, var_id, &
1073 'longitude_of_central_meridian', &
1074 longitude_of_central_meridian), &
1076 call nf_verify(nf90_put_att(this%ncid, var_id, &
1077 'latitude_of_projection_origin', &
1078 latitude_of_projection_origin), &
1080 call nf_verify(nf90_put_att(this%ncid, var_id, &
1081 'scale_factor_at_central_meridian', &
1082 scale_factor_at_central_meridian), &
1084 call nf_verify(nf90_put_att(this%ncid, var_id,
'false_easting', &
1085 false_easting), this%nc_fname)
1086 call nf_verify(nf90_put_att(this%ncid, var_id,
'false_northing', &
1087 false_northing), this%nc_fname)
1088 call nf_verify(nf90_put_att(this%ncid, var_id,
'semi_major_axis', &
1089 semi_major_axis), this%nc_fname)
1090 call nf_verify(nf90_put_att(this%ncid, var_id,
'inverse_flattening', &
1091 inverse_flattening), this%nc_fname)
1093 write (warnmsg,
'(a)')
'Structured grid: unable to extract CF &
1094 &transverse_mercator grid_mapping parameters from CRS_WKT; &
1095 &some netCDF readers may not correctly position this grid. &
1096 &Applies to file "'//trim(this%nc_fname)//
'".'
1099 else if (trim(gmname) ==
'lambert_conformal_conic')
then
1100 call wkt_lambert_conformal_conic_params(trim(effective_crs_wkt), &
1101 standard_parallel_1, &
1102 standard_parallel_2, &
1103 longitude_of_central_meridian, &
1104 latitude_of_projection_origin, &
1105 false_easting, false_northing, &
1107 inverse_flattening, is_2sp, &
1109 if (params_found)
then
1110 call nf_verify(nf90_put_att(this%ncid, var_id,
'standard_parallel', &
1111 (/standard_parallel_1, &
1112 standard_parallel_2/)), this%nc_fname)
1113 call nf_verify(nf90_put_att(this%ncid, var_id, &
1114 'longitude_of_central_meridian', &
1115 longitude_of_central_meridian), &
1117 call nf_verify(nf90_put_att(this%ncid, var_id, &
1118 'latitude_of_projection_origin', &
1119 latitude_of_projection_origin), &
1121 call nf_verify(nf90_put_att(this%ncid, var_id,
'false_easting', &
1122 false_easting), this%nc_fname)
1123 call nf_verify(nf90_put_att(this%ncid, var_id,
'false_northing', &
1124 false_northing), this%nc_fname)
1125 call nf_verify(nf90_put_att(this%ncid, var_id,
'semi_major_axis', &
1126 semi_major_axis), this%nc_fname)
1127 call nf_verify(nf90_put_att(this%ncid, var_id,
'inverse_flattening', &
1128 inverse_flattening), this%nc_fname)
1129 else if (.not. is_2sp)
then
1130 write (warnmsg,
'(a)')
'Structured grid: 1SP lambert_conformal_conic &
1131 &variants are not supported for CF grid_mapping parameter &
1132 &extraction (CF has no scale_factor attribute for this method); &
1133 &some netCDF readers may not correctly position this grid. &
1134 &Applies to file "'//trim(this%nc_fname)//
'".'
1137 write (warnmsg,
'(a)')
'Structured grid: unable to extract CF &
1138 &lambert_conformal_conic grid_mapping parameters from CRS_WKT; &
1139 &some netCDF readers may not correctly position this grid. &
1140 &Applies to file "'//trim(this%nc_fname)//
'".'
1143 else if (trim(gmname) ==
'albers_conical_equal_area')
then
1144 call wkt_albers_conical_equal_area_params(trim(effective_crs_wkt), &
1145 standard_parallel_1, &
1146 standard_parallel_2, &
1147 longitude_of_central_meridian, &
1148 latitude_of_projection_origin, &
1149 false_easting, false_northing, &
1151 inverse_flattening, &
1153 if (params_found)
then
1154 call nf_verify(nf90_put_att(this%ncid, var_id,
'standard_parallel', &
1155 (/standard_parallel_1, &
1156 standard_parallel_2/)), this%nc_fname)
1157 call nf_verify(nf90_put_att(this%ncid, var_id, &
1158 'longitude_of_central_meridian', &
1159 longitude_of_central_meridian), &
1161 call nf_verify(nf90_put_att(this%ncid, var_id, &
1162 'latitude_of_projection_origin', &
1163 latitude_of_projection_origin), &
1165 call nf_verify(nf90_put_att(this%ncid, var_id,
'false_easting', &
1166 false_easting), this%nc_fname)
1167 call nf_verify(nf90_put_att(this%ncid, var_id,
'false_northing', &
1168 false_northing), this%nc_fname)
1169 call nf_verify(nf90_put_att(this%ncid, var_id,
'semi_major_axis', &
1170 semi_major_axis), this%nc_fname)
1171 call nf_verify(nf90_put_att(this%ncid, var_id,
'inverse_flattening', &
1172 inverse_flattening), this%nc_fname)
1174 write (warnmsg,
'(a)')
'Structured grid: unable to extract CF &
1175 &albers_conical_equal_area grid_mapping parameters from &
1176 &CRS_WKT; some netCDF readers may not correctly position this &
1177 &grid. Applies to file "'//trim(this%nc_fname)//
'".'
1185 call nf_verify(nf90_enddef(this%ncid), this%nc_fname)
1186 call nf_verify(nf90_put_var(this%ncid, var_id, 1), &
1195 if (this%latlon)
then
1197 call nf_verify(nf90_def_var(this%ncid,
'lat', nf90_double, &
1198 (/this%dim_ids%x, this%dim_ids%y/), &
1199 this%var_ids%latitude), this%nc_fname)
1200 call nf_verify(nf90_put_att(this%ncid, this%var_ids%latitude, &
1201 'units',
'degrees_north'), this%nc_fname)
1202 call nf_verify(nf90_put_att(this%ncid, this%var_ids%latitude, &
1203 'standard_name',
'latitude'), this%nc_fname)
1204 call nf_verify(nf90_put_att(this%ncid, this%var_ids%latitude, &
1205 'long_name',
'latitude'), this%nc_fname)
1208 call nf_verify(nf90_def_var(this%ncid,
'lon', nf90_double, &
1209 (/this%dim_ids%x, this%dim_ids%y/), &
1210 this%var_ids%longitude), this%nc_fname)
1211 call nf_verify(nf90_put_att(this%ncid, this%var_ids%longitude, &
1212 'units',
'degrees_east'), this%nc_fname)
1213 call nf_verify(nf90_put_att(this%ncid, this%var_ids%longitude, &
1214 'standard_name',
'longitude'), this%nc_fname)
1215 call nf_verify(nf90_put_att(this%ncid, this%var_ids%longitude, &
1216 'long_name',
'longitude'), this%nc_fname)
1224 if (this%latlon)
then
1226 call nf_verify(nf90_put_var(this%ncid, this%var_ids%latitude, &
1227 this%latitude, start=(/1, 1/), &
1228 count=(/this%dis%ncol, this%dis%nrow/)), &
1232 call nf_verify(nf90_put_var(this%ncid, this%var_ids%longitude, &
1233 this%longitude, start=(/1, 1/), &
1234 count=(/this%dis%ncol, this%dis%nrow/)), &
1243 integer(I4B) :: ibnd, n, k
1244 real(DP),
dimension(:, :),
pointer,
contiguous :: dbl2d
1245 real(DP),
dimension(:),
allocatable :: x, y
1246 real(DP),
dimension(:, :, :),
allocatable :: elev3d
1247 real(DP) :: xoff, yoff
1249 if (this%dis%angrot /= dzero)
then
1253 xoff = this%dis%xorigin
1254 yoff = this%dis%yorigin
1257 allocate (x(
size(this%dis%cellx)))
1258 allocate (y(
size(this%dis%celly)))
1260 do n = 1,
size(this%dis%cellx)
1261 x(n) = this%dis%cellx(n) + xoff
1264 do n = 1,
size(this%dis%celly)
1265 y(n) = this%dis%celly(n) + yoff
1268 call nf_verify(nf90_put_var(this%ncid, this%var_ids%x, x), &
1270 call nf_verify(nf90_put_var(this%ncid, this%var_ids%y, y), &
1273 call nf_verify(nf90_put_var(this%ncid, this%var_ids%layer, this%layers), &
1281 allocate (elev3d(this%dis%ncol, this%dis%nrow, this%nlay))
1284 elev3d(:, :, k) = (this%dis%top2d(:, :) + this%dis%bot3d(:, :, k)) * &
1287 elev3d(:, :, k) = (this%dis%bot3d(:, :, k - 1) + &
1288 this%dis%bot3d(:, :, k)) * dhalf
1291 call nf_verify(nf90_put_var(this%ncid, this%var_ids%elevation, elev3d), &
1296 allocate (dbl2d(2,
size(this%dis%cellx)))
1298 do n = 1,
size(this%dis%cellx)
1300 dbl2d(1, ibnd) = xoff
1301 dbl2d(2, ibnd) = xoff + this%dis%delr(ibnd)
1303 dbl2d(1, ibnd) = dbl2d(1, ibnd - 1) + this%dis%delr(ibnd)
1304 dbl2d(2, ibnd) = dbl2d(2, ibnd - 1) + this%dis%delr(ibnd)
1308 call nf_verify(nf90_put_var(this%ncid, this%var_ids%x_bnds, dbl2d), &
1313 allocate (dbl2d(2,
size(this%dis%celly)))
1315 do n =
size(this%dis%celly), 1, -1
1317 dbl2d(1, ibnd) = yoff + sum(this%dis%delc) - this%dis%delc(n)
1318 dbl2d(2, ibnd) = yoff + sum(this%dis%delc)
1320 dbl2d(1, ibnd) = dbl2d(1, ibnd - 1) - this%dis%delc(n)
1321 dbl2d(2, ibnd) = dbl2d(2, ibnd - 1) - this%dis%delc(n)
1325 call nf_verify(nf90_put_var(this%ncid, this%var_ids%y_bnds, dbl2d), &
1333 integer(I4B),
intent(in) :: ncid
1334 integer(I4B),
intent(in) :: varid
1335 integer(I4B),
intent(in) :: chunk_x
1336 integer(I4B),
intent(in) :: chunk_y
1337 character(len=*),
intent(in) :: nc_fname
1338 if (chunk_y > 0 .and. chunk_x > 0)
then
1339 call nf_verify(nf90_def_var_chunking(ncid, varid, nf90_chunked, &
1340 (/chunk_x, chunk_y/)), nc_fname)
1347 integer(I4B),
intent(in) :: ncid
1348 integer(I4B),
intent(in) :: varid
1349 integer(I4B),
intent(in) :: chunk_x
1350 integer(I4B),
intent(in) :: chunk_y
1351 integer(I4B),
intent(in) :: chunk_z
1352 character(len=*),
intent(in) :: nc_fname
1353 if (chunk_z > 0 .and. chunk_y > 0 .and. chunk_x > 0)
then
1354 call nf_verify(nf90_def_var_chunking(ncid, varid, nf90_chunked, &
1355 (/chunk_x, chunk_y, chunk_z/)), &
1363 integer(I4B),
intent(in) :: ncid
1364 integer(I4B),
intent(in) :: varid
1365 integer(I4B),
intent(in) :: deflate
1366 integer(I4B),
intent(in) :: shuffle
1367 character(len=*),
intent(in) :: nc_fname
1369 if (deflate >= 0)
then
1370 call nf_verify(nf90_def_var_deflate(ncid, varid, shuffle=shuffle, &
1371 deflate=1, deflate_level=deflate), &
1387 integer(I4B),
intent(in) :: ncid
1388 integer(I4B),
intent(in) :: varid
1389 character(len=*),
intent(in) :: gridmap_name
1390 logical(LGP),
intent(in) :: latlon
1391 logical(LGP),
intent(in) :: has_layer
1392 character(len=*),
intent(in) :: nc_fname
1393 character(len=LINELENGTH) :: coords
1403 if (len_trim(coords) > 0)
then
1404 coords = trim(coords)//
' z'
1409 if (len_trim(coords) > 0)
then
1410 call nf_verify(nf90_put_att(ncid, varid,
'coordinates', trim(coords)), &
1413 if (gridmap_name /=
'')
then
1414 call nf_verify(nf90_put_att(ncid, varid,
'grid_mapping', gridmap_name), &
1422 integer(I4B),
intent(in) :: ncid
1423 integer(I4B),
intent(in) :: varid
1424 integer(I4B),
intent(in) :: iaux
1425 character(len=*),
intent(in) :: nc_tag
1426 character(len=*),
intent(in) :: nc_fname
1427 if (nc_tag /=
'')
then
1428 call nf_verify(nf90_put_att(ncid, varid,
'modflow_input', &
1431 call nf_verify(nf90_put_att(ncid, varid,
'modflow_iaux', &
1440 nc_tag, pkgname, gridmap_name, latlon, deflate, &
1441 shuffle, chunk_z, chunk_y, chunk_x, iper, nc_fname)
1443 integer(I4B),
dimension(:),
pointer,
contiguous,
intent(in) :: p_mem
1444 integer(I4B),
intent(in) :: ncid
1447 type(
distype),
pointer,
intent(in) :: dis
1449 character(len=*),
intent(in) :: mempath
1450 character(len=*),
intent(in) :: nc_tag
1451 character(len=*),
intent(in) :: pkgname
1452 character(len=*),
intent(in) :: gridmap_name
1453 logical(LGP),
intent(in) :: latlon
1454 integer(I4B),
intent(in) :: deflate
1455 integer(I4B),
intent(in) :: shuffle
1456 integer(I4B),
intent(in) :: chunk_z
1457 integer(I4B),
intent(in) :: chunk_y
1458 integer(I4B),
intent(in) :: chunk_x
1459 integer(I4B),
intent(in) :: iper
1460 character(len=*),
intent(in) :: nc_fname
1461 integer(I4B) :: var_id, axis_sz
1462 character(len=LINELENGTH) :: varname, longname
1464 varname = export_varname(pkgname, idt%tagname, mempath)
1466 if (idt%shape ==
'NROW' .or. &
1467 idt%shape ==
'NCOL' .or. &
1468 idt%shape ==
'NCPL' .or. &
1469 idt%shape ==
'NAUX NCPL')
then
1472 select case (idt%shape)
1479 longname = export_longname(idt%longname, pkgname, idt%tagname, mempath, &
1480 component_type=idt%component_type, &
1481 subcomponent_type=idt%subcomponent_type)
1484 call nf_verify(nf90_redef(ncid), nc_fname)
1485 call nf_verify(nf90_def_var(ncid, varname, nf90_int, &
1486 (/axis_sz/), var_id), &
1490 call ncvar_deflate(ncid, var_id, deflate, shuffle, nc_fname)
1493 call nf_verify(nf90_put_att(ncid, var_id,
'_FillValue', &
1494 (/nf90_fill_int/)), nc_fname)
1495 call nf_verify(nf90_put_att(ncid, var_id,
'long_name', &
1496 longname), nc_fname)
1502 call nf_verify(nf90_enddef(ncid), nc_fname)
1503 call nf_verify(nf90_put_var(ncid, var_id, p_mem), &
1508 var_ids%export, p_mem, &
1509 start=(/1, 1,
kper/), &
1510 count=(/dis%ncol, dis%nrow, 1/)), nc_fname)
1517 call nf_verify(nf90_redef(ncid), nc_fname)
1518 call nf_verify(nf90_def_var(ncid, varname, nf90_int, &
1519 (/dim_ids%x, dim_ids%y, dim_ids%layer/), &
1523 call ncvar_chunk3d(ncid, var_id, chunk_x, chunk_y, chunk_z, nc_fname)
1525 call ncvar_deflate(ncid, var_id, deflate, shuffle, nc_fname)
1528 call nf_verify(nf90_put_att(ncid, var_id,
'_FillValue', &
1529 (/nf90_fill_int/)), nc_fname)
1530 call nf_verify(nf90_put_att(ncid, var_id,
'long_name', &
1531 idt%longname), nc_fname)
1534 call ncvar_gridmap(ncid, var_id, gridmap_name, latlon, .true., &
1539 call nf_verify(nf90_enddef(ncid), nc_fname)
1540 call nf_verify(nf90_put_var(ncid, var_id, p_mem, start=(/1, 1, 1/), &
1541 count=(/dis%ncol, dis%nrow, dis%nlay/)), &
1546 var_ids%export, p_mem, &
1547 start=(/1, 1, 1,
kper/), &
1548 count=(/dis%ncol, dis%nrow, dis%nlay, 1/)), &
1557 nc_tag, pkgname, gridmap_name, latlon, deflate, &
1558 shuffle, chunk_z, chunk_y, chunk_x, nc_fname)
1559 integer(I4B),
dimension(:, :),
pointer,
contiguous,
intent(in) :: p_mem
1560 integer(I4B),
intent(in) :: ncid
1563 type(
distype),
pointer,
intent(in) :: dis
1565 character(len=*),
intent(in) :: mempath
1566 character(len=*),
intent(in) :: nc_tag
1567 character(len=*),
intent(in) :: pkgname
1568 character(len=*),
intent(in) :: gridmap_name
1569 logical(LGP),
intent(in) :: latlon
1570 integer(I4B),
intent(in) :: deflate
1571 integer(I4B),
intent(in) :: shuffle
1572 integer(I4B),
intent(in) :: chunk_z
1573 integer(I4B),
intent(in) :: chunk_y
1574 integer(I4B),
intent(in) :: chunk_x
1575 character(len=*),
intent(in) :: nc_fname
1576 character(len=LINELENGTH) :: varname
1577 integer(I4B) :: var_id
1579 varname = export_varname(pkgname, idt%tagname, mempath)
1582 call nf_verify(nf90_redef(ncid), nc_fname)
1583 call nf_verify(nf90_def_var(ncid, varname, nf90_int, &
1584 (/dim_ids%x, dim_ids%y/), var_id), &
1588 call ncvar_chunk2d(ncid, var_id, chunk_x, chunk_y, nc_fname)
1590 call ncvar_deflate(ncid, var_id, deflate, shuffle, nc_fname)
1593 call nf_verify(nf90_put_att(ncid, var_id,
'_FillValue', &
1594 (/nf90_fill_int/)), nc_fname)
1595 call nf_verify(nf90_put_att(ncid, var_id,
'long_name', &
1596 idt%longname), nc_fname)
1599 call ncvar_gridmap(ncid, var_id, gridmap_name, latlon, .false., &
1604 call nf_verify(nf90_enddef(ncid), nc_fname)
1605 call nf_verify(nf90_put_var(ncid, var_id, p_mem, start=(/1, 1/), &
1606 count=(/dis%ncol, dis%nrow/)), &
1613 nc_tag, pkgname, gridmap_name, latlon, deflate, &
1614 shuffle, chunk_z, chunk_y, chunk_x, nc_fname)
1615 integer(I4B),
dimension(:, :, :),
pointer,
contiguous,
intent(in) :: p_mem
1616 integer(I4B),
intent(in) :: ncid
1619 type(
distype),
pointer,
intent(in) :: dis
1621 character(len=*),
intent(in) :: mempath
1622 character(len=*),
intent(in) :: nc_tag
1623 character(len=*),
intent(in) :: pkgname
1624 character(len=*),
intent(in) :: gridmap_name
1625 logical(LGP),
intent(in) :: latlon
1626 integer(I4B),
intent(in) :: deflate
1627 integer(I4B),
intent(in) :: shuffle
1628 integer(I4B),
intent(in) :: chunk_z
1629 integer(I4B),
intent(in) :: chunk_y
1630 integer(I4B),
intent(in) :: chunk_x
1631 character(len=*),
intent(in) :: nc_fname
1632 character(len=LINELENGTH) :: varname
1633 integer(I4B) :: var_id
1635 varname = export_varname(pkgname, idt%tagname, mempath)
1638 call nf_verify(nf90_redef(ncid), nc_fname)
1639 call nf_verify(nf90_def_var(ncid, varname, nf90_int, &
1640 (/dim_ids%x, dim_ids%y, dim_ids%layer/), &
1644 call ncvar_chunk3d(ncid, var_id, chunk_x, chunk_y, chunk_z, nc_fname)
1646 call ncvar_deflate(ncid, var_id, deflate, shuffle, nc_fname)
1649 call nf_verify(nf90_put_att(ncid, var_id,
'_FillValue', &
1650 (/nf90_fill_int/)), nc_fname)
1651 call nf_verify(nf90_put_att(ncid, var_id,
'long_name', &
1652 idt%longname), nc_fname)
1655 call ncvar_gridmap(ncid, var_id, gridmap_name, latlon, .true., &
1660 call nf_verify(nf90_enddef(ncid), nc_fname)
1661 call nf_verify(nf90_put_var(ncid, var_id, p_mem, start=(/1, 1, 1/), &
1662 count=(/dis%ncol, dis%nrow, dis%nlay/)), &
1669 nc_tag, pkgname, gridmap_name, latlon, deflate, &
1670 shuffle, chunk_z, chunk_y, chunk_x, iper, iaux, &
1673 real(DP),
dimension(:),
pointer,
contiguous,
intent(in) :: p_mem
1674 integer(I4B),
intent(in) :: ncid
1677 type(
distype),
pointer,
intent(in) :: dis
1679 character(len=*),
intent(in) :: mempath
1680 character(len=*),
intent(in) :: nc_tag
1681 character(len=*),
intent(in) :: pkgname
1682 character(len=*),
intent(in) :: gridmap_name
1683 logical(LGP),
intent(in) :: latlon
1684 integer(I4B),
intent(in) :: deflate
1685 integer(I4B),
intent(in) :: shuffle
1686 integer(I4B),
intent(in) :: chunk_z
1687 integer(I4B),
intent(in) :: chunk_y
1688 integer(I4B),
intent(in) :: chunk_x
1689 integer(I4B),
intent(in) :: iper
1690 integer(I4B),
intent(in) :: iaux
1691 character(len=*),
intent(in) :: nc_fname
1692 integer(I4B) :: var_id, axis_sz
1693 character(len=LINELENGTH) :: varname, longname
1695 if (idt%shape ==
'NROW' .or. &
1696 idt%shape ==
'NCOL' .or. &
1697 idt%shape ==
'NCPL' .or. &
1698 idt%shape ==
'NAUX NCPL')
then
1701 select case (idt%shape)
1708 varname = export_varname(pkgname, idt%tagname, mempath)
1709 longname = export_longname(idt%longname, pkgname, idt%tagname, mempath, &
1711 component_type=idt%component_type, &
1712 subcomponent_type=idt%subcomponent_type)
1715 call nf_verify(nf90_redef(ncid), nc_fname)
1716 call nf_verify(nf90_def_var(ncid, varname, nf90_double, &
1717 (/axis_sz/), var_id), &
1721 call ncvar_deflate(ncid, var_id, deflate, shuffle, nc_fname)
1724 call nf_verify(nf90_put_att(ncid, var_id,
'_FillValue', &
1725 (/nf90_fill_double/)), nc_fname)
1726 call nf_verify(nf90_put_att(ncid, var_id,
'long_name', &
1727 longname), nc_fname)
1733 call nf_verify(nf90_enddef(ncid), nc_fname)
1734 call nf_verify(nf90_put_var(ncid, var_id, p_mem), &
1739 var_ids%export, p_mem, &
1740 start=(/1, 1,
kper/), &
1741 count=(/dis%ncol, dis%nrow, 1/)), nc_fname)
1747 varname = export_varname(pkgname, idt%tagname, mempath, iaux=iaux)
1748 longname = export_longname(idt%longname, pkgname, idt%tagname, mempath, &
1750 component_type=idt%component_type, &
1751 subcomponent_type=idt%subcomponent_type)
1754 call nf_verify(nf90_redef(ncid), nc_fname)
1755 call nf_verify(nf90_def_var(ncid, varname, nf90_double, &
1756 (/dim_ids%x, dim_ids%y, dim_ids%layer/), &
1760 call ncvar_chunk3d(ncid, var_id, chunk_x, chunk_y, chunk_z, nc_fname)
1762 call ncvar_deflate(ncid, var_id, deflate, shuffle, nc_fname)
1765 call nf_verify(nf90_put_att(ncid, var_id,
'_FillValue', &
1766 (/nf90_fill_double/)), nc_fname)
1767 call nf_verify(nf90_put_att(ncid, var_id,
'long_name', &
1768 longname), nc_fname)
1771 call ncvar_gridmap(ncid, var_id, gridmap_name, latlon, .true., &
1776 call nf_verify(nf90_enddef(ncid), nc_fname)
1777 call nf_verify(nf90_put_var(ncid, var_id, p_mem, start=(/1, 1, 1/), &
1778 count=(/dis%ncol, dis%nrow, dis%nlay/)), &
1783 var_ids%export, p_mem, &
1784 start=(/1, 1, 1,
kper/), &
1785 count=(/dis%ncol, dis%nrow, dis%nlay, 1/)), &
1794 nc_tag, pkgname, gridmap_name, latlon, deflate, &
1795 shuffle, chunk_z, chunk_y, chunk_x, nc_fname)
1796 real(DP),
dimension(:, :),
pointer,
contiguous,
intent(in) :: p_mem
1797 integer(I4B),
intent(in) :: ncid
1800 type(
distype),
pointer,
intent(in) :: dis
1802 character(len=*),
intent(in) :: mempath
1803 character(len=*),
intent(in) :: nc_tag
1804 character(len=*),
intent(in) :: pkgname
1805 character(len=*),
intent(in) :: gridmap_name
1806 logical(LGP),
intent(in) :: latlon
1807 integer(I4B),
intent(in) :: deflate
1808 integer(I4B),
intent(in) :: shuffle
1809 integer(I4B),
intent(in) :: chunk_z
1810 integer(I4B),
intent(in) :: chunk_y
1811 integer(I4B),
intent(in) :: chunk_x
1812 character(len=*),
intent(in) :: nc_fname
1813 character(len=LINELENGTH) :: varname
1814 integer(I4B) :: var_id
1816 varname = export_varname(pkgname, idt%tagname, mempath)
1819 call nf_verify(nf90_redef(ncid), nc_fname)
1820 call nf_verify(nf90_def_var(ncid, varname, nf90_double, &
1821 (/dim_ids%x, dim_ids%y/), var_id), &
1825 call ncvar_chunk2d(ncid, var_id, chunk_x, chunk_y, nc_fname)
1827 call ncvar_deflate(ncid, var_id, deflate, shuffle, nc_fname)
1830 call nf_verify(nf90_put_att(ncid, var_id,
'_FillValue', &
1831 (/nf90_fill_double/)), nc_fname)
1832 call nf_verify(nf90_put_att(ncid, var_id,
'long_name', &
1833 idt%longname), nc_fname)
1836 call ncvar_gridmap(ncid, var_id, gridmap_name, latlon, .false., &
1841 call nf_verify(nf90_enddef(ncid), nc_fname)
1842 call nf_verify(nf90_put_var(ncid, var_id, p_mem, start=(/1, 1/), &
1843 count=(/dis%ncol, dis%nrow/)), &
1850 nc_tag, pkgname, gridmap_name, latlon, deflate, &
1851 shuffle, chunk_z, chunk_y, chunk_x, nc_fname)
1852 real(DP),
dimension(:, :, :),
pointer,
contiguous,
intent(in) :: p_mem
1853 integer(I4B),
intent(in) :: ncid
1856 type(
distype),
pointer,
intent(in) :: dis
1858 character(len=*),
intent(in) :: mempath
1859 character(len=*),
intent(in) :: nc_tag
1860 character(len=*),
intent(in) :: pkgname
1861 character(len=*),
intent(in) :: gridmap_name
1862 logical(LGP),
intent(in) :: latlon
1863 integer(I4B),
intent(in) :: deflate
1864 integer(I4B),
intent(in) :: shuffle
1865 integer(I4B),
intent(in) :: chunk_z
1866 integer(I4B),
intent(in) :: chunk_y
1867 integer(I4B),
intent(in) :: chunk_x
1868 character(len=*),
intent(in) :: nc_fname
1869 integer(I4B) :: var_id
1870 character(len=LINELENGTH) :: varname, longname
1872 varname = export_varname(pkgname, idt%tagname, mempath)
1873 longname = export_longname(idt%longname, pkgname, idt%tagname, mempath, &
1874 component_type=idt%component_type, &
1875 subcomponent_type=idt%subcomponent_type)
1878 call nf_verify(nf90_redef(ncid), nc_fname)
1879 call nf_verify(nf90_def_var(ncid, varname, nf90_double, &
1880 (/dim_ids%x, dim_ids%y, dim_ids%layer/), &
1884 call ncvar_chunk3d(ncid, var_id, chunk_x, chunk_y, chunk_z, nc_fname)
1886 call ncvar_deflate(ncid, var_id, deflate, shuffle, nc_fname)
1889 call nf_verify(nf90_put_att(ncid, var_id,
'_FillValue', &
1890 (/nf90_fill_double/)), nc_fname)
1891 call nf_verify(nf90_put_att(ncid, var_id,
'long_name', &
1892 longname), nc_fname)
1895 call ncvar_gridmap(ncid, var_id, gridmap_name, latlon, .true., &
1900 call nf_verify(nf90_enddef(ncid), nc_fname)
1901 call nf_verify(nf90_put_var(ncid, var_id, p_mem, start=(/1, 1, 1/), &
1902 count=(/dis%ncol, dis%nrow, dis%nlay/)), &
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
real(dp), parameter dnodata
real no data constant
integer(i4b), parameter lenbigline
maximum length of a big line
real(dp), parameter dhnoflo
real no flow constant
@ dis
DIS6 discretization.
real(dp), parameter dhalf
real constant 1/2
real(dp), parameter dzero
real constant zero
integer(i4b), parameter lenmempath
maximum length of the memory path
This module contains the DefinitionSelectModule.
type(inputparamdefinitiontype) function, pointer, public get_param_definition_type(input_definition_types, component_type, subcomponent_type, blockname, tagname, filename, found)
Return parameter definition.
This module contains the DisNCStructuredModule.
subroutine add_pkg_data(this)
determine packages to write gridded input
subroutine ncvar_mf6attr(ncid, varid, iaux, nc_tag, nc_fname)
put variable internal modflow6 attributes
subroutine dis_export_destroy(this)
netcdf export dis destroy
subroutine nc_export_int3d(p_mem, ncid, dim_ids, var_ids, dis, idt, mempath, nc_tag, pkgname, gridmap_name, latlon, deflate, shuffle, chunk_z, chunk_y, chunk_x, nc_fname)
netcdf export 3D integer
subroutine ncvar_gridmap(ncid, varid, gridmap_name, latlon, has_layer, nc_fname)
put variable gridmap attributes
subroutine add_global_att(this)
create file (group) attributes
subroutine dis_export_init(this, modelname, modeltype, modelfname, nc_fname, disenum, nctype, iout)
netcdf export dis init
subroutine export_input_arrays(this, pkgtype, pkgname, mempath, param_dfns)
write package gridded input data
subroutine add_grid_data(this)
add grid coordinates
subroutine define_geocoords(this)
define grid projection variables
subroutine df(this)
netcdf export define
subroutine nc_export_dbl3d(p_mem, ncid, dim_ids, var_ids, dis, idt, mempath, nc_tag, pkgname, gridmap_name, latlon, deflate, shuffle, chunk_z, chunk_y, chunk_x, nc_fname)
netcdf export 3D double
subroutine nc_export_dbl2d(p_mem, ncid, dim_ids, var_ids, dis, idt, mempath, nc_tag, pkgname, gridmap_name, latlon, deflate, shuffle, chunk_z, chunk_y, chunk_x, nc_fname)
netcdf export 2D double
subroutine ncvar_chunk2d(ncid, varid, chunk_x, chunk_y, nc_fname)
define 2d variable chunking
subroutine nc_export_int1d(p_mem, ncid, dim_ids, var_ids, dis, idt, mempath, nc_tag, pkgname, gridmap_name, latlon, deflate, shuffle, chunk_z, chunk_y, chunk_x, iper, nc_fname)
netcdf export 1D integer
subroutine add_proj_data(this)
add grid projection data
subroutine df_export(this)
define timeseries input variables
subroutine step(this)
netcdf export step
subroutine ncvar_deflate(ncid, varid, deflate, shuffle, nc_fname)
define variable compression
subroutine export_df(this, export_pkg)
define export package
subroutine define_dependent(this)
create the model layer dependent variables
subroutine create_timeseries(this, idt, iparam, iaux, export_pkg)
create timeseries export variable
subroutine export_input_array(this, pkgtype, pkgname, mempath, idt)
netcdf export an input array
subroutine ncvar_chunk3d(ncid, varid, chunk_x, chunk_y, chunk_z, nc_fname)
define 3d variable chunking
subroutine nc_export_int2d(p_mem, ncid, dim_ids, var_ids, dis, idt, mempath, nc_tag, pkgname, gridmap_name, latlon, deflate, shuffle, chunk_z, chunk_y, chunk_x, nc_fname)
netcdf export 2D integer
subroutine define_dim(this)
netcdf export define dimensions
subroutine package_step(this, export_pkg)
netcdf export package dynamic input
subroutine nc_export_dbl1d(p_mem, ncid, dim_ids, var_ids, dis, idt, mempath, nc_tag, pkgname, gridmap_name, latlon, deflate, shuffle, chunk_z, chunk_y, chunk_x, iper, iaux, nc_fname)
netcdf export 1D double
subroutine define_gridmap(this)
create the file grid mapping container variable
type(inputparamdefinitiontype) function, dimension(:), pointer, public param_definitions(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)
Get the number of elements for this variable.
This module contains the NCModelExportModule.
character(len=lenbigline) function, public wrap_rotated_crs(wkt, xorigin, yorigin, angrot)
wrap a WKT2 PROJCRS in a derived CRS encoding grid rotation
character(len=linelength) function, public wkt_to_cf_gridmapping(wkt)
map a WKT string to a CF-1.13 grid_mapping_name
character(len=linelength) function, public export_varname(pkgname, tagname, mempath, layer, iaux)
build netcdf variable name
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
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
character(len=linelength) function, public export_longname(longname, pkgname, tagname, mempath, layer, iaux, component_type, subcomponent_type)
build netcdf variable longname
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
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_warning(msg, substring)
Store warning message.
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
character(len=maxcharlen) warnmsg
warning message string
integer(i4b) isim_mode
simulation mode
This module contains the SourceCommonModule.
character(len=lencomponentname) function, public idm_subcomponent_type(component, subcomponent)
component from package or model type
character(len=lenpackagename) function, public idm_subcomponent_name(component_type, subcomponent_type, sc_name)
model package subcomponent name
real(dp), dimension(:), pointer, public, contiguous perlen
length of each stress period
real(dp), pointer, public totim
time relative to start of simulation
integer(i4b), pointer, public kper
current stress period number
This class is used to store a single deferred-length character string. It was designed to work in an ...
Structured grid discretization.
abstract type for model netcdf export type