在IDL编程语言中调用例程

时间:2017-09-13 16:00:16

标签: idl-programming-language

我是新手,在陡峭的曲线上学习IDL。我有2 PROS第一个跟随

Pro READ_Netcdf1,infile,temperature,time,print_prompts=print_prompts 

COMPILE_OPt IDL2

infile='D:/Rwork/dataset/monthly_mean/version_2C/air.2m.mon.mean.nc'


IF (N_Elements(infile) EQ 0 ) Then STOP,'You are being silly, you must specify infile on call'



print,infile
iid = NCDF_OPEN(infile)
NCDF_VARGET, iid, 'time',  time              ; Read time
NCDF_VARGET, iid, 'air',   temperature       ; Read surface average temperature
NCDF_VARGET, iid, 'lat',   latitude          ; Read Latitude
NCDF_VARGET, iid, 'lon',   longitude         ; Read Longitude
NCDF_CLOSE, iid                              ; Close Input File

Centigrade=temperature-273.15

  print,'Time' 
  print,time[0:9]  
  Print, 'Latitude'
  Print, latitude[0:9]
  Print, 'Longitude'
  Print, longitude[0:9]
  print,'Temperature'
  print, temperature[0:9]  
  Print, 'Centigrade'
  Print, Centigrade[0:9]

;ENDIF

RETURN
END  

这完美无缺。我的第二个专业版如下: -

PRO Change_Kelvin_to_Cent,Temperature

;+ This programme take the temperature from the NETCDF file and converts 
;   to Centigrade
;Output 
;  The Month Mean Temperature in Centigrade
;  Must have read ncdf1 in the directory run first
;  
;  -
COMPILE_OPt IDL2

infile='D:/Rwork/dataset/monthly_mean/version_2c/air.2m.mon.mean.nc'

read_netcdf1, infile, Temperature                



Centigrade = Temperature-273.15

print,'Centigrade'
print,Centigrade[0:9]

RETURN
END

这也有效 我被指示从第一个PRO调用变量“Temperature”来计算第二个PRO 中没有命令行的温度

read_netcdf1,infile,Temperature

我无法让这个工作。请有人建议并帮助我摆脱这个问题

1 个答案:

答案 0 :(得分:0)

我被误导了。它无法完成。你必须拥有 “read_netcdf1,infile,Temperature”这段代码。虽然温度可以是任何标签,因为它的位置不是措辞。 我希望这能成为现实