Scheduled Downtime
On Tuesday 24 October 2023 @ 5pm MT the forums will be in read only mode in preparation for the downtime. On Wednesday 25 October 2023 @ 5am MT, this website will be down for maintenance and expected to return online later in the morning.
Normal Operations
The forums are back online with normal operations. If you notice any issues or errors related to the forums, please reach out to help@ucar.edu

Writing out the variables in the surface map data with the mksurfdata_map tools

Status
Not open for further replies.

Yi Yao

Yi Yao
Member
Dear all, recently I was trying to develop the mksurfdata_map tools, in order to generate the surface data map with a new variable. However, there are some problems while writing out the new variable. My variable is 3-Dimentional, so I have checked other 3-D variables. Normally in the source code of the modules, the dimension of the variables to be written would be (ns_o) X (number of the third dimension), where (ns_o) = (num_lon) x (num_lat). Although it's 2-D in the source code, it it can be written well into the 3-D variable in the surface data map with the function nf_put_vara_double(). Here is an example (output grid is 10 x 15):
thumbnail_image.png
This is the dimension of the variable in the output surface data map.
thumbnail_image (1).png
And here is the dimension of the array which is going to be written in the module. As you can see, 24 x 19 = 456. With the function nf_put_vara_double(), the variable was written into the output surface map.
However, in my case,
thumbnail_pastedImagebase640.png
this is the dimension in the output surface data map,
thumbnail_image (2).png
and this is the dimension of the array which is going to be written. I used the function nf_put_vara_int(), but the error occurred ...23.PNG
Does someone have a similar experience?
 

Attachments

  • 23.PNG
    23.PNG
    7.2 KB · Views: 3

oleson

Keith Oleson
CSEG and Liaisons
Staff member
The error you're seeing suggests that the data being written is too large for the size of the dimensions which have been
specified (indicated by error -57). Not sure why that is happening but it possibly could be caused by the dimensions being switched?
 

Yi Yao

Yi Yao
Member
The error you're seeing suggests that the data being written is too large for the size of the dimensions which have been
specified (indicated by error -57). Not sure why that is happening but it possibly could be caused by the dimensions being switched?
I have transferred the variable from 2-D to 3-D, while this error still occurred.
1605890670147.png
This is how I get the dimension of the variabl specified in the output netcdf file, and the result is:
1605890733304.png
This is how I get the dimention of the array which is going to be written into the output file:
1605890798776.png
and the result is :
1605890824475.png
Finally I used this function:
1605890865955.png
But:
1605890895454.png
I am a little confused, as the dimensions are all got by Fortran, I don't think there is any issue about the place of different dimentions.
Do you have any idea?
 

Yi Yao

Yi Yao
Member
Dear, I just solved the bug by specifying the start and count, and I will check whether the variable has been written properly. I'll let you know.
 

oleson

Keith Oleson
CSEG and Liaisons
Staff member
I think you could also use nf_put_var_int (instead of nf_put_vara_int) and not have to specify the start and count?
 

Yi Yao

Yi Yao
Member
Thank you, it has been solved! I just didn't realize the difference between nf_put_vara and nf_put_var.
 
Status
Not open for further replies.
Top