ERROR COMPILING FOR THE FIRST TIME

Discussion on computers, ROMS installation and compiling

Moderators: arango, robertson

Post Reply
Message
Author
Tilldrop

ERROR COMPILING FOR THE FIRST TIME

#1 Unread post by Tilldrop »

Hi, everybody.

I'm new in ROMS. I installed ROMS in my Windows computer using Cygwin, according to the Tutorial on the Wiki (Tutorial: Installing ROMS in Windows XP / Vista / 7 (via Cygwin)). Even though I'm using Windows 10 I succeed in the installation process. Now I'm trying to compile ROMS for the first time in order to run the Upwelling test case, but I've got the compiling error bellow:

Code: Select all

cd /home/USUARI/roms/Projects/Upwelling/Build_roms; /usr/bin/gfortran -c -frepack-arrays -O3 -ffast-math -ffree-form -ffree-line-length-none -ffree-form -ffree-line-length-none mod_strings.f90
mod_strings.f90:218:42:

  218 |         character (len=80)  :: my_fort = "gfortran
      |                                          1
Error: Unterminated character constant beginning at (1)
make: *** [ROMS/Modules/Module.mk:15: /home/USUARI/roms/Projects/Upwelling/Build_roms/mod_strings.o] Error 1
When I open the mod_strings.f90 file it seems to be missing the closing quotation mark for "gfortran", and I don't know why.

Any help?

Really thank you,

Màrius

jcwarner
Posts: 1200
Joined: Wed Dec 31, 2003 6:16 pm
Location: USGS, USA

Re: ERROR COMPILING FOR THE FIRST TIME

#2 Unread post by jcwarner »

in your build.bash, you set FORT=gfortran
then in the makefile, it reads that $FORT from the environment and makes it
-DMY_FORT='"$(FORT)"'
so now the var MY_FORT is "gfortran"
then in mod_strings
it compiles
character (len=80) :: my_fort = MY_FORT
to become
character (len=80) :: my_fort = "gfortran"
confused yet?

here is what my cygwin built gfortran has in mod_strongs.
Do you get the "" around the other strings???

character (len=80) :: my_os = "CYGWIN"
character (len=80) :: my_cpu = "x86_64"
character (len=80) :: my_fort = "gfortran"
character (len=80) :: my_fc = "/usr/bin/mpif90"
character (len=512) :: my_fflags = "-frepack-arrays -O3 -ffast-math -Ic:\\work\\models\\MPICH2\\include -O3 -ffree-form -ffree-line-length-none"
....
!

Tilldrop

Re: ERROR COMPILING FOR THE FIRST TIME

#3 Unread post by Tilldrop »

Hi, jcwarner, thank you in advance.

Yes there's all "" in all other strings, it's missing only for gfortran. This is how my mod_strings.f90 looks like:

Code: Select all

        character (len=80)  :: my_os = "CYGWIN"
        character (len=80)  :: my_cpu = "i686"
        character (len=80)  :: my_fort = "gfortran
        character (len=80)  :: my_fc = "/usr/bin/gfortran"
        character (len=512) :: my_fflags = "-frepack-arrays -O3 -ffast-math -ffree-form -ffree-line-length-none -ffree-form -ffree-line-length-none"
That's why I'm confused.

Thanks again,

Màrius

jcwarner
Posts: 1200
Joined: Wed Dec 31, 2003 6:16 pm
Location: USGS, USA

Re: ERROR COMPILING FOR THE FIRST TIME

#4 Unread post by jcwarner »

longshot but .... where do you specify gfortran. in the roms.bash or something, right. make sure there are no characters after the gfortran, like a horrible tab or space or any weird unseen character.
can you post your roms.bash??
-j

Tilldrop

Re: ERROR COMPILING FOR THE FIRST TIME

#5 Unread post by Tilldrop »

It seems not to be any character after gfortran

Code: Select all

#--------------------------------------------------------------------------
# Compiler options.
#--------------------------------------------------------------------------
#
# Other user defined environmental variables. See the ROMS makefile for
# details on other options the user might want to set here. Be sure to
# leave the switches meant to be off set to an empty string or commented
# out. Any string value (including off) will evaluate to TRUE in
# conditional if-statements.

#export           USE_MPI=on            # distributed-memory parallelism
#export        USE_MPIF90=on            # compile with mpif90 script
#export         which_MPI=mpich         # compile with MPICH library
#export         which_MPI=mpich2        # compile with MPICH2 library
#export         which_MPI=mvapich2      # compile with MVAPICH2 library
 export         which_MPI=openmpi       # compile with OpenMPI library

#export        USE_OpenMP=on            # shared-memory parallelism

#export              FORT=ifort
 export              FORT=gfortran
#export              FORT=pgi

#export         USE_DEBUG=on            # use Fortran debugging flags
 export         USE_LARGE=on            # activate 64-bit compilation
 export       USE_NETCDF4=on            # compile with NetCDF-4 library
#export   USE_PARALLEL_IO=on            # Parallel I/O with NetCDF-4/HDF5
See build_roms.bash in attachment.
Attachments
build_roms.bash
(10.92 KiB) Downloaded 419 times

jcwarner
Posts: 1200
Joined: Wed Dec 31, 2003 6:16 pm
Location: USGS, USA

Re: ERROR COMPILING FOR THE FIRST TIME

#6 Unread post by jcwarner »

really not sure what is going on with that.
if this is holding you up, you could just edit the *.f90 and put the closing quote, then do ./roms.bash -noclean
or
(not recommended) you could edit the *.F and just replace to my_fort = "gfortran" but then it will not be correct if you change the compiler.
either way this is for reporting information and has nothing to do with the performance of the code.

-j

Tilldrop

Re: ERROR COMPILING FOR THE FIRST TIME

#7 Unread post by Tilldrop »

Hi, @jcwarner, thank you really much for your help.

I've edit *.f90 file ./roms.bash -noclean and it seems to works, but, it appeared this new error:

Code: Select all

/usr/lib/gcc/i686-pc-cygwin/9.3.0/../../../../i686-pc-cygwin/bin/ld: /usr/local/lib/libnetcdff.a(nf_nc4.o): in function `nf_def_var_chunking_':
/home/USUARI/software/netcdf-fortran-4.4.5/fortran/nf_nc4.f90:1491: undefined reference to `nc_def_var_chunking_ints'
/usr/lib/gcc/i686-pc-cygwin/9.3.0/../../../../i686-pc-cygwin/bin/ld: /home/USUARI/software/netcdf-fortran-4.4.5/fortran/nf_nc4.f90:1491: undefined reference to `nc_def_var_chunking_ints'
/usr/lib/gcc/i686-pc-cygwin/9.3.0/../../../../i686-pc-cygwin/bin/ld: /usr/local/lib/libnetcdff.a(nf_nc4.o): in function `nf_inq_var_chunking_':
/home/USUARI/software/netcdf-fortran-4.4.5/fortran/nf_nc4.f90:1538: undefined reference to `nc_inq_var_chunking_ints'
/usr/lib/gcc/i686-pc-cygwin/9.3.0/../../../../i686-pc-cygwin/bin/ld: /usr/local/lib/libnetcdff.a(nf_nc4.o): in function `nf_get_chunk_cache_':
/home/USUARI/software/netcdf-fortran-4.4.5/fortran/nf_nc4.f90:2712: undefined reference to `nc_get_chunk_cache_ints'
/usr/lib/gcc/i686-pc-cygwin/9.3.0/../../../../i686-pc-cygwin/bin/ld: /usr/local/lib/libnetcdff.a(nf_nc4.o): in function `nf_get_var_chunk_cache_':
/home/USUARI/software/netcdf-fortran-4.4.5/fortran/nf_nc4.f90:2773: undefined reference to `nc_get_var_chunk_cache_ints'
/usr/lib/gcc/i686-pc-cygwin/9.3.0/../../../../i686-pc-cygwin/bin/ld: /usr/local/lib/libnetcdff.a(nf_nc4.o): in function `nf_set_chunk_cache_':
/home/USUARI/software/netcdf-fortran-4.4.5/fortran/nf_nc4.f90:2690: undefined reference to `nc_set_chunk_cache_ints'
/usr/lib/gcc/i686-pc-cygwin/9.3.0/../../../../i686-pc-cygwin/bin/ld: /usr/local/lib/libnetcdff.a(nf_nc4.o): in function `nf_set_var_chunk_cache_':
/home/USUARI/software/netcdf-fortran-4.4.5/fortran/nf_nc4.f90:2746: undefined reference to `nc_set_var_chunk_cache_ints'
collect2: error: ld returned 1 exit status
make: *** [Master/Module.mk:22: /home/USUARI/roms/Projects/Upwelling/romsS.exe] Error 1

Tilldrop

Re: ERROR COMPILING FOR THE FIRST TIME

#8 Unread post by Tilldrop »

I remember I had serious problems with those files during the installation process, so I will install again Cygwin and trying not to miss any step.

Thank you anyway,

robertson
Site Admin
Posts: 227
Joined: Wed Feb 26, 2003 3:12 pm
Location: IMCS, Rutgers University

Re: ERROR COMPILING FOR THE FIRST TIME

#9 Unread post by robertson »

We need the linking command that precedes the errors you posted. It should be a multi-line command listing all the built libraries that will makeup the executable...something similar to this:
/opt/sw/packages/intel/17.0.4/compilers_and_libraries/linux/mpi/intel64/bin/mpiifort -fp-model precise -heap-arrays -ip -O3 -traceback -check uninit -fp-model precise -heap-arrays -ip -O3 -traceback -check uninit /home/rjdave/ESMs/Projects/upwelling/Build_roms/roms_import.o /home/rjdave/ESMs/Projects/upwelling/Build_roms/propagator.o /home/rjdave/ESMs/Projects/upwelling/Build_roms/master.o /home/rjdave/ESMs/Projects/upwelling/Build_roms/roms_export.o /home/rjdave/ESMs/Projects/upwelling/Build_roms/coupler.o /home/rjdave/ESMs/Projects/upwelling/Build_roms/esmf_roms.o /home/rjdave/ESMs/Projects/upwelling/Build_roms/ocean_control.o -o /home/rjdave/ESMs/Projects/upwelling/romsM /home/rjdave/ESMs/Projects/upwelling/Build_roms/libUTIL.a /home/rjdave/ESMs/Projects/upwelling/Build_roms/libNLM.a /home/rjdave/ESMs/Projects/upwelling/Build_roms/libNLM_bio.a /home/rjdave/ESMs/Projects/upwelling/Build_roms/libNLM_sed.a /home/rjdave/ESMs/Projects/upwelling/Build_roms/libANA.a /home/rjdave/ESMs/Projects/upwelling/Build_roms/libUTIL.a /home/rjdave/ESMs/Projects/upwelling/Build_roms/libMODS.a -L/projects/dmcs_1/sw/packages/intel-17.0.4/netcdf/4.6.2/lib -lnetcdff -L/projects/dmcs_1/sw/packages/intel-17.0.4/netcdf/4.6.2/lib -L/projects/dmcs_1/sw/packages/intel-17.0.4/hdf5/1.10.4/lib -lnetcdf -lnetcdf -lhdf5_hl -lhdf5 -lz -lcurl -lm
I suspect the reference to the NetCDF-C library (-lnetcdf) is missing from your link line. Please paste your link line (similar to the above) and the next several lines after that.

Tilldrop

Re: ERROR COMPILING FOR THE FIRST TIME

#10 Unread post by Tilldrop »

Here you are the complete sequence:

Code: Select all

$ ./build_roms.bash -noclean
./build_roms.bash: línia 168: $'\r': no s'ha trobat l'ordre
./build_roms.bash: línia 170: $'\r': no s'ha trobat l'ordre
./build_roms.bash: línia 174: $'\r': no s'ha trobat l'ordre
/home/USUARI/roms/Projects/Upwelling/my_build_paths.bash: línia 20: $'\r': no s'ha trobat l'ordre

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Using customized library paths from:  /home/USUARI/roms/Projects/Upwelling/my_build_paths.bash
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

/usr/bin/gfortran -frepack-arrays -O3 -ffast-math -frepack-arrays -O3 -ffast-math /home/USUARI/roms/Projects/Upwelling/Build_roms/coupler.o /home/USUARI/roms/Projects/Upwelling/Build_roms/esmf_roms.o /home/USUARI/roms/Projects/Upwelling/Build_roms/master.o /home/USUARI/roms/Projects/Upwelling/Build_roms/ocean_control.o /home/USUARI/roms/Projects/Upwelling/Build_roms/propagator.o /home/USUARI/roms/Projects/Upwelling/Build_roms/roms_export.o /home/USUARI/roms/Projects/Upwelling/Build_roms/roms_import.o -o /home/USUARI/roms/Projects/Upwelling/romsS.exe /home/USUARI/roms/Projects/Upwelling/Build_roms/libNLM.a /home/USUARI/roms/Projects/Upwelling/Build_roms/libUTIL.a /home/USUARI/roms/Projects/Upwelling/Build_roms/libNLM.a /home/USUARI/roms/Projects/Upwelling/Build_roms/libNLM_bio.a /home/USUARI/roms/Projects/Upwelling/Build_roms/libNLM_sed.a /home/USUARI/roms/Projects/Upwelling/Build_roms/libANA.a /home/USUARI/roms/Projects/Upwelling/Build_roms/libUTIL.a /home/USUARI/roms/Projects/Upwelling/Build_roms/libMODS.a /home/USUARI/roms/Projects/Upwelling/Build_roms/libNLM.a          -L/usr/local/lib -lnetcdff -L/usr/local/lib -lnetcdf -lnetcdf -lhdf5_hl -lhdf5 -lz -lcurl -lm
/usr/lib/gcc/i686-pc-cygwin/9.3.0/../../../../i686-pc-cygwin/bin/ld: /usr/local/lib/libnetcdff.a(nf_nc4.o): in function `nf_def_var_chunking_':
/home/USUARI/software/netcdf-fortran-4.4.5/fortran/nf_nc4.f90:1491: undefined reference to `nc_def_var_chunking_ints'
/usr/lib/gcc/i686-pc-cygwin/9.3.0/../../../../i686-pc-cygwin/bin/ld: /home/USUARI/software/netcdf-fortran-4.4.5/fortran/nf_nc4.f90:1491: undefined reference to `nc_def_var_chunking_ints'
/usr/lib/gcc/i686-pc-cygwin/9.3.0/../../../../i686-pc-cygwin/bin/ld: /usr/local/lib/libnetcdff.a(nf_nc4.o): in function `nf_inq_var_chunking_':
/home/USUARI/software/netcdf-fortran-4.4.5/fortran/nf_nc4.f90:1538: undefined reference to `nc_inq_var_chunking_ints'
/usr/lib/gcc/i686-pc-cygwin/9.3.0/../../../../i686-pc-cygwin/bin/ld: /usr/local/lib/libnetcdff.a(nf_nc4.o): in function `nf_get_chunk_cache_':
/home/USUARI/software/netcdf-fortran-4.4.5/fortran/nf_nc4.f90:2712: undefined reference to `nc_get_chunk_cache_ints'
/usr/lib/gcc/i686-pc-cygwin/9.3.0/../../../../i686-pc-cygwin/bin/ld: /usr/local/lib/libnetcdff.a(nf_nc4.o): in function `nf_get_var_chunk_cache_':
/home/USUARI/software/netcdf-fortran-4.4.5/fortran/nf_nc4.f90:2773: undefined reference to `nc_get_var_chunk_cache_ints'
/usr/lib/gcc/i686-pc-cygwin/9.3.0/../../../../i686-pc-cygwin/bin/ld: /usr/local/lib/libnetcdff.a(nf_nc4.o): in function `nf_set_chunk_cache_':
/home/USUARI/software/netcdf-fortran-4.4.5/fortran/nf_nc4.f90:2690: undefined reference to `nc_set_chunk_cache_ints'
/usr/lib/gcc/i686-pc-cygwin/9.3.0/../../../../i686-pc-cygwin/bin/ld: /usr/local/lib/libnetcdff.a(nf_nc4.o): in function `nf_set_var_chunk_cache_':
/home/USUARI/software/netcdf-fortran-4.4.5/fortran/nf_nc4.f90:2746: undefined reference to `nc_set_var_chunk_cache_ints'
collect2: error: ld returned 1 exit status
make: *** [Master/Module.mk:22: /home/USUARI/roms/Projects/Upwelling/romsS.exe] Error 1
Thank you

Tilldrop

Re: ERROR COMPILING FOR THE FIRST TIME

#11 Unread post by Tilldrop »

I've realised that /usr/bin (considering C:/Cygwin/usr/bin) does not exist in my computer. Instead, it exist a directory C:/Cygwin/bin where I found a file called gfortran.exe.

I don't know if it could be the problem,

Màrius

robertson
Site Admin
Posts: 227
Joined: Wed Feb 26, 2003 3:12 pm
Location: IMCS, Rutgers University

Re: ERROR COMPILING FOR THE FIRST TIME

#12 Unread post by robertson »

Did you build NetCDF yourself or use the NetCDF (and NetCDF fortran) provided by Cygwin? From you error messages it looks like you built netcdf fortran but not the required Netcdf-C. I would suggest installing the cygwin provided netcdf and netcdf-fortran.

Tilldrop

Re: ERROR COMPILING FOR THE FIRST TIME

#13 Unread post by Tilldrop »

I used NetCDF -c and -fortran from www.unidata.ucar.edu/downloads/netcdf:

netcdf-c-4.7.0.tar.gz
netcdf-fortran-4.4.5.tar.gz

And at the same time I installed any item related with netCDF in Cygwin installation process.

Màrius

robertson
Site Admin
Posts: 227
Joined: Wed Feb 26, 2003 3:12 pm
Location: IMCS, Rutgers University

Re: ERROR COMPILING FOR THE FIRST TIME

#14 Unread post by robertson »

I also just noticed that it looks like you have edited the build script and my_build_paths files with a windows editor that uses incorrect line returns (those \r warnings). That could have been causing the error you had originally. When I look at your build_roms.bash with an editor like vim I see sections of the file have a ^M at the end of each line. I have never seen an editor mix different line endings in the same file but that appears to have happened in your case. Depending on what else you installed with Cygwin you can use

Code: Select all

dos2unix <filename>
to convert the files or

Code: Select all

 perl -p -i -e 's/\r\n$/\n/g' <filename>
if dos2unix is unavailable.

For the linking error I would suggest changing your NETCDF to /usr in your my_build_paths.bash to use the NetCDF provided by Cygwin.

Tilldrop

Re: ERROR COMPILING FOR THE FIRST TIME

#15 Unread post by Tilldrop »

Hi, @robertson, thank you again.

I'm using Microsoft Visual Studio, that is my Fotran compiler in Windows 10, and it's my usual file editor. I have never had any problem with that editor in Windows, but maybe it is in Linux, I don't know.

On the other hand, I installed netCDF -c and -gfortran according to the Tutorial on the Wiki (Tutorial: Installing ROMS in Windows XP / Vista / 7 (via Cygwin)), here you are my steps:

Code: Select all

- In cygwin change into your software directory and download the NetCDF source code.

mkdir software
cd ~/software
wget https://www.unidata.ucar.edu/downloads/netcdf/ftp/netcdf-c-4.7.0.tar.gz
wget https://www.unidata.ucar.edu/downloads/netcdf/ftp/netcdf-fortran-4.4.5.tar.g

- Unpack it and change into the resulting director
 
tar -xvzf netcdf-c-4.7.0.tar.gz
cd netcdf-c-4.7.0

- Start the compilation by typing the lines below.

CC=gcc FC=gfortran F77=gfortran CPPFLAGS=-DpgiFortran
./configure --disable-netcdf-4
make all
make check
make install

- Change the directory

cd ~/software

- Unpack it and change into the resulting directory
tar -xvzf netcdf-fortran-4.4.5.tar.gz
cd ~/software/netcdf-fortran-4.4.5

- Start the compilation by typing the lines below.
export LD_LIBRARY_PATH=/usr/local/lib
export LDFLAGS=-L/usr/local/lib
export CPPFLAGS=-I/usr/local/include
./configure
make all
make check
make install
Do you recommend me to download the vim editor?

Anyway, I'm installing again Cygwin and I'll repeat all the process from the beginning, initially editing any file with Wordpad (maybe vim) instead of Microsoft Visual Studio, and I'll report on how it's going.

jcwarner
Posts: 1200
Joined: Wed Dec 31, 2003 6:16 pm
Location: USGS, USA

Re: ERROR COMPILING FOR THE FIRST TIME

#16 Unread post by jcwarner »

"initially editing any file with Wordpad"
WordPad is just as bad. That is not a good alternative.
I use emacs, or TextPad.
-j

Post Reply