Re: Problem using conditional statements (if then else) in NCL

From: Andrea Hahmann <ahah_at_nyahnyahspammersnyahnyah>
Date: Fri, 24 Jul 2009 09:55:01 +0200

Oi Rosa

I think the only solution is to split your ³if ³ statement in two pieces:
one to check if there are values (not all missing) and another to check the
value of it. Something like:

if (.not.all(ismissing(x))) then
   if (x .gt. 1000) then
  ....
   else
  ...
 end if
end if

Hope this helps,
Andrea

-- 
Andrea N. Hahmann
Senior Scientist
Phone direct +45 4677 5471
andrea.n.hahmann_at_risoe.dk
 
Wind energy Division
Risø National Laboratory for Sustainable Energy
Technical University of Denmark ­ DTU
Building 114, P.O. Box 49
DK-4000 Roskilde, Denmark
Tel +45 4677 5471
Fax +45 4677 5083
www.risoe.dtu.dk
From: Rosa Maria Nascimento dos Santos <rosinha2005_at_gmail.com>
Date: Fri, 24 Jul 2009 03:17:12 -0400
To: <ncl-talk_at_ucar.edu>
Subject: Problem using conditional statements (if then else) in
NCL
Hi,
I have a problem when trying to use "if then else" statments i  my script it
gets the following error mensage: "fatal:Conditional statements (if and do
while) require SCALAR logical values, see all and any functions". I've tryed
to use the  functions "all" and "ismissing" to solve it but it didn't work.
What can i do to solve this?! Could anyone help me?!
Thanks!
Rosa
P.S.: I'm sending a part of the script bellow!
====================================================
begin
 
file_in = 
addfile("/home/rosa/CCSM3/dados_paulo/BRAMS.1997_mes06_dia18_hora18.nc
<http://BRAMS.1997_mes06_dia18_hora18.nc> ","r")
att_names = getvaratts(file_in)           ; get cdf_file file's global
attributes
psnm = file_in->psnm
uvel = file_in->uvel
vvel = file_in->vvel
zgeo = file_in->zgeo
temp = file_in->temp
umrl = file_in->umrl
time = file_in->time
lev = file_in->lev
lat = file_in->lat
lon = file_in->lon
;******************* criar as novas variaveis TS e ur ****************
TS = new(dimsizes(temp),float)
TS!0 = "time"
TS!1 = "lev"
TS!2 = "lat"
TS!3 = "lon"
TS&time = time
TS&lev = lev
TS&lat = lat
TS&lon = lon
TS_at_long_name = "temperatura do ar a superficie"
TS_at_units = "oC"
TS_at_grid_type = "gaussian"
TS = temp - 273.15
;============================================================
ur = new(dimsizes(umrl),float)
ur!0 = "time"
ur!1 = "lev"
ur!2 = "lat"
ur!3 = "lon"
ur&time = time
ur&lev = lev
ur&lat = lat
ur&lon = lon
ur_at_long_name = "temperatura do ar a superficie"
ur_at_units = "oC"
ur_at_grid_type = "gaussian"
  if (.not.all(ismissing(umrl)) .and. umrl .gt. 100) then
   ur = 100
  else
   ur = umrl
  end if
print(ur)
==================================================
-- 
Rosa Maria Nascimento Santos
Profra. Dra. do Curso de Meteorologia
EST / UEA
Av. Darcy Vargas, 1200  -  Parque 10
CEP 690050-020, Manaus ­ AM ­ BR
Fone: +55 92 32365573 Ramal 22
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Fri Jul 24 2009 - 01:55:01 MDT

This archive was generated by hypermail 2.2.0 : Wed Jul 29 2009 - 09:07:41 MDT