-3

I am trying to debug a fortran script and I can't figure out why an array is not being defined how it should be. I have parameters

  parameter(nx0=101,nd0=40,nindex=1)
  parameter(dep1=0,dep2=200,dep3=5)
  parameter(del1=0,del2=1000,del3=10)
  parameter(pmin=0,nump=6000)

and the array is defined as

  real t(nx0,nd0,nindex)

However when I get fortran to print t (which is huge)

 print *, 't = ', t

It outputs only zeros and NaNs. Yet when a vector is defined in the same manner:

 real x(nx0)

x is defined properly with no zero or NaN terms that do not belong.

I can't understand why t is not initialized properly, does anyone know why?

  • NOTE: this fortran code that I'm working with is widely used and freely available via the USGS as HASH_v1.2
zigzs
  • 33
  • 1
  • 5
  • 1
    I do not understand your description at all. What exactly is printed? Which values do you expect and why? Please explain the details and show a complete [mcve]. Make sure you assign some meaningful values to your arrays before using them. – Vladimir F Героям слава May 11 '18 at 21:03

1 Answers1

1

Variable initialisation is often compiler specific. You should check the documentation for your compiler. Better yet. Manually initialise the arrays and then check that the correct values are returned. Manual initialisation is best practise.

Russell Jurek
  • 84
  • 1
  • 1
  • 7