Skip to content

Fortran column-major in netCDF files

While writing two components grids, one written in Python and the other in Fortran, and using netCDF files in the process, it is important to keep in mind that the Fortran approach to array-like structures is column-major, while Python's default approach is row-major.

This difference can be overcome by subjecting one of the languages to the other. netCDF files stored in Fortran will be written in a column-major fashion, so in order to retrieve the data in Python and be able to process and store it with the same format and shape, we must transpose the arrays by numpy.transpose(a). An example of this approach can be found in the read_grid.py file.

Edited by rmarti1