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

Use .nc files to run MPAS

This post was from a previous version of the WRF&MPAS-A Support Forum. New replies have been disabled and if you have follow up questions related to this post, then please start a new thread from the forum home page.



I have read that it is possible to use netCDF files to replace the WPS intermediate format files when creating MPAS's and However, I have not found any information on how to do so. If this is true, can you provide any information or links that can help me to accomplish this?

Thanks as always,

In general, you'll always need to write datasets into the WPS intermediate format -- whether through the ungrib program or with your own code -- in order to allow the init_atmosphere_model program to read those datasets to produce ICs, LBCs, or surface update files. If you do have datasets in mind that aren't available in GRIB format, we could provide some guidance on how to write those data into the intermediate format, though.
That would be great! I have CESM output from 6ka time period which are currently in netCDF format (i.e., I am unsure how to begin to convert that into the necessary GRIB format.

Thanks again.
I've attached a few files that you can use as examples of how to convert fields from NetCDF files into the WPS intermediate format using Python.

Since the intermediate format consists of Fortran unformatted records, it's actually easiest to write fields from Fortran, which can be called from Python by compiling the Fortran code into a Python-callable module with f2py. You can first compile the attached "intermediate.F90" code into a Python module with f2py:

f2py -c -m WPSUtils intermediate.F90

Note that you'll probably need to use the GNU compilers (or have used the GNU compilers when installing NumPy), since there is GNU-specific code in the "intermediate.F90" file to ensure that records are written in big-endian byte order, which the WPS expects:

      open(unit=output_unit, action='write', &
#ifdef __GNUC__
           convert='big_endian', &
           file=trim(met_out_filename), status='unknown', form='unformatted', iostat=io_status)

Then, you can import the 'WPSUtils' module from your Python code to call the Fortran functions for writing intermediate files.

The attached example Python script, "", would be a good starting point for learning how to call the resulting WPSUtils module. There are comments in the "" script that explain each function call.

Once you have created some test intermediate files with the "" script, you can use the "" script as an example for converting your own NetCDF data. Because the NetCDF file format is flexible and datasets may be organized in one or more NetCDF files in various ways, you may find that you need to completely restructure the "" example, which was developed for converting ERA5 reanalysis fields on isobaric levels from NCAR's Research Data Archive.


  • intermediate.F90
    9.1 KB · Views: 83
    2.6 KB · Views: 78
    2.9 KB · Views: 82
I am planning to investigate CESM1.1 LME output from the period from 1000 CE to 1300 CE. I remember a 2015 paper written by Cindy Bruyere et al., "Bias-Corrected CMIP5 CESM Data in WRF/MAPS Intermediate File Format" (Bias-Corrected CMIP5 CESM Data in WRF/MPAS Intermediate File Format | OpenSky) that describes how to force WRF with CESM output.

I am curious to know if CESM LME output can be first averaged over a number of decades and then be used to force WRF?
cwrenn said:
I am curious to know if CESM LME output can be first averaged over a number of decades and then be used to force WRF?
It may be worth posting this question as a separate topic in the WRF section of the forum.