Compiling with gfortran

Using CAM3.5.32 ...

Does anyone know why the configure does not like gfortran?

Here is the netcdf-4.0.1 environment compiled with gfortran:

----
daniele@daniele-laptop:~/Code/cam$ ls local_netcdf/include/
ncvalues.h netcdfcpp.h netcdf.h netcdf.hh netcdf.inc netcdf.mod typesizes.mod

daniele@daniele-laptop:~/Code/cam$ ls local_netcdf/lib/
libnetcdf.a libnetcdf_c++.a libnetcdf_c++.la libnetcdf.la pkgconfig
---

Here is the configure with fc and linker set to gfortran:

---
./ccp-ucb_wcopy/models/atm/cam/bld/configure -test -cam_bld ./tmp -cam_exedir ./run -dyn fv -cc cc -nosmp -nospmd -nc_inc /usr/include -nc_lib /usr/lib -fc gfortran -linker gfortran -v
Setting CAM configuration script directory to /home/daniele/Code/cam/ccp-ucb_wcopy/models/atm/cam/bld
Using configuration defaults file config_defaults_fv.xml
Setting CAM root directory to /home/daniele/Code/cam/ccp-ucb_wcopy
Setting CAM build directory to /home/daniele/Code/cam/tmp
The CAM executable will be created in /home/daniele/Code/cam/run
Setting user source directories to
The configuration cache file will be created in /home/daniele/Code/cam/tmp/config_cache.xml
Using fv dynamics.
Using cam1 physics.
Using clm2 land package.
Using dom ocean package.
Using csim4 ice package.
Generating and writing SOM input fields to history tapes: OFF.
Perturbation growth testing: OFF.
Configure CAM for single column mode: OFF.
Configure CAM to produce IOP file for SCAM: OFF.
Horizontal grid specifier: 1.9x2.5.
Maximum number of columns in a chunk: 16.
Number of vertical levels: 26.
Total advected constituents: 3.
Target OS: linux.
Name of CAM executable: cam.
Override Makefile default Fortran compiler with: gfortran.
Override Makefile default C compiler with: cc.
Setting linker to gfortran.
Compiler debugging options: OFF.
SPMD parallelism: OFF
SMP parallelism: OFF
CPP definitions set by configure: ' -DFORTRANUNDERSCORE -DPLON=144 -DPLAT=96 -DPLEV=26 -DPCNST=3 -DPCOLS=16 -DPTRM=1 -DPTRN=1 -DPTRK=1 -DSTAGGERED -DDYN_STATE_INTERFACE'
Found netCDF include file in /usr/include
Found netCDF library in /usr/lib
Found netCDF module files in /usr/include
creating /home/daniele/Code/cam/tmp/Filepath
creating /home/daniele/Code/cam/tmp/misc.h
creating /home/daniele/Code/cam/tmp/preproc.h
creating /home/daniele/Code/cam/tmp/Makefile
creating /home/daniele/Code/cam/tmp/config_cache.xml
Looking for a valid GNU make... using make
Testing for Fortran 90 compatible compiler... **** PASS ****
Issued the command:
make -f /home/daniele/Code/cam/tmp/Makefile test_fc 2>&1

The output was:
/home/daniele/Code/cam/ccp-ucb_wcopy/models/atm/cam/bld/mkSrcfiles > /home/daniele/Code/cam/tmp/configure-tests/Srcfiles
/home/daniele/Code/cam/ccp-ucb_wcopy/models/atm/cam/bld/mkDepends Filepath Srcfiles > /home/daniele/Code/cam/tmp/configure-tests/Depends
gfortran -c -DHIDE_MPI test_fc.F90
gfortran -o test_fc test_fc.o

**** PASS ****
Issued the command:
./test_fc

The output was:
hello world

using gfortran
Test linking to NetCDF library...
---------------- /home/daniele/Code/cam/tmp/configure-tests
-----------------
**** FAILED ****
Issued the command:
make -f /home/daniele/Code/cam/tmp/Makefile test_nc 2>&1

The output was:
cat: Srcfiles: No such file or directory
/home/daniele/Code/cam/tmp/Makefile:916: /home/daniele/Code/cam/tmp/configure-tests/Depends: No such file or directory
/home/daniele/Code/cam/ccp-ucb_wcopy/models/atm/cam/bld/mkSrcfiles > /home/daniele/Code/cam/tmp/configure-tests/Srcfiles
/home/daniele/Code/cam/ccp-ucb_wcopy/models/atm/cam/bld/mkDepends Filepath Srcfiles > /home/daniele/Code/cam/tmp/configure-tests/Depends
gfortran -c -DHIDE_MPI test_nc.F90
test_nc.F90:2.13:

use netcdf
1
Fatal Error: Can't open module file 'netcdf.mod' for reading at (1): No such file or directory
make: *** [test_nc.o] Error 1

exit 1
---

If I go to /home/daniele/Code/cam/tmp/configure-tests and run:

daniele@daniele-laptop:~/Code/cam/tmp/configure-tests$ gfortran -c -DHIDE_MPI test_nc.F90

use netcdf
1
Fatal Error: Can't open module file 'netcdf.mod' for reading at (1): No such file or directory

I get an error, but if I add -I/usr/include (where netcdf.mod is), I get no error:

daniele@daniele-laptop:~/Code/cam/tmp/configure-tests$ gfortran -c -DHIDE_MPI -I/usr/include test_nc.F90
 
Download the binary for netcdf at:

http://www.unidata.ucar.edu/downloa...netcdf-3.6.3_nc3_gfortran_gfortran_c++.tar.gz

Then adding this to your Makefile.in right before '# pgf90' will get you through the -test for the configure
---
ifeq ($(FC),gfortran)

CPPDEF += -DNO_R16
FFLAGS := $(cpp_path) $(mod_path) $(CPPDEF)
#Arithmetic overflow of bit-wise transferred BOZ disabling
FFLAGS += -fno-range-check
# Compatible with g77
FFLAGS += -ff2c
# Avoid appending second underscore to external names
# FFLAGS += -fno-second-underscore -fno-underscoring
FREEFLAGS := -ffree-form

ifeq ($(DEBUG),TRUE)
FFLAGS += -g -frecursive -fbounds-check
else
# Check for override of default Fortran compiler optimizations
ifeq ($(F_OPTIMIZATION_OVERRIDE),$(null))
FORTRAN_OPTIMIZATION :=
endif
FFLAGS += $(FORTRAN_OPTIMIZATION)
endif

ifeq ($(SMP),TRUE)
FFLAGS += -fopenmp
LDFLAGS += -fopenmp
endif

endif
---

if you run the configure without the -test option and you actually want to compile the code you will get a problem in:

./models/atm/cam/src/physics/cam/convect_ke.F

The error message is:

/home/daniele/Code/cam/ccp-ucb_wcopy/models/atm/cam/src/physics/cam/convect_ke.F:179.72:

REAL(R8) T(ND),Q(ND),QS(ND),U(ND),V(ND),TRA(ND,NTRA),P(ND),PH(ND+1
1
Error: Expected another dimension in array declaration at (1)

Which is discussed at:

http://gcc.gnu.org/ml/gcc-bugs/2008-04/msg01105.html

Do the expert CAM users know what this is about?
 
in /home/daniele/Code/cam/ccp-ucb_wcopy/models/atm/cam/src/physics/cam/convect_ke.F

changed
REAL(R8) T(ND),Q(ND),QS(ND),U(ND),V(ND),TRA(ND,NTRA),P(ND),PH(ND+1)
in
REAL(R8) T(ND)
REAL(R8) Q(ND),QS(ND),U(ND),V(ND),TRA(ND,NTRA),P(ND),PH(ND+1)
 
to fix the following error:

---
/home/daniele/Code/cam/ccp-ucb_wcopy/models/atm/cam/src/dynamics/fv/geopk.F90:253.14:

pointer (ptr_inbuf8, inbuf8)
1
Error: Cray pointer declaration at (1) requires -fcray-pointer flag
---

add -fcray-pointer in Makefile.in section gfortran

FFLAGS += -ff2c -fcray-pointer
 
renamed 'string' to 'stringa'

ccp-ucb_wcopy/models/drv/seq_mct/seq_diag_mct.F90: type(mct_string) :: stringa ! mct char type
ccp-ucb_wcopy/models/drv/seq_mct/seq_diag_mct.F90: call mct_aVect_getRList(stringa,k,AV)
ccp-ucb_wcopy/models/drv/seq_mct/seq_diag_mct.F90: k,mct_string_toChar(stringa),minbuf(k),maxbuf(k),sumbuf(k)
ccp-ucb_wcopy/models/drv/seq_mct/seq_diag_mct.F90: type(mct_string) :: stringa ! mct char type
ccp-ucb_wcopy/models/drv/seq_mct/seq_diag_mct.F90: call mct_aVect_getRList(stringa,k,AV1)
ccp-ucb_wcopy/models/drv/seq_mct/seq_diag_mct.F90: iam,mct_string_toChar(stringa),cnt,adiff,rdiff, &

here is where the problem is described and should be solved but ... ?
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35945
 
with this section in Makefile.in
---
ifeq ($(FC),gfortran)

CPPDEF += -DNO_R16
FFLAGS := $(cpp_path) $(mod_path) $(CPPDEF)
#Arithmetic overflow of bit-wise transferred BOZ disabling
FFLAGS += -fno-range-check
# Compatible with g77
FFLAGS += -ff2c -fcray-pointer
# Avoid appending second underscore to external names
FFLAGS += -fno-underscoring
FREEFLAGS := -ffree-form

ifeq ($(DEBUG),TRUE)
FFLAGS += -g -frecursive -fbounds-check
else
# Check for override of default Fortran compiler optimizations
ifeq ($(F_OPTIMIZATION_OVERRIDE),$(null))
FORTRAN_OPTIMIZATION :=
endif
FFLAGS += $(FORTRAN_OPTIMIZATION)
endif

ifeq ($(SMP),TRUE)
FFLAGS += -fopenmp
LDFLAGS += -fopenmp
endif

endif
---
and modifications to certain files (see above) i can compile everything but i can't link.
I use gfortran -o -L/home/daniele/Code/cam/netcdf_x86/lib -lnetcdf.
The errors are of these kinds:

STATICEcosysDynMod.o: In function `__staticecosysdynmod_MOD_readmonthlyvegetation':
STATICEcosysDynMod.F90:(.text+0x81c): undefined reference to `nf_open'
STATICEcosysDynMod.F90:(.text+0x865): undefined reference to `nf_inq_dimid'

The references not found are:
daniele@daniele-laptop:~/Code/cam$ grep 'undefined reference' compile.log | cut -d '`' -f 2 | cut -d "'" -f 1 |sort -u
get_memusage
get_zeits
gptldisable
gptlenable
gptlfinalize
gptlinitialize
gptlpr
gptlsetoption
gptlstamp
gptlstart
gptlstop
mpi_abort
mpi_allgather
mpi_allreduce
mpi_alltoallv
mpi_barrier
mpi_bcast
mpi_comm_create
mpi_comm_dup
mpi_comm_group
mpi_comm_rank
mpi_comm_size
mpi_error_string
mpi_finalize
mpi_gather
mpi_gatherv
mpi_get_processor_name
mpi_group_range_incl
mpi_group_translate_ranks
mpi_group_union
mpi_init_fort
mpi_initialized
mpi_irecv
mpi_isend
mpi_recv
mpi_reduce
mpi_scatterv
mpi_send
mpi_wait
mpi_waitall
mpi_waitany
mpi_wtime
nf_close
nf_create
nf_def_dim
nf_def_var
nf_enddef
nf_get_att_text
nf_get_vara_double
nf_get_vara_int
nf_get_vara_text
nf_get_var_double
nf_get_var_int
nf_get_var_text
nf_inq_attid
nf_inq_attlen
nf_inq_dim
nf_inq_dimid
nf_inq_dimlen
nf_inq_dimname
nf_inq_ndims
nf_inq_unlimdim
nf_inq_var
nf_inq_vardimid
nf_inq_varid
nf_inq_varname
nf_inq_varndims
nf_open
nf_put_att_double
nf_put_att_int
nf_put_att_text
nf_put_var1_double
nf_put_var1_int
nf_put_vara_double
nf_put_vara_int
nf_put_vara_real
nf_put_vara_text
nf_put_var_double
nf_put_var_int
nf_redef
nf_set_fill
nf_strerror
nf_sync

Hope somebody can explain this.
 
Back
Top