Dear Dr. Jim and Steve,
Thank you very much for your kindly reply.
Now the problem is that my original code works under Visual Studio 2019+Intel Fortran 2020 but doesn't work under Visual Studio 2022+IntelAPI 2022. Is it a Fortran syntax error that Intel Fortran 2011-2020 all works?
On the other hand, the code Dr. Jim modified also doesn't work.
Any postings of suggested solutions, lacking simple reproducer, are to be treated as hints as to the solution you should take. Meaning, the working solution may require a little rework on your part.
The suggestion I made outlined how you might structure your interface such that you would not need to decorate the many CALL's to your C++ code in your program.
By the way. I do not have a PhD in computer science. In fact, I've never taken a computer science course (or programming class). In college (1967-1971) I self-learned programming, became a teaching assistant for computer science classes, and also taught computer programming at a local high school. Because I was, to some extent, teaching the CS classes, the college wouldn't let me take the classes. Hence, I do not have a computer science degree. In 1972 I began working at Digital Equipment Corporation as a software support engineer. In 1974 I left to join a different company and wrote my first operating system, a multi-user virtual memory system. In 1976 I left there to form my first computer software/hardware company and wrote another much improved multi-user operating system. And between then and now I formed a small handful of computer software/consulting companies. You can call me Jim (without the Dr.)