private List < String > getFileNames ( ) throws IOException { if ( fileNames == null ) { fileNames = new ArrayList <> ( ) ; timeStepsPerFile = tDim . getSize ( ) ; if ( ! isTemplate ( ) ) { // single file fileNames . add ( getFullPath ( getDataFile ( ) ) ) ; } else { // figure out template type long start = System . currentTimeMillis ( ) ; List < String > fileSet = new ArrayList <> ( ) ; String template = getDataFile ( ) ; if ( GradsTimeDimension . hasTimeTemplate ( template ) ) { if ( template . contains ( GradsEnsembleDimension . ENS_TEMPLATE_ID ) ) { templateType = ENS_TIME_TEMPLATE ; } else { templateType = TIME_TEMPLATE ; } } else { // not time - either ens or chsub if ( template . contains ( GradsEnsembleDimension . ENS_TEMPLATE_ID ) ) { templateType = ENS_TEMPLATE ; } else { templateType = TIME_TEMPLATE ; } } if ( templateType == ENS_TEMPLATE ) { for ( int e = 0 ; e < eDim . getSize ( ) ; e ++ ) { fileSet . add ( getFullPath ( eDim . replaceFileTemplate ( template , e ) ) ) ; } } else if ( ( templateType == TIME_TEMPLATE ) || ( templateType == ENS_TIME_TEMPLATE ) ) { int numens = ( templateType == TIME_TEMPLATE ) ? 1 : eDim . getSize ( ) ; for ( int t = 0 ; t < tDim . getSize ( ) ; t ++ ) { for ( int e = 0 ; e < numens ; e ++ ) { String file = getFileName ( e , t ) ; if ( ! fileSet . contains ( file ) ) { fileSet . add ( file ) ; } } } // this'll be a bogus number if chsub was used timeStepsPerFile = tDim . getSize ( ) / ( fileSet . size ( ) / numens ) ; } //System.out.println("Time to generate file list = " // + (System.currentTimeMillis() - start)); fileNames . addAll ( fileSet ) ; } //long start2 = System.currentTimeMillis(); // now make sure they exist for ( String file : fileNames ) { File f = new File ( file ) ; if ( ! f . exists ( ) ) { log . error ( "File: " + f + " does not exist" ) ; throw new IOException ( "File: " + f + " does not exist" ) ; } } //System.out.println("Time to check file list = " // + (System.currentTimeMillis() - start2)); } return fileNames ; }
Get the list of filenames