private static int writeProfileFeatureCollection(FeatureDatasetPoint fdpoint, ProfileFeatureCollection pds, String fileOut,
CFPointWriterConfig config) throws IOException {
WriterCFProfileCollection cfWriter = new WriterCFProfileCollection(fileOut, fdpoint.getGlobalAttributes(), fdpoint.getDataVariables(), pds.getExtraVariables(),
pds.getTimeUnit(), pds.getAltUnits(), config);
int count = 0;
int name_strlen = 0;
int nprofiles = pds.size();
if (nprofiles < 0) {
pds.resetIteration();
while (pds.hasNext()) {
ProfileFeature pf = pds.next();
name_strlen = Math.max(name_strlen, pf.getName().length());
count++;
}
nprofiles = count;
}
cfWriter.setFeatureAuxInfo(nprofiles, name_strlen);
count = 0;
pds.resetIteration();
while (pds.hasNext()) {
ucar.nc2.ft.ProfileFeature profile = pds.next();
count += cfWriter.writeProfile(profile);
if (debug && count % 10 == 0) System.out.printf("%d ", count);
if (debug && count % 100 == 0) System.out.printf("%n ");
}
cfWriter.finish();
return count;
}