Commit 531fafe75e1659897c30954b0085e2c976e9d582
1 parent
346f683b
Exists in
master
and in
10 other branches
Install AddLocalVI + some other tools with DDServer
Showing
22 changed files
with
880 additions
and
13 deletions
Show diff stats
.gitignore
CMakeLists.txt
@@ -27,13 +27,14 @@ find_package( CRYPT REQUIRED ) | @@ -27,13 +27,14 @@ find_package( CRYPT REQUIRED ) | ||
27 | find_package( NetCDF REQUIRED ) | 27 | find_package( NetCDF REQUIRED ) |
28 | find_package( DDClient REQUIRED ) | 28 | find_package( DDClient REQUIRED ) |
29 | find_package( CDF REQUIRED ) | 29 | find_package( CDF REQUIRED ) |
30 | +find_package( LibXML2 REQUIRED ) | ||
30 | 31 | ||
31 | get_filename_component(NETCDFLIB_DIR ${NETCDFLIBRARIES} PATH) | 32 | get_filename_component(NETCDFLIB_DIR ${NETCDFLIBRARIES} PATH) |
32 | get_filename_component(DDCLIENTLIB_DIR ${DDCLIENTLIBRARIES} PATH) | 33 | get_filename_component(DDCLIENTLIB_DIR ${DDCLIENTLIBRARIES} PATH) |
33 | 34 | ||
34 | configure_file ( | 35 | configure_file ( |
35 | - "${CMAKE_SOURCE_DIR}/scripts/StartServer.in" | ||
36 | - "${CMAKE_SOURCE_DIR}/scripts/StartServer" | 36 | + "${CMAKE_SOURCE_DIR}/scripts/DDServer.env.in" |
37 | + "${CMAKE_SOURCE_DIR}/scripts/DDServer.env" | ||
37 | ) | 38 | ) |
38 | 39 | ||
39 | MESSAGE( STATUS "Build DD_Server Project" ) | 40 | MESSAGE( STATUS "Build DD_Server Project" ) |
@@ -46,11 +47,18 @@ add_subdirectory(src/DECODERS/themis/esafull2nc) | @@ -46,11 +47,18 @@ add_subdirectory(src/DECODERS/themis/esafull2nc) | ||
46 | add_subdirectory(src/DECODERS/themis/esamom2nc) | 47 | add_subdirectory(src/DECODERS/themis/esamom2nc) |
47 | add_subdirectory(src/DECODERS/themis/fgm2nc) | 48 | add_subdirectory(src/DECODERS/themis/fgm2nc) |
48 | add_subdirectory(src/DECODERS/themis/sst2nc) | 49 | add_subdirectory(src/DECODERS/themis/sst2nc) |
49 | -add_subdirectory(src/TIMESUPDATE) | ||
50 | -add_subdirectory(src/TIMESUPDATENODATA) | 50 | +add_subdirectory(src/DATA/TIMESUPDATE) |
51 | +add_subdirectory(src/DATA/TIMESUPDATENODATA) | ||
52 | +add_subdirectory(src/DATA/STARTSTOPLOCAL) | ||
53 | +add_subdirectory(src/DATA/INFOLOCAL2NC) | ||
54 | +add_subdirectory(src/DATA/MAKEDDSYS) | ||
55 | +add_subdirectory(src/DATA/JOIN_NC) | ||
51 | add_subdirectory(tests) | 56 | add_subdirectory(tests) |
52 | 57 | ||
53 | install(FILES "scripts/StartServer" DESTINATION . PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) | 58 | install(FILES "scripts/StartServer" DESTINATION . PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) |
59 | +install(FILES "scripts/DDServer.env" DESTINATION . PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) | ||
60 | +install(FILES "scripts/AddLocalVI.sh" DESTINATION . PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) | ||
54 | install(DIRECTORY "src/CALLEXT/" DESTINATION bin/CALLEXT) | 61 | install(DIRECTORY "src/CALLEXT/" DESTINATION bin/CALLEXT) |
62 | +install(DIRECTORY "src/DATA/MANAGER/" DESTINATION bin/DATAMANAGER) | ||
55 | 63 | ||
56 | SET(CMAKE_VERBOSE_MAKEFILE ON) | 64 | SET(CMAKE_VERBOSE_MAKEFILE ON) |
cmake/modules/FindCDF.cmake
@@ -5,8 +5,8 @@ | @@ -5,8 +5,8 @@ | ||
5 | # libcdf_INCLUDE_DIR - the libcdf include directory | 5 | # libcdf_INCLUDE_DIR - the libcdf include directory |
6 | # libcdf_LIBRARIES - the libcdf library directory | 6 | # libcdf_LIBRARIES - the libcdf library directory |
7 | 7 | ||
8 | -FIND_PATH(libcdf_INCLUDE_DIR cdf.h PATHS /include /usr/include /usr/local/include /usr/local/cdf/include ${USERLOCAL_ROOT}/include) | ||
9 | -FIND_LIBRARY(libcdf_LIBRARIES NAMES cdf PATHS /lib /usr/lib /usr/local/lib /usr/local/cdf/lib ${USERLOCAL_ROOT}/lib ) | 8 | +FIND_PATH(libcdf_INCLUDE_DIR cdf.h PATHS /include /usr/include /usr/local/include /usr/local/cdf/include ${USERLOCAL_ROOT}/include /opt/local/include ) |
9 | +FIND_LIBRARY(libcdf_LIBRARIES NAMES cdf PATHS /lib /usr/lib /usr/local/lib /usr/local/cdf/lib ${USERLOCAL_ROOT}/lib /opt/local/lib) | ||
10 | 10 | ||
11 | # set FOUND flag | 11 | # set FOUND flag |
12 | IF(libcdf_INCLUDE_DIR AND libcdf_LIBRARIES) | 12 | IF(libcdf_INCLUDE_DIR AND libcdf_LIBRARIES) |
@@ -0,0 +1,25 @@ | @@ -0,0 +1,25 @@ | ||
1 | +# - Try to find LibXml2 | ||
2 | +# Once done this will define | ||
3 | +# LIBXML2_FOUND - System has LibXml2 | ||
4 | +# LIBXML2_INCLUDE_DIRS - The LibXml2 include directories | ||
5 | +# LIBXML2_LIBRARIES - The libraries needed to use LibXml2 | ||
6 | +# LIBXML2_DEFINITIONS - Compiler switches required for using LibXml2 | ||
7 | + | ||
8 | +FIND_PATH(LIBXML2_INCLUDE_DIR libxml/xinclude.h PATHS ${USERLOCAL_ROOT}/include/libxml2 /opt/local/include/libxml2) | ||
9 | + | ||
10 | +FIND_LIBRARY(LIBXML2_LIBRARIES NAMES xml2 libxml2 PATHS ${USERLOCAL_ROOT}/lib /opt/local/lib NO_DEFAULT_PATH) | ||
11 | + | ||
12 | +IF(LIBXML2_INCLUDE_DIR AND LIBXML2_LIBRARIES) | ||
13 | + SET(LibXML2_FOUND 1) | ||
14 | + #remove last /libxml2 string | ||
15 | + STRING(REGEX REPLACE "/libxml2" "" LIBXML2_INCLUDE_DIR_SUP_LEVEL ${LIBXML2_INCLUDE_DIR}) | ||
16 | + SET (LIBXML2_INCLUDE_DIR ${LIBXML2_INCLUDE_DIR_SUP_LEVEL} ${LIBXML2_INCLUDE_DIR} ) | ||
17 | + if(NOT LibXML2_FIND_QUIETLY) | ||
18 | + message(STATUS "Found libXML2: ${LIBXML2_LIBRARIES}") | ||
19 | + endif(NOT LibXML2_FIND_QUIETLY) | ||
20 | +ELSE(LIBXML2_INCLUDE_DIR AND LIBXML2_LIBRARIES) | ||
21 | + SET(LibXML2_FOUND 0 CACHE BOOL "Not found libxml2 library") | ||
22 | + message(STATUS "NOT Found libxml2, disabling it") | ||
23 | +ENDIF(LIBXML2_INCLUDE_DIR AND LIBXML2_LIBRARIES) | ||
24 | + | ||
25 | +MARK_AS_ADVANCED(LIBXML2_INCLUDE_DIR LIBXML2_LIBRARIES) |
@@ -0,0 +1,9 @@ | @@ -0,0 +1,9 @@ | ||
1 | +#!/bin/sh | ||
2 | + | ||
3 | +export NETCDF_ROOT="/opt/local" | ||
4 | +export DDCLIENT_ROOT="/opt/local" | ||
5 | + | ||
6 | +cmake -E make_directory build | ||
7 | +cmake -E chdir build cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/opt/local .. | ||
8 | +cmake --build build | ||
9 | +sudo make -C build install VERBOSE=1 |
scripts/StartServer.in renamed to scripts/DDServer.env.in
100755 → 100644
1 | #!/bin/bash | 1 | #!/bin/bash |
2 | -#------------------------------------------------------------------- | ||
3 | -# StartServer | ||
4 | -#------------------------------------------------------------------- | 2 | + |
5 | DDBASE=/home/budnik/AMDA-NG.core/DDBASE/DATA | 3 | DDBASE=/home/budnik/AMDA-NG.core/DDBASE/DATA |
6 | DDPATH=/home/budnik/AMDA-NG.core/DDBASE | 4 | DDPATH=/home/budnik/AMDA-NG.core/DDBASE |
7 | DDLIB=@DDCLIENTLIB_DIR@ | 5 | DDLIB=@DDCLIENTLIB_DIR@ |
8 | DDBASEBIN=@CMAKE_INSTALL_PREFIX@/bin | 6 | DDBASEBIN=@CMAKE_INSTALL_PREFIX@/bin |
9 | LD_LIBRARY_PATH=$DDLIB/:@NETCDFLIB_DIR@:@libcdf_LIBRARY_DIR@:@USRLIB_DIR@ | 7 | LD_LIBRARY_PATH=$DDLIB/:@NETCDFLIB_DIR@:@libcdf_LIBRARY_DIR@:@USRLIB_DIR@ |
8 | +DATAMANAGER=@CMAKE_INSTALL_PREFIX@/bin/DATAMANAGER | ||
10 | export DDBASE DDPATH DDBASEBIN DDLIB LD_LIBRARY_PATH | 9 | export DDBASE DDPATH DDBASEBIN DDLIB LD_LIBRARY_PATH |
11 | - | ||
12 | -#$DDBASEBIN/DD_Server 1>/dev/null 2>/dev/null& | ||
13 | -$DDBASEBIN/DD_Server -V |
@@ -0,0 +1,11 @@ | @@ -0,0 +1,11 @@ | ||
1 | +#!/bin/bash | ||
2 | +#------------------------------------------------------------------- | ||
3 | +# StartServer | ||
4 | +#------------------------------------------------------------------- | ||
5 | + | ||
6 | +BASEDIR=$(dirname "$0") | ||
7 | + | ||
8 | +. ${BASEDIR}/DDServer.env | ||
9 | + | ||
10 | +#$DDBASEBIN/DD_Server 1>/dev/null 2>/dev/null& | ||
11 | +$DDBASEBIN/DD_Server -V |
@@ -0,0 +1,26 @@ | @@ -0,0 +1,26 @@ | ||
1 | + | ||
2 | +PROJECT(infoLocal2nc) | ||
3 | + | ||
4 | +include_directories( | ||
5 | + ${DDCLIENTINCLUDE_DIR} | ||
6 | + ${NETCDFINCLUDE_DIR} | ||
7 | + ${LIBXML2_INCLUDE_DIR} | ||
8 | +) | ||
9 | + | ||
10 | +#ConLIBXML2_INCLUDE_DIRfiguration de l'exécutable | ||
11 | +file( | ||
12 | + GLOB_RECURSE | ||
13 | + source_files | ||
14 | + ./* | ||
15 | +) | ||
16 | + | ||
17 | +ADD_EXECUTABLE (infoLocal2nc ${source_files} ) | ||
18 | + | ||
19 | +target_link_libraries( | ||
20 | + infoLocal2nc | ||
21 | + ${DDCLIENTLIBRARY} | ||
22 | + ${NETCDFLIBRARY} | ||
23 | + ${LIBXML2_LIBRARIES} | ||
24 | +) | ||
25 | + | ||
26 | +install (TARGETS infoLocal2nc DESTINATION bin) |
@@ -0,0 +1,132 @@ | @@ -0,0 +1,132 @@ | ||
1 | +/** | ||
2 | +* @file infoLocal2nc.c | ||
3 | +* @version $Id: infoLocal2nc.c,v 1.4 2012/11/12 09:55:15 budnik Exp $ | ||
4 | +* @brief DD Server Tools: Stand alone executable to convert info.xml to info.nc | ||
5 | +* @arg xml_name nc_name | ||
6 | +* | ||
7 | +*/ | ||
8 | +/*================================================================================ | ||
9 | + * DD | ||
10 | + * Server Manager | ||
11 | + * infoLocal2nc.c | ||
12 | + * V.1.0 | ||
13 | + * args -> XML name and nc name | ||
14 | + * Modification of info2nc | ||
15 | + *================================================================================*/ | ||
16 | +#include <stdlib.h> | ||
17 | +#include <stdio.h> | ||
18 | +#include <string.h> | ||
19 | +#include <time.h> | ||
20 | +#include <math.h> | ||
21 | +#include <netcdf.h> | ||
22 | +#include <libxml/xmlmemory.h> | ||
23 | +#include <libxml/parser.h> | ||
24 | +#include <libxml/xpath.h> | ||
25 | +#include <DD.h> | ||
26 | +#include <DD_comm.h> | ||
27 | + | ||
28 | +/*----------- General constants ----------------------------*/ | ||
29 | +#define MAXVAR 100 | ||
30 | +#define BASEDIR "DDBASE" | ||
31 | + | ||
32 | +/*------------- Global variables ---------------------------*/ | ||
33 | +char temp[MAXVAR][PATHLENGTH]; | ||
34 | + | ||
35 | +int main(int argc, char **argv) | ||
36 | +{ | ||
37 | + char *ncname; | ||
38 | + xmlDocPtr doc; | ||
39 | + int i = 0, status; | ||
40 | + xmlNodePtr cur; | ||
41 | + size_t length; | ||
42 | + | ||
43 | + int fileID; | ||
44 | + int InfoDimID, VarID[MAXVAR]; | ||
45 | + double number; | ||
46 | + char DocPath[PATHLENGTH], *BasePathP; | ||
47 | + /*---------- Get Target name from arguments -------------*/ | ||
48 | + if (argc < 3) | ||
49 | + { | ||
50 | + fprintf(stderr,"Usage: infoLocal2nc SourceName TargetName\n"); | ||
51 | + exit(0); | ||
52 | + } | ||
53 | + | ||
54 | + /*------- Get full source name --------------------*/ | ||
55 | + if((BasePathP = getenv(BASEDIR)) == NULL) | ||
56 | + { | ||
57 | + fprintf(stderr,"infoLocal2nc: no %s environment\n",BASEDIR); | ||
58 | + exit(0); | ||
59 | + } | ||
60 | + strcpy(DocPath,argv[1]); | ||
61 | + | ||
62 | + ncname = argv[2]; | ||
63 | + doc = xmlParseFile(DocPath); | ||
64 | + | ||
65 | + if(doc == NULL ) | ||
66 | + { | ||
67 | + fprintf(stderr,"infoLocal2nc: Source document %s is not parsed successfully.\n",DocPath); | ||
68 | + exit(0); | ||
69 | + } | ||
70 | + | ||
71 | + cur = xmlDocGetRootElement(doc); //GO the first node | ||
72 | + if (cur == NULL) | ||
73 | + { | ||
74 | + fprintf(stderr,"info2nc: empty Source Document %s\n",DocPath); | ||
75 | + xmlFreeDoc(doc); | ||
76 | + exit(0); | ||
77 | + } | ||
78 | + | ||
79 | +// Define nc file | ||
80 | + ncopts = NC_VERBOSE; | ||
81 | + | ||
82 | + if((status = nc_create(ncname,NC_CLOBBER, &fileID)) != NC_NOERR) | ||
83 | + { | ||
84 | + fprintf(stderr,"info2nc: Could not create file %s\n",ncname); | ||
85 | + exit(1); | ||
86 | + } | ||
87 | + status = nc_def_dim(fileID,"info",PATHLENGTH, &InfoDimID); | ||
88 | + status = nc_enddef(fileID); | ||
89 | + | ||
90 | +// Now treat info.xml | ||
91 | + cur = cur->xmlChildrenNode; | ||
92 | + while (cur != NULL) | ||
93 | + { | ||
94 | + if (xmlStrcmp(cur->name, (const xmlChar *)"text")) | ||
95 | + { | ||
96 | + status = nc_redef(fileID); | ||
97 | + if ((!xmlStrcmp(cur->name, (const xmlChar *)"MinSampling")) || | ||
98 | + (!xmlStrcmp(cur->name, (const xmlChar *)"MaxSampling")) || | ||
99 | + (!xmlStrcmp(cur->name, (const xmlChar *)"FillValue"))) | ||
100 | + | ||
101 | + status = nc_def_var(fileID, (char *)cur->name, NC_DOUBLE, 0, &InfoDimID, &VarID[i]); | ||
102 | + | ||
103 | + else | ||
104 | + status = nc_def_var(fileID, (char *)cur->name, NC_CHAR, 1, &InfoDimID, &VarID[i]); | ||
105 | + status = nc_enddef(fileID); | ||
106 | + | ||
107 | + if ((cur->xmlChildrenNode) != NULL) | ||
108 | + { | ||
109 | + length = strlen((char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1)); | ||
110 | + strcpy(temp[i], (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1)); | ||
111 | + temp[i][length]='\0'; | ||
112 | + | ||
113 | + if ((!xmlStrcmp(cur->name, (const xmlChar *)"MinSampling")) || | ||
114 | + (!xmlStrcmp(cur->name, (const xmlChar *)"MaxSampling")) || | ||
115 | + (!xmlStrcmp(cur->name, (const xmlChar *)"FillValue"))) | ||
116 | + { | ||
117 | + number = atof(temp[i]); | ||
118 | + status = nc_put_var_double(fileID, VarID[i], &number); | ||
119 | + } else status = nc_put_var_text(fileID,VarID[i],temp[i]); | ||
120 | + } | ||
121 | + i++; | ||
122 | + | ||
123 | + } | ||
124 | + cur = cur->next; | ||
125 | + } | ||
126 | + | ||
127 | + xmlFree(cur); | ||
128 | + xmlFreeDoc(doc); | ||
129 | + status=nc_close(fileID); | ||
130 | + exit(1); | ||
131 | +} | ||
132 | +/*==========================================================================================================*/ |
@@ -0,0 +1,24 @@ | @@ -0,0 +1,24 @@ | ||
1 | + | ||
2 | +PROJECT(join_nc) | ||
3 | + | ||
4 | +include_directories( | ||
5 | + ${DDCLIENTINCLUDE_DIR} | ||
6 | + ${NETCDFINCLUDE_DIR} | ||
7 | +) | ||
8 | + | ||
9 | +#Configuration de l'exécutable | ||
10 | +file( | ||
11 | + GLOB_RECURSE | ||
12 | + source_files | ||
13 | + ./* | ||
14 | +) | ||
15 | + | ||
16 | +ADD_EXECUTABLE (join_nc ${source_files} ) | ||
17 | + | ||
18 | +target_link_libraries( | ||
19 | + join_nc | ||
20 | + ${DDCLIENTLIBRARY} | ||
21 | + ${NETCDFLIBRARY} | ||
22 | +) | ||
23 | + | ||
24 | +install (TARGETS join_nc DESTINATION bin) |
@@ -0,0 +1,139 @@ | @@ -0,0 +1,139 @@ | ||
1 | +/* $Id: join_nc.c,v 1.2 2008/06/13 09:17:30 elena Exp $ */ | ||
2 | +/** | ||
3 | +* @file join_nc.c | ||
4 | +* @brief append input nc file to output nc file | ||
5 | +* @arg input-file output-file | ||
6 | +* @todo Process errors - if needed ? | ||
7 | +* @date 03.01.2008 | ||
8 | +*/ | ||
9 | + | ||
10 | +#include <stdio.h> | ||
11 | +#include <stdlib.h> | ||
12 | +#include <string.h> | ||
13 | +#include <netcdf.h> | ||
14 | + | ||
15 | +void handle_error(int status) | ||
16 | +{ | ||
17 | + fprintf(stderr, "%s\n", nc_strerror(status)); | ||
18 | + exit(1); | ||
19 | +} | ||
20 | + | ||
21 | +int main(int argc, char *argv[]) | ||
22 | +{ | ||
23 | + int status, ncID, infoID; | ||
24 | + int ndims, nvars, ngatts, unlimdimid; | ||
25 | + size_t dimlength, totalDimension = 1; | ||
26 | + size_t *start, *count; | ||
27 | + char dimname[NC_MAX_NAME], varname[NC_MAX_NAME], attname[NC_MAX_NAME]; | ||
28 | + int i, j; | ||
29 | + int dimID[NC_MAX_DIMS]; | ||
30 | + int varID[NC_MAX_DIMS]; | ||
31 | + char constantInfoFile[NC_MAX_ATTRS]; | ||
32 | + char infoFile[NC_MAX_ATTRS]; | ||
33 | + nc_type var_type; /* variable type */ | ||
34 | + int var_ndims; /* number of dims */ | ||
35 | + int var_dimids[NC_MAX_VAR_DIMS]; /* dimension ids */ | ||
36 | + int var_natts; /* number of attributes */ | ||
37 | + void *variable; | ||
38 | + | ||
39 | + | ||
40 | + if (argc < 3) | ||
41 | + { | ||
42 | + fprintf(stderr,"Usage: join_nc inputName outputName\n"); | ||
43 | + exit(0); | ||
44 | + } | ||
45 | + | ||
46 | + strcpy(constantInfoFile,argv[1]); | ||
47 | + strcpy(infoFile,argv[2]); | ||
48 | + | ||
49 | + if ((status = nc_open(infoFile, NC_WRITE, &ncID)) != NC_NOERR) | ||
50 | + handle_error(status); | ||
51 | + | ||
52 | + if ((status = nc_open(constantInfoFile, NC_NOWRITE, &infoID)) != NC_NOERR) | ||
53 | + handle_error(status); | ||
54 | + | ||
55 | + if ((status = nc_inq(infoID, &ndims, &nvars, &ngatts, &unlimdimid)) != NC_NOERR) | ||
56 | + handle_error(status); | ||
57 | +// file into DEFINITION mode | ||
58 | + nc_redef(ncID); | ||
59 | + | ||
60 | +// Start with adding dimensions | ||
61 | + for (i = 0; i < ndims; i++) { | ||
62 | + status = nc_inq_dim(infoID, i, dimname, &dimlength); | ||
63 | + if (status == NC_NOERR) nc_def_dim(ncID, dimname, dimlength, &dimID[i]); | ||
64 | + } | ||
65 | + | ||
66 | +// adding Global Attributes | ||
67 | + | ||
68 | + if (ngatts > 0) | ||
69 | + for (i = 0; i < ngatts; i++) { | ||
70 | + status = nc_inq_attname(infoID, NC_GLOBAL, i, attname); | ||
71 | + if (status == NC_NOERR) nc_copy_att(infoID, NC_GLOBAL, attname, ncID, NC_GLOBAL); | ||
72 | + } | ||
73 | + nc_enddef(ncID); | ||
74 | + | ||
75 | +// adding variables | ||
76 | + for (i = 0; i < nvars; i++) { | ||
77 | + nc_redef(ncID); | ||
78 | + | ||
79 | + | ||
80 | + status = nc_inq_var (infoID, i, varname, &var_type, &var_ndims, var_dimids, &var_natts); | ||
81 | + start = (size_t *) malloc(var_ndims*sizeof(size_t)); | ||
82 | + count = (size_t *) malloc(var_ndims*sizeof(size_t)); | ||
83 | + for (j = 0; j < var_ndims; j++) { | ||
84 | + status = nc_inq_dimlen(infoID, var_dimids[j], &dimlength); | ||
85 | + if (status == NC_NOERR) totalDimension *= dimlength; | ||
86 | + start[j] = 0; | ||
87 | + count[j] = dimlength; | ||
88 | + var_dimids[j] = dimID[var_dimids[j]]; | ||
89 | + } | ||
90 | + if (status == NC_NOERR) nc_def_var(ncID, varname, var_type, var_ndims, var_dimids, &varID[i]); | ||
91 | + if (var_natts > 0) | ||
92 | + for (j = 0; j < var_natts; j++) { | ||
93 | + status = nc_inq_attname(infoID, i, j, attname); | ||
94 | + if (status == NC_NOERR) nc_copy_att(infoID, i, attname, ncID, varID[i]); | ||
95 | + } | ||
96 | + nc_enddef(ncID); | ||
97 | + | ||
98 | + switch(var_type){ | ||
99 | + case NC_FLOAT: { | ||
100 | + variable = (float *) malloc(totalDimension*sizeof(float)); | ||
101 | + status = nc_get_vara_float(infoID, i, start, count, variable); | ||
102 | + if (status == NC_NOERR) nc_put_vara_float(ncID, varID[i], start, count, variable); | ||
103 | + break; | ||
104 | + } | ||
105 | + case NC_DOUBLE: { | ||
106 | + variable = (double *) malloc(totalDimension*sizeof(double)); | ||
107 | + status = nc_get_vara_double(infoID, i, start, count, variable); | ||
108 | + if (status == NC_NOERR) nc_put_vara_double(ncID, varID[i], start, count, variable); | ||
109 | + break; | ||
110 | + } | ||
111 | + case NC_SHORT: { | ||
112 | + variable = (short *) malloc(totalDimension*sizeof(short)); | ||
113 | + status = nc_get_vara_short(infoID, i, start, count, variable); | ||
114 | + if (status == NC_NOERR) nc_put_vara_short(ncID, varID[i], start, count, variable); | ||
115 | + break; | ||
116 | + } | ||
117 | + case NC_INT: { | ||
118 | + variable = (int *) malloc(totalDimension*sizeof(int)); | ||
119 | + status = nc_get_vara_int(infoID, i, start, count, variable); | ||
120 | + if (status == NC_NOERR) nc_put_vara_int(ncID, varID[i], start, count, variable); | ||
121 | + break; | ||
122 | + } | ||
123 | + case NC_CHAR: { | ||
124 | + variable = (char *) malloc(totalDimension*sizeof(char)); | ||
125 | + status = nc_get_vara_text(infoID, i, start, count, variable); | ||
126 | + if (status == NC_NOERR) nc_put_vara_text(ncID, varID[i], start, count, variable); | ||
127 | + } | ||
128 | + } | ||
129 | + totalDimension = 1; | ||
130 | + free(variable); free(start); free(count); | ||
131 | + } | ||
132 | + | ||
133 | + | ||
134 | + if ((status = nc_close(ncID)) != NC_NOERR) | ||
135 | + handle_error(status); | ||
136 | + | ||
137 | + if ((status = nc_close(infoID)) != NC_NOERR) | ||
138 | + handle_error(status); | ||
139 | +} |
@@ -0,0 +1,26 @@ | @@ -0,0 +1,26 @@ | ||
1 | + | ||
2 | +PROJECT(makeDDsys) | ||
3 | + | ||
4 | +include_directories( | ||
5 | + ${DDCLIENTINCLUDE_DIR} | ||
6 | + ${NETCDFINCLUDE_DIR} | ||
7 | + ${LIBXML2_INCLUDE_DIR} | ||
8 | +) | ||
9 | + | ||
10 | +#Configuration de l'exécutable | ||
11 | +file( | ||
12 | + GLOB_RECURSE | ||
13 | + source_files | ||
14 | + ./* | ||
15 | +) | ||
16 | + | ||
17 | +ADD_EXECUTABLE (makeDDsys ${source_files} ) | ||
18 | + | ||
19 | +target_link_libraries( | ||
20 | + makeDDsys | ||
21 | + ${DDCLIENTLIBRARY} | ||
22 | + ${NETCDFLIBRARY} | ||
23 | + ${LIBXML2_LIBRARIES} | ||
24 | +) | ||
25 | + | ||
26 | +install (TARGETS makeDDsys DESTINATION bin) |
@@ -0,0 +1,204 @@ | @@ -0,0 +1,204 @@ | ||
1 | +/*================================================================================ | ||
2 | + * DD | ||
3 | + * Server Package | ||
4 | + * makeDDsys.c | ||
5 | + * V.4.2 | ||
6 | + * Stand-alone executable to create refer.nc file form DDsys.xml file | ||
7 | + * Program search the DDsys.xml in the directory $DDBASE, and creates | ||
8 | + * refer.nc in this directory. See structure of DDsys.xml in | ||
9 | + * ../DOC/TECHDOC/DDBaseStruc.html | ||
10 | + * | ||
11 | + * Versions: | ||
12 | + * Apr 23 1997, V.2.0 Adding CASH into refer.nc file | ||
13 | + * Jun 18 2007, V.3.0 Length 128 | ||
14 | + * 1 Aug 2007, V.4.0 XML version | ||
15 | + * 6 Sep 2007, V.4.1 Knizhnikova-Fedorova, small changes | ||
16 | + * 9 Nov 2009, V.4.2 netCDF 3 | ||
17 | + *================================================================================*/ | ||
18 | + | ||
19 | +#include <stdlib.h> | ||
20 | +#include <stdio.h> | ||
21 | +#include <string.h> | ||
22 | +#include <time.h> | ||
23 | +#include <math.h> | ||
24 | +#include <netcdf.h> | ||
25 | +#include <libxml/xmlmemory.h> | ||
26 | +#include <libxml/parser.h> | ||
27 | +#include <libxml/xpath.h> | ||
28 | +#include <DD.h> | ||
29 | +#include <DD_comm.h> | ||
30 | + | ||
31 | +/*----------- General constants ----------------------------*/ | ||
32 | +#define MAXVIRIN 1000 | ||
33 | +#define SOURCENAME "/DDsys.xml" | ||
34 | +#define BASEDIR "DDBASE" | ||
35 | + | ||
36 | +/*----------- Global variables ------------------------------*/ | ||
37 | +char varname[MAXVIRIN][PATHLENGTH]; | ||
38 | +char datadirname[MAXVIRIN][PATHLENGTH]; | ||
39 | +char timesname[MAXVIRIN][PATHLENGTH]; | ||
40 | +char infoname[MAXVIRIN][PATHLENGTH]; | ||
41 | +char cashname[MAXVIRIN][PATHLENGTH]; | ||
42 | + | ||
43 | +int basenumber; /* number of virtual instruments */ | ||
44 | + | ||
45 | +/*---------------------- REFER CREATE ------------------------*/ | ||
46 | +void ReferCreate(char *BasePathP) | ||
47 | +{ | ||
48 | + int fileID; | ||
49 | + int InfoDimID, LengthDimID; | ||
50 | + int VarDimVector[2]; | ||
51 | + int VarID[MAXVIRIN]; | ||
52 | + size_t DirStart[2] = {0L,0L}; | ||
53 | + size_t TimesStart[2] = {1L,0L}; | ||
54 | + size_t InfoStart[2] = {2L,0L}; | ||
55 | + size_t CashStart[2] = {3L,0L}; | ||
56 | + size_t VarCount[2] = {1L,PATHLENGTH}; | ||
57 | + int i, status; | ||
58 | + char DestPath[PATHLENGTH]; | ||
59 | + | ||
60 | + // ncopts = NC_VERBOSE; | ||
61 | + | ||
62 | + /* | ||
63 | + * Full path name | ||
64 | + */ | ||
65 | + | ||
66 | + strcpy(DestPath,BasePathP); | ||
67 | + strcat(DestPath,REFNAME); | ||
68 | + | ||
69 | + if((status = nc_create( DestPath, NC_CLOBBER, &fileID)) != NC_NOERR) | ||
70 | + { | ||
71 | + fprintf(stderr,"makeDDsys: Could not create file %s\n",DestPath); | ||
72 | + exit(1); | ||
73 | + } | ||
74 | + | ||
75 | + nc_def_dim(fileID, "info", 4L, &InfoDimID); | ||
76 | + nc_def_dim(fileID, "length", PATHLENGTH, &LengthDimID); | ||
77 | + | ||
78 | + VarDimVector[0] = InfoDimID; | ||
79 | + VarDimVector[1] = LengthDimID; | ||
80 | + | ||
81 | + for(i = 0; i < basenumber; i++) | ||
82 | + nc_def_var(fileID, varname[i], NC_CHAR, 2, VarDimVector, &VarID[i]); | ||
83 | + | ||
84 | + nc_enddef(fileID); | ||
85 | + | ||
86 | + for(i = 0; i < basenumber; i++) | ||
87 | + { | ||
88 | + nc_put_vara_text(fileID,VarID[i],DirStart,VarCount,(void *)datadirname[i]); | ||
89 | + nc_put_vara_text(fileID,VarID[i],TimesStart,VarCount,(void *)timesname[i]); | ||
90 | + nc_put_vara_text(fileID,VarID[i],InfoStart,VarCount,(void *)infoname[i]); | ||
91 | + nc_put_vara_text(fileID,VarID[i],CashStart,VarCount,(void *)cashname[i]); | ||
92 | + | ||
93 | + } | ||
94 | + status = nc_close(fileID); | ||
95 | +} | ||
96 | +/*--------------------------------------------------------------------------*/ | ||
97 | + | ||
98 | + int main(int argc, char **argv) | ||
99 | +{ | ||
100 | + | ||
101 | + xmlDocPtr doc; | ||
102 | + xmlChar *xpath = (xmlChar*) "//VI"; | ||
103 | + xmlNodeSetPtr nodeset; | ||
104 | + xmlXPathObjectPtr result; | ||
105 | + int i, j, size = 2, length; | ||
106 | + xmlChar *name, *argsNr; | ||
107 | + xmlXPathContextPtr context; | ||
108 | + xmlNodePtr cur; | ||
109 | + char BasePath[PATHLENGTH], *BasePathP; | ||
110 | + | ||
111 | + /* | ||
112 | + * Create full Source Name | ||
113 | + */ | ||
114 | + if((BasePathP = getenv(BASEDIR)) == NULL) | ||
115 | + { | ||
116 | + fprintf(stderr,"makeDDsys: no %s environment\n",BASEDIR); | ||
117 | + exit(0); | ||
118 | + } | ||
119 | + strcpy(BasePath,BasePathP); | ||
120 | + strcat(BasePath,SOURCENAME); | ||
121 | + | ||
122 | + doc = xmlParseFile(BasePath); | ||
123 | + if (doc == NULL ) | ||
124 | + { | ||
125 | + fprintf(stderr,"Document not parsed successfully. \n"); | ||
126 | + exit(0); | ||
127 | + } | ||
128 | + | ||
129 | + context = xmlXPathNewContext(doc); | ||
130 | + if (context == NULL) | ||
131 | + { | ||
132 | + fprintf(stderr,"Error in xmlXPathNewContext\n"); | ||
133 | + exit(0); | ||
134 | + } | ||
135 | + result = xmlXPathEvalExpression(xpath, context); | ||
136 | + | ||
137 | + if (result == NULL) | ||
138 | + { | ||
139 | + fprintf(stderr,"Error in xmlXPathEvalExpression\n"); | ||
140 | + exit(0); | ||
141 | + } | ||
142 | + | ||
143 | + if(xmlXPathNodeSetIsEmpty(result->nodesetval)) | ||
144 | + { | ||
145 | + xmlXPathFreeObject(result); | ||
146 | + fprintf(stderr,"No result\n"); | ||
147 | + exit(0); | ||
148 | + } | ||
149 | + if (result) | ||
150 | + { | ||
151 | + nodeset = result->nodesetval; | ||
152 | + fprintf(stderr," VI number: %d\n", nodeset->nodeNr); | ||
153 | + basenumber = nodeset->nodeNr; | ||
154 | + for (i = 0; i < nodeset->nodeNr; i++) | ||
155 | + { | ||
156 | + cur = nodeset->nodeTab[i]->xmlChildrenNode; | ||
157 | + while (cur != NULL) | ||
158 | + { | ||
159 | + if((xmlStrcmp(cur->name, (const xmlChar *)"text"))){ | ||
160 | + length = strlen((char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1)); | ||
161 | + | ||
162 | + } | ||
163 | + if (!(xmlStrcmp(cur->name, (const xmlChar *)"NAME"))) | ||
164 | + { | ||
165 | + | ||
166 | + strncpy(varname[i], (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1), length); | ||
167 | + } | ||
168 | + if (!(xmlStrcmp(cur->name, (const xmlChar *)"LOCATION"))) | ||
169 | + { | ||
170 | + strncpy(datadirname[i], (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1), length); | ||
171 | + } | ||
172 | + if (!(xmlStrcmp(cur->name, (const xmlChar *)"TIMES"))) | ||
173 | + { | ||
174 | + strncpy(timesname[i],datadirname[i], strlen(datadirname[i])); | ||
175 | + strncpy(×name[i][strlen(datadirname[i])], (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1), length); | ||
176 | + | ||
177 | + } | ||
178 | + if (!(xmlStrcmp(cur->name, (const xmlChar *)"INFO"))) | ||
179 | + { | ||
180 | + strncpy(infoname[i],datadirname[i], strlen(datadirname[i])); | ||
181 | + strncpy(&infoname[i][strlen(datadirname[i])], (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1), length); | ||
182 | + } | ||
183 | + if (!(xmlStrcmp(cur->name, (const xmlChar *)"CACHE"))) | ||
184 | + { | ||
185 | + strncpy(cashname[i],datadirname[i], strlen(datadirname[i])); | ||
186 | + strncpy(&cashname[i][strlen(datadirname[i])], (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1), length); | ||
187 | + } | ||
188 | + | ||
189 | + cur = cur->next; | ||
190 | + } | ||
191 | + } | ||
192 | + xmlFree(cur); | ||
193 | + xmlXPathFreeObject(result); | ||
194 | + } | ||
195 | + | ||
196 | + xmlXPathFreeContext(context); | ||
197 | + xmlFreeDoc(doc); | ||
198 | + xmlCleanupParser(); | ||
199 | + | ||
200 | + ReferCreate(BasePathP); | ||
201 | + return (1); | ||
202 | +} | ||
203 | +/*================================================================================*/ | ||
204 | + |
@@ -0,0 +1,100 @@ | @@ -0,0 +1,100 @@ | ||
1 | +<?php | ||
2 | + | ||
3 | +/** | ||
4 | +* @file AddLocalVI.php | ||
5 | +* @version $Id: AddLocalVI.php,v 1.3 2010/10/29 14:03:53 budnik Exp $ | ||
6 | +* @brief DD Server Tools: | ||
7 | +* @arg | ||
8 | +*/ | ||
9 | + | ||
10 | + function makeInfoXml() { | ||
11 | + | ||
12 | + $xml_dom = new DomDocument("1.0"); | ||
13 | + $rootElement = $xml_dom -> createElement("VI"); | ||
14 | + $rootElement -> appendChild($xml_dom -> createElement("Mission",mission)); | ||
15 | + $rootElement -> appendChild($xml_dom -> createElement("Instrument",instrument)); | ||
16 | + $rootElement -> appendChild($xml_dom -> createElement("GlobalStart")); | ||
17 | + $rootElement -> appendChild($xml_dom -> createElement("GlobalStop")); | ||
18 | + $rootElement -> appendChild($xml_dom -> createElement("MinSampling", MinSampling)); | ||
19 | + if (MaxSampling > MinSampling) $rootElement -> appendChild($xml_dom -> createElement("MaxSampling", MaxSampling)); | ||
20 | + $rootElement -> appendChild($xml_dom -> createElement("LocalStart")); | ||
21 | + $rootElement -> appendChild($xml_dom -> createElement("LocalStop")); | ||
22 | + $xml_dom -> appendChild($rootElement); | ||
23 | + $xml_dom -> save(brief."_info.xml"); | ||
24 | + | ||
25 | +} | ||
26 | + | ||
27 | + require_once 'mgr_ini.php'; | ||
28 | + define("CURRDIR",dirname(__FILE__)); | ||
29 | + | ||
30 | +/* | ||
31 | +* DEFINITIONS TO FILL | ||
32 | +*/ | ||
33 | + define("brief", "jedi"); // prefix | ||
34 | + define("ViId", "juno_jedi_i180"); | ||
35 | + define("mission", "JUNO"); | ||
36 | + define("instrument", "JEDI"); | ||
37 | + define("MISSION_DIR", DDBASE."JUNO/"); | ||
38 | + define("location", MISSION_DIR."JEDI/I_180"); | ||
39 | + define("MinSampling", 2); | ||
40 | + define("MaxSampling", 3); // 0 if constant sampling | ||
41 | +/* | ||
42 | +* DO NOT TOUCH | ||
43 | +*/ | ||
44 | + | ||
45 | + $times = brief."_times.nc"; | ||
46 | + $info = brief."_info.nc"; | ||
47 | + $info_xml = brief."_info.xml"; | ||
48 | + $cache = brief."_cache.nc"; | ||
49 | + | ||
50 | + $DDsysDoc = new DomDocument(); | ||
51 | + $DDsysDoc->preserveWhiteSpace = false; | ||
52 | + $DDsysDoc->formatOutput = true; | ||
53 | + $DDsysDoc->load(DDBASE.DDsys); | ||
54 | + $dataSet = $DDsysDoc->getElementsByTagName("VI"); | ||
55 | +/* | ||
56 | +* Check if there is already such VI | ||
57 | +*/ | ||
58 | + foreach ($dataSet as $theDataSet) | ||
59 | + if (strcmp($theDataSet->getElementsByTagName("NAME")->item(0)->nodeValue, ViId) == 0) | ||
60 | + die(ViId." Already Exists!!!\n"); | ||
61 | + | ||
62 | + $refNode = $dataSet->item(0); | ||
63 | + $newNode = $DDsysDoc->createElement("VI"); | ||
64 | + $name = $newNode->appendChild($DDsysDoc->createElement("NAME",ViId)); | ||
65 | + $name->setAttributeNode(new DOMAttr('base', 'LOCAL')); | ||
66 | + $name->setAttributeNode(new DOMAttr('mission', mission)); | ||
67 | + $name->setAttributeNode(new DOMAttr('instrument', instrument)); | ||
68 | + | ||
69 | + if (substr(location, -1) !== "/") $newNode->appendChild($DDsysDoc->createElement("LOCATION",location."/")); | ||
70 | + else $newNode->appendChild($DDsysDoc->createElement("LOCATION",location)); | ||
71 | + | ||
72 | + $newNode->appendChild($DDsysDoc->createElement("TIMES",$times)); | ||
73 | + $newNode->appendChild($DDsysDoc->createElement("INFO",$info)); | ||
74 | + $newNode->appendChild($DDsysDoc->createElement("CACHE",$cache)); | ||
75 | + | ||
76 | + $newNode = $refNode->parentNode->insertBefore($newNode, $refNode); | ||
77 | + | ||
78 | + $DDsysDoc->save(DDBASE.DDsys); | ||
79 | + system(DDBASEBIN."/makeDDsys"); | ||
80 | + | ||
81 | +/* | ||
82 | +* Create Real Stuff | ||
83 | +* | ||
84 | +*/ | ||
85 | + | ||
86 | + if (!is_dir(MISSION_DIR)) mkdir(MISSION_DIR); | ||
87 | + if (!is_dir(location)) mkdir(location, 0775, true); | ||
88 | + echo location."\n"; | ||
89 | + chdir(location); | ||
90 | + if (!file_exists($times)) system("TimesUpdate -r ".$times." ".brief."_0*.nc"); | ||
91 | + if (!file_exists($info_xml)) makeInfoXml(); | ||
92 | + if (!file_exists($info)) system("infoLocal2nc ".$info_xml." ".$info); | ||
93 | + if (!file_exists("clean")) { | ||
94 | + copy (DDLIB."/Cash.template", $cache); | ||
95 | + $SED = "sed 's/NAME/".brief."/g' ".DDLIB."/Clean.template > clean"; | ||
96 | + exec($SED); | ||
97 | + exec('chmod ugo+x clean'); | ||
98 | + } | ||
99 | + chdir(CURRDIR); | ||
100 | +?> |
@@ -0,0 +1,59 @@ | @@ -0,0 +1,59 @@ | ||
1 | +<?php | ||
2 | + | ||
3 | +/** | ||
4 | +* @file mgr_ini.php | ||
5 | +* @brief All necessary SETUP for DD Data Center Manager | ||
6 | +* @version $Id: mgr_ini.php,v 1.1 2013/03/13 08:44:40 budnik Exp $ | ||
7 | +*/ | ||
8 | + | ||
9 | +/* MAIN DEFINITIONS SHOULD BE MODIFIED!!!!!! */ | ||
10 | + define("rootDir", "/home/budnik/AMDA-NG.core/DDBASE"); | ||
11 | + define("DDLIBHOME","/opt/local"); | ||
12 | + define ("DDLIB", DDLIBHOME."/lib"); | ||
13 | + define('CEFLIB', '/opt/local/lib'); | ||
14 | + define('CDFLIB', '/opt/local/lib'); | ||
15 | + define('SYS_LIBS', '/lib:/usr/lib:/usr/local/lib'); | ||
16 | + | ||
17 | + | ||
18 | + /* CDAWeb stuff */ | ||
19 | + define ("wsdlCDAWEB", "https://cdaweb.sci.gsfc.nasa.gov/WS/jaxrpc?WSDL"); | ||
20 | + define ("viewID" , "sp_phys"); | ||
21 | + | ||
22 | +/* THEMIS stuff */ | ||
23 | + define ("ThemisDir", "/THEMIS_B1/themisdata/"); | ||
24 | + | ||
25 | +/* Compound Definitions: Nothing to modify */ | ||
26 | + | ||
27 | + define ("DDBASEBIN", DDLIBHOME."/bin"); | ||
28 | + define ("DDBASE", rootDir."/DATA/"); | ||
29 | + define ("DDsys", "DDsys.xml"); | ||
30 | + | ||
31 | + define ("INFO_DIR", rootDir."/INFO/"); | ||
32 | + define ("DICTIONARY_DIR", INFO_DIR."Dictionary/"); | ||
33 | + define ("XML_BASE_DIR",INFO_DIR."xsl/"); | ||
34 | + | ||
35 | + define ("USERS_INFO","AMDA_Users_Info.xml"); | ||
36 | + define ("USERS_GROUPS","AMDA_Users.xml"); | ||
37 | + | ||
38 | + putenv("LD_LIBRARY_PATH=".SYS_LIBS.":".DDLIB.":".CEFLIB.":".CDFLIB); | ||
39 | + $old_include_path = set_include_path("./:".DDLIB.":".DDBASEBIN); | ||
40 | + | ||
41 | + define("STDERR", fopen("php://stderr","w")); | ||
42 | + define("log_", fopen("log","w")); | ||
43 | + | ||
44 | + define("treeLATMOS", "http://impex.latmos.ipsl.fr/tree.xml"); | ||
45 | + define("treeSINP", "http://smdc.sinp.msu.ru/impex/SINP_tree.xml"); // official: http://dec1.sinp.msu.ru/~lucymu/paraboloid/SINP_tree.xml | ||
46 | + define("treeFMI_HYB", "http://impex-fp7.fmi.fi/ws/Tree_FMI_HYB.xml"); | ||
47 | + define("treeFMI_GUMICS", "http://impex-fp7.fmi.fi/ws/Tree_FMI_GUMICS.xml"); | ||
48 | + define("treeLESIA", "http://maser.obspm.fr/IMPExWS/tree_Mag.xml"); | ||
49 | + define("treeCCMC", "http://apus.irap.omp.eu/AMDA-IMPEX/public/trees/Tree_CCMC_chablon5.xml"); | ||
50 | + | ||
51 | + define('wsdl_LESIA', 'http://maser.obspm.fr/IMPExWS/Methods_LESIA-Mag.wsdl'); | ||
52 | + | ||
53 | + if (!function_exists('__autoload')) { | ||
54 | + function __autoload($class_name) { | ||
55 | + require_once $class_name . '.php'; | ||
56 | + } | ||
57 | + } | ||
58 | + | ||
59 | +?> |
@@ -0,0 +1,24 @@ | @@ -0,0 +1,24 @@ | ||
1 | + | ||
2 | +PROJECT(StartStopLocal) | ||
3 | + | ||
4 | +include_directories( | ||
5 | + ${DDCLIENTINCLUDE_DIR} | ||
6 | + ${NETCDFINCLUDE_DIR} | ||
7 | +) | ||
8 | + | ||
9 | +#Configuration de l'exécutable | ||
10 | +file( | ||
11 | + GLOB_RECURSE | ||
12 | + source_files | ||
13 | + ./* | ||
14 | +) | ||
15 | + | ||
16 | +ADD_EXECUTABLE (StartStopLocal ${source_files} ) | ||
17 | + | ||
18 | +target_link_libraries( | ||
19 | + StartStopLocal | ||
20 | + ${DDCLIENTLIBRARY} | ||
21 | + ${NETCDFLIBRARY} | ||
22 | +) | ||
23 | + | ||
24 | +install (TARGETS StartStopLocal DESTINATION bin) |
@@ -0,0 +1,75 @@ | @@ -0,0 +1,75 @@ | ||
1 | + | ||
2 | +/** @file StartStopLocal.c | ||
3 | +* @brief Stand-alone executable <br> Returns real Start-Stop for VI in DDBase <br> | ||
4 | +* Update Start-Stop times in INFO files for LOCAL data<br> | ||
5 | +* @details StartStopLocal(string *) <br> | ||
6 | +* @arg @c argv[1] Virtual Instrument ID (DD notation) <br> | ||
7 | +* Output: YYYYDDdayHHMMSSMLS-YYYYDDdayHHMMSSMLS | ||
8 | +* | ||
9 | +* @date 10.10.2007 | ||
10 | +* @version $Id: StartStopLocal.c,v 1.4 2011/09/05 11:27:34 budnik Exp $ | ||
11 | +*/ | ||
12 | + | ||
13 | + | ||
14 | +#include <stdlib.h> | ||
15 | +#include <stdio.h> | ||
16 | +#include <string.h> | ||
17 | +#include <time.h> | ||
18 | +#include <math.h> | ||
19 | +#include <netcdf.h> | ||
20 | +#include <DD.h> | ||
21 | + | ||
22 | + | ||
23 | +int DataID, RecID, StartID, StopID; | ||
24 | +size_t RecNum; | ||
25 | +char StartT[TIMELENGTH], StopT[TIMELENGTH], Var[128]; | ||
26 | +size_t count[2] = {1L,TIMELENGTH}; | ||
27 | +size_t start[2] = {0L,0L}; | ||
28 | +size_t countVar[2] = {1L,128L}; | ||
29 | + | ||
30 | +/*---------------- NC ERROR --------------------------------------*/ | ||
31 | +void nc_handle_error(int status) | ||
32 | +{ | ||
33 | + fprintf(stderr, "%s\n", nc_strerror(status)); | ||
34 | + exit(1); | ||
35 | +} | ||
36 | + | ||
37 | +/* ----------------------- MAIN ------------------------------------*/ | ||
38 | + int main(int argc, char *argv[]) | ||
39 | +{ | ||
40 | + | ||
41 | + int status, len; | ||
42 | + | ||
43 | + | ||
44 | +/* Open VI_times.nc */ | ||
45 | + | ||
46 | + if ((status = nc_open(argv[1], NC_NOWRITE, &DataID)) != NC_NOERR) | ||
47 | + nc_handle_error(status); | ||
48 | + | ||
49 | + if ((status = nc_inq_dimid(DataID, "record", &RecID)) != NC_NOERR) | ||
50 | + nc_handle_error(status); | ||
51 | + | ||
52 | +/* Get Number of Records */ | ||
53 | + | ||
54 | + if ((status = nc_inq_dimlen(DataID, RecID, &RecNum)) != NC_NOERR) | ||
55 | + nc_handle_error(status); | ||
56 | + | ||
57 | + if ((status = nc_inq_varid(DataID, "StartTime", &StartID)) != NC_NOERR) | ||
58 | + nc_handle_error(status); | ||
59 | + if ((status = nc_inq_varid(DataID, "StopTime", &StopID)) != NC_NOERR) | ||
60 | + nc_handle_error(status); | ||
61 | + | ||
62 | +/* Get The First Start and The Last Stop Times */ | ||
63 | + start[0] = 0; | ||
64 | + | ||
65 | + if((status = nc_get_vara_text(DataID, StartID, start, count, StartT)) != NC_NOERR) | ||
66 | + nc_handle_error(status); | ||
67 | + | ||
68 | + start[0] = RecNum-1; | ||
69 | + if((status = nc_get_vara_text(DataID, StopID, start, count, StopT)) != NC_NOERR) | ||
70 | + nc_handle_error(status); | ||
71 | + | ||
72 | + printf("%s-%s\n", StartT, StopT); | ||
73 | + if ((status = nc_close(DataID)) != NC_NOERR) nc_handle_error(status); | ||
74 | + | ||
75 | +} |
src/TIMESUPDATE/CMakeLists.txt renamed to src/DATA/TIMESUPDATE/CMakeLists.txt
src/TIMESUPDATE/TimesUpdate.c renamed to src/DATA/TIMESUPDATE/TimesUpdate.c
src/TIMESUPDATENODATA/CMakeLists.txt renamed to src/DATA/TIMESUPDATENODATA/CMakeLists.txt
src/TIMESUPDATENODATA/TimesUpdateNoData.c renamed to src/DATA/TIMESUPDATENODATA/TimesUpdateNoData.c