-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcheck_size.cpp
88 lines (69 loc) · 4.01 KB
/
check_size.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*
$Id: check_size.cpp,v 1.14 2017/05/18 21:19:34 mp Exp $
AutoGrid
Copyright (C) 2009 The Scripps Research Institute. All rights reserved.
AutoGrid is a Trade Mark of The Scripps Research Institute.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <iostream>
#include <math.h>
#include <cstdlib>
#include "autogrid.h" // for print_error
extern char *programname;
/*----------------------------------------------------------------------------*/
int check_size(int nelements,
char axischar, FILE *logFile)
/*----------------------------------------------------------------------------*/
/******************************************************************************/
/* Name: check_size */
/* Function: Checks that number of grid elements is valid. */
/*Copyright (C) 2009 The Scripps Research Institute. All rights reserved. */
/*----------------------------------------------------------------------------*/
/* Author: Garrett Morris, The Scripps Research Institute */
/* Date: 13/07/92 */
/*----------------------------------------------------------------------------*/
/* Inputs: nelements, axischar */
/* Returns: nelements */
/* Globals: MAX_GRID_PTS */
/*----------------------------------------------------------------------------*/
/* Modification Record */
/* Date Inits Comments */
/* 04/01/93 GMM Created for use in makefile. */
/******************************************************************************/
{
int oldnelements;
char msg[1000];
if (nelements < 0) {
fprintf(stderr, "\n%s: Error! Negative number of %c-grid elements! Aborting.\n\n", programname, axischar);
sprintf(msg, "\n%s: Error! Negative number of %c-grid elements! Aborting.\n\n", programname, axischar);
print_error( logFile, FATAL_ERROR, msg ); // exits
}
if (nelements == 0) {
fprintf(stderr, "\n%s: Error!! 0 %c-grid elements!\n\n", programname, axischar);
sprintf(msg, "\n%s: Error!! 0 %c-grid elements!\n\n", programname, axischar);
print_error( logFile, FATAL_ERROR, msg ); // exits
}
if (nelements>MAX_GRID_PTS) {
fprintf(stderr, "\n%s: Error! Maximum number of %c-grid elements allowed is %d.\n", programname, axischar, MAX_GRID_PTS);
sprintf(msg, "\n%s: Error! Maximum number of %c-grid elements allowed is %d.\n", programname, axischar, MAX_GRID_PTS);
print_error( logFile, FATAL_ERROR, msg); // exits
}
oldnelements = nelements;
nelements = (int) ((nelements/2) * 2); // N.B.: integer divide truncates remainder.
if (oldnelements != nelements)
fprintf(logFile, "%s: Number of grid elements must be even; %c-elements changed to: %d\n", programname, axischar, nelements);
return nelements;
}
/*----------------------------------------------------------------------------*/
/* EOF. */
/*----------------------------------------------------------------------------*/