nasa / AmesGCM

13 stars 5 forks source link

GNU-gFortran-10 -- Compiling error #1

Closed fgr81 closed 7 months ago

fgr81 commented 8 months ago

Hi,

I'm trying to compiling AmesGCM into a Singularity container with these characteristics:

Following and adapting the UserGuide indications (Appendix A, in particular), I have these vars in 'compile.mine':

setenv NETCDF "/usr/local"
setenv NETCDFPATH "/usr/local"
setenv GCC_PATH "/usr/local/bin"     
setenv MPI_INC "/usr/local/include"
setenv MPI_LIB "/usr/local/lib"

and these in mkfs.template.mine:

CPPFLAGS = -I$(NETCDF)/include -I$(MPI_INC)

MARS_CPP = -DSPMD -Duse_libMPI -Duse_netCDF -DINTERNAL_FILE_NML -DCUBE_CORE

FFLAGS = $(CPPFLAGS) $(MARS_CPP) -w -fdefault-real-8 -O2 -c -fopenmp -fbacktrace -ffree-line-length-none -fcray-pointer -fno-range-check -fdefault-double-8 -Waliasing -fallow-invalid-boz -fallow-argument-mismatch

CC = $(GCC_PATH)/mpicc
FC = $(GCC_PATH)/mpif90
LD = $(GCC_PATH)/mpif90
AR = ar cr
LDFLAGS = -L$(NETCDF)/lib -L$(MPI_LIB) -lnetcdff -lnetcdf -fopenmp -lmpi
ARFLAGS =
CFLAGS = -D__GFORTRAN $(CPPFLAGS) $(MARS_CPP) $(FFLAGS)

Now, when I launch compile.mine I have this error:

/usr/local/bin/mpif90 -DMARS_GCM -DMARS_SURFACE -DRELEASE  -I/usr/local/include -I/usr/local/include -DSPMD -Duse_libMPI -Duse_netCDF -DINTERNAL_FILE_NML -DCUBE_CORE -w -fdefault-real-8 -O2 -c -fopenmp -fbacktrace -ffree-line-length-none -fcray-pointer -fno-range-check -fdefault-double-8 -Waliasing -fallow-invalid-boz -fallow-argument-mismatch   -c -I/opt/AM4/exec/../src/FMS/include   /opt/AM4/exec/../src/FMS/astronomy/astronomy.F90
/opt/AM4/exec/../src/FMS/astronomy/astronomy.F90:399:26:

   36 | use constants_mod, only: PI, RADIAN, seconds_per_day
      |    2                      
......
  399 | real    :: seconds_per_day=86400.   !< seconds in a day
      |                          1
Error: Symbol ‘seconds_per_day’ at (1) conflicts with symbol from module ‘constants_mod’, use-associated at (2)

I've tried to varying the versions of Ubuntu and gFortran, delete FFLAGS '-fallow-invalid-boz -fallow-argument-mismatch' , but I couldn't compiled the source.

Have I to try to fix the code ?

Thanx for your attention,

-fabio-

rurata commented 7 months ago

Hi Fabio, Thank you for finding this bug. We will introduce a fix as soon as we can. In the meantime, please remove or comment out L399 | real :: seconds_per_day=86400. !< seconds in a day Let me know if this fixes this issue.

fgr81 commented 7 months ago

Hi Rurata,

thank you for your reply.

I comment the line but I involved in a new compilation error:

/opt/AM4/exec/../src/FMS/affinity/affinity.c:52:14: error: static declaration of ‘gettid’ follows non-static declaration

It seems to be a GLibC problem thus I retroceded to Ubuntu18 and installed gFortran-9. Now I've this problem:

/opt/AM4/exec/../src/GFDL_atmos_cubed_sphere/driver/mars/atmosphere.F90:63:4:

   63 | use mars_physics_mod,   only: mars_physics_init, mars_physics_end
      |    1
Fatal Error: Cannot open module file ‘mars_physics_mod.mod’ for reading at (1): No such file or directory
rurata commented 7 months ago

Hi Fabio, I am not sure why the mars_physics_mod.mod file would be missing. Can you check the exec.mine/mars_atmos_phys/pathnames_mars_atmos_phys file to confirm that mars_physics.F90 is present?

fgr81 commented 7 months ago

Hi Richard,

yes, it's present:

/opt/AM4/exec/../src/GFDL_atmos_cubed_sphere/driver/mars/atmosphere.F90
/opt/AM4/exec/../src/atmos_drivers/mars/atmos_model.F90
/opt/AM4/exec/../src/AmesGCM/atmos_cubed_sphere_mars/mars_physics_update.F90
/opt/AM4/exec/../src/AmesGCM/atmos_param_mars/null_physics_mod.F90
/opt/AM4/exec/../src/AmesGCM/atmos_param_mars/mars_physics.F90
/opt/AM4/exec/../src/AmesGCM/atmos_param_mars/update_mars_atmos.F90
/opt/AM4/exec/../src/AmesGCM/atmos_param_mars/testconserv.F90
/opt/AM4/exec/../src/AmesGCM/atmos_param_mars/aerosol.F90
/opt/AM4/exec/../src/AmesGCM/atmos_param_mars/sedim_mod.F90
/opt/AM4/exec/../src/AmesGCM/atmos_param_mars/palmer_topo_drag.F90
/opt/AM4/exec/../src/AmesGCM/atmos_param_mars/initracer_mod.F90
/opt/AM4/exec/../src/AmesGCM/atmos_param_mars/BLcode/pblmod_mgcm.F90
/opt/AM4/exec/../src/AmesGCM/atmos_param_mars/BLcode/tridiagonal.F90
/opt/AM4/exec/../src/AmesGCM/atmos_param_mars/BLcode/ames_pbl_interface.F90
/opt/AM4/exec/../src/AmesGCM/atmos_param_mars/dust_update.F90
/opt/AM4/exec/../src/AmesGCM/atmos_param_mars/surface_flux.F90
/opt/AM4/exec/../src/AmesGCM/atmos_param_mars/aerosol_util.F90
/opt/AM4/exec/../src/AmesGCM/atmos_param_mars/Rad/ames_rt_interface.F90
/opt/AM4/exec/../src/AmesGCM/atmos_param_mars/Rad/rtmod_mgcm.F90
/opt/AM4/exec/../src/AmesGCM/atmos_param_mars/Rad/radiation_driver.F90
/opt/AM4/exec/../src/AmesGCM/atmos_param_mars/Rad/radiation_util.f90
/opt/AM4/exec/../src/AmesGCM/atmos_param_mars/Rad/simple_rad_driver.F90
/opt/AM4/exec/../src/AmesGCM/atmos_param_mars/mars_surface.F90

and the path seems to be correct.

Edit: I saved compilation output and it seems there's the checkout of mars_atmos_phys folder:

A list of the files you checked out is in the file /opt/AM4/exec/exec.stromboli.mars3.1/fms/pathnames_fms.
/opt/AM4/exec/exec.stromboli.mars3.1/fms /opt/AM4/exec/exec.stromboli.mars3.1
 Makefile is ready.
/opt/AM4/exec/exec.stromboli.mars3.1
A list of the files you checked out is in the file /opt/AM4/exec/exec.stromboli.mars3.1/atmos_cubed/pathnames_atmos_cubed.
/opt/AM4/exec/exec.stromboli.mars3.1/atmos_cubed /opt/AM4/exec/exec.stromboli.mars3.1
 Makefile is ready.
/opt/AM4/exec/exec.stromboli.mars3.1
A list of the files you checked out is in the file /opt/AM4/exec/exec.stromboli.mars3.1/mars_atmos_phys/pathnames_mars_atmos_phys.
/opt/AM4/exec/exec.stromboli.mars3.1/mars_atmos_phys /opt/AM4/exec/exec.stromboli.mars3.1
 Makefile is ready.

but the compilation stopped itself at the second folder, atmos_cubed:

/usr/local/bin/mpif90 -DMARS_GCM -DMARS_SURFACE -DRELEASE  -I/usr/local/include -I/usr/local/include -DSPMD -Duse_libMPI -Duse_netCDF -DINTERNAL_FILE_NML -DCUBE_CORE -w -fdefault-real-8 -O2 -c -fopenmp -fbacktrace -ffree-line-length-none -fcray-pointer -fno-range-check -fdefault-double-8 -Waliasing -fno-underscoring -I/opt/AM4/exec/exec.stromboli.mars3.1/fms  -c    /opt/AM4/exec/../src/GFDL_atmos_cubed_sphere/tools/coarse_grained_diagnostics.F90
/usr/local/bin/mpif90 -DMARS_GCM -DMARS_SURFACE -DRELEASE  -I/usr/local/include -I/usr/local/include -DSPMD -Duse_libMPI -Duse_netCDF -DINTERNAL_FILE_NML -DCUBE_CORE -w -fdefault-real-8 -O2 -c -fopenmp -fbacktrace -ffree-line-length-none -fcray-pointer -fno-range-check -fdefault-double-8 -Waliasing -fno-underscoring -I/opt/AM4/exec/exec.stromboli.mars3.1/fms  -c -I/opt/AM4/exec/../src/FMS/include /opt/AM4/exec/../src/GFDL_atmos_cubed_sphere/driver/mars/atmosphere.F90
Makefile:19: recipe for target 'atmosphere.o' failed
make[1]: Leaving directory '/opt/AM4/exec/exec.stromboli.mars3.1/atmos_cubed'
Makefile:15: recipe for target 'atmos_cubed/lib_atmos_cubed.a' failed
ERROR: make failed for FMS_MARS

This is the Makefile written in exec.mine folder:

SRCROOT = /opt/AM4/exec/../src/
BUILDROOT = /opt/AM4/exec/exec.stromboli.mars3.1/

MK_TEMPLATE = /opt/AM4/exec/../bin/mkmf.template.stromboli
include $(MK_TEMPLATE)

FMS_MARS.x: mars_atmos_phys/libmars_atmos_phys.a atmos_cubed/lib_atmos_cubed.a fms/libfms.a
        $(LD) $^ $(LDFLAGS) -o $@

fms/libfms.a:  FORCE
        $(MAKE) SRCROOT=$(SRCROOT) BUILDROOT=$(BUILDROOT) MK_TEMPLATE=$(MK_TEMPLATE)  --directory=fms $(@F)

atmos_cubed/lib_atmos_cubed.a: fms/libfms.a FORCE
        $(MAKE) SRCROOT=$(SRCROOT) BUILDROOT=$(BUILDROOT) MK_TEMPLATE=$(MK_TEMPLATE)  --directory=atmos_cubed $(@F)

mars_atmos_phys/libmars_atmos_phys.a: atmos_cubed/lib_atmos_cubed.a fms/libfms.a FORCE
        $(MAKE) SRCROOT=$(SRCROOT) BUILDROOT=$(BUILDROOT) MK_TEMPLATE=$(MK_TEMPLATE)  --directory=mars_atmos_phys $(@F)

FORCE: 

.DEFAULT:
        -echo $@ does not exist.
all: ar cr a.out
SRC =
OBJ =
clean: neat
        -rm -f .a.out.cppdefs $(OBJ) a.out
        -rm -r fms
        -rm -r mars_atmos_phys
neat:
        -rm -f $(TMPFILES)
TAGS: $(SRC)
        etags $(SRC)
tags: $(SRC)
        ctags $(SRC)
a.out: $(OBJ)
        $(LD) $(OBJ) -o a.out  $(LDFLAGS)

~                                   
rurata commented 7 months ago

The error looks like it's trying to compile the atmosphere.F90 file during the atmos_cubed section. Can you modify your compile script like this: these 3 lines egrep -v "atmos_cubed_sphere/driver/GFDL/" pathnames.all > pathnames_atmos_cubed /bin/mv pathnames_atmos_cubed pathnames.all egrep -v "atmos_cubed_sphere/driver/SHiELD/" pathnames.all > pathnames_atmos_cubed

to this single line

egrep -v "atmos_cubed_sphere/driver/*" pathnames.all > pathnames_atmos_cubed

fgr81 commented 7 months ago

Thank you Richard ! , now I'm able to compile the AmesGCM and soon I'll try to run it on my host.

I created a repo: https://github.com/fgr81/AmesGCM_Singularity