I have run simulations on software (named CMG) using command prompt. The command prompt works well in all respect of running the software as well as generating reports and output files. To generate an ouput file (.rwo format) containing the desired result, we have to run the executable of the report program which uses a parameter file (.rwd format). For example if I were to implement these steps in command prompt, it would be like this:
“C:\Program Files\CMG\BR\2008.10\Win32\EXE\report.exe” –f ReportBHP1.rwd –o ReportBHP1.rwo
The output file is ReportBHP1.rwo, this file will contain the variable exported.
Now to implement this in Matlab, below is a small script giving a gist of what I am trying to achieve. It call CMG for each realization and extract the data.
for nr=1:NREAL
dlmwrite(‘PERM.INC’,PERM(:,nr),’delimiter’,’\n’); % Writes the permeability file for each realization
system('"C:\Program Files\CMG\IMEX\2008.10\Win32\EXE\mx200810.exe" -f "C:\Documents and Settings\HSingh2\Desktop\Work\Model - SGEMS, CMG and MATLAB\ReservoirModel_CMGBuilder.dat"'); % calls CMG
system('"C:\Program Files\CMG\BR\2008.10\Win32\EXE\report.exe" –f "C:\Documents and Settings\HSingh2\Desktop\Work\Model - SGEMS, CMG and MATLAB\ReportBHP1.rwd" –o "C:\Documents and Settings\HSingh2\Desktop\Work\Model - SGEMS, CMG and MATLAB\ReportBHP1.rwo"'); % calls report for well 1
[TIME,BHP1]=textread(‘"C:\Documents and Settings\HSingh2\Desktop\Work\Model - SGEMS, CMG and MATLAB\ReportBHP1.rwo".rwo’,’%f\t%f’); % Reads the well data and store it in the variable BHP1 for well 1
end
So I have two problems:
1) When I run this script in Matlab, it does not generates output file ReportBHP.rwo. So consequently it gives error when it reaches the line containing 'textread' function because of absence of the file.
2) Everytime Matlab calls a report (.rwd file), it prompts me to hit enter or type 'q' to quit. If suppose there are hundreds of realizations to run, then for every realization I would be prompted to hit enter to proceed. The following line causes the prompt:
system('"C:\Program Files\CMG\BR\2008.10\Win32\EXE\report.exe" –f "C:\Documents and Settings\HSingh2\Desktop\Work\Model - SGEMS, CMG and MATLAB\ReportBHP1.rwd" –o "C:\Documents and Settings\HSingh2\Desktop\Work\Model - SGEMS, CMG and MATLAB\ReportBHP1.rwo"'); % Calls report
I will appreciate if someone can solve these issues which have have paused my work. Thank you.
OLDER EDIT: There are 2 updates to my problem as follow:
Update 1: It seems that part 2 of my problem above has been resolved by Jacob. It is working fine for one realization. However the final outcome will be confirmed only when I am able to run whole of my program which involves running hundreds of realizations of model.
Update 2: I can run the software (CMG) and generate output file (.rwo format) using command-prompt as follow:
This command makes my CMG software run:
“C:\Program Files\CMG\IMEX\2008.10\Win32\EXE\mx200810.exe” –f CMGfile.dat
This command reads the report parameter file (.rwd format) and generates output file (.rwd format):
“C:\Program Files\CMG\BR\2008.10\Win32\EXE\report.exe” –f ReportBHP.rwd –o ReportBHP.rwo
Thanks to Jacob and yuk who have been trying to resolve the problem.
LATEST EDIT:
1) I am able to run the software, avoid the prompt to hit the return key and generate the output file (.rwo format) using Matlab through the following commands:
system('report.exe /f ReportBHP1.rwd /o ReportBHP1.rwo')
system('mx200810.exe -f ReservoirModel_CMGBulider.dat')
However I was able to do it only after copying my required .exe and .dll files in the same folder where I have my .dat file. So I am running the .m file through the same folder where I have all these files.
2) However there is still one error in Matlab's command window which says this:
"...STOP: Unable to open the following file as data file:
'ReservoirModel_CMGBuilder.dat'
Check path name for spaces, special character or a total length greater than 256 characters
Cannot find data file named 'ReservoirModel_CMGBuilder.dat'
Date and Time of End of Run: .....
ans = 0"
As a consequence of this the result of my all the realizations is coming out to be same as the first realization. I need help in correcting this error.