NOAA-GFDL / AM4

19 stars 21 forks source link

autotools build for consideration #16

Closed edwardhartnett closed 3 years ago

edwardhartnett commented 5 years ago

Not quite working yet, but submitted for discussion.

edwardhartnett commented 5 years ago

This fails for me like this:

Making all in land_lad2
make[2]: Entering directory '/home/ed/noaa/AM4/src/land_lad2'
gfortran -DPACKAGE_NAME=\"AM4\" -DPACKAGE_TARNAME=\"am4\" -DPACKAGE_VERSION=\"2.0-development\" -DPACKAGE_STRING=\"AM4\ 2.0-development\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DPACKAGE=\"am4\" -DVERSION=\"2.0-development\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -I.     -I/usr/local/netcdf-c-4.7.2-development_mpich-3.2/include -I/usr/local/netcdf-fortran-4.5.0_mpich-3.2/include -I/usr/local/fms/include -c -o land_constants.o land_constants.F90
gfortran -DPACKAGE_NAME=\"AM4\" -DPACKAGE_TARNAME=\"am4\" -DPACKAGE_VERSION=\"2.0-development\" -DPACKAGE_STRING=\"AM4\ 2.0-development\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DPACKAGE=\"am4\" -DVERSION=\"2.0-development\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -I.     -I/usr/local/netcdf-c-4.7.2-development_mpich-3.2/include -I/usr/local/netcdf-fortran-4.5.0_mpich-3.2/include -I/usr/local/fms/include -c -o land_data.o land_data.F90
land_data.F90:536:64:

                                    err_msg, new_missing_handle )
                                                                1
Error: There is no specific subroutine for the generic ‘horiz_interp’ at (1)
land_data.F90:537:84:

     call mpp_pass_sg_to_ug(lnd%domain, data_sg, data_out)
                                                                                    1
Error: There is no specific subroutine for the generic ‘mpp_pass_sg_to_ug’ at (1)
land_data.F90:410:59:

            call get_grid_comp_area('LND',n,lnd_area(:,:,n))
                                                           1
Error: There is no specific subroutine for the generic ‘get_grid_comp_area’ at (1)
land_data.F90:488:77:

   call get_grid_cell_vertices('LND',lnd%face,lnd%coord_glonb,lnd%coord_glatb)
                                                                             1
Error: There is no specific subroutine for the generic ‘get_grid_cell_vertices’ at (1)
land_data.F90:489:76:

   call get_grid_cell_centers ('LND',lnd%face,lnd%coord_glon, lnd%coord_glat)
                                                                            1
Error: There is no specific subroutine for the generic ‘get_grid_cell_centers’ at (1)
land_data.F90:490:88:

   call get_grid_cell_area    ('LND',lnd_sg%face,lnd%cellarea, lnd_sg%domain, lnd%domain)
                                                                                        1
Error: There is no specific subroutine for the generic ‘get_grid_cell_area’ at (1)
land_data.F90:491:88:

   call get_grid_comp_area    ('LND',lnd_sg%face,lnd%area,     lnd_sg%domain, lnd%domain)
                                                                                        1
Error: There is no specific subroutine for the generic ‘get_grid_comp_area’ at (1)
land_data.F90:496:93:

   call get_grid_cell_vertices('LND',lnd_sg%face,lnd%lonb,lnd%latb, lnd_sg%domain, lnd%domain)
                                                                                             1
Error: There is no specific subroutine for the generic ‘get_grid_cell_vertices’ at (1)
land_data.F90:497:92:

   call get_grid_cell_centers ('LND',lnd_sg%face,lnd%lon, lnd%lat, lnd_sg%domain, lnd%domain)
                                                                                            1
Error: There is no specific subroutine for the generic ‘get_grid_cell_centers’ at (1)
land_data.F90:347:86:

   call get_grid_cell_vertices('LND',lnd_sg%face,lnd_sg%coord_glonb,lnd_sg%coord_glatb)
                                                                                      1
Error: There is no specific subroutine for the generic ‘get_grid_cell_vertices’ at (1)
land_data.F90:348:85:

   call get_grid_cell_centers ('LND',lnd_sg%face,lnd_sg%coord_glon, lnd_sg%coord_glat)
                                                                                     1
Error: There is no specific subroutine for the generic ‘get_grid_cell_centers’ at (1)
land_data.F90:349:86:

   call get_grid_cell_area    ('LND',lnd_sg%face,lnd_sg%cellarea, domain=lnd_sg%domain)
                                                                                      1
Error: There is no specific subroutine for the generic ‘get_grid_cell_area’ at (1)
land_data.F90:350:86:

   call get_grid_comp_area    ('LND',lnd_sg%face,lnd_sg%area,     domain=lnd_sg%domain)
                                                                                      1
Error: There is no specific subroutine for the generic ‘get_grid_comp_area’ at (1)
land_data.F90:355:94:

   call get_grid_cell_vertices('LND',lnd_sg%face,lnd_sg%lonb,lnd_sg%latb, domain=lnd_sg%domain)
                                                                                              1
Error: There is no specific subroutine for the generic ‘get_grid_cell_vertices’ at (1)
land_data.F90:356:93:

   call get_grid_cell_centers ('LND',lnd_sg%face,lnd_sg%lon, lnd_sg%lat, domain=lnd_sg%domain)
                                                                                             1
Error: There is no specific subroutine for the generic ‘get_grid_cell_centers’ at (1)
land_data.F90:243:20:

   call mpp_min(qmin)
                    1
Error: There is no specific subroutine for the generic ‘mpp_min’ at (1)
land_data.F90:244:20:

   call mpp_max(qmax)
                    1
Error: There is no specific subroutine for the generic ‘mpp_max’ at (1)
land_data.F90:245:20:

   call mpp_sum(qsum)
                    1
Error: There is no specific subroutine for the generic ‘mpp_sum’ at (1)
land_data.F90:223:20:

   call mpp_min(qmin)
                    1
Error: There is no specific subroutine for the generic ‘mpp_min’ at (1)
land_data.F90:224:20:

   call mpp_max(qmax)
                    1
Error: There is no specific subroutine for the generic ‘mpp_max’ at (1)
land_data.F90:225:20:

   call mpp_sum(qsum)
                    1
Error: There is no specific subroutine for the generic ‘mpp_sum’ at (1)
Makefile:473: recipe for target 'land_data.o' failed
make[2]: *** [land_data.o] Error 1
make[2]: Leaving directory '/home/ed/noaa/AM4/src/land_lad2'
Makefile:366: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/home/ed/noaa/AM4/src'
Makefile:396: recipe for target 'all-recursive' failed
make: *** [all-recursive] Error 1
thomas-robinson commented 5 years ago

@edhartnett I think you are missing an include path?

gfortran -DPACKAGE_NAME=\"AM4\" -DPACKAGE_TARNAME=\"am4\" -DPACKAGE_VERSION=\"2.0-development\" -DPACKAGE_STRING=\"AM4\ 2.0-development\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DPACKAGE=\"am4\" -DVERSION=\"2.0-development\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -I.     -I/usr/local/netcdf-c-4.7.2-development_mpich-3.2/include -I/usr/local/netcdf-fortran-4.5.0_mpich-3.2/include -I/usr/local/fms/include -c -o land_constants.o land_constants.F90

You should have compiled libfms, which is required for compiling the land model. You need to add the location of libfms.a to the makefile of all of the other components.

edwardhartnett commented 5 years ago

There is no land_model.F90 in the FMS package (looking here: https://github.com/NOAA-GFDL/FMS)

Also in the build above, I am including the FMS library in my FCFLAGS, LDFLAGS, and LIBS: autoreconf -i && FCFLAGS='-ffree-line-length-none -I/usr/local/netcdf-c-4.7.2-development_mpich-3.2/include -I/usr/local/netcdf-fortran-4.5.0_mpich-3.2/include -I/usr/local/fms/include' LDFLAGS='-L/usr/local/netcdf-c-4.7.2-development_mpich-3.2/lib -L/usr/local/netcdf-fortran-4.5.0_mpich-3.2/lib -L/usr/local/fms/lib' CC=mpicc LIBS='-lFMS' ./configure && make clean && make

thomas-robinson commented 5 years ago

All of the routines that are 'not found' are in the FMS repository, so there is a problem with how you are including the FMS library. The land model (and every other component) depends on FMS.

I am looking at our own build right now, and the land code goes through a cpp preprocessor before it's compiled. This could potentially be your problem. Here is my example

cpp -nostdinc -C -v -DINTERNAL_FILE_NML -g -nostdinc  /home/Thomas.Robinson/AM4/src/land_lad2/land_constants.F90 > land_constants.DO_NOT_MODIFY.f90
mpiifort -msse2 -fno-alias -auto -safe-cray-ptr -ftz -assume byterecl -i4 -r8 -nowarn -sox -traceback -I/opt/netcdf/4.6.1/INTEL/include -I/opt/hdf5/1.10.1/INTEL/include -O3 -fp-model source -qoverride-limits -qopenmp -I/home/Thomas.Robinson/AM4/build/fms  -c -o land_constants.o  land_constants.DO_NOT_MODIFY.f90

-I/home/Thomas.Robinson/AM4/build/fms is where my libfms.a resides.

edwardhartnett commented 5 years ago

I seem to remember something about branches in the FMS library? Are you using the master branch of FMS?

I will take a look at the land_model stuff...

edwardhartnett commented 5 years ago

Which of the land code files goes through the extra pre-processor phase?

thomas-robinson commented 5 years ago

Ed, all of the land code goes through preprocessing. Everything in the land_lad2 folder including the source files in the subdirectories.

This version of AM4 uses an older commit from the FMS repository, not what's currently on master. I think it's tagged at 'warsaw'.

I think my build for the components such as land doesn't actually use libfms, but instead has an include -I to the directory where all of the .mod files are made. libfms and all of the other libs are linked in at the end.

edwardhartnett commented 5 years ago

There is no "warsaw" branch in the FMS directory here: https://github.com/NOAA-GFDL/FMS.

Is there any way to build the FMS project in such a way that it will allow AM4 to build?

Alternatively, is there any way to get AM4 to build with the FMS code that has been released?

edwardhartnett commented 5 years ago

OK, actually it looks like your F90 pre-processing only does one thing, it defines INTERNAL_FILE_NML.

I have added this to the configure script. The F90 files are already automatically pre-processed by the fortran pre-processor when compiled (because they are F90 not f90 files). So no additional processing should be needed.

However, even with this defined, the build fails the same as before.

underwoo commented 5 years ago

The land_lad2 .F90 files require post-processing with the cpp for some Fortran compilers. I tend to remember gfortran and the PGI Fortran compilers are in that group. The reason for this is that land_lad2 (and the newer LM4 land) use C Preprocessor macros like __FILE__ and other pre-processor tricks that some Fortran compilers in their preprocessor do not expand properly. Some of us would like to have these macros removed, but the land developers find them useful.

As for the -DINTERNAL_FILE_NML, I have begun to develop some m4 macros to help determine what features a Fortran compiler has. I would rather use something like that than simply set defines in the configure.ac. Please look at https://github.com/underwoo/FRE-NCtools/blob/autotools.postprocessing/m4/gx_fortran_options.m4. I'm still adding tests to this and need to expand some of the documentation, but once finished, I will add it to the FMS autotools build.

underwoo commented 5 years ago

I have just looked closer at your compile command and the error. I think the problem may be with your compile options for the land component v/s the compile options for the FMS library. You likely built the FMS library with the option -fdefault-real-8. If so, the compile command for the land will also need this option.

thomas-robinson commented 5 years ago

@edhartnett warsaw is a tag in FMS