📄 ne_test.c
字号:
/* * Copyright (c) 1998 Sandia Corporation. Under the terms of Contract * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Governement * retains certain rights in this software. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials provided * with the distribution. * * * Neither the name of Sandia Corporation nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * *//*****************************************************************************//*****************************************************************************//*****************************************************************************//* This file contains the source code for the program used to test the * Nemesis distribution. ***************************************************************************** * Written By: Gary L. Hennigan (SNL, 1421) ***************************************************************************** * Functions contained in this file: * main() - Entry point and main calling program. *//*****************************************************************************//*****************************************************************************//*****************************************************************************/#include <stdio.h>#include <stdlib.h>#include <string.h>#include <exodusII.h>#include "ne_nemesisI.h"/* Constants for init_global functions */#define NNG 100#define NEG 50#define NEBG 5#define NEBCG 10#define NNSG 2#define NSSG 3/* Constants for load-balance functions */#define NPROC 10#define NPROCF NPROC#define NINTN 200#define NBORN 10#define NEXTN 5#define NINTE 100#define NBORE 20#define NNCMAP 4#define NECMAP 2/* Constants for communication map */#define NCNTCM 20#define ECNTCM 17int main(int argc, char *argv[]){ /* Local function calls */ int ne_test_glbp(int); int ne_test_piinf(int); int ne_test_pinig(int); int ne_test_pelbid(int); int ne_test_pnsp(int); int ne_test_pssp(int); int ne_test_pnm(int); int ne_test_pem(int); int ne_test_pcmp(int); int ne_test_pncm(int); int ne_test_pecm(int); int ne_test_giinf(int); int ne_test_ginig(int); int ne_test_gelbid(int); int ne_test_gnsp(int); int ne_test_gssp(int); int ne_test_gnm(int); int ne_test_gem(int); int ne_test_gncm(int); int ne_test_gecm(int); int ne_test_plbpc(int); int ne_test_pcmpc(int); /* Unitialized local variables */ int ne_file_id; char test_direc[256], file_name[256]; float version; /* Initialized local variables */ char *yo="main"; int io_ws=0, cpu_ws=0, t_pass=0, t_fail=0; int debug_flag=0;/*-----------------------------Execution Begins-----------------------------*/ /* Get the location of the temporary file to use for the test */ if (argc <= 1) { /* Nothing specified. Use defaults. */ strcpy(file_name, "./ne_test.exoII"); } else if (argc == 2) { /* Test for the help flag */ if (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "-?") == 0) { /* Output the help line */ printf("Usage:\n\tne_test <optional directory> <optional file name>\n"); exit(0); } /* Test for the debug flag */ else if (strcmp(argv[1], "-d") == 0 || strcmp(argv[1], "-d") == 0) { printf("****DEBUG MODE****\n"); ex_opts(EX_VERBOSE | EX_DEBUG); strcpy(file_name, "./ne_test.exoII"); debug_flag = 1; } /* Else get the directory name and assign default name */ else { strcpy(test_direc, argv[1]); if (test_direc[strlen(test_direc)-1] != '/') { strcpy(file_name, test_direc); strcat(file_name, "/ne_test.exoII"); } else { strcpy(file_name, test_direc); strcat(file_name, "ne_test.exoII"); } } } else if (argc == 3) { /* Both directory and file name specified */ strcpy(test_direc, argv[1]); if (test_direc[strlen(test_direc)-1] == '/') { strcpy(file_name, test_direc); strcat(file_name, "/"); strcat(file_name, argv[2]); } else { strcpy(file_name, test_direc); strcat(file_name, argv[2]); } }/*---------------------------------------------------------------------------*//* OUTPUT TEST SECTION *//*---------------------------------------------------------------------------*/ printf("*********************Output Tests***********************\n"); /* Create the ExodusII/Nemesis file */ printf("creating ExodusII file..."); fflush(stdout); if ((ne_file_id=ex_create(file_name, EX_CLOBBER, &cpu_ws, &io_ws)) < 0) { printf("FAILED\n"); t_fail++; fprintf(stderr, "[%s]: ERROR, unable to create test file \"%s\"!\n", yo, file_name); exit(-1); } printf("successful\n"); fflush(stdout); t_pass++; /* Test the output of initial information */ printf("testing init info output..."); fflush(stdout); if (ne_test_piinf(ne_file_id) < 0) { printf("FAILED\n"); fflush(stdout); t_fail++; if (debug_flag == 1) return 1; } else { printf("successful\n"); fflush(stdout); t_pass++; } /* Test the output of initial global information */ printf("testing global init info output..."); fflush(stdout); if (ne_test_pinig(ne_file_id) < 0) { printf("FAILED\n"); fflush(stdout); t_fail++; if (debug_flag == 1) return 1; } else { printf("successful\n"); fflush(stdout); t_pass++; } /* Test the output of the global element block IDs */ printf("testing global element block ID output..."); fflush(stdout); if (ne_test_pelbid(ne_file_id) < 0) { printf("FAILED\n"); fflush(stdout); t_fail++; if (debug_flag == 1) return 1; } else { printf("successful\n"); fflush(stdout); t_pass++; } /* Test the output of the global node-set info */ printf("testing global node-set params output..."); fflush(stdout); if (ne_test_pnsp(ne_file_id) < 0) { printf("FAILED\n"); fflush(stdout); t_fail++; if (debug_flag == 1) return 1; } else { printf("successful\n"); fflush(stdout); t_pass++; } /* Test the output of the global side-set info */ printf("testing global side-set params output..."); fflush(stdout); if (ne_test_pssp(ne_file_id) < 0) { printf("FAILED\n"); fflush(stdout); t_fail++; if (debug_flag == 1) return 1; } else { printf("successful\n"); fflush(stdout); t_pass++; } /* Test the output of the concatenated load-balance parameters */ printf("testing concatenated load balance info output..."); fflush(stdout); if (ne_test_plbpc(ne_file_id) < 0) { printf("FAILED\n"); fflush(stdout); } else { printf("succesful\n"); fflush(stdout); } /* Test the output of the node map */ printf("testing node map output..."); fflush(stdout); if (ne_test_pnm(ne_file_id) < 0) { printf("FAILED\n"); fflush(stdout); t_fail++; if (debug_flag == 1) return 1; } else { printf("successful\n"); fflush(stdout); t_pass++; } /* Test the output of the element map */ printf("testing element map output..."); fflush(stdout); if (ne_test_pem(ne_file_id) < 0) { printf("FAILED\n"); fflush(stdout); t_fail++; if (debug_flag == 1) return 1; } else { printf("successful\n"); fflush(stdout); t_pass++; } /* Test the output of the concatenated communication map params */ printf("testing concatenated communication map params output..."); fflush(stdout); if (ne_test_pcmpc(ne_file_id) < 0) { printf("FAILED\n"); fflush(stdout); t_fail++; if (debug_flag == 1) return 1; } else { printf("successful\n"); fflush(stdout); t_pass++; } /* Test nodal communication map output */ printf("testing nodal communication map output..."); fflush(stdout); if (ne_test_pncm(ne_file_id) < 0) { printf("FAILED\n"); fflush(stdout); t_fail++; if (debug_flag == 1) return 1; } else { printf("successful\n"); fflush(stdout); t_pass++; } /* Test elemental communication map output */ printf("testing elemental communication map output..."); fflush(stdout); if (ne_test_pecm(ne_file_id) < 0) { printf("FAILED\n"); fflush(stdout); t_fail++; if (debug_flag == 1) return 1; } else { printf("successful\n"); fflush(stdout); t_pass++; } /* Close the ExodusII/Nemesis test file */ printf("closing ExodusII file..."); fflush(stdout); if (ex_close(ne_file_id) < 0) { printf("FAILED\n"); fflush(stdout); t_fail++; if (debug_flag == 1) return 1; fprintf(stderr, "[%s]: ERROR, unable to close test file \"%s\"!\n", yo, file_name); exit(-1); } printf("successful\n"); fflush(stdout); t_pass++;/*---------------------------------------------------------------------------*//* INPUT TEST SECTION *//*---------------------------------------------------------------------------*/ printf("**********************Input Tests***********************\n"); /* Re-open the ExodusII/NemesisI file */ printf("reopening ExodusII file..."); fflush(stdout); if (ex_open(file_name, EX_READ, &cpu_ws, &io_ws, &version) < 0) { printf("FAILED\n"); fflush(stdout); t_fail++; if (debug_flag == 1) return 1; } else { printf("successful\n"); fflush(stdout); t_pass++; } /* Test read of of the initial information */ printf("testing init info input..."); fflush(stdout); if (ne_test_giinf(ne_file_id) < 0) { printf("FAILED\n"); fflush(stdout); t_fail++; if (debug_flag == 1) return 1; } else { printf("successful\n"); fflush(stdout); t_pass++; } /* Test read of initial global information */ printf("testing global init info input..."); fflush(stdout); if (ne_test_ginig(ne_file_id) < 0) { printf("FAILED\n"); fflush(stdout); t_fail++; if (debug_flag == 1) return 1; } else { printf("successful\n"); fflush(stdout); t_pass++; } /* Test read of global element block IDs */ printf("testing global element block IDs input..."); fflush(stdout); if (ne_test_gelbid(ne_file_id) < 0) { printf("FAILED\n"); fflush(stdout); t_fail++; if (debug_flag == 1) return 1; } else { printf("successful\n"); fflush(stdout); t_pass++; } /* Test read of global node-set params */ printf("testing global node-set params input..."); fflush(stdout); if (ne_test_gnsp(ne_file_id) < 0) { printf("FAILED\n"); fflush(stdout); t_fail++; if (debug_flag == 1) return 1; } else { printf("successful\n"); fflush(stdout); t_pass++; } /* Test read of global side-set params */ printf("testing global side-set params input..."); fflush(stdout); if (ne_test_gssp(ne_file_id) < 0) { printf("FAILED\n"); fflush(stdout); t_fail++; if (debug_flag == 1) return 1; } else { printf("successful\n"); fflush(stdout); t_pass++; } /* Test read of load-balance params */ printf("testing load-balance params input..."); fflush(stdout); if (ne_test_glbp(ne_file_id) < 0) { printf("FAILED\n"); fflush(stdout); t_fail++; if (debug_flag == 1) return 1; } else { printf("successful\n"); fflush(stdout); t_pass++; } /* Test read of the node map */ printf("testing node map input..."); fflush(stdout); if (ne_test_gnm(ne_file_id) < 0) { printf("FAILED\n"); fflush(stdout); t_fail++; if (debug_flag == 1) return 1; } else { printf("successful\n"); fflush(stdout); t_pass++; } /* Test read of element map */ printf("testing element map input..."); fflush(stdout); if (ne_test_gem(ne_file_id) < 0) { printf("FAILED\n"); fflush(stdout); t_fail++; if (debug_flag == 1) return 1; } else { printf("successful\n"); fflush(stdout); t_pass++; } /* Test read of nodal communication maps */ printf("testing nodal communication map input..."); fflush(stdout); if (ne_test_gncm(ne_file_id) < 0) { printf("FAILED\n"); fflush(stdout); t_fail++; if (debug_flag == 1) return 1; } else { printf("successful\n"); fflush(stdout); t_pass++; } /* Test read of elemental communication maps */ printf("testing elemental communication map input..."); fflush(stdout); if (ne_test_gecm(ne_file_id) < 0) { printf("FAILED\n"); fflush(stdout); t_fail++; if (debug_flag == 1) return 1; } else { printf("successful\n"); fflush(stdout); t_pass++; } /* Close the ExodusII/Nemesis test file */ printf("closing ExodusII file..."); fflush(stdout); if (ex_close(ne_file_id) < 0) { printf("FAILED\n"); fflush(stdout); t_fail++; fprintf(stderr, "[%s]: ERROR, unable to close test file \"%s\"!\n", yo, file_name); exit(-1); } printf("successful\n"); fflush(stdout); t_pass++; /* Output a test summary */ printf("\n"); printf("Tests Passed: %d\n", t_pass); printf("Tests Failed: %d\n", t_fail); return 0;}/*****************************************************************************/int ne_test_piinf(int fileid){ char ftype[3]; strcpy(ftype, "s");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -