@@ -281,7 +281,7 @@ subroutine export_input_array(this, pkgtype, pkgname, mempath, idt)
281281 iaux = 0
282282
283283 ! set variable name and input attribute string
284- nc_varname = export_varname(pkgname, idt)
284+ nc_varname = export_varname(pkgname, idt% mf6varname )
285285 input_attr = this% input_attribute(pkgname, idt)
286286
287287 select case (idt% datatype)
@@ -411,8 +411,8 @@ subroutine package_step_ilayer(this, export_pkg, ilayer_varname, ilayer)
411411 ' PERIOD' , export_pkg% param_names(iparam), &
412412 this% nc_fname)
413413 ! set variable name and input attrs
414- nc_varname = export_varname(export_pkg% mf6_input% subcomponent_name, idt, &
415- iper= kper)
414+ nc_varname = export_varname(export_pkg% mf6_input% subcomponent_name, &
415+ idt % mf6varname, iper= kper)
416416 input_attr = this% input_attribute(export_pkg% mf6_input% subcomponent_name, &
417417 idt)
418418 ! export arrays
@@ -457,13 +457,19 @@ subroutine package_step(this, export_pkg)
457457 use TdisModule, only: kper
458458 use NCModelExportModule, only: ExportPackageType
459459 use DefinitionSelectModule, only: get_param_definition_type
460+ use ConstantsModule, only: DNODATA, LENAUXNAME
460461 class(DisNCStructuredType), intent (inout ) :: this
461462 class(ExportPackageType), pointer , intent (in ) :: export_pkg
462463 integer (I4B), dimension (:), pointer , contiguous :: int1d
463464 real (DP), dimension (:), pointer , contiguous :: dbl1d
465+ real (DP), dimension (:, :), pointer , contiguous :: dbl2d
466+ real (DP), dimension (:, :, :), pointer , contiguous :: dbl3d
464467 type (InputParamDefinitionType), pointer :: idt
465468 character (len= LINELENGTH) :: nc_varname, input_attr
466- integer (I4B) :: iparam
469+ character (len= LENAUXNAME) :: aux
470+ type (CharacterStringType), dimension (:), pointer , &
471+ contiguous :: auxname_cst
472+ integer (I4B) :: iparam, n
467473
468474 do iparam = 1 , export_pkg% nparam
469475 ! set input definition
@@ -474,8 +480,8 @@ subroutine package_step(this, export_pkg)
474480 this% nc_fname)
475481
476482 ! set variable name and input attribute string
477- nc_varname = export_varname(export_pkg% mf6_input% subcomponent_name, idt, &
478- iper= kper)
483+ nc_varname = export_varname(export_pkg% mf6_input% subcomponent_name, &
484+ idt % mf6varname, iper= kper)
479485 input_attr = this% input_attribute(export_pkg% mf6_input% subcomponent_name, &
480486 idt)
481487
@@ -501,6 +507,26 @@ subroutine package_step(this, export_pkg)
501507 this% gridmap_name, this% latlon, this% deflate, &
502508 this% shuffle, this% chunk_z, this% chunk_y, &
503509 this% chunk_x, kper, this% nc_fname)
510+ case (' DOUBLE2D' )
511+ call mem_setptr(dbl2d, idt% mf6varname, export_pkg% mf6_input% mempath)
512+ call mem_setptr(auxname_cst, ' AUXILIARY' , export_pkg% mf6_input% mempath)
513+ do n = 1 , size (dbl2d, dim= 1 ) ! naux
514+ ! reset varname to auxname
515+ aux = auxname_cst(n)
516+ nc_varname = export_varname(export_pkg% mf6_input% subcomponent_name, &
517+ aux, iper= kper)
518+
519+ ! export the 1d array as a structured 3d array
520+ dbl3d(1 :export_pkg% mshape(3 ), 1 :export_pkg% mshape(2 ), &
521+ 1 :export_pkg% mshape(1 )) = > dbl2d(n, :)
522+ call nc_export_array(this% ncid, this% dim_ids, this% var_ids, &
523+ this% dis, dbl3d, nc_varname, &
524+ export_pkg% mf6_input% subcomponent_name, &
525+ aux, ' NCOL NROW NLAY' , idt% longname, input_attr, &
526+ this% gridmap_name, this% latlon, this% deflate, &
527+ this% shuffle, this% chunk_z, this% chunk_y, &
528+ this% chunk_x, kper, n, this% nc_fname)
529+ end do
504530 case default
505531 errmsg = ' EXPORT unsupported datatype=' // trim (idt% datatype)
506532 call store_error(errmsg, .true. )
@@ -515,7 +541,7 @@ end subroutine package_step
515541 ! <
516542 subroutine export_layer_3d (this , export_pkg , idt , ilayer_read , ialayer , &
517543 dbl1d , nc_varname , input_attr , iaux )
518- use ConstantsModule, only: DNODATA, DZERO
544+ use ConstantsModule, only: DNODATA, DZERO, LENAUXNAME
519545 use TdisModule, only: kper
520546 use NCModelExportModule, only: ExportPackageType
521547 class(DisNCStructuredType), intent (inout ) :: this
@@ -530,12 +556,17 @@ subroutine export_layer_3d(this, export_pkg, idt, ilayer_read, ialayer, &
530556 real (DP), dimension (:, :, :), pointer , contiguous :: dbl3d
531557 integer (I4B) :: n, i, j, k, nvals, idxaux
532558 real (DP), dimension (:, :), contiguous, pointer :: dbl2d_ptr
559+ character (len= LENAUXNAME) :: aux
560+ type (CharacterStringType), dimension (:), pointer , &
561+ contiguous :: auxname_cst
533562
534563 ! initialize
535564 idxaux = 0
536565 if (present (iaux)) then
566+ call mem_setptr(auxname_cst, ' AUXILIARY' , export_pkg% mf6_input% mempath)
567+ aux = auxname_cst(iaux)
537568 nc_varname = export_varname(export_pkg% mf6_input% subcomponent_name, &
538- idt , iper= kper, iaux = iaux )
569+ aux , iper= kper)
539570 idxaux = iaux
540571 end if
541572
@@ -1454,27 +1485,21 @@ end subroutine nc_export_dbl3d
14541485
14551486 ! > @brief build netcdf variable name
14561487 ! <
1457- function export_varname (pkgname , idt , iper , iaux ) result(varname )
1488+ function export_varname (pkgname , varname , iper ) result(fullname )
14581489 use InputOutputModule, only: lowcase
14591490 character (len=* ), intent (in ) :: pkgname
1460- type (InputParamDefinitionType ), pointer , intent (in ) :: idt
1491+ character (len =* ), intent (in ) :: varname
14611492 integer (I4B), optional , intent (in ) :: iper
1462- integer (I4B), optional , intent (in ) :: iaux
1463- character (len= LINELENGTH) :: varname
1493+ character (len= LINELENGTH) :: fullname
14641494 character (len= LINELENGTH) :: pname, vname
14651495 pname = pkgname
1466- vname = idt % mf6varname
1496+ vname = varname
14671497 call lowcase(pname)
14681498 call lowcase(vname)
14691499 if (present (iper)) then
1470- if (present (iaux)) then
1471- write (varname, ' (a,i0,a,i0)' ) trim (pname)// ' _' // trim (vname)// &
1472- ' _p' , iper, ' a' , iaux
1473- else
1474- write (varname, ' (a,i0)' ) trim (pname)// ' _' // trim (vname)// ' _p' , iper
1475- end if
1500+ write (fullname, ' (a,i0)' ) trim (pname)// ' _' // trim (vname)// ' _p' , iper
14761501 else
1477- varname = trim (pname)// ' _' // trim (vname)
1502+ fullname = trim (pname)// ' _' // trim (vname)
14781503 end if
14791504 end function export_varname
14801505
0 commit comments