Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Can not open a xml with QFile in a MPI environment
Forum Updated to NodeBB v4.3 + New Features

Can not open a xml with QFile in a MPI environment

Scheduled Pinned Locked Moved Unsolved General and Desktop
14 Posts 3 Posters 1.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • JoeCFDJ Offline
    JoeCFDJ Offline
    JoeCFD
    wrote on last edited by
    #1

    I made a xml file as input file for fortran MPI app. Since fortran does not have a parser for xml file, I made a C interface for my fortran code to load the XML file. The interface works fine for node number is 1. If I increase the node number to more than one, the QFile can not open the XML file any more. It fails at QFile file(file_name); file.open() returns false; Any comments? Thanks.

    1 Reply Last reply
    0
    • JoeCFDJ Offline
      JoeCFDJ Offline
      JoeCFD
      wrote on last edited by
      #2

      The problem is gone when I recompiled the code. It is odd.

      1 Reply Last reply
      0
      • JoeCFDJ Offline
        JoeCFDJ Offline
        JoeCFD
        wrote on last edited by JoeCFD
        #3

        I compiled the code a few more times. The problem comes back. The file does exist since my MPI code runs fine with one node option. It is so weird.
        The error message is no such file or directory and
        QFileDevice error code is 5

        JonBJ 1 Reply Last reply
        0
        • JoeCFDJ JoeCFD

          I compiled the code a few more times. The problem comes back. The file does exist since my MPI code runs fine with one node option. It is so weird.
          The error message is no such file or directory and
          QFileDevice error code is 5

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #4

          @JoeCFD
          It is simply impossible for QFile file(file_name); file.open(); to "fail" depending on what the content of the file is or is not.

          Who knows what is inside your C code? Look through it. Just maybe you leave the file open and that prevents a second open in your environment, I don't know.

          JoeCFDJ 1 Reply Last reply
          1
          • JonBJ JonB

            @JoeCFD
            It is simply impossible for QFile file(file_name); file.open(); to "fail" depending on what the content of the file is or is not.

            Who knows what is inside your C code? Look through it. Just maybe you leave the file open and that prevents a second open in your environment, I don't know.

            JoeCFDJ Offline
            JoeCFDJ Offline
            JoeCFD
            wrote on last edited by JoeCFD
            #5

            @JonB Thanks for your reply. If I run the same code with one node mpirun -np 1 myapp, it runs immediately without any problem. If I execute it with mpirun -np 2 myapp, it fails right away becuase of the error above. And the C interface is called only in node 1. The code worked before sometimes, but not all the times.

            JonBJ 1 Reply Last reply
            0
            • JoeCFDJ JoeCFD

              @JonB Thanks for your reply. If I run the same code with one node mpirun -np 1 myapp, it runs immediately without any problem. If I execute it with mpirun -np 2 myapp, it fails right away becuase of the error above. And the C interface is called only in node 1. The code worked before sometimes, but not all the times.

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by
              #6

              @JoeCFD
              Only you know whatever it is your code does. The code hasn't even got as far as doing any XML stuff when you go file.open().

              JoeCFDJ 1 Reply Last reply
              0
              • JonBJ JonB

                @JoeCFD
                Only you know whatever it is your code does. The code hasn't even got as far as doing any XML stuff when you go file.open().

                JoeCFDJ Offline
                JoeCFDJ Offline
                JoeCFD
                wrote on last edited by
                #7

                @JonB right. I just rebooted my computer. My code works fine with 3 nodes. I am testing the code and stop it often. Is it possible that MPI resources are not cleaned up completely?

                jsulmJ 1 Reply Last reply
                0
                • JoeCFDJ JoeCFD

                  @JonB right. I just rebooted my computer. My code works fine with 3 nodes. I am testing the code and stop it often. Is it possible that MPI resources are not cleaned up completely?

                  jsulmJ Offline
                  jsulmJ Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on last edited by jsulm
                  #8

                  @JoeCFD QFile really doesn't care what is inside your file, whether it is XML and has one or two nodes, or whether it is something else. If it can't open the file, then most obvious reasons are: wrong path and missing access rights.
                  What could be the problem here

                  QFile file(file_name); 
                  

                  Does file_name contain only file name or absolute path to the file?
                  If it is only the file name then QFile will try to open this file from the current working directory. And if it is not there then it will fail.

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • JoeCFDJ Offline
                    JoeCFDJ Offline
                    JoeCFD
                    wrote on last edited by JoeCFD
                    #9

                    The input file is same for one node or two nodes run. I do not change the path and file name of the input file(file_name). If I type mpurun -np 1 myapp, my code runs fine. If I type mpirun -np 2 myapp on the same terminal, the input file can not be found. Nothig has been changed here. I tried both with and without absolute path.

                    jsulmJ 1 Reply Last reply
                    0
                    • JoeCFDJ JoeCFD

                      The input file is same for one node or two nodes run. I do not change the path and file name of the input file(file_name). If I type mpurun -np 1 myapp, my code runs fine. If I type mpirun -np 2 myapp on the same terminal, the input file can not be found. Nothig has been changed here. I tried both with and without absolute path.

                      jsulmJ Offline
                      jsulmJ Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      @JoeCFD then it is something in your app...
                      Just debug

                      https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      0
                      • JoeCFDJ Offline
                        JoeCFDJ Offline
                        JoeCFD
                        wrote on last edited by
                        #11

                        agree. But the bug is odd.

                        1 Reply Last reply
                        0
                        • JoeCFDJ Offline
                          JoeCFDJ Offline
                          JoeCFD
                          wrote on last edited by JoeCFD
                          #12

                          The problem is solved after Qt plugin/platforms is copied to the dir of myapp. Some other people could hit this problem in the future. When Qt code has some weird behavior, try this copy

                          jsulmJ 1 Reply Last reply
                          0
                          • JoeCFDJ JoeCFD

                            The problem is solved after Qt plugin/platforms is copied to the dir of myapp. Some other people could hit this problem in the future. When Qt code has some weird behavior, try this copy

                            jsulmJ Offline
                            jsulmJ Offline
                            jsulm
                            Lifetime Qt Champion
                            wrote on last edited by
                            #13

                            @JoeCFD Yes, if you want to use your app outside of QtCreator you need to deploy it.
                            Take a look at http://doc.qt.io/qt-5/deployment.html

                            https://forum.qt.io/topic/113070/qt-code-of-conduct

                            1 Reply Last reply
                            1
                            • JoeCFDJ Offline
                              JoeCFDJ Offline
                              JoeCFD
                              wrote on last edited by JoeCFD
                              #14

                              Sorry I have to reopen this case. Copy platforms to the dir of myapp does help a bit. However,the problem comes back after I tested my code for some time on any computer. I tried to compile the Qt code with mpicxx and it does not help either. I use QProcess from GUI to launch MPI myapp.

                              1 Reply Last reply
                              0

                              • Login

                              • Login or register to search.
                              • First post
                                Last post
                              0
                              • Categories
                              • Recent
                              • Tags
                              • Popular
                              • Users
                              • Groups
                              • Search
                              • Get Qt Extensions
                              • Unsolved