-
Notifications
You must be signed in to change notification settings - Fork 1
/
rmc-irrep-decompose.c
74 lines (59 loc) · 1.88 KB
/
rmc-irrep-decompose.c
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
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <stdint.h>
#include <math.h>
#include "defs.h"
#include "globals.h"
#define USAGE_MESSAGE "Script Use: rmc-irrep-decompose [xyzinput].cfg [irrepinput].cfg [eyeinput].eye\n"
#include "io.h"
#include "memlapack.h"
#include "supercell.h"
#include "xyzinput.h"
#include "irrepinput.h"
#include "ircontrib.h"
#include "eyefile.h"
#include "irrepdecompose.h"
int main(int argc, char *argv[]) { // argv[1] = xyzinput, argv[2] = irrepinput, argv[3] = eyeinput
char *opfName = NULL;
// results
LAPACK *irMatrix = NULL; // numCells x numIrreps (complex)
// check number of input parameters
if (argc != 4) printUsageAndExit(1);
// Disable output buffering of status and error messages (helps debugging)
setvbuf(stdout, NULL, _IONBF, 0);
setvbuf(stderr, NULL, _IONBF, 0);
/*
* Read ideal unit cell, the "xyzinput"
*/
readXYZFile(FTA_FILE, argv[1]);
/*
* Read in atom positions.
*/
readEyeFile(FTA_FILE, argv[3]);
/*
* Read in irreducible representations.
*/
readIrrepFile(FTA_FILE,argv[2]);
// Allocate result matrix
printStatus("Allocating result matrix...\n");
irMatrix = lp_malloc(numCells,numIrreps,true);
printStatus("Generating irrep contributions...\n");
irrepDecompose(atomMatrix,atomMatrixLabels,&irMatrix,false,false,NULL);
/*
* Write result to file
*/
opfName = safe_malloc((UINT64)strlen(argv[3])+(UINT64)7);
strncpy(opfName, argv[3], strlen(argv[3])+7);
strncat(opfName, "_irrep", 7);
writeIRContribFile(opfName, irMatrix, false, false, NULL);
safe_free(opfName); opfName = NULL;
printStatus("Memory Used (excluding stack and overhead): %i MB\n", maxMemAllocated/1048576);
// Free memory
lp_free(irMatrix);
freeGlobals();
if (memAllocated > (UINT64)0)
printStatus("%i bytes of memory left unfreed.\n", memAllocated);
// Done
return 0;
}