Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
29283 Discussions

A problem in my if ... then ... else ... endif program. Please have a look.

changks888
Beginner
566 Views
Dear friends, I'm trying to isolating the Stage into 4 stages. The output only shows 1, 2 and 4. Why theStage = 3 is missing ?
if (gdd.lt.90.0) then
Stage = 1
else
if((gdd.gt.1800.0) then
if (Stage.eq.2) then
Stage = 3
end = doys
endif
if (Stage.eq.3 .and. growth.le.0.0) then
Stage = 4
else
if (Stage.eq.1) then
Stage = 2
start = doys
endif
endif
endif
0 Kudos
1 Solution
jimdempseyatthecove
Honored Contributor III
566 Views

Add diagnostic WRITE statements

[bash]write(*,*) 'IN: Stage, gdd, growth', Stage, gdd, growth
if (gdd.lt.90.0) then
  Stage = 1
else
  if((gdd.gt.1800.0) then
    if (Stage.eq.2) then
      Stage = 3
      end = doys
    endif
    if (Stage.eq.3 .and. growth.le.0.0) then
      Stage = 4
    else
      if (Stage.eq.1) then
        Stage = 2
        start = doys
      endif
    endif
  endif
<--- missing endif here
write(*,*) 'OUT: Stage, gdd, growth', Stage, gdd, growth

Not knowing initial value of Stage and sequencing of values of gdd
and value of growth makes it difficult for use to guess what will happen

Jim Dempsey[/bash]
[bash][/bash]

View solution in original post

0 Kudos
1 Reply
jimdempseyatthecove
Honored Contributor III
567 Views

Add diagnostic WRITE statements

[bash]write(*,*) 'IN: Stage, gdd, growth', Stage, gdd, growth
if (gdd.lt.90.0) then
  Stage = 1
else
  if((gdd.gt.1800.0) then
    if (Stage.eq.2) then
      Stage = 3
      end = doys
    endif
    if (Stage.eq.3 .and. growth.le.0.0) then
      Stage = 4
    else
      if (Stage.eq.1) then
        Stage = 2
        start = doys
      endif
    endif
  endif
<--- missing endif here
write(*,*) 'OUT: Stage, gdd, growth', Stage, gdd, growth

Not knowing initial value of Stage and sequencing of values of gdd
and value of growth makes it difficult for use to guess what will happen

Jim Dempsey[/bash]
[bash][/bash]
0 Kudos
Reply