예제 #1
0
static void
ui_check_options_and_arguments(struct cropparams *p)
{
  /* Make sure we actually have inputs. */
  if(p->inputs==NULL)
    error(EXIT_FAILURE, 0, "no input file given");

  /* Make sure that a HDU is also given. */
  if(p->cp.hdu==NULL )
    error(EXIT_FAILURE, 0, "no HDU specified. When the input is a FITS "
          "file, a HDU must also be specified, you can use the `--hdu' "
          "(`-h') option and give it the HDU number (starting from "
          "zero), extension name, or anything acceptable by CFITSIO");

  /* If in image mode, there should only be one input image. */
  if(p->mode==IMGCROP_MODE_IMG && p->numin>1)
    error(EXIT_FAILURE, 0, "in image mode, only one input image may be "
          "specified");

  /* If no output name is given, set it to the current directory. */
  if(p->cp.output==NULL)
    gal_checkset_allocate_copy("./", &p->cp.output);

  /* Only catalog mode needs multiple threads and a directory for the
     output. */
  if(p->catname)
    {
      /* When multiple threads need to access a file, CFITSIO needs to be
         configured with the `--enable-reentrant` option. */
      if(p->cp.numthreads>1 && fits_is_reentrant()==0)
        error(EXIT_FAILURE, 0, "CFITSIO was not configured with the "
              "`--enable-reentrant` option but you have asked to crop "
              "on %zu threads.\n\nPlease configure, make and install CFITSIO "
              "again with this flag. Alternatively, to avoid this error "
              "you can set the number of threads to 1 by adding the "
              "`--numthreads=1` or `-N1` options. Please run the following "
              "command to learn more about configuring CFITSIO:\n\n"
              "    $ info gnuastro CFITSIO", p->cp.numthreads);

      /* Make sure the given output is a directory. */
      gal_checkset_check_dir_write_add_slash(&p->cp.output);
    }
  else
    {
      p->cp.numthreads=1;
      p->outnameisfile=gal_checkset_dir_0_file_1(p->cp.output,
                                                 p->cp.dontdelete);
    }
}
예제 #2
0
void cfitsio_unlock()
{
    if(!fits_is_reentrant())
        pthread_mutex_unlock(&cfitsio_mutex);
}