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

write to netcdf issue

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.


New member
Hi all,

I am encountering a weird issue when using WRF to write some output to netcdf. This is custom code, not in the general WRF model, but it has been used before successfully.

When I compile the model in serial, what happens is some variables are being output to netcdf, and the netcdf file size is growing (the file size scales linearly with the length of the simulation, as expected), but the "time" dimension of the netcdf file remains zero. When I use ncdump to view the contents of the file, the only variables that drop out are lat/long and height---dimension variables. All of the other expected variables are listed, with the correct names, units, etc., but they do not appear as arrays in the file, and if I open the file for example with python and extract those variables, they are just empty arrays (not even zeros). So it's confusing that the file size is growing.

The only other clue I have is that when I compile the model in parallel instead of serial, I have gotten a runtime error for a statement of this form:
   do j = 1, dim
      allocate( sample_file%var(j)%ptr(num_samples,1,nz) )
    end do
where the sample_file structure is what gets fed into the netcdf file. This error is just before the call to the subroutine that writes to netcdf. The error reads

Fortran runtime error: Index '1' of dimension 1 of array 'sample_file%var' above upper bound of 0.

I don't get this error when running in serial. The model completes successfully, rather I just get the weird behavior described above.

Thanks for any input!
Hi Ben,
I just stumbled across this post when reviewing some others in this section, and noticed that there was never a reply for this. I apologize for the very long delay. It was certainly not intentional.

As for the problem, since you posted this so long ago, I assume that you may have gotten past the problem. If not, unfortunately we are unable to support code that has been modified, as many errors can be introduced in the code and it could take a while to track down. We don't have the resources for that. Furthermore, it seems that the problem is likely related to either your code changes, or to the netcdf library on your system. I would test this with a non-modified newest version of the WRF code (WRFV4.2.1). If it works okay with that version, then you'll know it likely has to do with some of your code modifications. If you are still seeing the problem, you will probably need to discuss the issue with a systems administrator at your institution, as they will know more about your system, environment, libraries, etc.