[MITgcm-support] Compiling problem by ifort: undefined reference to '_gfortran_st_write'

Martin Losch Martin.Losch at awi.de
Mon Feb 15 06:32:16 EST 2021


Hi Shawn,

could you try to compile and run a simple mpi program with the compiler and mpi library of your choice.
E.g. something like the ones suggested on this page:
https://curc.readthedocs.io/en/latest/programming/MPI-Fortran.html

Once that works (and you may have to consult with you sys admins), you can use the working combination of compiler and MPI enviroment to construct your build options file. You’ll need the name of the mpi compiler (script), usually something like mpif77 or mpif90 (this compiler/script should know about the correct libraries), and the location of your include directories. This information then goes into the build options file.

I would first try to make it work without netcdf support.

Martin

> On 13. Feb 2021, at 09:36, H.W. Shu <shawn_chou at ees.hokudai.ac.jp> wrote:
> 
> Dear Dr. Martin,
> 
> Hi, this is Shawn. Thank you for your advices before, 
> I thus re-check my configurations in our system but the problem of "
> undefined reference to '_gfortran_st_write'".
> 
> By using the option-file: linux_amd64_gfortran,
> I inserted our libraries of MPI and netcdf inside that:
> 
> 
> elif test -d /usr/local/netcdf-fortran/4.5.2_intel ; then
>    INCLUDES='-I/usr/local/netcdf-fortran/4.5.2_intel/include'
>    LIBS='-L/usr/local/netcdf-fortran/4.5.2_intel/lib'
> 
> and
> 
> if [ -n "$MPI_HOME" -a -z "$MPI_INC_DIR" ]; then
>        MPI_INC_DIR="/opt/hpe/hpc/mpt/mpt-2.21/include"
> 
> which mpi.h is included in this directory. 
> However, when I used the command 
>>> ../../../tools/genmake2 -mods=../code  -mpi -of=/home/my_name/MITgcm_
> c66j/tools/build_options/linux_amd64_gfortran
> where I added the -mpi flag, 
> it still gave me the error message that 
> "undefined reference to '_gfortran_st_write_done'"
> and
> "undefined reference to '_gfortran_transfer_character_write'"
> 
> What else the problem you think is possible in my compiling process?
> or I inserted the directories of MPI and NectCDF in wrong places?
> 
> Thank you for your help!
> 
> Best regards,
> Shawn
> 
> ----- Original Message -----
> From: "H.W. Shu" <shawn_chou at ees.hokudai.ac.jp>
> Sent Date: 18:42:00 Wed February 10, 2021
> 
>> Dear Dr. Martin,
>> 
>> Thank you for your message. 
>> In fact, I think I have the problem that I don't really know how to 
>> connect all these libraries into my compiling process. 
>> For example, 
>> I can load my netcdf library by : module load netcdf-fortran/4.5.2_
> intel
>> I also know my MPI directory: /opt/hpe/hpc/mpt/mpt-2.21/lib
>> so, in compiling process, I follow by the commands in "build" file as 
>> below:
>> $ module load netcdf-fortran/4.5.2_intel
>> $ ../../../tools/genmake2 -mods=../code  -mpi -of=/home/my_name/MITgcm
> _
>> c66j/tools/build_options/linux_amd64_ifort+mpi_ice_nas
>> $ make depend
>> $ make
>> 
>> note that I inserted the -mpi as you recommanded in previous mail in 
> the 
>> command and also change my option file to linux_amd64_ifort+mpi_ice_
> nas
>> However, although at this moment I don't have the gfortran's problem
>> it gave me the other error message that:
>> -----
>> -L/nasa/sgi/mpt/2.14r19/lib -lmpi -L/nasa/netcdf/4.0/lib -lnetcdf
>> /usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/
> ld: 
>> main.o: in function `main':
>> main.f:(.text.startup+0x0): multiple definition of `main'; /opt/intel/
>> compilers_and_libraries_2020.0.166/linux/compiler/lib/intel64_lin/for_
>> main.o:for_main.c:(.text+0x0): first defined here
>> /usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/
> ld: 
>> cannot find -lnetcdf
>> make[1]: *** [Makefile:1943: mitgcmuv] Error 1
>> make[1]: Leaving directory '/home/shawn_chou/MITgcm_c66j/verification/
>> totten_high/build'
>> make: *** [Makefile:1939: fwd_exe_target] Error 2
>> ------
>> 
>> I have no further idea what is wrong at this moment.
>> I will really appreciate that if can have any hints. 
>> 
>> Thank you really much!
>> 
>> ------
>> Dear Dr. Gus Correa
>> 
>> Thank you really much! 
>> After changing to other option-file, I dont have the gfortran's 
> problem. 
>> but there's other one occurred as I described above. 
>> 
>> I will really appreciate if having any hints on this problem..
>> Thank you in advanced!
>> 
>> Best regards,
>> Shawn (Shu)
>> 
>> 
>> 
>> 
>>> --------------------------------------------------------------------
> --
>>> 
>>> Message: 1
>>> Date: Tue, 09 Feb 2021 15:49:49 +0900
>>> From: "H.W. Shu" <shawn_chou at ees.hokudai.ac.jp>
>>> To: <mitgcm-support at mitgcm.org>
>>> Subject: [MITgcm-support] Compiling problem by ifort: undefined
>>> 	reference to	'_gfortran_st_write'
>>> Message-ID:
>>> 	<20210209064949.0032A501.0222 at HINES-WebMail.hines.hokudai.ac.jp>
>>> Content-Type: text/plain; charset=US-ASCII
>>> 
>>> Dear MITgcm users, 
>>> 
>>> Hello, this is Shawn from Hokkaido University.
>>> We are trying compiling an mpi run in our system by default compiler 
>> in 
>>> tools/build_options: linux_amd64_ifort
>>> (we added "-lmpi -03" in flags.)
>>> 
>>> However, in the process of Make,
>>> it told us that "undefined reference to '_gfortran_st_write_done'" 
> and 
>> " 
>>> undefined reference to '_gfortran_transfer'".
>>> and leaved by this error. 
>>> 
>>> I am not familiar with compile problems, 
>>> I will really appreciate if can get any hint to start to fix the 
>> problem.
>>> 
>>> Thank you really much,
>>> 
>>> Best regards,
>>> Shawn
>>> 
>>> 
>>> 
>>> 
>>> ------------------------------
>>> 
>>> Message: 2
>>> Date: Tue, 9 Feb 2021 08:14:25 +0100
>>> From: Martin Losch <Martin.Losch at awi.de>
>>> To: MITgcm Support <mitgcm-support at mitgcm.org>
>>> Subject: Re: [MITgcm-support] Compiling problem by ifort: undefined
>>> 	reference to '_gfortran_st_write'
>>> Message-ID: <875C3E06-7FC8-456C-B4AD-B1657151B5D0 at awi.de>
>>> Content-Type: text/plain; charset="utf-8"
>>> 
>>> Hi Shawn,
>>> 
>>> normally you don?t have to add ?-lmpi" to the build options file. 
> For 
>> MPI simulations it?s important that you add the -mpi flag to genmake2 
>> and that you know where your mpi include files are.
>>> Before you run genmake2 set the enviroment flag MPI_INC_DIR to the 
>> location of your mpifiles. E.g. on my laptop I installed OpenMP and 
> have 
>> this:
>>> 
>>>>> echo $MPI_INC_DIR
>>> /opt/local/include/openmpi-mp
>>>>> ls /opt/local/include/openmpi-mp
>>> mpi-ext.h               mpi_portable_platform.h mpif-config.h        
> 
>> mpif-ext.h              mpif-handles.h          mpif-io-handles.h     
> 
>> mpif-sizeof.h           openmpi
>>> mpi.h                   mpif-c-constants-decl.h mpif-constants.h     
> 
>> mpif-externals.h        mpif-io-constants.h     mpif-sentinels.h      
> 
>> mpif.h
>>> 
>>> it?s important that ?mpif.h? is also in that directory.
>>> 
>>> Martin
>>> 
>>> 
>>>> On 9. Feb 2021, at 07:49, H.W. Shu <shawn_chou at ees.hokudai.ac.jp> 
>> wrote:
>>>> 
>>>> Dear MITgcm users, 
>>>> 
>>>> Hello, this is Shawn from Hokkaido University.
>>>> We are trying compiling an mpi run in our system by default 
> compiler 
>> in 
>>>> tools/build_options: linux_amd64_ifort
>>>> (we added "-lmpi -03" in flags.)
>>>> 
>>>> However, in the process of Make,
>>>> it told us that "undefined reference to '_gfortran_st_write_done'" 
>> and " 
>>>> undefined reference to '_gfortran_transfer'".
>>>> and leaved by this error. 
>>>> 
>>>> I am not familiar with compile problems, 
>>>> I will really appreciate if can get any hint to start to fix the 
>> problem.
>>>> 
>>>> Thank you really much,
>>>> 
>>>> Best regards,
>>>> Shawn
>>>> 
>>>> 
>>>> _______________________________________________
>>>> MITgcm-support mailing list
>>>> MITgcm-support at mitgcm.org
>>>> http://mailman.mitgcm.org/mailman/listinfo/mitgcm-support
>>> 
>>> -------------- next part --------------
>>> A non-text attachment was scrubbed...
>>> Name: smime.p7s
>>> Type: application/pkcs7-signature
>>> Size: 1665 bytes
>>> Desc: not available
>>> URL: <http://mailman.mitgcm.org/pipermail/mitgcm-support/attachments/20210209/cbd2172a/attachment-0001.p7s>
> 
>> 
>>> 
>>> ------------------------------
>>> 
>>> Message: 3
>>> Date: Tue, 9 Feb 2021 02:14:08 -0500
>>> From: Gus Correa <gus at ldeo.columbia.edu>
>>> To: MITgcm Support <mitgcm-support at mitgcm.org>
>>> Subject: Re: [MITgcm-support] Compiling problem by ifort: undefined
>>> 	reference to '_gfortran_st_write'
>>> Message-ID:
>>> 	<CA+TEG=W3fPFcYnFv1bcPzeP12qGRy254xNZbSbVkD32r35HE8Q at mail.gmail.com
>> 
>>> Content-Type: text/plain; charset="utf-8"
>>> 
>>> Hi H. W. Shu
>>> 
>>> Those are gfortran symbols that the Intel (ifort) compiler is unable 
>> to
>>> find,
>>> most likely when trying to link a library to the main MITgcm code.
>>> 
>>> If your MPI and netCDF libraries were compiled with gfortran,
>>> or, which is more common, if you installed them from packages in 
> your 
>> Linux
>>> distribution,
>>> which normally compiles them with gfortran, it may be easier to try 
> to 
>> use
>>> a build_options file that uses gfortran instead of Intel ifort.
>>> This is probably the shortest path to solve the problem.
>>> 
>>> If you prefer to use ifort, then a more laborious alternative is to 
>> compile
>>> MPI and netCDF
>>> from scratch (i.e., download the MPI and netCDF source code and 
>> compile)
>>> with Intel icc and ifort, and use them to link the MITgcm.
>>> 
>>> I hope this helps,
>>> 
>>> Gus Correa
>>> 
>>> On Tue, Feb 9, 2021 at 1:50 AM H.W. Shu <shawn_chou at ees.hokudai.ac.
> jp>
>>> wrote:
>>> 
>>>> Dear MITgcm users,
>>>> 
>>>> Hello, this is Shawn from Hokkaido University.
>>>> We are trying compiling an mpi run in our system by default 
> compiler 
>> in
>>>> tools/build_options: linux_amd64_ifort
>>>> (we added "-lmpi -03" in flags.)
>>>> 
>>>> However, in the process of Make,
>>>> it told us that "undefined reference to '_gfortran_st_write_done'" 
>> and "
>>>> undefined reference to '_gfortran_transfer'".
>>>> and leaved by this error.
>>>> 
>>>> I am not familiar with compile problems,
>>>> I will really appreciate if can get any hint to start to fix the 
>> problem.
>>>> 
>>>> Thank you really much,
>>>> 
>>>> Best regards,
>>>> Shawn
>>>> 
>>>> 
>>>> _______________________________________________
>>>> MITgcm-support mailing list
>>>> MITgcm-support at mitgcm.org
>>>> http://mailman.mitgcm.org/mailman/listinfo/mitgcm-support
>>>> 
>>> -------------- next part --------------
>>> An HTML attachment was scrubbed...
>>> URL: <http://mailman.mitgcm.org/pipermail/mitgcm-support/attachments/20210209/4985757d/attachment-0001.html>
> 
>> 
>>> 
>>> ------------------------------
>>> 
>>> Subject: Digest Footer
>>> 
>>> _______________________________________________
>>> MITgcm-support mailing list
>>> MITgcm-support at mitgcm.org
>>> http://mailman.mitgcm.org/mailman/listinfo/mitgcm-support
>>> 
>>> 
>>> ------------------------------
>>> 
>>> End of MITgcm-support Digest, Vol 212, Issue 6
>>> **********************************************
>>> 
>> 
>> 
> 
> 
> _______________________________________________
> MITgcm-support mailing list
> MITgcm-support at mitgcm.org
> http://mailman.mitgcm.org/mailman/listinfo/mitgcm-support

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 1665 bytes
Desc: not available
URL: <http://mailman.mitgcm.org/pipermail/mitgcm-support/attachments/20210215/7dae1bf8/attachment.p7s>


More information about the MITgcm-support mailing list