public void writeHeader(
      List<ucar.unidata.geoloc.Station> stns,
      List<VariableSimpleIF> vars,
      int nprofiles,
      String altVarName)
      throws IOException {
    createGlobalAttributes();
    createStations(stns);
    createProfiles(nprofiles);

    // dummys, update in finish()
    ncfile.addGlobalAttribute("zaxis_coordinate", altVarName);
    ncfile.addGlobalAttribute("time_coverage_start", dateFormatter.toDateTimeStringISO(new Date()));
    ncfile.addGlobalAttribute("time_coverage_end", dateFormatter.toDateTimeStringISO(new Date()));

    createDataVariables(vars);

    ncfile.create(); // done with define mode

    writeStationData(stns); // write out the station info

    // now write the observations
    if (!(Boolean) ncfile.sendIospMessage(NetcdfFile.IOSP_MESSAGE_ADD_RECORD_STRUCTURE))
      throw new IllegalStateException("can't add record variable");
  }