public StationTimeSeriesNetCDFFile( File file, RecordType rt, Map<String, String> globalAttrs, boolean doChunking, Station... stations) { this.record = rt; this.record_index = 0; this.name = file.getName(); this.createFlags = NC_NETCDF4; // this.convention = convention; int ncStatus; IntByReference iRef = new IntByReference(); ncStatus = nc_create(file.getAbsolutePath(), createFlags, iRef); status(ncStatus); ncId = iRef.getValue(); // DIMENSIONS: ncStatus = nc_def_dim(ncId, STATION_DIM_NAME, new NativeLong(stations.length), iRef); status(ncStatus); ncDimId_station = iRef.getValue(); int max_length = Station.findMaxStationLength(stations); ncStatus = nc_def_dim(ncId, STATION_ID_LEN_NAME, new NativeLong(max_length), iRef); status(ncStatus); ncDimId_station_id_len = iRef.getValue(); ncStatus = nc_def_dim(ncId, OBSERVATION_DIM_NAME, new NativeLong(NC_UNLIMITED), iRef); status(ncStatus); ncDimId_observation = iRef.getValue(); //// VARIABLES // STATION int ncTypeId_record_type = this.record.writeRecordCompound(ncId); Map<String, Variable> stVars = this.record.writeStationVariables(ncId, ncDimId_station, ncDimId_station_id_len); this.record.writeObservationVariables( ncId, new int[] {ncDimId_observation}, ncTypeId_record_type, doChunking); // Global Attributes writeGlobalAttributes(globalAttrs); ncStatus = nc_enddef(ncId); status(ncStatus); // Now lets fill in the Station data from vararg stations // Then we're set up to start putting observations NativeLong station_indexp = new NativeLong(0); NativeLong stationid_len_indexp = new NativeLong(0); for (Station station : stations) { ncStatus = nc_put_var1_float(ncId, stVars.get("lon").ncVarId, station.longitude, station_indexp); status(ncStatus); ncStatus = nc_put_var1_float(ncId, stVars.get("lat").ncVarId, station.latitude, station_indexp); status(ncStatus); ncStatus = nc_put_vara_text( ncId, stVars.get("station_id").ncVarId, station.station_id, station_indexp, stationid_len_indexp); status(ncStatus); station_indexp.setValue(station_indexp.longValue() + 1); } }