private FmrcInv makeFmrcInv ( Formatter debug ) throws IOException { try { Map < CalendarDate , FmrInv > fmrMap = new HashMap <> ( ) ; // all files are grouped by run date in an FmrInv List < FmrInv > fmrList = new ArrayList <> ( ) ; // an fmrc is a collection of fmr // get the inventory, sorted by path for ( MFile f : manager . getFilesSorted ( ) ) { Map < String , String > filesRunDateMap = ( ( MFileCollectionManager ) manager ) . getFilesRunDateMap ( ) ; CalendarDate runDate ; if ( ! filesRunDateMap . isEmpty ( ) ) { // run time has been defined in NcML FMRC agg by the coord attribute, // so explicitly set it in the dataset using the _Coordinate.ModelBaseDate // global attribute, otherwise the run time offsets might be incorrectly // computed if the incorrect run date is found in GridDatasetInv.java (line // 177 with comment // Look: not really right ) runDate = CalendarDate . parseISOformat ( null , filesRunDateMap . get ( f . getPath ( ) ) ) ; Element element = new Element ( "netcdf" , ncNSHttps ) ; Element runDateAttr = ncmlWriter . makeAttributeElement ( new Attribute ( _Coordinate . ModelRunDate , runDate . toString ( ) ) ) ; config . innerNcml = element . addContent ( runDateAttr ) ; } GridDatasetInv inv ; try { inv = GridDatasetInv . open ( manager , f , config . innerNcml ) ; // inventory is discovered for each GDS } catch ( IOException ioe ) { logger . warn ( "Error opening " + f . getPath ( ) + "(skipped)" , ioe ) ; continue ; // skip } runDate = inv . getRunDate ( ) ; if ( debug != null ) debug . format ( " opened %s rundate = %s%n" , f . getPath ( ) , inv . getRunDateString ( ) ) ; // add to fmr for that rundate FmrInv fmr = fmrMap . get ( runDate ) ; if ( fmr == null ) { fmr = new FmrInv ( runDate ) ; fmrMap . put ( runDate , fmr ) ; fmrList . add ( fmr ) ; } fmr . addDataset ( inv , debug ) ; } if ( debug != null ) debug . format ( "%n" ) ; // finish the FmrInv Collections . sort ( fmrList ) ; for ( FmrInv fmr : fmrList ) { fmr . finish ( ) ; if ( logger . isDebugEnabled ( ) ) logger . debug ( "Fmrc:" + config . name + ": made fmr with rundate=" + fmr . getRunDate ( ) + " nfiles= " + fmr . getFiles ( ) . size ( ) ) ; } return new FmrcInv ( "fmrc:" + manager . getCollectionName ( ) , fmrList , config . fmrcConfig . regularize ) ; } catch ( Throwable t ) { logger . error ( "makeFmrcInv" , t ) ; throw new RuntimeException ( t ) ; } }
scan has been done create FmrcInv