# [gradsusr] [EXTERNAL] Multiple AND (logical) statements inside an if() in GrADS

Tue Feb 16 13:16:08 EST 2021

```Please have a look at these doc pages:

There are examples there that shows how to use logical expressions to create the GrADS defined variable you’re looking for. The use of the if-else-endif clauses inside a script will not do what you’re expecting.
--Jennifer

--
NASA/GSFC, Code 610.2
Building 32, Room S159
(301) 614-6070

From: gradsusr <gradsusr-bounces at gradsusr.org> on behalf of Lyndz <olagueralyndonmark429 at gmail.com>
Date: Saturday, February 13, 2021 at 6:40 AM
Subject: [EXTERNAL] [gradsusr] Multiple AND (logical) statements inside an if() in GrADS

I am calculating the heat stress index using the following:

'define temp = t2 - 273.16'

'define tempF = (temp *1.8) +32'

'define tempF = maskout(tempF,tempF-80)'

'define rh = rh2'

'define HI = -42.379 + (2.04901523*tempF) + (10.14333127*rh)-(0.22475541*tempF*rh) - (0.00683783*pow(tempF,2)) - (0.05481717*pow(rh,2)) + (0.00122874*pow(tempF,2)*rh) + (0.00085282*tempF*pow(rh,2)) - (0.00000199*pow(tempF,2)*pow(rh,2))'

if (rh < 13 & tempF >= 80 & tempF <= 112)

'define HIA = HI'

else

'define HIA = HI-((13-rh)/4)*sqrt(17-abs(tempF-95)/17)'

endif

if (rh > 85 & tempF >= 80 & tempF <= 87)

'define HIA = HI + 0.5*(tempF + 61 + ((tempF-68)*1.2) + (rh*0.094))'

endif

Adjustments are added to and subtracted from the HI equation if the temperature falls at a certain range.

Is this the correct way for doing this?
if (rh < 13 & tempF >= 80 & tempF <= 112)
if (rh > 85 & tempF >= 80 & tempF <= 87)

Or maybe there is a better approach for this....

I'll appreciate any comment/suggestion on this.

Sincerely,

Lyndon Mark P. Olaguera, Ph.D.
+63 906 023 9926
Manila Observatory,
Ateneo de Manila University Campus
Loyola Heights, Quezon city
-------------- next part --------------
A non-text attachment was scrubbed...
Name: winmail.dat
Type: application/ms-tnef
Size: 30912 bytes
Desc: not available