44 mwpointer,
dimension(*) :: plhs
53 mwpointer,
dimension(*) :: prhs
55 mwpointer :: mxgetpr, mxcreatedoublematrix, mxgetstring
56 integer :: mxIsNumeric, mxIsChar
57 mwsize :: mxgetm, mxgetn
59 mwsize :: narg1s, narg2s
61 mwpointer :: arg1s_pr, arg2s_pr, ys_pr
62 real(kind=8),
allocatable :: Arg1s(:), Arg2s(:)
63 real(kind=8),
allocatable :: Ys(:,:,:)
64 integer,
parameter :: MAX_STR_LEN = 1024
65 character(MAX_STR_LEN) :: filePath,reactionIndexStr
66 character(EIRAM_FILE_NAME_LENGTH) :: fileName
67 character(EIRAM_TYPE_LENGTH) :: reactionType
68 character(EIRAM_INDEX_LENGTH),
allocatable :: reactionIndex(:)
70 integer :: numberOfArgs,n_reactions,reactions_length,i,j,ind
71 logical :: lPath,fileExists
75 f
call mexerrmsgtxt(
'More than three inputs required.')
78 if( mxisnumeric(prhs(1)) /= 1 )
79 f
call mexerrmsgtxt(
'Input # 1 must be a numeric array.')
80 if( mxisnumeric(prhs(2)) == 1 )
then
86 if( numberofargs == 1 )
then
88 f
call mexerrmsgtxt(
'Four or five inputs required.')
89 if(mxischar(prhs(2)) /= 1)
90 f
call mexerrmsgtxt(
'Input # 2 must be a string.')
91 if(mxischar(prhs(3)) /= 1)
92 f
call mexerrmsgtxt(
'Input # 3 must be a string.')
93 if(mxischar(prhs(4)) /= 1)
94 f
call mexerrmsgtxt(
'Input # 4 must be a string.')
96 if(mxischar(prhs(5)) /= 1)
97 f
call mexerrmsgtxt(
'Input # 5 must be a string.')
104 if( numberofargs == 2 )
then
105 if (nrhs > 6 .or. nrhs < 5)
106 f
call mexerrmsgtxt(
'Five or six inputs required.')
107 if(mxischar(prhs(3)) /= 1)
108 f
call mexerrmsgtxt(
'Input # 3 must be a string.')
109 if(mxischar(prhs(4)) /= 1)
110 f
call mexerrmsgtxt(
'Input # 4 must be a string.')
111 if(mxischar(prhs(5)) /= 1)
112 f
call mexerrmsgtxt(
'Input # 5 must be a string.')
114 if(mxischar(prhs(6)) /= 1)
115 f
call mexerrmsgtxt(
'Input # 6 must be a string.')
122 narg1s = mxgetn(prhs(1))
123 if(mxgetm(prhs(1)) /= 1)
then
124 call mexerrmsgtxt(
'Input #1 must be a row vector.')
127 arg1s_pr = mxgetpr(prhs(1))
128 if(numberofargs == 2)
then
129 arg2s_pr = mxgetpr(prhs(2))
130 narg2s = mxgetn(prhs(2))
131 if(mxgetm(prhs(2)) /= 1)
then
132 call mexerrmsgtxt(
'Input #2 must be a row vector.')
138 n_reactions = mxgetm(prhs(numberofargs+3))
139 reactions_length = mxgetn(prhs(numberofargs+3))
141 allocate(reactionindex(n_reactions))
143 err=mxgetstring(prhs(numberofargs+1),filename,
145 err=mxgetstring(prhs(numberofargs+2),
147 err=mxgetstring(prhs(numberofargs+3),
148 , reactionindexstr,max_str_len)
150 err=mxgetstring(prhs(numberofargs+4),filepath, max_str_len)
156 do i = 1, n_reactions
158 ind = (j-1)*n_reactions+i
159 reactionindex(i)(j:j) = reactionindexstr(ind:ind)
164 allocate(arg1s(narg1s))
165 call mxcopyptrtoreal8(arg1s_pr, arg1s, narg1s)
167 allocate(arg2s(narg2s))
168 call mxcopyptrtoreal8(arg2s_pr, arg2s, narg2s)
178 call mexerrmsgtxt(
'Input file '//trim(filepath)
179 / //trim(filename)//
' is not found.')
181 call mexerrmsgtxt(
'Cannot read input file '
182 / //trim(filepath)//trim(filename))
184 call mexerrmsgtxt(
"error during initialization of EIRAM")
189 allocate(ys(narg2s,narg1s,n_reactions))
191 allocate(ys(narg1s,1,n_reactions))
197 & filename,reactiontype,reactionindex(i),err)
200 & filename,reactiontype,reactionindex(i),err)
205 call mexerrmsgtxt(
"error : negative argument")
207 call mexerrmsgtxt(
"error : negative 1st argument")
209 call mexerrmsgtxt(
"error : negative 2nd argument")
211 call mexerrmsgtxt(
"error: requested reaction "
212 / //trim(filename)//
" "//trim(reactiontype)//
" "
213 / //trim(reactionindex(i))//
" is not found")
215 call mexerrmsgtxt(
"error: double fit is requested for reaction"
216 / //
" described by a single fit")
218 call mexerrmsgtxt(
"error: single fit is requested for reaction"
219 / //
" described by a double fit")
221 if(err/=0)
call mexerrmsgtxt(
"error in EIRAM")
227 plhs(i) = mxcreatedoublematrix(narg2s,narg1s,0)
229 plhs(i) = mxcreatedoublematrix(narg1s,1,0)
231 ys_pr = mxgetpr(plhs(i))
232 call mxcopyreal8toptr(ys(:,:,i), ys_pr, max(1,narg2s)*narg1s)
237 deallocate(reactionindex)
239 if(
allocated(arg2s))
deallocate(arg2s)
integer, public eiram_unit
Unit to which messages are written.
integer, parameter, public eiram_index_length
Length of the string with reaction index.
subroutine, public eiram_load(filePath, fileName, err)
Initialization of the module from input files (data sets)
subroutine, public eiram_deallocate(err)
Deallocate dynamic arrays used by this module.
integer, parameter, public eiram_file_name_length
Length of the string with a name of an input file.
integer, parameter, public eiram_type_length
Length of the string with reactiontype.
subroutine mexfunction(nlhs, plhs, nrhs, prhs)
Matlab interface for EIRAM.
subroutine eiram_matlab_calc2(Y, X1, X2, M, N, fileName, reactionType, reactionIndex, err)
Binding for eiram_calc2 which has to be called from Matlab/Octave interface.
subroutine eiram_matlab_calc1(Y, X, N, fileName, reactionType, reactionIndex, err)
Binding for eiram_calc1 which has to be called from Matlab/Octave interface.