#include <common.h>
#include <ioserv.h>    /* error_found */
#include "tran_nbp.h"  /* NBP_ENSEMBLE_TYPE */

void set_depth(db_ens)
DB_ENSEMBLE_TYPE *db_ens;
{
   int i;
   db_ens->depth[0] = db_ens->conf1.tr_depth + db_ens->conf1.blank_length +
      0.5 * (db_ens->conf1.bin_length + db_ens->conf1.pls_length);
   for (i = 1; i < db_ens->conf1.num_bins; i++)
      db_ens->depth[i] = db_ens->depth[0] + i * db_ens->conf1.bin_length;
   db_ens->depth_range.min_depth = db_ens->depth[0];
   db_ens->depth_range.max_depth = db_ens->depth[db_ens->conf1.num_bins-1];
}

int set_block_comments(db_ens, ens)
DB_ENSEMBLE_TYPE *db_ens;
NBP_ENSEMBLE_TYPE *ens;
{
   db_ens->bc_nbytes = 32 + ens->conf.direct_cmd_size;
   if (error_found( db_ens->bc == NULL ?
      (db_ens->bc = malloc(db_ens->bc_nbytes)) == NULL :
      (db_ens->bc = realloc(db_ens->bc, db_ens->bc_nbytes)) == NULL, 
      "Can't allocate memory for block comments."))
      return(INSUFFICIENT_MEMORY);
   sprintf(db_ens->bc, "Name: %-4s\nDirectCommands:\n%s",
      (ens->conf.dply_name_size > 0 ? ens->conf.name : "none"),
      (ens->conf.direct_cmd_size > 0 ? ens->conf.direct_cmd : "none"));
   return(OK);
}

