Hello,
I am trying to combine an external routine with the ncl. WRAPIT seems to be working fine. I also tested the subroutine separately to make sure it works. The following ncl script gives dimension error during the call to the subroutine. Could you tell me where I am setting the values wrong? The ncl script, output, and beginning of external routine are given below. Thanks.
Kemal.
------------------------ test.ncl script --------------------------
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
external EX01 "./vad.so"
begin
; Open some netCDF files.
a = addfile("test.nc","r")
; Read variables
spd1 = a->VEL
spd = spd1(0,:,:,:)
dir1 = a->AZIM
dir = dir1(0,:,:,:)
printVarSummary(spd)
dims = dimsizes(spd)
nlev = dims(0)
nlat = dims(1)
mlon = dims(2)
print(nlev)
print(nlat)
print(mlon)
u1 = new((/nlev,nlat,mlon/),float)
v1 = new((/nlev,nlat,mlon/),float)
u2 = new((/nlev,nlat,mlon/),float)
v2 = new((/nlev,nlat,mlon/),float)
printVarSummary(u1)
EX01::vad(spd,dir,nlev,nlat,mlon,u1,v1,u2,v2)
end
----------------------------- end of script -------------------------------
----------------------- beginning of external routine -------------------
C NCLFORTSTART
subroutine vad(spd,dir,nlev,nlat,mlon,u1,v1,u2,v2)
real spd(nlev,nlat,mlon), dir(nlev,nlat,mlon)
real u1(nlev,nlat,mlon), v1(nlev,nlat,mlon)
real u2(nlev,nlat,mlon), v2(nlev,nlat,mlon)
C NCLEND
--------------------- end of external routine (snipped) -----------------------
----------------------------- beginning of ncl output ----------------------
Variable: spd
Type: float
Total Size: 4711252 bytes
1177813 values
Number of Dimensions: 3
Dimensions and sizes: [z | 13] x [y | 301] x [x | 301]
Coordinates:
z: [0.3..1.5]
y: [-150..150]
x: [-150..150]
Number Of Attributes: 3
missing_value : ( -32768, -32768 )
add_offset : 0
scale_factor : 100
Variable: nlev
Type: integer
Total Size: 4 bytes
1 values
Number of Dimensions: 1
Dimensions and sizes: [1]
Coordinates:
(0) 13
Variable: nlat
Type: integer
Total Size: 4 bytes
1 values
Number of Dimensions: 1
Dimensions and sizes: [1]
Coordinates:
(0) 301
Variable: mlon
Type: integer
Total Size: 4 bytes
1 values
Number of Dimensions: 1
Dimensions and sizes: [1]
Coordinates:
(0) 301
Variable: u1
Type: float
Total Size: 4711252 bytes
1177813 values
Variable: u1
Type: float
Total Size: 4711252 bytes
1177813 values
Number of Dimensions: 3
Dimensions and sizes: [13] x [301] x [301]
Coordinates:
Number Of Attributes: 1
_FillValue : 9.96921e+36
fatal:vad: dimension size of dimension (2) of spd must be equal to the value of nlev
fatal:Execute: Error occurred at or near line 37 in file test.ncl
----------------------- end of output ----------------------
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Feb 3 14:09:15 2014
This archive was generated by hypermail 2.1.8 : Fri Feb 07 2014 - 16:39:11 MST