Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

equivalence - variable naming - ?

teammig
Beginner
503 Views
Background: I am trying to get version 3 of the NCAR Community Atmosphere Model(CAM3) running with the Intel fortran compiler(l_fc_p_8.0.034). I have been successfully running version 2 of the model with the same compiler. V3 compiles, but will crash for (what I think is) a strange reason. I have striped out the problem into 3 small files to mimic the model:

cam.F90:

program cam
use runtime_opts, only: runtime_options
implicit none
call runtime_options ()
end program cam

history.F90:

module history
implicit none
PRIVATE
character*1 fincl1
character*1 fincl1l

equivalence (fincl1,fincl1l)
public :: fincl1, fincl1l
end module history

runtime_opts.F90:

module runtime_opts
use history
implicit none
private
save
public runtime_options

contains

subroutine read_namelist
fincl1l = '2'
return
end subroutine read_namelist

subroutine preset
use history, only: fincl1
fincl1 = '1'
return
end subroutine preset

subroutine runtime_options( )
print*,'in runtime_options:',fincl1,':&:',fincl1l,':'
call preset ()
print*,'in runtime_options:',fincl1,':&:',fincl1l,':'
call read_namelist () ! used to be called parse_namelist()
print*,'in runtime_options:',fincl1,':&:',fincl1l,':'
end subroutine runtime_options

end module runtime_opts

compiling this set as:
ifort -c history.F90
ifort -c runtime_opts.F90
ifort -c cam.F90
ifort -o cam cam.o runtime_opts.o history.o

produces the "correct" answer:
in runtime_options::&::
in runtime_options:1:&:1:
in runtime_options:2:&:2:

However, changing fincl1 to fincla everywhere while leaving fincl1l unchanged produces:
in runtime_options::&::
in runtime_options::&::
in runtime_options:2:&:2:

I get mixed results by changing the variable names with seemingly no logical reason. In the model code the equivalence pair fincl1latlon and fincllatlon produces result 2 while several other pairs such as fincl1 and fincl produce result 1. I believe that I can solve the problem without any detrimental effects by changing a line in subroutine preset
use history, only: fincla
to
use history
but it has become more of a mystery solver for me. Any suggestions are greatly appreciated.

Mike
0 Kudos
3 Replies
Steven_L_Intel1
Employee
503 Views
Please stop using 8.0.034. Log into your Premier Support account and download 8.0.050 plus the 8.0.053 patch. Uninstall 8.0.034 and install these instead.
If you continue to have problems after doing this, let us know.
0 Kudos
teammig
Beginner
503 Views
Update on the above issue using the latest release on my Premier Support: l_fc_pc_8.0.046_pe050.1

The above code will now compile and produce what I expect:

in runtime_options::&::
in runtime_options:1:&:1:
in runtime_options:2:&:2:

However, the full model will now not compile the runtime_opts module. I can reproduce the error by swapping fincl and fincl1 in the above code:

cam.F90:

program cam
use runtime_opts, only: runtime_options
implicit none
call runtime_options ()
end program cam

history.F90:

module history
implicit none
PRIVATE
character*1 fincl1l
character*1 fincl1

equivalence (fincl1l,fincl1)
public :: fincl1l, fincl1
end module history

runtime_opts.F90:

module runtime_opts
use history
implicit none
private
save
public runtime_options

contains

subroutine read_namelist
fincl1 = '2'
return
end subroutine read_namelist

subroutine preset
use history, only: fincl1l
fincl1l = '1'
return
end subroutine preset

subroutine runtime_options( )
print*,'in runtime_options:',fincl1l,':&:',fincl1,':'
call preset ()
print*,'in runtime_options:',fincl1l,':&:',fincl1,':'
call read_namelist () ! used to be called parse_namelist()
print*,'in runtime_options:',fincl1l,':&:',fincl1,':'
end subroutine runtime_options

end module runtime_opts

compiling this set as:
ifort -c history.F90
ifort -c runtime_opts.F90
ifort -c cam.F90
ifort -o cam cam.o runtime_opts.o history.o

produces:

runtime_opts.o(.text+0xc): In function `runtime_opts_mp_preset_':
: undefined reference to `history_mp_fincl1l_'
0 Kudos
Steven_L_Intel1
Employee
503 Views
Please report problems to Intel Premier Support.
0 Kudos
Reply