Skip to content

Commit

Permalink
sync and reduce examples files (#513)
Browse files Browse the repository at this point in the history
* sync the examples to HDF4Examples and eliminate old dirs
  • Loading branch information
byrnHDF authored Feb 12, 2024
1 parent 520f5db commit be9b9c9
Show file tree
Hide file tree
Showing 203 changed files with 1,669 additions and 11,616 deletions.
6 changes: 0 additions & 6 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,6 @@ hdf/util/testfiles/tvattr.hdf -text
java/CMakeLists.txt -text
java/Makefile.am -text
java/Makefile.in -text
java/examples/CMakeLists.txt -text
java/examples/HDF4DatasetCreate.java -text
java/examples/HDF4FileCreate.java -text
java/examples/HDF4GroupCreate.java -text
java/examples/Makefile.am -text
java/examples/Makefile.in -text
java/lib/ext/slf4j-nop-1.7.33.jar -text svneol=unset#application/zip
java/lib/ext/slf4j-simple-1.7.33.jar -text svneol=unset#application/zip
java/lib/hamcrest-core.jar -text svneol=unset#application/java-archive
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/cmake-bintest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ jobs:
# MacOS w/ Clang + CMake
#
name: "MacOS Clang Binary Test"
if: false
runs-on: macos-13
steps:
- name: Install Dependencies (MacOS)
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/main-cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,6 @@ jobs:
#
# CMAKE CONFIGURE
#
- name: Get Java setting
run: echo "useJava=${{ inputs.shared=='true' }}" >> $GITHUB_ENV

- name: CMake Configure
run: |
Expand All @@ -167,7 +165,7 @@ jobs:
-DBUILD_JPEG_WITH_PIC:BOOL=ON \
-DHDF4_ENABLE_NETCDF:BOOL=${{ inputs.netcdf }} \
-DHDF4_BUILD_FORTRAN:BOOL=${{ matrix.fortran }} \
-DHDF4_BUILD_JAVA:BOOL=${{ env.useJava }} \
-DHDF4_BUILD_JAVA:BOOL=${{ inputs.shared }} \
-DHDF4_BUILD_DOC:BOOL=${{ matrix.docs }} \
-DJPEG_USE_LOCALCONTENT:BOOL=${{ matrix.localjpeg }} \
-DLIBAEC_USE_LOCALCONTENT:BOOL=${{ matrix.locallibaec }} \
Expand Down
247 changes: 113 additions & 134 deletions HDF4Examples/C/AN/h4ex_AN_create_annotation.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,144 +12,123 @@ main()
{
/************************* Variable declaration **************************/

intn status_n; /* returned status for functions returning an intn */
int32 status_32; /* returned status for functions returning an int32 */
int32 file_id; /* HDF file identifier */
int32 an_id; /* AN interface identifier */
int32 file_label_id; /* file label identifier */
int32 file_desc_id; /* file description identifier */
int32 data_label_id; /* data label identifier */
int32 data_desc_id; /* data description identifier */
int32 vgroup_id;
uint16 vgroup_tag;
uint16 vgroup_ref;
int ret_val = FAIL;
int32 file_id, /* HDF file identifier */
an_id, /* AN interface identifier */
file_label_id, /* file label identifier */
file_desc_id, /* file description identifier */
data_label_id, /* data label identifier */
data_desc_id, /* data description identifier */
vgroup_id;
uint16 vgroup_tag, vgroup_ref;

/********************** End of variable declaration **********************/

/*
* Create the HDF file.
*/
file_id = Hopen(FILE_NAME, DFACC_CREATE, 0);
if (file_id == FAIL)
printf("\nUnable to open file %s for writing.\n", FILE_NAME);
else {
/*
* Initialize the AN interface.
*/
an_id = ANstart(file_id);
if (an_id == FAIL)
printf("\nCannot start annotation handling on the file %s.\n", FILE_NAME);
else {
/*
* Create the file label.
*/
file_label_id = ANcreatef(an_id, AN_FILE_LABEL);
if (file_label_id == FAIL)
printf("\nCannot create a new file label annotation.\n");
else {
/*
* Write the annotations to the file label.
*/
status_32 = ANwriteann(file_label_id, FILE_LABEL_TXT, (int32)strlen(FILE_LABEL_TXT));
if (status_32 == FAIL)
printf("\nFailed to write label annotation.\n");

/*
* Create file description.
*/
file_desc_id = ANcreatef(an_id, AN_FILE_DESC);
if (file_desc_id == FAIL)
printf("\nCannot create a new file description annotation.\n");
else {
/*
* Write the annotation to the file description.
*/
status_32 = ANwriteann(file_desc_id, FILE_DESC_TXT, (int32)strlen(FILE_DESC_TXT));
if (status_32 == FAIL)
printf("\nFailed to write description annotation.\n");

/*
* Create a vgroup in the V interface. Note that the vgroup's ref number
* is set to -1 for creating and the access mode is "w" for writing.
*/
status_n = Vstart(file_id);
if (status_n == FAIL)
printf("\nCould not start VGroup interface\n");
else {
vgroup_id = Vattach(file_id, -1, "w");
if (vgroup_id == FAIL)
printf("\nCould not attach to VGroup interface\n");
else {
status_32 = Vsetname(vgroup_id, VG_NAME);
if (status_32 == FAIL)
printf("\nCould not name group.\n");

/*
* Obtain the tag and ref number of the vgroup for subsequent
* references.
*/
vgroup_tag = (uint16)VQuerytag(vgroup_id);
vgroup_ref = (uint16)VQueryref(vgroup_id);

/*
* Create the data label for the vgroup identified by its tag
* and ref number.
*/
data_label_id = ANcreate(an_id, vgroup_tag, vgroup_ref, AN_DATA_LABEL);
if (data_label_id == FAIL)
printf("\nCannot create a new data label annotation.\n");
else {
/*
* Write the annotation text to the data label.
*/
status_32 =
ANwriteann(data_label_id, DATA_LABEL_TXT, (int32)strlen(DATA_LABEL_TXT));
if (status_32 == FAIL)
printf("\nFailed to write data label annotation.\n");

/*
* Create the data description for the vgroup identified by its tag
* and ref number.
*/
data_desc_id = ANcreate(an_id, vgroup_tag, vgroup_ref, AN_DATA_DESC);
if (data_desc_id == FAIL)
printf("\nCannot create a new data description annotation.\n");
else {
/*
* Write the annotation text to the data description.
*/
status_32 =
ANwriteann(data_desc_id, DATA_DESC_TXT, strlen(DATA_DESC_TXT));
if (status_32 == FAIL) {
printf("\nFailed to write data description annotation.\n");
}
else {
ret_val = SUCCEED;
}
status_n = ANendaccess(data_desc_id);
}
status_n = ANendaccess(data_label_id);
}
/*
* Terminate access to the vgroup and to the V interface.
*/
status_32 = Vdetach(vgroup_id);
}
status_n = Vend(file_id);
}
status_n = ANendaccess(file_desc_id);
}
status_n = ANendaccess(file_label_id);
}
/*
* Terminate access to the AN interface and close the HDF file.
*/
status_32 = ANend(an_id);
}
status_n = Hclose(file_id);
}
if (ret_val == SUCCEED)
printf("\nSuccessful!\n");
return ret_val;
if ((file_id = Hopen(FILE_NAME, DFACC_CREATE, 0)) == FAIL)
printf("*** ERROR from Hopen\n");

/*
* Initialize the AN interface.
*/
if ((an_id = ANstart(file_id)) == FAIL)
printf("*** ERROR from ANstart\n");

/*
* Create the file label.
*/
if ((file_label_id = ANcreatef(an_id, AN_FILE_LABEL)) == FAIL)
printf("*** ERROR from ANcreatef\n");

/*
* Write the annotations to the file label.
*/
if (ANwriteann(file_label_id, FILE_LABEL_TXT, strlen(FILE_LABEL_TXT)) == FAIL)
printf("*** ERROR from ANwriteann\n");

/*
* Create file description.
*/
if ((file_desc_id = ANcreatef(an_id, AN_FILE_DESC)) == FAIL)
printf("*** ERROR from ANcreatef\n");

/*
* Write the annotation to the file description.
*/
if (ANwriteann(file_desc_id, FILE_DESC_TXT, strlen(FILE_DESC_TXT)) == FAIL)
printf("*** ERROR from ANwriteann\n");

/*
* Create a vgroup in the V interface. Note that the vgroup's ref number
* is set to -1 for creating and the access mode is "w" for writing.
*/
if (Vstart(file_id) == FAIL)
printf("*** ERROR from Vstart\n");
if ((vgroup_id = Vattach(file_id, -1, "w")) == FAIL)
printf("*** ERROR from Vattach\n");
if (Vsetname(vgroup_id, VG_NAME) == FAIL)
printf("*** ERROR from Vsetname\n");

/*
* Obtain the tag and ref number of the vgroup for subsequent
* references.
*/
vgroup_tag = (uint16)VQuerytag(vgroup_id);
vgroup_ref = (uint16)VQueryref(vgroup_id);

/*
* Create the data label for the vgroup identified by its tag
* and ref number.
*/
if ((data_label_id = ANcreate(an_id, vgroup_tag, vgroup_ref, AN_DATA_LABEL)) == FAIL)
printf("*** ERROR from ANcreate\n");

/*
* Write the annotation text to the data label.
*/
if (ANwriteann(data_label_id, DATA_LABEL_TXT, strlen(DATA_LABEL_TXT)) == FAIL)
printf("*** ERROR from ANwriteann\n");

/*
* Create the data description for the vgroup identified by its tag
* and ref number.
*/
if ((data_desc_id = ANcreate(an_id, vgroup_tag, vgroup_ref, AN_DATA_DESC)) == FAIL)
printf("*** ERROR from ANcreate\n");

/*
* Write the annotation text to the data description.
*/
if (ANwriteann(data_desc_id, DATA_DESC_TXT, strlen(DATA_DESC_TXT)) == FAIL)
printf("*** ERROR from ANwriteann\n");

/*
* Terminate access to the vgroup and to the V interface.
*/
if (Vdetach(vgroup_id) == FAIL)
printf("*** ERROR from Vdetach\n");
if (Vend(file_id) == FAIL)
printf("*** ERROR from Vend\n");

/*
* Terminate access to each annotation explicitly.
*/
if (ANendaccess(file_label_id) == FAIL)
printf("*** ERROR from ANendaccess(file_label_id)\n");
if (ANendaccess(file_desc_id) == FAIL)
printf("*** ERROR from ANendaccess(file_desc_id)\n");
if (ANendaccess(data_label_id) == FAIL)
printf("*** ERROR from ANendaccess(data_label_id)\n");
if (ANendaccess(data_desc_id) == FAIL)
printf("*** ERROR from ANendaccess(data_desc_id)\n");

/*
* Terminate access to the AN interface and close the HDF file.
*/
if (ANend(an_id) == FAIL)
printf("*** ERROR from ANend\n");
if (Hclose(file_id) == FAIL)
printf("*** ERROR from Hclose\n");
return 0;
}
Loading

0 comments on commit be9b9c9

Please sign in to comment.