Commit 9360bbfa authored by Houtan Bastani's avatar Houtan Bastani
Browse files

introduce mex write statements

parent d40e89ef
......@@ -430,10 +430,19 @@ C LOCALS
DATA T(198,6:10)/199.8400, 205.0857, 211.0344, 218.6401, 231.8292/
DATA T(199,6:10)/200.8463, 206.1051, 212.0684, 219.6922, 232.9118/
DATA T(200,6:10)/201.8526,207.1244, 213.1022, 220.7441, 233.9943/
#if defined(MEX)
CHARACTER(len=200) :: MEXPRINT
INTEGER*4 mexPrintf
INTEGER*4 mpfout
#endif
IF (V.GT.200) THEN
#ifdef __GFORTRAN__
WRITE(MEXPRINT,*) 'CHI2INV: Too many degrees of freedom'
mpfout = mexPrintf(MEXPRINT//achar(13))
#else
WRITE(*,*) 'CHI2INV: Too many degrees of freedom'
PAUSE
#endif
RETURN
ENDIF
......
......@@ -105,7 +105,9 @@ C CHEK theta
IF (NN.LE.1000) THEN
GOTO 7777
ELSE
#ifdef __GFORTRAN__
#if defined(MEX)
CALL mexErrMsgTxt('\nReduce skcriterium or use Slice sampling\nProgram aborting\n')
#elif defined(__GFORTRAN__)
WRITE(*,*) ' '
WRITE(*,*) 'Reduce skcriterium or use Slice sampling'
WRITE(*,*) 'Program aborting'
......
......@@ -105,7 +105,9 @@ C CHEK theta
IF (NN.LE.1000) THEN
GOTO 7777
ELSE
#ifdef __GFORTRAN__
#if defined(MEX)
CALL mexErrMsgTxt('\nReduce skcriterium or use Slice sampling\nProgram aborting\n')
#elif defined(__GFORTRAN__)
WRITE(*,*) ' '
WRITE(*,*) 'Reduce skcriterium or use Slice sampling'
WRITE(*,*) 'Program aborting'
......
......@@ -48,9 +48,13 @@ C LOCALS
ERRMSG = 'INPUT ERROR: '// STR2 //' is not set'
IPOS = INDEX(TRIM(STR1),STR2)
IF (IPOS.EQ.0) THEN
#if defined(MEX)
CALL mexErrMsgTxt(ERRMSG)
#else
WRITE(*,*) ERRMSG
PAUSE
STOP
#endif
ELSE
IPOS = IPOS+2
DO WHILE ((OSTR.NE.'=').AND.(OSTR.NE.'$'))
......@@ -66,9 +70,13 @@ C LOCALS
READ(STR1(IPOS:IPOS2-2),'(F20.10)') NUM
READ(STR1(IPOS:IPOS2-2),*) NUM
ELSE
#if defined(MEX)
CALL mexErrMsgTxt(ERRMSG)
#else
WRITE(*,*) ERRMSG
PAUSE
STOP
#endif
ENDIF
ENDIF
......
This diff is collapsed.
......@@ -136,6 +136,9 @@ C X-filter initialization
ENDDO
ELSE
#if defined(MEX)
CALL mexErrMsgTxt('\nERROR: d(1)=2 not implemeted yet\n')
#endif
WRITE(*,*) 'ERROR: d(1)=2 not implemeted yet'
PAUSE
STOP
......
......@@ -63,7 +63,9 @@ C CALL F02EAF('V',nx,T,nx,WR,WI,Z,nx,WORK,LWORK,IFAIL) ! F = ZTZ'
# BWORK,IFAIL)
DO I = 1,nx
IF (WI(I)**2+WR(I)**2.GE.1.D0) THEN
#ifdef __GFORTRAN__
#if defined(MEX)
CALL mexErrMsgTxt('\nLYAPUNOV SUBROUTINE: Some parameters out of\nstationary region. Check hyptheta in namelist prior.\nProgram aborting')
#elif defined(__GFORTRAN__)
WRITE(*,*) ' '
WRITE(*,*) ' LYAPUNOV SUBROUTINE: Some parameters out of '
WRITE(*,*) ' stationary region. Check hyptheta in namelist '
......
......@@ -35,6 +35,7 @@ C You should have received a copy of the GNU General Public License
C along with DMM. If not, see <http://www.gnu.org/licenses/>.
C --------------------------------------------------------------------------------------
#if defined(MEX)
#include "fintrf.h"
SUBROUTINE DMMMAIN(FILEIN)
#else
PROGRAM DMM
......@@ -76,7 +77,15 @@ C LOCALS
DOUBLE PRECISION AUX,lastl,lasth
CHARACTER*3 DLLEXT
CHARACTER*200 mfile,pathmfile
CHARACTER*200 FILEIN,NMLNAME,PATH,FILEOUT,DMMTITLE,CURDIR
CHARACTER*200 FILEIN,NMLNAME,PATH,FILEOUT,CURDIR
#ifndef __GFORTRAN__
CHARACTER*200 DMMTITLE
#endif
#if defined(MEX)
CHARACTER(len=200) :: MEXPRINT
INTEGER*4 mexPrintf
INTEGER*4 mpfout
#endif
#ifdef __GFORTRAN__
CHARACTER*16 fmt
......@@ -102,7 +111,9 @@ C GET the namelist specified by FILEIN
#endif
C CHECK FILEIN
IF (TRIM(FILEIN).EQ.'') THEN
#ifdef __GFORTRAN__
#if defined(MEX)
CALL mexErrMsgTxt('\nNo input file provided\nProgram Aborting\n')
#elif defined(__GFORTRAN__)
WRITE(*,*) ' '
WRITE(*,*) ' No input file provided'
WRITE(*,*) ' Program aborting'
......@@ -151,8 +162,7 @@ C Assign the name of the matlab file
ENDIF
C SET SHELL title
#ifdef __GFORTRAN__
#else
#ifndef __GFORTRAN__
DMMTITLE = 'title DMM input:' // TRIM(PATH) // TRIM(NMLNAME)
# // '.nml' // ' - '
CALL system(DMMTITLE)
......@@ -361,7 +371,9 @@ C SIMULATION of DATA and UNOBSERVABLES
C MAXIMUM LIKELIHOOD ESTIMATION
IF ((estimation.EQ.'ML').OR.(estimation.EQ.'ml').OR.
& (estimation.EQ.'Ml').OR.(estimation.EQ.'mL')) THEN
#ifdef __GFORTRAN__
#if defined(MEX)
CALL mexErrMsgTxt('\nMaximum Likelihood inference not allowed\nProgram aborting\n')
#elif defined(__GFORTRAN__)
WRITE(*,*) ' '
WRITE(*,*) ' Maximum Likelihood inference not allowed '
WRITE(*,*) ' Program aborting'
......@@ -769,28 +781,59 @@ C MCMC RECORDING phase
C MARGINAL LIKELIHOOD
IF ((MargLik.EQ.'Y').OR.(MargLik.EQ.'y')) THEN
#if defined(MEX)
WRITE(MEXPRINT,*) ' '
mpfout = mexPrintf(MEXPRINT//achar(13))
WRITE(MEXPRINT,*) 'Computing the marginal likelihood. Please wait ...'
mpfout = mexPrintf(MEXPRINT//achar(13))
#else
WRITE(*,*) ' '
WRITE(*,*) 'Computing the marginal likelihood. Please wait ...'
#endif
IF (nmis.GT.0) THEN
CALL HARMONIC(GGG,nobs,d,ny,nz,nx,nu,nv,ns,nstot,nt,np,
1 INFOS,yk(1:nobs,:),IYK(1:nobs,:),gibtheta,gibZ,
2 thetaprior,psiprior,pdftheta,MLHM)
#if defined(MEX)
WRITE(MEXPRINT,*) 'Modified harmonic mean: done!'
mpfout = mexPrintf(MEXPRINT//achar(13))
#else
WRITE(*,*) 'Modified harmonic mean: done!'
#endif
CALL MENGWONG(GGG,nobs,d,ny,nz,nx,nu,nv,ns,nstot,nt,np,
1 INFOS,yk(1:nobs,:),IYK(1:nobs,:),gibtheta,gibZ,
2 thetaprior,psiprior,pdftheta,MLHM(5,1),MLMW)
#if defined(MEX)
WRITE(MEXPRINT,*) 'Bridge sampling: done!'
mpfout = mexPrintf(MEXPRINT//achar(13))
WRITE(MEXPRINT,*) ' '
mpfout = mexPrintf(MEXPRINT//achar(13))
#else
WRITE(*,*) 'Bridge sampling: done!'
WRITE(*,*) ' '
#endif
ELSE
CALL HARMONIC2(GGG,nobs,d,ny,nz,nx,nu,nv,ns,nstot,nt,np,
1 INFOS,yk(1:nobs,:),gibtheta,gibZ,thetaprior,
2 psiprior,pdftheta,MLHM)
#if defined(MEX)
WRITE(MEXPRINT,*) 'Modified harmonic mean: done!'
mpfout = mexPrintf(MEXPRINT//achar(13))
#else
WRITE(*,*) 'Modified harmonic mean: done!'
#endif
CALL MENGWONG2(GGG,nobs,d,ny,nz,nx,nu,nv,ns,nstot,nt,np,
1 INFOS,yk(1:nobs,:),gibtheta,gibZ,thetaprior,
2 psiprior,pdftheta,MLHM(5,1),MLMW)
#if defined(MEX)
WRITE(MEXPRINT,*) 'Bridge sampling: done!'
mpfout = mexPrintf(MEXPRINT//achar(13))
WRITE(MEXPRINT,*) ' '
mpfout = mexPrintf(MEXPRINT//achar(13))
#else
WRITE(*,*) 'Bridge sampling: done!'
WRITE(*,*) ' '
#endif
ENDIF
WRITE(15,*) 'Modified Harmonic mean (ML and Var)'
#ifdef __GFORTRAN__
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment