diff --git a/core/java/src/org/openda/blackbox/interfaces/IKeyDateType.java b/core/java/src/org/openda/blackbox/interfaces/IKeyDateType.java index 54d6b698e..ac62aa146 100644 --- a/core/java/src/org/openda/blackbox/interfaces/IKeyDateType.java +++ b/core/java/src/org/openda/blackbox/interfaces/IKeyDateType.java @@ -24,22 +24,22 @@ * Interface class for key types processing startDate and endDate */ public interface IKeyDateType { - /** - * Set start date - * - * @param date double value representing the start date - */ - public void setStartDate(double date); + /** + * Set start date + * + * @param date double value representing the start date + */ + void setStartDate(double date); - /** - * Set end date - * @param date double value representing the end date - */ - public void setEndDate(double date); + /** + * Set end date + * @param date double value representing the end date + */ + void setEndDate(double date); - /** - * Compute string representation of value - * @return interpreted output string - */ - public String calculateValue(); + /** + * Compute string representation of value + * @return interpreted output string + */ + String calculateValue(); } diff --git a/core/java/src/org/openda/blackbox/interfaces/IKeyType.java b/core/java/src/org/openda/blackbox/interfaces/IKeyType.java index 0aad4f897..f41cb6434 100644 --- a/core/java/src/org/openda/blackbox/interfaces/IKeyType.java +++ b/core/java/src/org/openda/blackbox/interfaces/IKeyType.java @@ -23,11 +23,11 @@ * Interface class for all key types */ public interface IKeyType { - /** - * Returns an interpreted string, where the interpretation of the input string is dependent on the key type. - * - * @param value input string containing a value - * @return interpreted output string - */ - public String getValueAsString(String value); + /** + * Returns an interpreted string, where the interpretation of the input string is dependent on the key type. + * + * @param value input string containing a value + * @return interpreted output string + */ + String getValueAsString(String value); } diff --git a/core/java/src/org/openda/blackbox/interfaces/IModelFactory.java b/core/java/src/org/openda/blackbox/interfaces/IModelFactory.java index 0ddcfbf26..1c4478813 100644 --- a/core/java/src/org/openda/blackbox/interfaces/IModelFactory.java +++ b/core/java/src/org/openda/blackbox/interfaces/IModelFactory.java @@ -30,16 +30,16 @@ */ public interface IModelFactory extends IConfigurable { - /** - * Create an instance of the Model - * @param arguments Arguments for this instance. (arguments == null) or (arguments.length == 0) means: no arguments. - * @param outputLevel The level of output to be produced by the new instance (default, suppressed, etc.) + /** + * Create an instance of the Model + * @param arguments Arguments for this instance. (arguments == null) or (arguments.length == 0) means: no arguments. + * @param outputLevel The level of output to be produced by the new instance (default, suppressed, etc.) * @return The Model instance - */ - IModelInstance getInstance(String[] arguments, IStochModelFactory.OutputLevel outputLevel); + */ + IModelInstance getInstance(String[] arguments, IStochModelFactory.OutputLevel outputLevel); /** * Shut down the model factory. */ void finish(); -} \ No newline at end of file +} diff --git a/core/java/src/org/openda/blackbox/interfaces/ITimeHorizonConsumer.java b/core/java/src/org/openda/blackbox/interfaces/ITimeHorizonConsumer.java index cb4f0e4e0..9da6304e8 100644 --- a/core/java/src/org/openda/blackbox/interfaces/ITimeHorizonConsumer.java +++ b/core/java/src/org/openda/blackbox/interfaces/ITimeHorizonConsumer.java @@ -26,5 +26,5 @@ * after the initialize method of the (stoch)ModelFactory has been called. */ public interface ITimeHorizonConsumer { - public void setTimeHorizon(ITime timeHorizon); + void setTimeHorizon(ITime timeHorizon); } diff --git a/core/java/src/org/openda/blackbox/interfaces/IoObjectInterface.java b/core/java/src/org/openda/blackbox/interfaces/IoObjectInterface.java index 9b31a2593..010d37dd1 100644 --- a/core/java/src/org/openda/blackbox/interfaces/IoObjectInterface.java +++ b/core/java/src/org/openda/blackbox/interfaces/IoObjectInterface.java @@ -30,19 +30,19 @@ */ public interface IoObjectInterface { - /** - * Initialize the IoObject - * @param workingDir Working directory - * @param fileName The name of the file containing the data (relative to the working dir.) - * @param arguments Additional arguments (may be null zero-length) - */ - public void initialize(File workingDir, String fileName, String[] arguments); + /** + * Initialize the IoObject + * @param workingDir Working directory + * @param fileName The name of the file containing the data (relative to the working dir.) + * @param arguments Additional arguments (may be null zero-length) + */ + void initialize(File workingDir, String fileName, String[] arguments); - /** - * Ask which elements can be accessed - * @return The list of element identifiers that can be accessed - */ - public IPrevExchangeItem[] getExchangeItems(); // + /** + * Ask which elements can be accessed + * @return The list of element identifiers that can be accessed + */ + IPrevExchangeItem[] getExchangeItems(); // - public void finish(); + void finish(); } diff --git a/core/java/src/org/openda/blackbox/interfaces/SelectorInterface.java b/core/java/src/org/openda/blackbox/interfaces/SelectorInterface.java index 64704e061..7e5598788 100644 --- a/core/java/src/org/openda/blackbox/interfaces/SelectorInterface.java +++ b/core/java/src/org/openda/blackbox/interfaces/SelectorInterface.java @@ -27,25 +27,25 @@ */ public interface SelectorInterface { - /** - * Initalize the selector - * @param workingDir Working directory - * @param arguments Configuration arguments - */ - void initialize(File workingDir, String[] arguments); + /** + * Initalize the selector + * @param workingDir Working directory + * @param arguments Configuration arguments + */ + void initialize(File workingDir, String[] arguments); /** * Apply this selector - * @param inputObject The input object for the selection - * @return The resulting selection - */ - public Object select(Object inputObject); + * @param inputObject The input object for the selection + * @return The resulting selection + */ + Object select(Object inputObject); - /** - * Apply this selector in the inversion way - * @param selection Result of a previous select() call - * @return The adjusted original input for the selection - */ - public Object deselect(Object selection); + /** + * Apply this selector in the inversion way + * @param selection Result of a previous select() call + * @return The adjusted original input for the selection + */ + Object deselect(Object selection); } diff --git a/core/java/src/org/openda/blackbox/wrapper/ArmaNoiseModel.java b/core/java/src/org/openda/blackbox/wrapper/ArmaNoiseModel.java index e5333dedc..d9678e656 100644 --- a/core/java/src/org/openda/blackbox/wrapper/ArmaNoiseModel.java +++ b/core/java/src/org/openda/blackbox/wrapper/ArmaNoiseModel.java @@ -35,18 +35,18 @@ public class ArmaNoiseModel { private static DistributedCounter instanceCount = new DistributedCounter(0); - private int stateVectorSize = Integer.MIN_VALUE; - private double[] armaConstants = null; + private int stateVectorSize; + private double[] armaConstants; private boolean useRandomSeed = false; private NormalDistribution normalDistribution = null; - private int instanceNumber = Integer.MIN_VALUE; + private int instanceNumber; private int realizationCounter = 0; // state vector for each previous arma step, // and 1 for the current state (index 0) - private double[][] noiseStateVector = null; + private double[][] noiseStateVector; private ITime currentTime = null; private File logFile = null; diff --git a/core/java/src/org/openda/exchange/dataobjects/AsciiKeywordDataObject.java b/core/java/src/org/openda/exchange/dataobjects/AsciiKeywordDataObject.java index 6ccb7aca4..a477c7dab 100644 --- a/core/java/src/org/openda/exchange/dataobjects/AsciiKeywordDataObject.java +++ b/core/java/src/org/openda/exchange/dataobjects/AsciiKeywordDataObject.java @@ -71,15 +71,15 @@ @SuppressWarnings("unused") public class AsciiKeywordDataObject implements IDataObject{ - private static final Logger logger = LoggerFactory.getLogger(AsciiKeywordDataObject.class); - MessageFormat logFormatter = new MessageFormat(""); + private static final Logger logger = LoggerFactory.getLogger(AsciiKeywordDataObject.class); + private MessageFormat logFormatter = new MessageFormat(""); - private String fileName = null; + private String fileName = null; private static final String keyWordPrefix ="#oda:"; private static final String multiplexId ="@"; private static final String arrayRegex = "\\[|\\]|\\s|,|\\(|\\)"; private HashMap items = new LinkedHashMap<>(); - private HashMap multiplexColumn = new LinkedHashMap<>(); + private HashMap multiplexColumn = new LinkedHashMap<>(); private ArrayList fileContent = new ArrayList<>(); private double referenceMjd = 0.0; private static final double SECONDS_TO_DAYS = 1.0 / 24.0 / 60.0 / 60.0; @@ -87,19 +87,8 @@ public class AsciiKeywordDataObject implements IDataObject{ private boolean convertTime = false; static private final String WITH_DELIMITER = "((?<=%1$s)|(?=%1$s))"; - /** - * Reads OpenFoam results generated by the sample utility. - * - * @param workingDir the working directory. - * @param arguments list of other arguments: - *
    - *
  1. The name of the file containing the data - * for this IoObject (relative to the working directory).
  2. - *
  3. Optional, a referenceDate in ISO 8601 notatation, e.g - * for this IoObject (relative to the working directory).
  4. - * - *
- */ + /** {@inheritDoc} + */ public void initialize(File workingDir, String[] arguments) { if ( arguments.length == 0 ) { @@ -117,7 +106,7 @@ public void initialize(File workingDir, String[] arguments) { try{ inputFile = new File(workingDir,fileName); if(!inputFile.isFile()){ - throw new IOException("Can not find file " + inputFile); + throw new IOException("Cannot find file " + inputFile); } this.fileName = inputFile.getCanonicalPath(); }catch (Exception e) { @@ -128,17 +117,13 @@ public void initialize(File workingDir, String[] arguments) { Scanner scanner = new Scanner(inputFile); scanner.useLocale(Locale.US); - //FileInputStream in = new FileInputStream(inputFile); - //BufferedReader buff = new BufferedReader(new InputStreamReader(in)); - String line; - logger.debug("Reading file"); + logger.debug("Reading file"); while (scanner.hasNext()) { line = scanner.nextLine(); fileContent.add(line); int locationIndex = line.indexOf(keyWordPrefix); - //Scanner lineScanner = new Scanner(line); if (locationIndex > 0) { logger.trace("Read line: "+ line); String valueString=""; @@ -150,7 +135,6 @@ public void initialize(File workingDir, String[] arguments) { Vector values = new Vector<>(); Vector column = new Vector<>(); for ( int index=0; index < parts.length ;index++) { - //for ( String part : parts) { if (!parts[index].isEmpty()) { try { Double value = Double.parseDouble(parts[index]); @@ -158,7 +142,7 @@ public void initialize(File workingDir, String[] arguments) { column.add(index); logger.debug("Found value part " + parts[index]); } catch (NumberFormatException e) { - logger.trace("Skipping " + parts[index]); + logger.trace("Skipping " + parts[index]); } } } @@ -188,7 +172,7 @@ public void initialize(File workingDir, String[] arguments) { } catch (Exception e) { throw new RuntimeException("Problem reading from file " + fileName+" : "+e.getClass()); } - } + } /** {@inheritDoc} */ @@ -214,32 +198,30 @@ public IExchangeItem getDataObjectExchangeItem(String exchangeItemID) { /** {@inheritDoc} */ public String[] getExchangeItemIDs() { - return items.keySet().toArray(new String[items.size()]); + return items.keySet().toArray(new String[0]); } /** {@inheritDoc} */ public String[] getExchangeItemIDs(IPrevExchangeItem.Role role) { //TODO: select on role - return items.keySet().toArray(new String[items.size()]); + return items.keySet().toArray(new String[0]); } /** {@inheritDoc} */ public void finish() { - //write to file + //write to file File outputFile = new File(fileName); try{ - if(outputFile.isFile()){ - if ( ! outputFile.delete() ) throw new RuntimeException("Cannot delete " + outputFile); - } + if (outputFile.isFile() && !outputFile.delete()) throw new RuntimeException("Cannot delete " + outputFile); }catch (Exception e) { logger.error("DictionaryDataObject: trouble removing file " + this.fileName +" :\n" + e.getMessage()); } try { FileWriter writer = new FileWriter(outputFile); BufferedWriter out = new BufferedWriter(writer); - for (String line: fileContent){ + for (String line: fileContent){ int locationIndex = line.indexOf(keyWordPrefix); //Scanner lineScanner = new Scanner(line); if (locationIndex > 0) { @@ -251,13 +233,13 @@ public void finish() { String[] parts = line.split(String.format(WITH_DELIMITER, arrayRegex)); if (multiplexColumn.containsKey(key)) { int index = multiplexColumn.get(key); - Double paramValue = (Double) items.get(key).getValues(); - if (timeExchangeItemIds.contains(key) && convertTime) { - logger.debug("Converting to MJD: " + key); - paramValue = (paramValue - referenceMjd ) / SECONDS_TO_DAYS; - } - logger.debug("Store value: " + paramValue); - parts[index] = Double.toString(paramValue); + Double paramValue = (Double) items.get(key).getValues(); + if (timeExchangeItemIds.contains(key) && convertTime) { + logger.debug("Converting to MJD: " + key); + paramValue = (paramValue - referenceMjd ) / SECONDS_TO_DAYS; + } + logger.debug("Store value: " + paramValue); + parts[index] = Double.toString(paramValue); } int nr = 1; while (multiplexColumn.containsKey(key + multiplexId + nr)) { @@ -265,7 +247,7 @@ public void finish() { int index = multiplexColumn.get(id); Double paramValue = (Double) items.get(id).getValues(); logger.debug("Store value part: " + paramValue); - parts[index] = Double.toString(paramValue); + parts[index] = Double.toString(paramValue); nr++; } StringBuilder builder = new StringBuilder(); @@ -276,15 +258,15 @@ public void finish() { logger.trace("Write line: " + outputLine); out.write(outputLine); } - else { - //Write Line - out.write(line + "\n"); - } - } + else { + //Write Line + out.write(line + "\n"); + } + } out.close(); } catch (Exception e) { throw new RuntimeException("DictionaryDataObject: Problem writing to file " + this.fileName+" :\n" + e.getMessage()); } - } + } } diff --git a/core/native/linux_install.sh b/core/native/linux_install.sh index e1deca339..9a24d9920 100755 --- a/core/native/linux_install.sh +++ b/core/native/linux_install.sh @@ -41,10 +41,10 @@ else else echo "No fortran compiler found" return 1 - fi + fi fi #defaults for 64/32bit (=look at architecture of this computer) -export RAWARCH=`uname -m` +export RAWARCH=$(uname -m) if [ "$RAWARCH" == "x86_64" ]; then export ARCH=64 else @@ -56,11 +56,11 @@ export IGNORENETCDF="no" #test for windows mingw export OSTYPE="unknown" -export TMPVAR=`uname -s|grep -i mingw` +export TMPVAR=$(uname -s|grep -i mingw) if [ ! -z "$TMPVAR" ]; then OSTYPE="win" fi -export TMPVAR=`uname -s|grep -i linux` +export TMPVAR=$(uname -s|grep -i linux) if [ ! -z "$TMPVAR" ]; then OSTYPE="linux" fi @@ -70,26 +70,26 @@ export DEBUG="no" # parse arguments for arg in "$@" do - case "$arg" in - 64*) ARCH="64" - ;; - 32*) ARCH="32" - ;; - ifort*) FORT="ifort" - ;; - gnu*) FORT="gnu" - ;; - ignorempi*) IGNOREMPI="yes" - ;; - ignorenetcdf*) IGNORENETCDF="yes" - ;; - noignorempi*) IGNOREMPI="no" - ;; - noignorenetcdf*) IGNORENETCDF="no" - ;; - debug*) DEBUG="yes" - ;; - esac + case "$arg" in + 64*) ARCH="64" + ;; + 32*) ARCH="32" + ;; + ifort*) FORT="ifort" + ;; + gnu*) FORT="gnu" + ;; + ignorempi*) IGNOREMPI="yes" + ;; + ignorenetcdf*) IGNORENETCDF="yes" + ;; + noignorempi*) IGNOREMPI="no" + ;; + noignorenetcdf*) IGNORENETCDF="no" + ;; + debug*) DEBUG="yes" + ;; + esac done #recheck compilers if [ "$FORT" == "ifort" ];then @@ -102,7 +102,7 @@ if [ "$FORT" == "ifort" ];then fi fi if [ "$FORT" == "gnu" ];then - export GFORTRANPATH=`which gfortran 2>/dev/null` + export GFORTRANPATH=$(which gfortran 2>/dev/null) if [ ! -z "$GFORTRANPATH" ]; then export MYFORT="$GFORTRANPATH" else @@ -173,17 +173,17 @@ fi # JAVA # if [ "$JAVA_HOME" == "" ]; then - if [ -f /opt/java/include/jni.h ]; then - export JAVA_HOME=/opt/java - elif [ -f /usr/local/include/jni.h ]; then - export JAVA_HOME=/usr/local - else - echo "Please set the environment variable JAVA_HOME to the directory that" - echo "contains the Java development kit" - exit - fi + if [ -f /opt/java/include/jni.h ]; then + export JAVA_HOME=/opt/java + elif [ -f /usr/local/include/jni.h ]; then + export JAVA_HOME=/usr/local + else + echo "Please set the environment variable JAVA_HOME to the directory that" + echo "contains the Java development kit" + exit + fi - echo "JAVA_HOME set to $JAVA_HOME" + echo "JAVA_HOME set to $JAVA_HOME" fi #