Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

replacing NAN with missing value

Status
Not open for further replies.

mathias1979

Technical User
Sep 28, 2005
27
US
I'm working with fortran 77 on pgi compilters. I need to go through a real array and replace occurrances of NAN with -9999. I was just trying a simple if statement such as:

if (test(i,j).eq.NAN) test(i,j)=-9999

This just seems to ignore occurances of NAN. And if I try to do something like test(i,j).eq.'NAN') I get a type mismatch error. How can I get around this?
 
Testing against NAN doesn't work because, by normal Fortran rules, (identifiers beginning with letters I-N are integers) NAN is just an integer variable whose initial value is probably zero or some random number.

Testing for 'NAN' as a string won't work because you are comparing a number with a string.

This may or may not work on your compiler
Code:
   if (isnan(test(i,j)) test(i,j) = -999
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top