Can't open grib_api.mod

Post any questions or comments regarding the LINUX version of HYSPLIT. This includes the model execution, GUIs, results, or graphics. Be sure to mention the version of LINUX you are using.
Post Reply
zhy566
Posts: 14
Joined: July 2nd, 2017, 11:30 pm
Registered HYSPLIT User: No

Can't open grib_api.mod

Post by zhy566 » September 29th, 2017, 6:01 pm

Hi,
I am having a problem when I am trying to compile api2arl.
I have installed the Gribapi (version 1.23.1) and Jasper (version 2.0) on my server. And I checked that the grib_api.mod exists under ../gribapi/include/grib_api.mod

The command I use to compile is "make -f Makefile_api1.9 api2arl".
Then I got the message:
gfortran -I../../../../grib_api-1.9.18/fortran -g -O2 -fconvert=big-endian -frecord-marker=4 -ffree-form -c -o api2arl_v4.o api2arl_v4.f
api2arl_v4.f:30.14:

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

It seems that it cannot find the grib_api.mod file. Could anyone please tell me what I should do so that it can run properly?
I notice that there is one line in the Makefile_api1.9: "top_builddir = ../../../../grib_api-1.9.18", which is not the correct version and directory of the Gribapi that I installed. Could that be the reason?

Many thanks!

Best,
Yang

Fantine
Posts: 81
Joined: November 8th, 2012, 3:41 pm

Re: Can't open grib_api.mod

Post by Fantine » October 2nd, 2017, 10:20 am

In the Makefile, you should put the path of grib_api library to "top_builddir" and include a correct directory for "grid_api.mod" in the compilation flag.

Example:
top_builddir = /usr
AM_FCFLAGS = -I$(top_builddir)/include -I$(top_builddir)/include/jasper -I$(top_builddir)/lib64/gfortran/modules
LDADD = $(top_builddir)/lib64/libgrib_api_f90.so $(top_builddir)/lib64/libgrib_api.so

The "grib_api.mod" is in /usr/lib64/gfortran/modules directory in this example.

zhy566
Posts: 14
Joined: July 2nd, 2017, 11:30 pm
Registered HYSPLIT User: No

Re: Can't open grib_api.mod

Post by zhy566 » October 2nd, 2017, 12:16 pm

Dear Fantine,

Thank you for your help. I changed the directory and a new error came up.

gfortran -I/opt/gribapi/include -I/opt/jasper -I/opt/gribapi/include -g -O2 -fconvert=big-endian -frecord-marker=4 -ffree-form -c -o api2arl_v4.o api2arl_v4.f
/bin/sh /opt/libtool --tag=FC --mode=link gfortran -I/opt/gribapi/include -I/opt/jasper -I/opt/gribapi/include -g -O2 -fconvert=big-endian -frecord-marker=4 -ffree-form -o /usr/yzhou/hysplit-886/exec/api2arl api2arl_v4.o /opt/gribapi/lib/libgrib_api_f90.so /opt/gribapi/lib/libgrib_api.so -lm -ljasper -L/usr/yzhou/hysplit-886/library -lhysplit
/bin/sh: /opt/libtool: No such file or directory

It seems that the problem belongs to the libtool directory, I looked up my gribapi directory, there is no libtool in it. I was using the Makefile_api1.9 for compiling, should I use the Makefile_api1.8 instead?

From the ECMWF website (https://software.ecmwf.int/wiki/display/GRIB/Home), the gribapi 1.9 is a libtool version, but the version that I have is 1.23.1, which is not noted as libtool version.


Thank you!

Yang

zhy566
Posts: 14
Joined: July 2nd, 2017, 11:30 pm
Registered HYSPLIT User: No

Re: Can't open grib_api.mod

Post by zhy566 » October 2nd, 2017, 2:40 pm

Hi,

I have tried to compile it with Makefile_api1.8. Here are the directories I changed:

EXE=/usr/yzhou/hysplit-886/exec

export GRIB_API_INCLUDE=/opt/gribapi/include
export GRIB_API_LIB=/opt/gribapi/lib

INC=-I/opt/gribapi/include
LIB=-L/opt/gribapi/lib -lgrib_api_f90 -lgrib_api -L/opt/jasper -ljasper -L/usr/yzhou/hysplit-886/library -lhysplit

However, I got the error message: make: *** No rule to make target `api2arl'. Stop.
There is no report on the missing file.

Could anyone please help me about this?
Thank you very much!

Best,
Yang

Fantine
Posts: 81
Joined: November 8th, 2012, 3:41 pm

Re: Can't open grib_api.mod

Post by Fantine » October 2nd, 2017, 3:25 pm

I am using grib_api 1.12.3 with libtool. But it is ok to compile api2arl without libtool.
Edit Makefile and take out libtool from the compilation flag.

zhy566
Posts: 14
Joined: July 2nd, 2017, 11:30 pm
Registered HYSPLIT User: No

Re: Can't open grib_api.mod

Post by zhy566 » October 2nd, 2017, 3:42 pm

Dear Fantine,

Thank you so much for your reply. Could you please tell me more about it?
The variable FCLINK is related to libtool, which is used in api2arl_v4. Relative lines in the makefile are:

LIBTOOL = $(SHELL) $(top_builddir)/libtool
FCLINK = $(LIBTOOL) --tag=FC \
--mode=link $(FCLD) $(AM_FCFLAGS) $(FCFLAGS) $(AM_LDFLAGS) \
$(LDFLAGS) -o $(EXE)/$@
...
...
api2arl: api2arl_v4.o $(api2arl_DEPENDENCIES)
@rm -f api2arl
$(FCLINK) api2arl_v4.o $(api2arl_LDADD) $(LIBS) $(LIBHYS)

I don't have much experience on modifying the makefiles. Could you please tell me how to take out the libtool in this case?

Cheers,
Yang

Fantine
Posts: 81
Joined: November 8th, 2012, 3:41 pm

Re: Can't open grib_api.mod

Post by Fantine » October 3rd, 2017, 9:32 am

Modify the "FCLINK" to remove $LIBTOOL.

Here is what I have in my Makefile:
#LIBTOOL = $(SHELL) $(top_builddir)/bin/libtool
FCLINK = $(FCLD) $(AM_FCFLAGS) $(FCFLAGS) $(AM_LDFLAGS) \
$(LDFLAGS) -o $(EXE)/$@

zhy566
Posts: 14
Joined: July 2nd, 2017, 11:30 pm
Registered HYSPLIT User: No

Re: Can't open grib_api.mod

Post by zhy566 » October 3rd, 2017, 11:45 am

Dear Fantine,

Thank you so so much for your help. I modified the code but it still failed. The message shows as follows:

gfortran -I/opt/gribapi/include -I/opt/jasper -I/opt/gribapi/include -g -O2 -fconvert=big-endian -frecord-marker=4 -ffree-form -c -o api2arl_v4.o api2arl_v4.f
gfortran -I/opt/gribapi/include -I/opt/jasper -I/opt/gribapi/include -g -O2 -fconvert=big-endian -frecord-marker=4 -ffree-form -o /usr/yzhou/hysplit-886/exec/api2arl api2arl_v4.o /opt/gribapi/lib/libgrib_api_f90.so /opt/gribapi/lib/libgrib_api.so -lm -ljasper -L/usr/yzhou/hysplit-886/library -lhysplit
/usr/yzhou/hysplit-886/library/libhysplit.a(pakset.o): In function `pakset_':
pakset.f:(.text+0x65c): undefined reference to `_gfortran_transfer_character_write'
...
pakset.f:(.text+0xecb): undefined reference to `_gfortran_transfer_character_write'
/usr/yzhou/hysplit-886/library/libhysplit.a(pakrec.o): In function `pakrec_':
pakrec.f:(.text+0xdb): undefined reference to `_gfortran_transfer_character_write'
...
pakrec.f:(.text+0x4f7): undefined reference to `_gfortran_transfer_integer_write'
/usr/yzhou/hysplit-886/library/libhysplit.a(pakrec.o):pakrec.f:(.text+0x509): more undefined references to `_gfortran_transfer_integer_write' follow
/usr/yzhou/hysplit-886/library/libhysplit.a(pakrec.o): In function `pakrec_':
pakrec.f:(.text+0x52e): undefined reference to `_gfortran_transfer_character_write'
...
pakrec.f:(.text+0x9bc): undefined reference to `_gfortran_transfer_integer_write'
/usr/yzhou/hysplit-886/library/libhysplit.a(pakrec.o):pakrec.f:(.text+0x9ce): more undefined references to `_gfortran_transfer_integer_write' follow
/usr/yzhou/hysplit-886/library/libhysplit.a(pakrec.o): In function `pakrec_':
pakrec.f:(.text+0xa50): undefined reference to `_gfortran_transfer_character_write'
...
/usr/yzhou/hysplit-886/library/libhysplit.a(pakndx.o):pakndx.f:(.text+0xdb7): more undefined references to `_gfortran_transfer_integer_write' follow
/usr/yzhou/hysplit-886/library/libhysplit.a(pakndx.o): In function `pakndx_':
pakndx.f:(.text+0xde7): undefined reference to `_gfortran_transfer_character_write'
pakndx.f:(.text+0xdfb): undefined reference to `_gfortran_transfer_integer_write'
pakndx.f:(.text+0xe0f): undefined reference to `_gfortran_transfer_real_write'
pakndx.f:(.text+0xe23): undefined reference to `_gfortran_transfer_real_write'
pakndx.f:(.text+0xf03): undefined reference to `_gfortran_transfer_character_write'
pakndx.f:(.text+0xf15): undefined reference to `_gfortran_stop_numeric_f08'
collect2: ld returned 1 exit status
make: *** [api2arl] Error 1

The message is too long so I copied some of the lines here, it seems that the main error is "undefined reference to". What I did in the makefile is changing the directory and modifying the FCLINK. Could you please tell me why is this occurring?

Thank you very much for helping me these days.

Best,
Yang

Fantine
Posts: 81
Joined: November 8th, 2012, 3:41 pm

Re: Can't open grib_api.mod

Post by Fantine » October 3rd, 2017, 5:04 pm

This error message is not related to grib_api and the api2arl program itself.
Check if the HYSPLIT was compiled using gfortran. It seems it is not. You need to use the same compiler to generate the hysplit library and compile api2arl.

Post Reply