1 /**********************************************************************
2 TRAN_Deallocate_RestartFile.c:
3
4 TRAN_Deallocate_RestartFile.c is a subroutine to deallocate arrays
5 storing a lots of data of electrodes.
6
7 Log of TRAN_Deallocate_RestartFile.c:
8
9 11/Dec/2005 Released by H.Kino
10
11 ***********************************************************************/
12
13 #include <stdio.h>
14 #include <string.h>
15 #include <stdlib.h>
16 #include "mpi.h"
17 #include "tran_variables.h"
18
19
TRAN_Deallocate_RestartFile(char * position)20 void TRAN_Deallocate_RestartFile(char *position)
21 {
22 int side,spin;
23 int i, k, Mc_AN, Gc_AN, tno0, Cwan, tno1, Gh_AN,m , h_AN, Hwan;
24
25 double ScaleSize_t;
26 int SpinP_switch_t, atomnum_t, SpeciesNum_t, Max_FSNAN_t, TCpyCell_t, Matomnum_t, MatomnumF_t, MatomnumS_t;
27 int *WhatSpecies_t;
28 int *Spe_Total_CNO_t;
29 int *Spe_Total_NO_t;
30 int *FNAN_t;
31 int **natn_t;
32 int **ncn_t;
33 int **atv_ijk_t;
34 double *****OLP_t;
35 double *****H_t;
36 double ******DM_t;
37
38 double *dDen_Grid_t;
39 double *dVHart_Grid_t;
40 double **Gxyz_t;
41
42 if ( strcasecmp(position,"left")==0) {
43 side = 0;
44 } else if ( strcasecmp(position,"right")==0) {
45 side = 1;
46 }
47
48 ScaleSize_t=ScaleSize_e[side];
49 SpinP_switch_t=SpinP_switch_e[side];
50 atomnum_t=atomnum_e[side];
51 SpeciesNum_t=SpeciesNum_e[side];
52 Max_FSNAN_t=Max_FSNAN_e[side];
53 TCpyCell_t=TCpyCell_e[side];
54 Matomnum_t=Matomnum_e[side];
55 MatomnumF_t=MatomnumF_e[side];
56 MatomnumS_t=MatomnumS_e[side];
57 WhatSpecies_t=WhatSpecies_e[side];
58 Spe_Total_CNO_t=Spe_Total_CNO_e[side];
59 Spe_Total_NO_t=Spe_Total_NO_e[side];
60 FNAN_t=FNAN_e[side];
61 natn_t=natn_e[side];
62 ncn_t=ncn_e[side];
63 atv_ijk_t=atv_ijk_e[side];
64 OLP_t=OLP_e[side];
65 H_t=H_e[side];
66 DM_t=DM_e[side];
67 dDen_Grid_t=dDen_Grid_e[side];
68 dVHart_Grid_t=dVHart_Grid_e[side];
69 Gxyz_t=Gxyz_e[side];
70
71 for (i=0;i<TCpyCell_t+1;i++) {
72 free(atv_ijk_t[i]);
73 }
74 free( atv_ijk_t );
75
76 for (k=0; k<4 ; k++){
77 for (Mc_AN=1; Mc_AN<=atomnum_t; Mc_AN++){
78 if (Mc_AN==0){
79 Gc_AN = 0;
80 tno0 = 1;
81 }
82 else{
83 Gc_AN = Mc_AN;
84 Cwan = WhatSpecies_t[Gc_AN];
85 tno0 = Spe_Total_NO_t[Cwan];
86 }
87 for (h_AN=0; h_AN<=FNAN_t[Gc_AN]; h_AN++){
88
89 if (Mc_AN==0){
90 tno1 = 1;
91 }
92 else{
93 Gh_AN = natn_t[Gc_AN][h_AN];
94 Hwan = WhatSpecies_t[Gh_AN];
95 tno1 = Spe_Total_NO_t[Hwan];
96 }
97
98 for (i=0; i<tno0; i++){
99 free( OLP_t[k][Mc_AN][h_AN][i] );
100 }
101 free( OLP_t[k][Mc_AN][h_AN] );
102 }
103 free( OLP_t[k][Mc_AN] );
104 }
105 free( OLP_t[k] );
106 }
107 free( OLP_t );
108
109 for (k=0; k<=SpinP_switch_t; k++){
110 for (Mc_AN=1; Mc_AN<=atomnum_t; Mc_AN++){
111 if (Mc_AN==0){
112 Gc_AN = 0;
113 tno0 = 1;
114 }
115 else{
116 Gc_AN = Mc_AN;
117 Cwan = WhatSpecies_t[Gc_AN];
118 tno0 = Spe_Total_NO_t[Cwan];
119 }
120 for (h_AN=0; h_AN<=FNAN_t[Gc_AN]; h_AN++){
121 if (Mc_AN==0){
122 tno1 = 1;
123 }
124 else{
125 Gh_AN = natn_t[Gc_AN][h_AN];
126 Hwan = WhatSpecies_t[Gh_AN];
127 tno1 = Spe_Total_NO_t[Hwan];
128 }
129 for (i=0; i<tno0; i++){
130 free( H_t[k][Mc_AN][h_AN][i] );
131 }
132 free( H_t[k][Mc_AN][h_AN] );
133 }
134 free( H_t[k][Mc_AN] );
135 }
136 free( H_t[k] );
137 }
138 free( H_t );
139
140 for (m=0; m<1; m++){
141 for (k=0; k<=SpinP_switch_t; k++){
142 for (Mc_AN=1; Mc_AN<=atomnum_t; Mc_AN++){
143 if (Mc_AN==0){
144 Gc_AN = 0;
145 tno0 = 1;
146 }
147 else{
148 Gc_AN = Mc_AN;
149 Cwan = WhatSpecies_t[Gc_AN];
150 tno0 = Spe_Total_NO_t[Cwan];
151 }
152 for (h_AN=0; h_AN<=FNAN_t[Gc_AN]; h_AN++){
153 if (Mc_AN==0){
154 tno1 = 1;
155 }
156 else{
157 Gh_AN = natn_t[Gc_AN][h_AN];
158 Hwan = WhatSpecies_t[Gh_AN];
159 tno1 = Spe_Total_NO_t[Hwan];
160 }
161 for (i=0; i<tno0; i++){
162 free( DM_t[m][k][Mc_AN][h_AN][i] );
163 }
164 free( DM_t[m][k][Mc_AN][h_AN] );
165 }
166 free( DM_t[m][k][Mc_AN] );
167 }
168 free( DM_t[m][k] );
169 }
170 free( DM_t[m] );
171 }
172 free( DM_t );
173
174 free( dDen_Grid_t );
175
176 free( dVHart_Grid_t );
177
178 for (i=0;i<= atomnum_t; i++) {
179 free(natn_t[i]);
180 }
181 free(natn_t);
182
183 for (i=0;i<= atomnum_t; i++) {
184 free(ncn_t[i]);
185 }
186 free(ncn_t);
187
188 free(WhatSpecies_t);
189 free(Spe_Total_CNO_t);
190 free(Spe_Total_NO_t);
191 free(FNAN_t);
192
193 for (k=0; k<(atomnum_t+1); k++){
194 free(Gxyz_t[k]);
195 }
196 free(Gxyz_t);
197
198 }
199
200