lfi2cdf: new option: "-s or --split" to split the variables in different files
authorPhilippe WAUTELET <philippe.wautelet@aero.obs-mip.fr>
Fri, 18 Sep 2015 09:07:22 +0000 (11:07 +0200)
committerPhilippe WAUTELET <philippe.wautelet@aero.obs-mip.fr>
Mon, 2 May 2016 10:23:53 +0000 (12:23 +0200)
         WARNING: not yet implemented! (the option is just recognized)

tools/lfi2cdf/src/lfi2cdf.f90
tools/lfi2cdf/src/newmain.c

index 41886f5..15a77be 100644 (file)
@@ -1,5 +1,5 @@
 subroutine  LFI2CDFMAIN(hinfile,iiflen,ooutname,houtfile,ioflen,hvarlist,ivlen,olfi2cdf,olfilist,ohdf5,omerge,nb_levels,&
-                        oreduceprecision,ocompress,compress_level)
+                        oreduceprecision,osplit,ocompress,compress_level)
   USE mode_util
   IMPLICIT NONE 
   INTEGER :: iiflen, ioflen, ivlen
@@ -7,7 +7,7 @@ subroutine  LFI2CDFMAIN(hinfile,iiflen,ooutname,houtfile,ioflen,hvarlist,ivlen,o
   CHARACTER(LEN=iiflen) :: hinfile
   CHARACTER(LEN=ioflen) :: houtfile
   CHARACTER(LEN=ivlen)  :: hvarlist
-  LOGICAL :: ooutname, olfi2cdf, olfilist, ohdf5, omerge, oreduceprecision, ocompress
+  LOGICAL :: ooutname, olfi2cdf, olfilist, ohdf5, omerge, oreduceprecision, osplit, ocompress
   INTEGER :: compress_level
 
   INTEGER :: ibuflen
index f2e5d0b..92b3964 100644 (file)
@@ -5,7 +5,7 @@
 
 #define BUFSIZE 4096
 
-extern lfi2cdfmain_(char*, int*, int *, char*, int*, char*, int*, int*, int*, int*, int*, int*, int*, int*, int*);
+extern lfi2cdfmain_(char*, int*, int *, char*, int*, char*, int*, int*, int*, int*, int*, int*, int*, int*, int*, int*);
 
 char *cleancomma(char *varlist)
 {
@@ -34,6 +34,7 @@ int main(int argc, char **argv)
   int reduceprecision_flag;
   int outname_flag;
   int compress_flag, compress_level;
+  int split_flag;
   char *cmd, *infile;
   int c;
   char buff[BUFSIZE];
@@ -72,11 +73,12 @@ int main(int argc, char **argv)
       {"merge",            required_argument, 0, 'm' },
       {"output",           required_argument, 0, 'o' },
       {"reduce-precision", no_argument,       0, 'r' },
+      {"split",            no_argument,       0, 's' },
       {"var",              required_argument, 0, 'v' },
       {0,                  0,                 0,  0  }
     };
 
-    c = getopt_long(argc, argv, "4c:lm:o:rv:",
+    c = getopt_long(argc, argv, "4c:lm:o:rsv:",
                    long_options, &option_index);
     if (c == -1)
       break;
@@ -114,6 +116,9 @@ int main(int argc, char **argv)
     case 'r':
       reduceprecision_flag = 1;
       break;
+    case 's':
+      split_flag = 1;
+      break;
     case 'v':
       if (l2c_flag) {
        lenopt = strlen(optarg);
@@ -135,7 +140,7 @@ int main(int argc, char **argv)
   }
 
   if (optind == argc) {
-    printf("usage : lfi2cdf [--cdf4 -4] [-l] [-v --var var1[,...]] [-r --reduce-precision] [-m --merge number_of_z_levels] [-o --output output-file.nc] [-c --compress compression_level] input-file.lfi\n");
+    printf("usage : lfi2cdf [--cdf4 -4] [-l] [-v --var var1[,...]] [-r --reduce-precision] [-m --merge number_of_z_levels] [-s --split] [-o --output output-file.nc] [-c --compress compression_level] input-file.lfi\n");
     printf("        cdf2lfi [-o --output output-file.lfi] input-file.nc\n");
     exit(EXIT_FAILURE);
   } 
@@ -178,8 +183,15 @@ int main(int argc, char **argv)
          infile, ilen, outfile, olen, varlist, varlistlen);
   */
 
+  /* Split flag only supported if -v is set */
+  if (varlistlen==0) {
+         split_flag = 0;
+         printf("Warning: split option is forced to disable.\n");
+  }
+
+
   lfi2cdfmain_(infile, &ilen, &outname_flag, outfile, &olen, varlist, &varlistlen, &l2c_flag, &list_flag, &hdf5_flag, &merge_flag,
-                      &nb_levels, &reduceprecision_flag, &compress_flag, &compress_level);
+                      &nb_levels, &reduceprecision_flag, &split_flag, &compress_flag, &compress_level);
 
   exit(EXIT_SUCCESS);
 }