Skip to content

Commit

Permalink
Merge pull request #188 from HydrologicEngineeringCenter/bugfix/v6-co…
Browse files Browse the repository at this point in the history
…py-large-record

DSS-127 Allow/test record/file copy with records > 2MB of data
  • Loading branch information
perrymanmd authored Jan 24, 2023
2 parents 052be43 + b7e91b5 commit cbdb126
Show file tree
Hide file tree
Showing 11 changed files with 600 additions and 439 deletions.
1 change: 1 addition & 0 deletions heclib/heclib_c/heclib_c.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
<ClCompile Include="src\Internal\zcloseInternal.c" />
<ClCompile Include="src\Internal\zcollectionsPath.c" />
<ClCompile Include="src\Internal\zcompareRecordStatus.c" />
<ClCompile Include="src\Internal\zCopyRecord6Dynamic.c" />
<ClCompile Include="src\Internal\zcopyRecordInternal.c" />
<ClCompile Include="src\Internal\zdeleteInternal.c" />
<ClCompile Include="src\Internal\zerrorDecode.c" />
Expand Down
3 changes: 3 additions & 0 deletions heclib/heclib_c/heclib_c.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -1302,6 +1302,9 @@
<ClCompile Include="src\Utilities\normalizeFPart.c">
<Filter>src\Utilities</Filter>
</ClCompile>
<ClCompile Include="src\Internal\zCopyRecord6Dynamic.c">
<Filter>src\Internal</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\headers\zlib\zconf.h">
Expand Down
64 changes: 64 additions & 0 deletions heclib/heclib_c/src/Internal/zCopyRecord6Dynamic.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#include <heclib.h>
#include <string.h>

#define KIHEAD 1000
#define KCHEAD 100

int zCopyRecord6Dynamic(long long* ifltabFrom, long long* ifltabTo, const char* pathnameFrom, const char* pathnameTo) {

int nPathname;
int kihead = KIHEAD;
int kchead = KCHEAD;
int kuhead = 0;
int kdata = 0;
int nihead = 0;
int nchead = 0;
int nuhead = 0;
int ndata = 0;
int found = 0;
int iplan = 0;
int itype = 0;
int status = 0;
int ihead[KIHEAD] = { 0 };
int chead[KCHEAD] = { 0 };
int* uhead = NULL;
int* data = NULL;

if (pathnameFrom == NULL || pathnameTo == NULL) {
return -1;
}
nPathname = strlen(pathnameFrom);
zcheck_(ifltabFrom, pathnameFrom, &nPathname, &kuhead, &kdata, &found, strlen(pathnameFrom));
if (!found) {
return -2;
}
itype = zdataType(ifltabFrom, pathnameFrom);
if (itype == 0) {
return -3;
}
if (kuhead > 0) {
uhead = (int*)malloc(kuhead * sizeof(int));
}
if (kdata > 0) {
data = (int*)malloc(kdata * sizeof(int));
}
zreadx(ifltabFrom, pathnameFrom, ihead, &kihead, &nihead, chead, &kchead, &nchead, uhead, &kuhead, &nuhead, data, &kdata, &ndata, &iplan, &found);
nPathname = strlen(pathnameTo);
zwritex_(ifltabTo, pathnameTo, &nPathname, ihead, &nihead, chead, &nchead, uhead, &nuhead, data, &ndata, &itype, &iplan, &status, &found, strlen(pathnameTo));

free(uhead);
free(data);
return status;
}

#undef KIHEAD
#undef KCHEAD

void zcopyrecord6dynamic_(long long* ifltabFrom, long long* ifltabTo, const char* pathnameFrom, const char* pathnameTo, int* status, size_t pathnameFromLen, size_t pathnameToLen) {
char* cPathnameFrom = stringFortToC(pathnameFrom, pathnameFromLen);
char* cPathnameTo = stringFortToC(pathnameTo, pathnameToLen);
*status = zCopyRecord6Dynamic(ifltabFrom, ifltabTo, cPathnameFrom, cPathnameTo);
free(cPathnameFrom);
free(cPathnameTo);
}

2 changes: 1 addition & 1 deletion heclib/heclib_c/src/headers/hecdssInternal.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@


#define DSS_VERSION "7-IQ"
#define DSS_VERSION_DATE "17 January 2023"
#define DSS_VERSION_DATE "23 January 2023"



Expand Down
45 changes: 31 additions & 14 deletions heclib/heclib_f/src/zcopyRecord6.f
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ SUBROUTINE zcopyRecord6(ifltabFrom, ifltabTo, cpathFrom, cpathTo,
implicit none
C
include 'dss_parameters.h'

INTEGER ifltabFrom(*), ifltabTo(*)
CHARACTER cpathFrom*(*), cpathTo*(*)
CHARACTER(len=dss_maxpath) CPATH
Expand Down Expand Up @@ -286,21 +287,37 @@ SUBROUTINE zcopyRecord6(ifltabFrom, ifltabTo, cpathFrom, cpathTo,
C
IPLAN = 0

CALL ZREADX(ifltabFrom, cpathFrom(1:npathFrom), IIHEAD, KIHEAD,
* NIHEAD, ICHEAD, KCHEAD, NCHEAD, INTBUF, NIBUFF, NUHEAD, ILBUFF,
* KLBUFF, NVALS, IPLAN, LFOUND)
IF (.NOT.LFOUND) THEN
if ((mlvl.ge.2).and.(munit.gt.0)) then
write(munit, 17) cpathFrom(1:npathFrom)
17 Format(' ---zcopyRecord Loc i, Error reading record: ',A)
endif
ISTAT = -1
RETURN
ENDIF
call zcheck(
* ifltabFrom,
* cpathto(1:npathTo),
* npathTo,
* nuhead,
* nvals,
* lfound)
if (nvals.gt.klbuff) then
call zCopyRecord6Dynamic(
* ifltabFrom,
* ifltabTo,
* cpathFrom,
* cpathTo,
* istat)
else
CALL ZREADX(ifltabFrom, cpathFrom(1:npathFrom), IIHEAD,KIHEAD,
* NIHEAD, ICHEAD, KCHEAD, NCHEAD, INTBUF, NIBUFF, NUHEAD,ILBUFF,
* KLBUFF, NVALS, IPLAN, LFOUND)
IF (.NOT.LFOUND) THEN
if ((mlvl.ge.2).and.(munit.gt.0)) then
write(munit, 17) cpathFrom(1:npathFrom)
17 Format(' ---zcopyRecord Loc i, Error reading record: ',A)
endif
ISTAT = -1
RETURN
ENDIF
CALL ZWRITEX(ifltabTo, cpathTo(1:npathTo), npathTo, IIHEAD,
* NIHEAD,ICHEAD, NCHEAD, INTBUF, NUHEAD, ILBUFF, NVALS,
* IDTYPE, IPLAN, ISTAT, LFOUND)
endif
C
CALL ZWRITEX(ifltabTo, cpathTo(1:npathTo), npathTo,IIHEAD,NIHEAD,
* ICHEAD, NCHEAD, INTBUF, NUHEAD, ILBUFF, NVALS, IDTYPE,
* IPLAN, ISTAT, LFOUND)
IF (ISTAT.ne.0) THEN
if ((mlvl.ge.2).and.(munit.gt.0)) then
write(munit, 22) istat, cpathTo(1:npathTo)
Expand Down
Loading

0 comments on commit cbdb126

Please sign in to comment.