Discussion Closed This discussion was created more than 6 months ago and has been closed. To start a new discussion with a link back to this one, click here.

Failed To Save Model. The File 'aa.Mph' Is Locked By Another Program.

Please login with a confirmed email address before reporting spam

The below post is related to an archived discussion


[start here] After the call from Matlab (when 'COMSOL with matlab' is open, and this model is also saved in workspace.), I failed to save the model, and the Eerror Message is :"Failed to save model. The file 'aa.mph' is locked by another program." Using "clear all" "clc" in Matlab is ineffective. So how to deal with this problem. Thank you !


5 Replies Last Post 2019/11/15 17:33 GMT-5
Lars Gregersen COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 5 years ago 2019/07/05 13:37 GMT-4
Updated: 5 years ago 2019/07/05 13:37 GMT-4

Hi Shawn

Usually the error message means that the file is indeed used by another program. Do you have the file open in the Comsol GUI? Do you see a file with the same name as your model, but with the extension .lock?

What operating system are you using? Where is the file stored?

Your problem can probably be fixed by opening the file in Comsol and resetting the lock.

-------------------
Lars Gregersen
Comsol Denmark
Hi Shawn Usually the error message means that the file is indeed used by another program. Do you have the file open in the Comsol GUI? Do you see a file with the same name as your model, but with the extension .lock? What operating system are you using? Where is the file stored? Your problem can probably be fixed by opening the file in Comsol and resetting the lock.

Please login with a confirmed email address before reporting spam

Posted: 5 years ago 2019/07/17 23:45 GMT-4
Updated: 5 years ago 2019/07/17 23:47 GMT-4

Hi Shawn

Usually the error message means that the file is indeed used by another program. Do you have the file open in the Comsol GUI? Do you see a file with the same name as your model, but with the extension .lock?

What operating system are you using? Where is the file stored?

Your problem can probably be fixed by opening the file in Comsol and resetting the lock.

Hi Gregersen

The file is being loaded by MATLAB with the "mphopen". At the meantime, I open this MTALAB loaded model with COMSOL GUI. Then when I make some changes in the COMSOL GUI, I found I cannot save this model since it has been locked by another program (I gauss it's MATLAB).

Because I also open this model with COMSOL GUI, there is a file with the same name as the model, and with the extension .lock.

I use Win 10.

Since it has been loaded by MATLAB and opened by COMSOL GUI, I think that's the reason why COMSOL GUI claimed the model is locked by another program (MATLAB). Do you have some solution for this kind of case? Thanks!

>Hi Shawn > >Usually the error message means that the file is indeed used by another program. Do you have the file open in the Comsol GUI? Do you see a file with the same name as your model, but with the extension .lock? > >What operating system are you using? Where is the file stored? > >Your problem can probably be fixed by opening the file in Comsol and resetting the lock. Hi Gregersen The file is being loaded by MATLAB with the "mphopen". At the meantime, I open this MTALAB loaded model with COMSOL GUI. Then when I make some changes in the COMSOL GUI, I found I cannot save this model since it has been locked by another program (I gauss it's MATLAB). Because I also open this model with COMSOL GUI, there is a file with the same name as the model, and with the extension .lock. I use Win 10. Since it has been loaded by MATLAB and opened by COMSOL GUI, I think that's the reason why COMSOL GUI claimed the model is locked by another program (MATLAB). Do you have some solution for this kind of case? Thanks!

Please login with a confirmed email address before reporting spam

Posted: 4 years ago 2019/11/14 22:21 GMT-5
Updated: 4 years ago 2019/11/14 17:21 GMT-5

Shawn,

I had the same problem as you (and still have half of the problem to solve).

I did some searching in the LiveLink for MatLab User Guide and found this function that releases the mph file from being locked by MatLab:

ModelUtil.remove('Model')

In order to get this to work in my Command Window in MatLab, I write, verbatim:

import com.comsol.model.* import com.comsol.model.util.* ModelUtil.remove('Model')

Then I am able to save the mph file in my Comsol GUI.

The second half of MY problem still exists because I don't know how to release the lock that the Comsol GUI now has on the file. So I cannot go back and forth (making a few model changes in MatLab then in the Comsol GUI, then in MatLab again, then in Comsol again, etc.) because I only know how to do the MatLab --> Comsol GUI direction. I'll post again if I figure out the second half of this puzzle.

Hope this helps you.

Alex

Shawn, I had the same problem as you (and still have half of the problem to solve). I did some searching in the LiveLink for MatLab User Guide and found this function that releases the mph file from being locked by MatLab: ModelUtil.remove('Model') In order to get this to work in my Command Window in MatLab, I write, verbatim: import com.comsol.model.* import com.comsol.model.util.* ModelUtil.remove('Model') Then I am able to save the mph file in my Comsol GUI. The second half of MY problem still exists because I don't know how to release the lock that the Comsol GUI now has on the file. So I cannot go back and forth (making a few model changes in MatLab then in the Comsol GUI, then in MatLab again, then in Comsol again, etc.) because I only know how to do the MatLab --> Comsol GUI direction. I'll post again if I figure out the second half of this puzzle. Hope this helps you. Alex

Lars Gregersen COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 4 years ago 2019/11/15 4:46 GMT-5

Hi

The solution is this: Load the model into Matlab using mphopen. Use mphlaunch to open the Comsol GUI with the same model as in Matlab. Since the model is really loaded by Comsol Multiphysics Server you can update the model settings either from Matlab or from the Comsol GUI and both programs can save the file at any time.

-------------------
Lars Gregersen
Comsol Denmark
Hi The solution is this: Load the model into Matlab using mphopen. Use mphlaunch to open the Comsol GUI with the same model as in Matlab. Since the model is really loaded by Comsol Multiphysics Server you can update the model settings either from Matlab or from the Comsol GUI and both programs can save the file at any time.

Please login with a confirmed email address before reporting spam

Posted: 4 years ago 2019/11/15 17:33 GMT-5
Updated: 4 years ago 2019/11/15 12:33 GMT-5

Thanks, Lars, that's exactly what I was looking for!

Thanks, Lars, that's exactly what I was looking for!

Note that while COMSOL employees may participate in the discussion forum, COMSOL® software users who are on-subscription should submit their questions via the Support Center for a more comprehensive response from the Technical Support team.