86 type(dict_struct),
pointer :: dict => null()
88 character(*),
parameter :: HEADER =
"Content-type: text/csv; charset=utf-8"//char(10)//&
89 "Content-Disposition: attachment; filename=data.csv"//char(10)
91 integer,
parameter :: MAX_POINTS = 1000000
93 integer,
parameter :: MAX_PARAM_LENGTH = 20
94 integer,
parameter :: TMP_UNIT = 142
95 character(DICT_VALUE_LENGTH) :: input =
""
96 character(MAX_PARAM_LENGTH),
dimension(:),
allocatable :: inputs
97 character(MAX_PARAM_LENGTH),
dimension(:),
allocatable :: projs
99 character(MAX_PARAM_LENGTH),
dimension(:),
allocatable :: targs
101 character(MAX_PARAM_LENGTH),
dimension(:),
allocatable :: versions
102 integer :: n_versions = 0
103 integer :: n_combinations
104 integer :: err, i, c, p, t, v, th, e
105 real(kind=ESPUTR_DP) :: E0min = 10.
106 real(kind=ESPUTR_DP) :: E0max = 10000.
107 integer :: n_E0s = 1001
108 real(kind=ESPUTR_DP) :: deltaE0 = 10.
109 real(kind=ESPUTR_DP) :: thMin = 0
110 real(kind=ESPUTR_DP) :: thMax = 1.57
112 real(kind=ESPUTR_DP) :: deltaTh = .1
113 real(kind=ESPUTR_DP),
dimension(:),
allocatable :: E0s
114 real(kind=ESPUTR_DP),
dimension(:),
allocatable :: Ths
115 real(kind=ESPUTR_DP),
dimension(:,:),
allocatable :: Ys
116 real(kind=ESPUTR_DP) :: epsfilter=0.
119 character(MAX_PARAM_LENGTH) :: ver
121 intrinsic floor,transfer,count,max,index
123 open(tmp_unit, iostat=err, status=
'scratch', action=
'readwrite')
126 call get_environment_variable(
"QUERY_STRING", input)
127 if(index(input,
'=') == 0)
then
134 call cgi_get(dict,
"projectiles", input)
135 if(input ==
"")
call cgi_error(
"esputr_cgi: no projectiles provided")
136 call split(input, projs)
137 n_projs =
size(projs)
140 call cgi_get(dict,
"targets", input)
141 if(input ==
"")
call cgi_error(
"esputr_cgi: no targets provided")
142 call split(input, targs)
143 n_targs =
size(targs)
145 if ( dict_has_key( dict,
"thdelta" ) .or. &
146 dict_has_key( dict,
"thmin" ) .or. &
147 dict_has_key( dict,
"thmax" ) )
then
148 call cgi_get(dict,
"thdelta", deltath)
149 if(deltath < .001) deltath = .001d0
150 call cgi_get(dict,
"thmin", thmin)
151 if(thmin < 0) thmin = 0
152 if(thmin > 1.57079d0) thmin = 1.57079d0
153 call cgi_get(dict,
"thmax", thmax)
154 if(thmax > 1.57079d0) thmax = 1.57079d0
155 if(thmax < thmin) thmax = thmin + deltath
156 n_ths = floor((thmax-thmin) / deltath + 1.)
157 if(thmin >= 41) n_ths = 0
163 call cgi_get(dict,
"versions", input)
164 if(input ==
"")
call cgi_error(
"esputr_cgi: the models are not specified")
165 call split(input, versions)
166 n_versions =
size(versions)
168 call cgi_get(dict,
"edelta", deltae0)
169 if(deltae0 < 0.) deltae0 = 0.
170 call cgi_get(dict,
"emin", e0min)
171 if(e0min < 0.) e0min = 0.
172 call cgi_get(dict,
"emax", e0max)
173 if(e0max < e0min) e0max = e0min + deltae0
174 call cgi_get(dict,
"epsfilter", epsfilter)
176 call cgi_get(dict,
"e0s", input)
178 call split(input, inputs)
183 n_e0s = floor( (e0max-e0min) / deltae0 + 1. )
187 allocate(e0s(n_e0s), stat=err)
188 if(err /= 0)
call cgi_error(
"esputr_cgi: memory allocation eror")
190 deltae0 = (e0max-e0min)/(n_e0s-1)
193 e0s(i)=e0s(i-1)+deltae0
201 if(n_e0s*max(n_projs, n_targs, n_versions)*max(1, n_ths) > max_points) &
202 call cgi_error(
"esputr_cgi: too many data points are requested")
204 allocate(ths(n_ths), stat=err)
205 if(err /= 0)
call cgi_error(
"esputr_cgi: memory allocation eror")
206 ths = (/ (i*deltath+thmin, i = 0, n_ths-1) /)
211 n_combinations = max(n_projs, n_targs, n_versions)
212 allocate(ys(n_combinations,n_e0s), stat=err)
213 if(err /= 0)
call cgi_error(
"esputr_cgi: allocation error")
215 foreachcombi:
do c = 1, n_combinations
218 v = min(n_versions, c)
220 if (index(ver,
'2007')>0) ver=
'2001'
221 call esputr_yn(e0s, n_e0s, projs(p), targs(t), ver, ys(c,:), err)
222 if(err /= 0)
call cgi_error(
"esputr_cgi: error while calculating the sputtering yield, check your input"&
226 write(unit,
'(A)') header
228 write(unit,
'(A)', advance=
'no')
"Energy [eV]"
229 foreachcombi1:
do c = 1, n_combinations
232 v = min(n_versions, c)
233 write(unit,
'(6A)', advance=
'no')
", Y_",trim(projs(p)),
"_on_",trim(targs(t)),
"_",trim(versions(v))
240 if(epsfilter>0.)
then
241 if (i>1.and.i<n_e0s)
then
243 do c = 1, n_combinations
244 if( abs(ys(c,i)-ys(c,ilast) ) > &
245 0.5*epsfilter*( abs(ys(c,i))+abs(ys(c,ilast)) ) )
then
257 write(unit,
'(E12.5)', advance=
'no') e0s(i)
258 foreachcombi2:
do c = 1, n_combinations
259 write(unit,
'(A,E12.5)', advance=
'no')
",",ys(c,i)
264 n_combinations = max(n_projs, n_targs, n_versions, n_e0s)
265 allocate(ys(n_combinations,n_ths), stat=err)
266 if(err /= 0)
call cgi_error(
"esputr_cgi: allocation error")
267 foreachcombith:
do c = 1, n_combinations
270 v = min(n_versions, c)
273 if (index(ver,
'2007')>0) ver=
'2001'
274 call esputr_yth(ths, n_ths, (/e0s(e)/), 1, projs(p), targs(t), ver, ys(c,:), err)
275 if(err /= 0)
call cgi_error(
"esputr_cgi: error while calculating the angular factor, check your input"//&
277 end do foreachcombith
279 write(unit,
'(A)') header
281 write(unit,
'(A)', advance=
'no')
"theta [radian]"
282 foreachcombith1:
do c = 1, n_combinations
285 v = min(n_versions, c)
287 if (index(versions(v),
'1993') > 0)
then
288 write(unit,
'(1A)', advance=
'no')
', Y(theta)/Y(0)_1993'
290 write(unit,
'(5A,E12.5,2A)', advance=
'no')
", Y(theta)/Y(0)_",trim(projs(p)),
"_on_",&
291 trim(targs(t)),
"_E=_",e0s(e),
"_eV_",trim(versions(v))
293 end do foreachcombith1
296 write(unit,
'(E12.5)', advance=
'no') ths(th)
297 foreachcombith2:
do c = 1, n_combinations
298 write(unit,
'(A,E12.5)', advance=
'no')
",",ys(c, th)
299 end do foreachcombith2
306 deallocate(e0s, ys, projs, targs, versions, ths)
313 subroutine split(csvString, array)
314 character(DICT_VALUE_LENGTH),
intent(in) :: csvString
315 character(MAX_PARAM_LENGTH),
dimension(:),
allocatable,
intent(inout) :: array
318 allocate(array(ncommas + 1))
319 read(csvstring, *) array(1:ncommas+1)
323 subroutine toreal8(strArr, realArr)
324 character(MAX_PARAM_LENGTH),
dimension(:),
intent(in) :: strArr
325 real(kind=8),
dimension(:),
allocatable,
intent(inout) :: realArr
327 allocate(realarr(
size(strarr)))
328 do i = 1,
size(strarr)
329 read(strarr(i), *, iostat=err) realarr(i)
330 if(err/=0)
call cgi_error(
"esputr_cgi: invalid real value")
336 character(ESPUTR2001_MAX_NAME_LENGTH),
dimension(:,:),
allocatable :: combinations_2001_N
337 character(ESPUTR2001_MAX_NAME_LENGTH*2),
dimension(:,:),
allocatable :: combinations_2001_TH
339 character(ESPUTR1993_FIRST_COL_WIDTH),
dimension(:,:),
allocatable :: combinations_1993
341 character(*),
parameter :: JSON_HEADER =
"Content-type: application/json; charset=utf-8"//char(10)//&
342 "Content-Disposition: attachment; filename=combinations.json"//char(10)
349 if(err /= 0)
call cgi_error(
"esputr_cgi: error retreiving data")
351 if(err /= 0)
call cgi_error(
"esputr_cgi: error retreiving data")
353 if(err /= 0)
call cgi_error(
"esputr_cgi: error retreiving data")
355 write(unit,
'(A)') json_header
373 character(*),
intent(in) :: name
374 character(*),
dimension(:,:),
intent(in) :: arr
375 integer :: i, iMax, err, indLo, indUp, pid, tid, ptid
376 real(kind=ESPUTR_DP) :: eMin, eMax, e_Th
377 write(unit,
'(3A)')
'"', name,
'": ['
380 write(unit,
'(A)', advance=
'no')
'{'
381 write(unit,
'(3A)', advance=
'no')
'"projectile":"', trim(arr(i, 1)),
'",'
382 write(unit,
'(3A)', advance=
'no')
'"target":"', trim(arr(i, 2)),
'"'
383 if(index(name,
"TH") > 0)
then
385 if(err /= 0)
call cgi_error(
"esputr_cgi: error while retrieving ids")
387 if(err /= 0)
call cgi_error(
"esputr_cgi: error while retrieving energy information")
388 write(unit,
'(A,E12.5,A,E12.5,A)', advance=
'no')
',"energyRange":[',emin,
',',emax,
']'
390 if(index(name,
"1993") > 0)
then
392 if(err /= 0)
call cgi_error(
"esputr_cgi: error while retrieving projectile id")
394 if(err /= 0)
call cgi_error(
"esputr_cgi: error while retrieving target id")
396 if(err /= 0)
call cgi_error(
"esputr_cgi: error while retrieving E_th")
399 if(err /= 0)
call cgi_error(
"esputr_cgi: error while retrieving projectile-target id")
401 if(err /= 0)
call cgi_error(
"esputr_cgi: error while retrieving E_th")
403 write(unit,
'(A,E12.5)', advance=
'no')
',"E_th":',e_th
405 write(unit,
'(A)', advance=
'no')
'}'
406 if(i < imax)
write(unit,
'(A)')
','
414 if(err /= 0)
call cgi_error(
"esputr_cgi: initialization error")
415 call esputr2001_init(
"../data/ECKSTEIN2007N",
"../data/ECKSTEIN2007TH", err)
416 if(err /= 0)
call cgi_error(
"esputr_cgi: initialization error")
422 backspace(tmp_unit, iostat=err)
423 backspace(tmp_unit, iostat=err)
subroutine initesputr()
Initialize all types of models.
integer function, public esputr1993_getprojectileid(proj, err)
Return ID of the projectile for the 1993-model.
subroutine cgi_error(msg, template)
subroutine, public esputr1993_deallocate(err)
Deallocate dynamic arrays used by the module ESPUTR1993.
subroutine toreal8(strArr, realArr)
Convert array of strings into array of reals.
integer, parameter output_no_header
subroutine, public esputr2001_getavailableenergyrange(projTargStartId, projTargEndId, Emin, Emax, err)
Get the minimum and maximum energies for which the angular dependency factor is defined.
subroutine, public esputr1993_init(constantsFile, err)
Initialization of the 1993-model.
subroutine split(csvString, array)
Split one line into individual strings for each comma separated substring.
character(dict_value_length *2) function getlastmessage()
Read two last lines printed in the output unit.
subroutine, public esputr2001_deallocate(err)
Deallocate dynamic arrays used by this module.
subroutine writejsonarray(name, arr)
Write the list of the projectile-target combinations in JSON (JavaScript Object Notation) format...
integer function, public esputr2001_getprojectiletargetidn(proj, targ, err)
Return ID for a projectile-target combination for 2001-model for normal incidence.
subroutine, public esputr2001_availablecombinationsth(combinations, err)
Return the list of available projectile-target combinations for angular dependence.
subroutine esputr_yth(THs, n_THs, E0s, n_E0s, proj, targ, version, YTHs, err)
Calculate the angular dependence factor Y(E,theta)/Y(E,0) for selected incident angles and energies f...
subroutine esputr_yn(E0s, n_E0s, proj, targ, version, YNs, err)
Calculate sputtering yield for normal incidence for selected incident energies and the specified proj...
integer function, public esputr1993_gettargetid(targ, err)
Return ID of the target for the 1993-model.
real(esputr_dp) function, public esputr2001_eth(projectileTarget_id, err)
Return the threshold energy E_th for the given projectile-target combination.
subroutine, public esputr1993_availablecombinations(combinations, err)
Return the list of available projectile-target combinations.
subroutine cgi_begin(html, dict, luout)
subroutine sendavailablecombinations()
Send the list of available target-projectile combinations to the server.
subroutine, public esputr2001_getprojectiletargetidsth(proj, targ, thLower, thUpper, err)
Return two IDs for a projectile-target combination for 2001-model for angular dependence.
subroutine, public esputr2001_init(fileNName, fileThName, err)
Initialization of the 2001-model.
subroutine, public esputr2001_availablecombinationsn(combinations, err)
Return the list of available projectile-target combinations for normal incidence. ...
integer, save, public esputr_unit
Index of the unit for standard output, default value 6.
real(esputr_dp) function, public esputr1993_eth(proj_id, targ_id, err)
Return threshold energy for the given projectile-target combination.
integer, parameter dict_value_length