source: ThirdParty/mpqc_open/src/lib/util/psi3/libpsio/init.cc@ 9f2071

Action_Thermostats Add_AtomRandomPerturbation Add_SelectAtomByNameAction Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_StructOpt_integration_tests AutomationFragmentation_failures Candidate_v1.6.1 Candidate_v1.7.0 ChangeBugEmailaddress ChemicalSpaceEvaluator Docu_Python_wait EmpiricalPotential_contain_HomologyGraph_documentation Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns ForceAnnealing_oldresults ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion Gui_displays_atomic_force_velocity IndependentFragmentGrids_IntegrationTest JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks StoppableMakroAction TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps stable
Last change on this file since 9f2071 was 860145, checked in by Frederik Heber <heber@…>, 9 years ago

Merge commit '0b990dfaa8c6007a996d030163a25f7f5fc8a7e7' as 'ThirdParty/mpqc_open'

  • Property mode set to 100644
File size: 1.9 KB
Line 
1/*!
2 \file init.cc
3 \ingroup (PSIO)
4*/
5
6#include <stdio.h>
7#include <stdlib.h>
8
9#include <util/psi3/libpsio/psio.h>
10#include <util/psi3/libpsio/psifiles.h>
11
12using namespace psi3::libpsio;
13
14namespace psi3 {
15namespace libpsio {
16
17psio_ud *psio_unit;
18psio_address PSIO_ZERO = {0,0};
19
20/* Library state variable */
21int _psi3_libpsio_state_ = 0;
22
23#ifdef PSIO_STATS
24ULI *psio_readlen;
25ULI *psio_writlen;
26#endif
27
28/*!
29** PSIO_INIT(): Allocates global memory needed by the I/O routines.
30**
31** No arguments.
32**
33** \ingroup (PSIO)
34*/
35
36int psio_init(void)
37{
38 int i,j;
39 char *userhome;
40 char filename[PSIO_MAXSTR];
41 FILE *psirc;
42
43 psio_unit = (psio_ud *) malloc(sizeof(psio_ud)*PSIO_MAXUNIT);
44
45#ifdef PSIO_STATS
46 psio_readlen = (ULI *) malloc(sizeof(ULI) * PSIO_MAXUNIT);
47 psio_writlen = (ULI *) malloc(sizeof(ULI) * PSIO_MAXUNIT);
48#endif
49
50 if(psio_unit == NULL) {
51 fprintf(stderr, "Error in PSIO_INIT()!\n");
52 exit(PSI_RETURN_FAILURE);
53 }
54
55 for(i=0; i < PSIO_MAXUNIT; i++) {
56#ifdef PSIO_STATS
57 psio_readlen[i] = psio_writlen[i] = 0;
58#endif
59 psio_unit[i].numvols = 0;
60 for(j=0; j < PSIO_MAXVOL; j++) {
61 psio_unit[i].vol[j].path = NULL;
62 psio_unit[i].vol[j].stream = -1;
63 }
64 psio_unit[i].tocaddress.page = 0;
65 psio_unit[i].tocaddress.offset = 0;
66 psio_unit[i].toclen = 0;
67 psio_unit[i].toc = NULL;
68 }
69
70 /* Open user's general .psirc file, if extant */
71 userhome = getenv("HOME");
72 sprintf(filename, "%s%s", userhome, "/.psirc");
73 psirc = fopen(filename, "r");
74 if(psirc != NULL) {
75 // Need to parse the file elsewhere
76 // ip_append(psirc, stdout);
77 fclose(psirc);
78 }
79
80 /* Set library's state variable to initialized value (1) */
81 _psi3_libpsio_state_ = 1;
82
83 return(0);
84}
85
86/*!
87** PSIO_STATE(): Returns state of the library (1=initialized, 0=noninitialized).
88**
89** No arguments.
90**
91** \ingroup (PSIO)
92*/
93
94int psio_state()
95{
96 return _psi3_libpsio_state_;
97}
98
99}
100}
101
Note: See TracBrowser for help on using the repository browser.