Hi Somnath Baidya Roy, > I am trying to read 2m temperature from MERRA. The data is 3d: nlat = > 21, nlon=17, time=24 corresponding to a 24 hr timeseries over a small > domain in Central Asia. > > I have used the pres_temp_4D_rd.f90 as a template to read the data. My > fortran code is test_4D_rd.f90. I am using Intel 11.0 compilers. I am > comparing the output from the write statement in line 99 of the Fortran > code with the output from ncdump -f. > > The outputs match for the first timestep but start diverging from the > second timestep. Please compare line 367 of StdoutFromFortan.out with > line 456 of DumpFromNcdump.out. this line corresponds to the first > read value at time = 2. All values prior to this line are identical > between the 2 files. However values starting from this line and beyond > are different. At the end of the file the difference is several degrees > Celsius. Please help me find the error. The error was treating a 3D array on disk as if it were a 4D array. When you call the nf90_get_var function, it "knows" the disk array is only 3-dimensional, so it only looks at the first 3 indices of the start and count arrays, which don't change, so it just keeps getting the same slice of data over and over. That's why the (1,1,1) value for temperature is the same as the (1,1,2) value and (1,1,3) value and so on. I've attached a corrected program that reads the 3D array one lat-lon slice at a time, and prints out the values, which agree with the ncdump output. I also included in comments after the slice-at-a-time loop, how you could also read the whole 3D array at once, if you have a big enough memory array. This is just to show another way of doing it, to show how the counter argument to nf90_get_var is used. I hope this helps ... --Russ Russ Rew UCAR Unidata Program address@hidden http://www.unidata.ucar.edu Ticket Details =================== Ticket ID: DBL-115183 Department: Support netCDF Priority: Normal Status: Closed
Description: Binary data
NOTE: All email exchanges with Unidata User Support are recorded in the Unidata inquiry tracking system and then made publicly available through the web. If you do not want to have your interactions made available in this way, you must let us know in each email you send to us.