Please take a look at this link for detailed information about this:
Example of how to add 4d arrays into ARW by davegill · Pull Request #528 · wrf-model/WRF
Example of how to add 4d arrays into ARW by davegill · Pull Request #528 · wrf-model/WRF