La subrutina open_over se ha incluido dentro de este modulo con procesos
[ptslat.git] / ncpack_pot.f90
blob1655f4a3edecf5591044a7884fdf362846709760
1 MODULE NCPACK_POT
2 Use typeSizes
3 Use NETCDF
4 Use Dot_Geometry, ONLY : Rqd_Base,Rqd_Top,Hqd,ISHAPE
5 Use Input_Data
6 Use Auxiliar_Procedures, ONLY : MTYPE, check
7 IMPLICIT NONE
9 INTEGER,PRIVATE :: ncFileID, HdVarID, RtVarID, RbVarID, NDots_XVarID, &
10 NDots_YVarID,NDots_ZVarID, A1VarID, A2VarID, A3VarID, &
11 DWL_VarID, Dim3ID
13 CONTAINS
15 SUBROUTINE NCPACK_PT(EEL,EHHUP,EHHDW,ELHUP,ELHDW,&
16 ESOUP,ESODW,ELAST)
17 IMPLICIT NONE
19 REAL,DIMENSION(:,:,:) :: EEL,EHHUP,EHHDW,ELHUP,ELHDW,&
20 ESOUP,ESODW,ELAST
22 ! netcdf related variables
23 integer :: DimXID, DimYID, DimZID,i, &
24 DimXVarID, DimYVarID, DimZVarID,&
25 eelVarID,ehhupVarID,ehhdwVarID,elhupVarID,&
26 elhdwVarID,esoupvarID,esodwvarID,elastvarID
28 ! Local variables
29 character (len = 120) :: fileName
31 real, dimension(1:XDim,1:ZDim) :: POT_AUX
33 !-----
34 ! Initialization
35 !-----
37 fileName = POT_Filename
40 ! --------------------
41 ! Code begins
42 ! --------------------
43 if(.not. byteSizesOK()) then
44 print *, "Compiler does not appear to support required kinds of variables."
45 stop
46 end if
48 ! Create the file
50 call open_over(fileName) !Check if a file with the same name exists
52 call check(nf90_create(path = trim(fileName), cmode = nf90_clobber, ncid = ncFileID))
54 CALL NCPACK_INPUT_POT( )
56 ! Define the dimensions
57 call check(nf90_def_dim(ncid = ncFileID, name = "dimx", len = XDim, dimid = DimXID))
58 IF(KCOOR.EQ.0) &
59 call check(nf90_def_dim(ncid = ncFileID, name = "dimy", len = YDim, dimid = DimYID))
60 call check(nf90_def_dim(ncid = ncFileID, name = "dimz", len = ZDim, dimid = DimZID))
62 ! Create variables and attributes
64 ! Box sizes
67 call check(nf90_def_var(ncFileID, "dimx", nf90_float, dimids = DimXID, varID = DimXVarID) )
68 call check(nf90_put_att(ncFileID, DimXVarID, "long_name", "Radial dimension"))
69 call check(nf90_put_att(ncFileID, DimXVarID, "units", "Angstroms"))
71 IF (KCOOR.EQ.0) THEN
72 call check(nf90_def_var(ncFileID, "dimy", nf90_float, dimids = DimYID, varID = DimYVarID) )
73 call check(nf90_put_att(ncFileID, DimYVarID, "long_name", "Z dimension"))
74 call check(nf90_put_att(ncFileID, DimYVarID, "units", "Angstroms"))
75 END IF
77 call check(nf90_def_var(ncFileID, "dimz", nf90_float, dimids = DimZID, varID = DimZVarID) )
78 call check(nf90_put_att(ncFileID, DimZVarID, "long_name", "Z dimension"))
79 call check(nf90_put_att(ncFileID, DimZVarID, "units", "Angstroms"))
82 ! potential grids
83 SELECT CASE(KCOOR)
84 CASE(0)
85 call check(nf90_def_var(ncid = ncFileID, name = "EEL", xtype = nf90_float, &
86 dimids = (/ DimXID, DimYID, DimZID /), varID = eelVarID) )
87 call check(nf90_put_att(ncFileID, eelVarID, "long_name", "Electron Potential"))
89 call check(nf90_def_var(ncid = ncFileID, name = "EHHUP", xtype = nf90_float, &
90 dimids = (/ DimXID, DimYID, DimZID /), varID = ehhupVarID) )
91 call check(nf90_put_att(ncFileID, ehhupVarID, "long_name", "Heavy Hole UP Potential"))
93 call check(nf90_def_var(ncid = ncFileID, name = "EHHDW", xtype = nf90_float, &
94 dimids = (/ DimXID, DimYID, DimZID /), varID = ehhdwVarID) )
95 call check(nf90_put_att(ncFileID, ehhdwVarID, "long_name", "Heavy Hole DW Potential"))
97 call check(nf90_def_var(ncid = ncFileID, name = "ELHUP", xtype = nf90_float, &
98 dimids = (/ DimXID, DimYID, DimZID /), varID = elhupVarID) )
99 call check(nf90_put_att(ncFileID, elhupVarID, "long_name", "Light Hole UP Potential"))
101 call check(nf90_def_var(ncid = ncFileID, name = "ELHDW", xtype = nf90_float, &
102 dimids = (/ DimXID, DimYID, DimZID /), varID = elhdwVarID) )
103 call check(nf90_put_att(ncFileID, elhdwVarID, "long_name", "Light Hole DW Potential"))
105 call check(nf90_def_var(ncid = ncFileID, name = "ESOUP", xtype = nf90_float, &
106 dimids = (/ DimXID, DimYID, DimZID /), varID = esoupVarID) )
107 call check(nf90_put_att(ncFileID, esoupVarID, "long_name", "Split-off UP Potential"))
109 call check(nf90_def_var(ncid = ncFileID, name = "ESODW", xtype = nf90_float, &
110 dimids = (/ DimXID, DimYID, DimZID /), varID = esodwVarID) )
111 call check(nf90_put_att(ncFileID, esodwVarID, "long_name", "Split-off DW Potential"))
113 call check(nf90_def_var(ncid = ncFileID, name = "ELAST", xtype = nf90_float, &
114 dimids = (/ DimXID, DimYID, DimZID /), varID = elastVarID) )
115 call check(nf90_put_att(ncFileID, elastVarID, "long_name", "Strain Energy"))
116 CASE(1)
117 call check(nf90_def_var(ncid = ncFileID, name = "EEL", xtype = nf90_float, &
118 dimids = (/ DimXID, DimZID /), varID = eelVarID) )
119 call check(nf90_put_att(ncFileID, eelVarID, "long_name", "Electron Potential"))
121 call check(nf90_def_var(ncid = ncFileID, name = "EHHUP", xtype = nf90_float, &
122 dimids = (/ DimXID, DimZID /), varID = ehhupVarID) )
123 call check(nf90_put_att(ncFileID, ehhupVarID, "long_name", "Heavy Hole UP Potential"))
125 call check(nf90_def_var(ncid = ncFileID, name = "EHHDW", xtype = nf90_float, &
126 dimids = (/ DimXID, DimZID /), varID = ehhdwVarID) )
127 call check(nf90_put_att(ncFileID, ehhdwVarID, "long_name", "Heavy Hole DW Potential"))
129 call check(nf90_def_var(ncid = ncFileID, name = "ELHUP", xtype = nf90_float, &
130 dimids = (/ DimXID, DimZID /), varID = elhupVarID) )
131 call check(nf90_put_att(ncFileID, elhupVarID, "long_name", "Light Hole UP Potential"))
133 call check(nf90_def_var(ncid = ncFileID, name = "ELHDW", xtype = nf90_float, &
134 dimids = (/ DimXID, DimZID /), varID = elhdwVarID) )
135 call check(nf90_put_att(ncFileID, elhdwVarID, "long_name", "Light Hole DW Potential"))
137 call check(nf90_def_var(ncid = ncFileID, name = "ESOUP", xtype = nf90_float, &
138 dimids = (/ DimXID, DimZID /), varID = esoupVarID) )
139 call check(nf90_put_att(ncFileID, esoupVarID, "long_name", "Split-off UP Potential"))
141 call check(nf90_def_var(ncid = ncFileID, name = "ESODW", xtype = nf90_float, &
142 dimids = (/ DimXID, DimZID /), varID = esodwVarID) )
143 call check(nf90_put_att(ncFileID, esodwVarID, "long_name", "Split-off DW Potential"))
145 call check(nf90_def_var(ncid = ncFileID, name = "ELAST", xtype = nf90_float, &
146 dimids = (/ DimXID, DimZID /), varID = elastVarID) )
147 call check(nf90_put_att(ncFileID, elastVarID, "long_name", "Strain Energy"))
148 END SELECT
149 ! In the C++ interface the define a scalar variable - do we know how to do this?
150 !call check(nf90_def_var(ncFileID, "ScalarVariable", nf90_real, scalarVarID))
152 ! Leave define mode
153 call check(nf90_enddef(ncfileID))
155 ! Write the dimension variables
157 call check(nf90_put_var(ncFileID, DimXVarId, (/(X_Min+REAL(I-1)*X_Inc, i=1,XDim)/)) )
158 IF(KCOOR.EQ.0) &
159 call check(nf90_put_var(ncFileID, DimYVarId, (/(Y_Min+REAL(I-1)*Y_Inc, i=1,YDim)/)) )
160 call check(nf90_put_var(ncFileID, DimZVarId, (/(Z_Min+REAL(I-1)*Z_Inc, i=1,ZDim)/)) )
163 ! Write the Strain distributions
165 SELECT CASE(KCOOR)
166 CASE(0)
167 call check(nf90_put_var(ncFileID, eelVarID, EEL) )
168 call check(nf90_put_var(ncFileID, ehhupVarID, EHHUP) )
169 call check(nf90_put_var(ncFileID, ehhdwVarID, EHHDW) )
170 call check(nf90_put_var(ncFileID, elhupVarID, ELHUP) )
171 call check(nf90_put_var(ncFileID, elhdwVarID, ELHDW) )
172 call check(nf90_put_var(ncFileID, esoupVarID, ESOUP) )
173 call check(nf90_put_var(ncFileID, esodwVarID, ESODW) )
174 call check(nf90_put_var(ncFileID, elastVarID, ELAST) )
175 CASE(1)
176 POT_AUX=EEL(1:XDim,1,1:ZDim)
177 call check(nf90_put_var(ncFileID, eelVarID, POT_AUX) )
178 POT_AUX=EHHUP(1:XDim,1,1:ZDim)
179 call check(nf90_put_var(ncFileID, ehhupVarID, POT_AUX) )
180 POT_AUX=EHHDW(1:XDim,1,1:ZDim)
181 call check(nf90_put_var(ncFileID, ehhdwVarID, POT_AUX) )
182 POT_AUX=ELHUP(1:XDim,1,1:ZDim)
183 call check(nf90_put_var(ncFileID, elhupVarID, POT_AUX) )
184 POT_AUX=ELHDW(1:XDim,1,1:ZDim)
185 call check(nf90_put_var(ncFileID, elhdwVarID, POT_AUX) )
186 POT_AUX=ESOUP(1:XDim,1,1:ZDim)
187 call check(nf90_put_var(ncFileID, esoupVarID, POT_AUX) )
188 POT_AUX=ESODW(1:XDim,1,1:ZDim)
189 call check(nf90_put_var(ncFileID, esodwVarID, POT_AUX) )
190 POT_AUX=ELAST(1:XDim,1,1:ZDim)
191 call check(nf90_put_var(ncFileID, elastVarID, POT_AUX) )
192 END SELECT
194 call check(nf90_close(ncFileID))
196 END SUBROUTINE NCPACK_PT
198 SUBROUTINE NCPACK_INPUT_POT( )
199 IMPLICIT NONE
201 CHARACTER(LEN=200) :: stitle
203 call check(nf90_def_dim(ncid = ncFileID, name = "vector", len = 3, dimid = Dim3ID))
205 call check(nf90_def_var(ncid = ncFileID, name = "HD", xtype = nf90_float, &
206 varID = HdVarID) )
207 call check(nf90_put_att(ncFileID, HdVarID, "long_name", "Dot Height (Angstroms)"))
209 call check(nf90_def_var(ncid = ncFileID, name = "RT", xtype = nf90_float, &
210 varID = RtVarID) )
211 call check(nf90_put_att(ncFileID, RtVarID, "long_name", "Top Dot Radius (Angstroms)"))
213 call check(nf90_def_var(ncid = ncFileID, name = "RB", xtype = nf90_float, &
214 varID = RbVarID ) )
215 call check(nf90_put_att(ncFileID, RbVarID, "long_name", "Base Dot Radius (Angstroms)"))
217 call check(nf90_def_var(ncid = ncFileID, name = "ND_X", xtype = nf90_int, &
218 varID = NDots_XVarID ) )
219 call check(nf90_put_att(ncFileID, NDots_XVarID, "long_name", "Number of Dots along X-axis"))
221 call check(nf90_def_var(ncid = ncFileID, name = "ND_Y", xtype = nf90_int, &
222 varID = NDots_YVarID ) )
223 call check(nf90_put_att(ncFileID, NDots_YVarID, "long_name", "Number of Dots along Y-axis"))
225 call check(nf90_def_var(ncid = ncFileID, name = "ND_Z", xtype = nf90_int, &
226 varID = NDots_ZVarID ) )
227 call check(nf90_put_att(ncFileID, NDots_ZVarID, "long_name", "Number of Dots along Z-axis"))
229 call check(nf90_def_var(ncFileID, "A1", nf90_float, dimids = Dim3ID, varID = A1VarID) )
230 call check(nf90_put_att(ncFileID, A1VarID, "long_name", "Vector A1 Superlattice"))
231 call check(nf90_put_att(ncFileID, A1VarID, "units", "Angstroms"))
233 call check(nf90_def_var(ncFileID, "A2", nf90_float, dimids = Dim3ID, varID = A2VarID) )
234 call check(nf90_put_att(ncFileID, A2VarID, "long_name", "Vector A2 Superlattice"))
235 call check(nf90_put_att(ncFileID, A2VarID, "units", "Angstroms"))
237 call check(nf90_def_var(ncFileID, "A3", nf90_float, dimids = Dim3ID, varID = A3VarID) )
238 call check(nf90_put_att(ncFileID, A3VarID, "long_name", "Vector A3 Superlattice"))
239 call check(nf90_put_att(ncFileID, A3VarID, "units", "Angstroms"))
241 call check(nf90_def_var(ncFileID, "DWL", nf90_float, varID = DWL_VarID))
243 SELECT CASE(ISHAPE)
244 CASE(1)
245 stitle="Shape: Truncated Cone. "
246 CASE(2)
247 stitle="Shape: Cap. "
248 END SELECT
250 SELECT CASE(MTYPE)
251 CASE DEFAULT !! Anisotropic Wurtzite
252 stitle="Material Type: Anisotropic Wurtzite. "//stitle
253 END SELECT
255 ! Global attributes
256 call check(nf90_put_att(ncFileID, nf90_global, "history", &
257 "NetCDF file"))
258 stitle="Confinement Potential. "//stitle
260 call check(nf90_put_att(ncFileID, nf90_global, "title", TRIM(stitle)))
262 call check(nf90_enddef(ncfileID))
264 call check(nf90_put_var(ncFileID, RbVarId, Rqd_Base ) )
265 call check(nf90_put_var(ncFileID, RtVarId, Rqd_Top ) )
266 call check(nf90_put_var(ncFileID, HdVarId, Hqd ) )
267 call check(nf90_put_var(ncFileID, DWL_VarId, D*ZC ) )
268 call check(nf90_put_var(ncFileID, NDots_XVarId, NMax_X-NMin_X+1 ) )
269 call check(nf90_put_var(ncFileID, NDots_YVarId, NMax_Y-NMin_Y+1 ) )
270 call check(nf90_put_var(ncFileID, NDots_ZVarId, NMax_Z-NMin_Z+1 ) )
271 call check(nf90_put_var(ncFileID, A1VarId, A1_S ) )
272 call check(nf90_put_var(ncFileID, A2VarId, A2_S ) )
273 call check(nf90_put_var(ncFileID, A3VarId, A3_S ) )
276 call check(nf90_redef(ncfileID))
278 RETURN
280 END SUBROUTINE NCPACK_INPUT_POT
282 END MODULE NCPACK_POT