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). 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 (software) for each realization and extracts the data.
for nr=1:NREAL
dlmwrite(‘PERM.INC’,PERM(:,nr),’delimiter’,’\n’); % Writes the permeability file for each realization
system('mx200810.exe -f ReservoirModel_CMGBulider.dat') % Calls CMG
system('report.exe /f ReportBHP1.rwd /o ReportBHP1.rwo') % Calls Parameter file and generates output file
[TIME(:,j),BHP1(:,j)]=textread('ReportBHP1.rwo','%f\t%f','headerlines',5); % reading the time and BHP from output file generated for well 1
end
All of my software's required .exe
and .dll
files are in the same folder where I have my ReservoirModel_CMGBulider.dat
file. So I am running the .m
file through the same folder where I have all these files.
I am able to generate the output (.rwo) file. However there is an error in the simulation report of the software which is displayed in Matlab's command window as follow:
"...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"
I think its reading the .dat file only one time and then overwriting the first realization result in rest of the realizations. As a consequence of this the result of all the realizations is coming out to be same as the first realization. I need help in correcting this error.