47 mwpointer,
dimension(*) :: plhs
55 mwpointer,
dimension(*) :: prhs
57 mwpointer :: mxgetpr, mxcreatedoublematrix, mxgetstring
58 integer :: mxIsNumeric, mxIsChar
59 mwsize :: mxgetm, mxgetn
61 mwsize :: n_e0s, n_projs, n_targs, n_combinations
62 integer :: err, i, p, t, c, ind
63 mwpointer :: e0s_pr, ys_pr
64 real(kind=8),
dimension(:),
allocatable :: E0s
65 real(kind=8),
dimension(:),
allocatable :: Ys
66 integer,
parameter :: MAX_STR_LEN = 255
67 character(MAX_STR_LEN) :: projsstr, targsstr
68 character(MAX_STR_LEN),
dimension(:),
allocatable :: projs, targs
69 mwsize :: projs_length, targs_length
70 character(MAX_STR_LEN) :: version, fileN
76 call mexerrmsgtxt(
'5 arguments required.')
77 elseif (mxisnumeric(prhs(1)) /= 1)
then
78 call mexerrmsgtxt(
'Input # 1 is not a numeric array.')
79 elseif(mxischar(prhs(2)) /= 1)
then
80 call mexerrmsgtxt(
'Input # 2 must be a string.')
81 elseif(mxischar(prhs(3)) /= 1)
then
82 call mexerrmsgtxt(
'Input # 3 must be a string.')
83 elseif(mxischar(prhs(4)) /= 1)
then
84 call mexerrmsgtxt(
'Input # 4 must be a string.')
85 elseif(mxischar(prhs(5)) /= 1)
then
86 call mexerrmsgtxt(
'Input # 5 must be a string.')
89 n_e0s = mxgetn(prhs(1))
90 if(mxgetm(prhs(1)) /= 1)
then
91 call mexerrmsgtxt(
'Input #1 must be a row vector.')
94 n_projs = mxgetm(prhs(2))
95 projs_length = mxgetn(prhs(2))
96 n_targs = mxgetm(prhs(3))
97 targs_length = mxgetn(prhs(3))
99 n_combinations = max(n_projs, n_targs)
101 allocate(projs(n_combinations))
102 allocate(targs(n_combinations))
104 e0s_pr = mxgetpr(prhs(1))
108 err = mxgetstring(prhs(2), projsstr, max_str_len)
110 foreachprojectile:
do p = 1, n_projs
111 foreachchar:
do c = 1, projs_length
112 ind = (c-1)*n_projs+p
113 projs(p)(c:c) = projsstr(ind:ind)
115 end do foreachprojectile
116 projs(n_projs:n_combinations) = projs(n_projs)
118 err = mxgetstring(prhs(3), targsstr, max_str_len)
120 foreachtarget:
do t = 1, n_targs
121 foreachchar2:
do c = 1, targs_length
122 ind = (c-1)*n_targs+t
123 targs(t)(c:c) = targsstr(ind:ind)
126 targs(n_targs:n_combinations) = targs(n_targs)
128 err = mxgetstring(prhs(4), version, max_str_len)
129 err = mxgetstring(prhs(5), filen, max_str_len)
133 call mxcopyptrtoreal8(e0s_pr, e0s, n_e0s)
138 inquire(file=filen,exist=ifexist,iostat=io)
139 if (.not.ifexist.or.io.ne.0)
140 f
call mexerrmsgtxt(
'File not found: '//trim(filen))
142 if(version ==
"1993")
then
144 else if(version ==
"2001")
then
147 call mexerrmsgtxt(
'unknown model: '//trim(version))
152 call mexerrmsgtxt(
'initialization error in ESPUTR')
155 foreachcombination:
do c=1, n_combinations
156 call esputr_yn(e0s, n_e0s, projs(c), targs(c), version,
160 call mexerrmsgtxt(
'projectile '//trim(projs(c))//
162 else if(err == 102)
then
163 call mexerrmsgtxt(
'target '//trim(targs(c))//
165 else if(err == 151)
then
166 call mexerrmsgtxt(
'projectile-target combination '//
167 & trim(projs(c))//
'-'//trim(targs(c))//
' not found')
169 call mexerrmsgtxt(
'error in ESPUTR')
174 plhs(c) = mxcreatedoublematrix(1,n_e0s,0)
175 ys_pr = mxgetpr(plhs(c))
176 call mxcopyreal8toptr(ys,ys_pr,n_e0s)
177 end do foreachcombination
subroutine, public esputr1993_deallocate(err)
Deallocate dynamic arrays used by the module ESPUTR1993.
subroutine mexfunction(nlhs, plhs, nrhs, prhs)
Matlab interface for calculation of sputtering yield for normal incidence.
subroutine, public esputr2001_initn(fileNName, err)
subroutine, public esputr1993_init(constantsFile, err)
Initialization of the 1993-model.
subroutine, public esputr2001_deallocate(err)
Deallocate dynamic arrays used by this module.
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, save, public esputr_unit
Index of the unit for standard output, default value 6.