Scheduled Downtime
On Friday 21 April 2023 @ 5pm MT, this website will be down for maintenance and expected to return online the morning of 24 April 2023 at the latest

Calling python from WRF

Freddy Paul

New member
I tried to add a python call in one of the modules of WRF. I am wondering to know where should I add
the object file of C code ( corresponding to the C program used for calling the python) while compiling the WRF.
 
I replaced one of the subroutines in module_electric_driver.F by a AI trained model (python script). I modified the
module_electric_driver.F by adding 1. Interface to the C function that calls Python and 2. call to python script.
I am wondering to know about how to proceed with the configure file and compilation of WRF model.
Also, where to add the object file of C program which act as a link between the electric driver and python script of AI
 
If you are using the make build, you should generally add it to the corresponding makefile within that directory. If you are using the CMake build, similarly add it to the corresponding CMakeLists.txt file within that directory.

You typically would add the file to respective build and expect the build system to compile the code for you, as opposed to a separate pre-compiled object file.

Once that is in place, the difficulty is coordinating data & runtime execution. I'm assuming the C code interfacing to python you have already takes care of this.
 
Thanks for the reply. I want to clarify one more thing, I have successfully compiled WRF. But, if I do ./clean or ./clean -a then compilation always shows this error: module_microphysics_driver.f90(5): error #7002: Error in opening the compiled module file. Check INCLUDE paths.
 
It is difficulty to say what the issue might be without a full log, as there might be problems earlier in the build process. Given that there are code modifications, it could be that the code you've added has caused the module to fail compilation with a series of cascading failures due to module dependencies causing the module_microphysics_driver.F file to fail as well.
 
Top