Problem compiling read_wrf_nc.f

Any problems/questions that might not fall into the other topics in this category.

Problem compiling read_wrf_nc.f

Postby Dred » Sun Jun 26, 2011 3:58 pm

I was about to post a request for assistance with a problem we were having compiling the utility program: read_wrf_nc.f but solved it myself. In the process of solving it I realized that the documentation is missing a key library, so I've decided to post the problem and the solution.

Objective: compile read_wrf_nc.f

Using instruction from this web site:
http://www.mmm.ucar.edu/wrf/OnLineTutor ... wrf_nc.htm

Issued the following instruction:
pgf90 read_wrf_nc.f -L/usr/local/netcdf/lib -lnetcdf -lm
-I/usr/local/netcdf/include -Mfree -o read_wrf_nc

...where /usr/local/netcdf was replaced with the correct path to our local install of netcdf.

The compile created the file: map_utils.mod and then died with the following error message:

/tmp/pgf90qkTWhJLBKZg.o: In function `get_info_from_cdf_':
..../wrf_utils/./read_wrf_nc.f:790: undefined reference to `nf_open_'
..../wrf_utils/./read_wrf_nc.f:793: undefined reference to `nf_open_'
..../wrf_utils/./read_wrf_nc.f:802: undefined reference to `nf_inq_varid_'
..../wrf_utils/./read_wrf_nc.f:811: undefined reference to `ncvid_'
...... this goes on for almost 100 lines .......

"undefined reference to ...." errors almost always point to a missing library link.

In this case I suspected the libnetcf.a library so I did:
nm /...path to.../libnetcdf.a | grep nf_open

This return nothing.... then I remembered that the configure.wrf file contained library links to not only libnetcdf.a (via -lnetcdf ) but also: libnetcdff.a (via -lnetcdff )

So I ran the 'nm' command again, but this time with libnetcdff.a and it returned a hit:
o[ebensman@newcell wrf_utils]$ nm $NETCDF/lib/libnetcdff.a | grep nf_open
0000000000000670 T nf_open_
U nf_open_

This told me that I was missing the library: libnetcdff.a

So I modified the instruction line provided at the web site above to read:
pgf90 read_wrf_nc.f -L/usr/local/netcdf/lib -lnetcdf -lnetcdff -L/usr/lib64 -lm
-I/usr/local/netcdf/include -Mfree -o read_wrf_nc

This created a working executable: read_wrf_nc

The pieces I added are in red text above. In addition to adding the -lnetcdff link I also added: -L/usr/lib64 in front of -lm because our version of libm.a is in /usr/lib64 not in the directory for $NETCDF/lib
Dred
 
Posts: 3
Joined: Fri May 16, 2008 10:16 pm

Re: Problem compiling read_wrf_nc.f

Postby sushant » Thu Apr 18, 2013 2:15 am

Hi
I am facing problem in compiling read_wrf.nc.f program. I am using ifort. So i use following flag

ifort read_wrf_nc.f -L/usr/local/netcdf/lib -lnetcdf -lnetcdff -L/usr/lib -lm -I/usr/local/netcdf/include -Mfree -o read_wrf_nc

but still not able to resolve the error. Error message is as :


ifort: Command line warning: ignoring unknown option '-Mfree'
fortcom: Error: Illegal character in statement label field [M]
fortcom: Error: Illegal character in statement label field [O]
fortcom: Error: Illegal character in statement label field [D]
fortcom: Error: Illegal character in statement label field [U]
fortcom: Error: Illegal character in statement label field [L]
fortcom: Error: First statement in file must not be continued
fortcom: Error: read_wrf_nc.f, line 187: Illegal character in statement label field [T]
TYPE proj_info
--^
fortcom: Error: read_wrf_nc.f, line 187: Illegal character in statement label field [Y]
TYPE proj_info
---^
fortcom: Error: read_wrf_nc.f, line 187: Illegal character in statement label field [P]
TYPE proj_info
----^
fortcom: Error: read_wrf_nc.f, line 185: Lead underscore not allowed
MODULE map_utils
----------^
fortcom: Error: read_wrf_nc.f, line 185: Syntax error, found IDENTIFIER '_UTILSPROJ_INFO' when expecting one of: <END-OF-STATEMENT> ;
MODULE map_utils
----------^
fortcom: Error: read_wrf_nc.f, line 214: Illegal character in statement label field [E]
END TYPE proj_info
--^
fortcom: Error: read_wrf_nc.f, line 214: Illegal character in statement label field [N]
END TYPE proj_info
---^
fortcom: Error: read_wrf_nc.f, line 214: Illegal character in statement label field [D]
END TYPE proj_info
----^
fortcom: Error: read_wrf_nc.f, line 216: Illegal character in statement label field [C]
CONTAINS
-^
fortcom: Error: read_wrf_nc.f, line 216: Illegal character in statement label field [O]
CONTAINS
--^
fortcom: Error: read_wrf_nc.f, line 216: Illegal character in statement label field [N]
CONTAINS
---^
fortcom: Error: read_wrf_nc.f, line 216: Illegal character in statement label field [T]
CONTAINS
----^
fortcom: Error: read_wrf_nc.f, line 219: Illegal character in statement label field [S]
SUBROUTINE latlon_to_ij(cdfid, proj, ts_ll, ts_xy )
---^
fortcom: Error: read_wrf_nc.f, line 219: Illegal character in statement label field [U]
SUBROUTINE latlon_to_ij(cdfid, proj, ts_ll, ts_xy )
----^
fortcom: Error: read_wrf_nc.f, line 266: Illegal character in statement label field [E]
END SUBROUTINE latlon_to_ij
---^
fortcom: Error: read_wrf_nc.f, line 266: Illegal character in statement label field [N]
END SUBROUTINE latlon_to_ij
----^
fortcom: Error: read_wrf_nc.f, line 269: Illegal character in statement label field [S]
SUBROUTINE llij_ps(lat,lon,proj,i,j)
---^
fortcom: Error: read_wrf_nc.f, line 269: Illegal character in statement label field [U]
SUBROUTINE llij_ps(lat,lon,proj,i,j)
----^
fortcom: Error: read_wrf_nc.f, line 308: Syntax error, found END-OF-STATEMENT when expecting one of: , )
proj%rsw = proj%rebydx*COS(ala1)*scale_top/(1.+proj%hemi*SIN(ala1))
-------------------------------------------------------------------------^
fortcom: Error: read_wrf_nc.f, line 324: Illegal character in statement label field [E]
END SUBROUTINE llij_ps
---^
fortcom: Error: read_wrf_nc.f, line 324: Illegal character in statement label field [N]
END SUBROUTINE llij_ps
----^
fortcom: Error: read_wrf_nc.f, line 327: Illegal character in statement label field [S]
SUBROUTINE llij_lc( lat, lon, proj, i, j)
---^
fortcom: Error: read_wrf_nc.f, line 327: Illegal character in statement label field [U]
SUBROUTINE llij_lc( lat, lon, proj, i, j)
----^
fortcom: Error: read_wrf_nc.f, line 367: Syntax error, found '&' when expecting one of: ( <IDENTIFIER> <CHAR_CON_KIND_PARAM> <CHAR_NAM_KIND_PARAM> <CHARACTER_CONSTANT> <INTEGER_CONSTANT> ...
proj%rsw = proj%rebydx * ctl1r/proj%cone * &
-------------------------------------------------^
fortcom: Severe: Too many errors, exiting
compilation aborted for read_wrf_nc.f (code 1)



any suggestion on this issue?


Thanks
sushant
 
Posts: 10
Joined: Sat Apr 19, 2008 2:08 am

Re: Problem compiling read_wrf_nc.f

Postby cxiao » Tue Nov 19, 2013 11:49 am

sushant wrote:Hi
I am facing problem in compiling read_wrf.nc.f program. I am using ifort. So i use following flag

ifort read_wrf_nc.f -L/usr/local/netcdf/lib -lnetcdf -lnetcdff -L/usr/lib -lm -I/usr/local/netcdf/include -Mfree -o read_wrf_nc

but still not able to resolve the error. Error message is as :


ifort: Command line warning: ignoring unknown option '-Mfree'
fortcom: Error: Illegal character in statement label field [M]
fortcom: Error: Illegal character in statement label field [O]
fortcom: Error: Illegal character in statement label field [D]
fortcom: Error: Illegal character in statement label field [U]
fortcom: Error: Illegal character in statement label field [L]
fortcom: Error: First statement in file must not be continued
fortcom: Error: read_wrf_nc.f, line 187: Illegal character in statement label field [T]
TYPE proj_info
--^
fortcom: Error: read_wrf_nc.f, line 187: Illegal character in statement label field [Y]
TYPE proj_info
---^
fortcom: Error: read_wrf_nc.f, line 187: Illegal character in statement label field [P]
TYPE proj_info
----^
fortcom: Error: read_wrf_nc.f, line 185: Lead underscore not allowed
MODULE map_utils
----------^
fortcom: Error: read_wrf_nc.f, line 185: Syntax error, found IDENTIFIER '_UTILSPROJ_INFO' when expecting one of: <END-OF-STATEMENT> ;
MODULE map_utils
----------^
fortcom: Error: read_wrf_nc.f, line 214: Illegal character in statement label field [E]
END TYPE proj_info
--^
fortcom: Error: read_wrf_nc.f, line 214: Illegal character in statement label field [N]
END TYPE proj_info
---^
fortcom: Error: read_wrf_nc.f, line 214: Illegal character in statement label field [D]
END TYPE proj_info
----^
fortcom: Error: read_wrf_nc.f, line 216: Illegal character in statement label field [C]
CONTAINS
-^
fortcom: Error: read_wrf_nc.f, line 216: Illegal character in statement label field [O]
CONTAINS
--^
fortcom: Error: read_wrf_nc.f, line 216: Illegal character in statement label field [N]
CONTAINS
---^
fortcom: Error: read_wrf_nc.f, line 216: Illegal character in statement label field [T]
CONTAINS
----^
fortcom: Error: read_wrf_nc.f, line 219: Illegal character in statement label field [S]
SUBROUTINE latlon_to_ij(cdfid, proj, ts_ll, ts_xy )
---^
fortcom: Error: read_wrf_nc.f, line 219: Illegal character in statement label field [U]
SUBROUTINE latlon_to_ij(cdfid, proj, ts_ll, ts_xy )
----^
fortcom: Error: read_wrf_nc.f, line 266: Illegal character in statement label field [E]
END SUBROUTINE latlon_to_ij
---^
fortcom: Error: read_wrf_nc.f, line 266: Illegal character in statement label field [N]
END SUBROUTINE latlon_to_ij
----^
fortcom: Error: read_wrf_nc.f, line 269: Illegal character in statement label field [S]
SUBROUTINE llij_ps(lat,lon,proj,i,j)
---^
fortcom: Error: read_wrf_nc.f, line 269: Illegal character in statement label field [U]
SUBROUTINE llij_ps(lat,lon,proj,i,j)
----^
fortcom: Error: read_wrf_nc.f, line 308: Syntax error, found END-OF-STATEMENT when expecting one of: , )
proj%rsw = proj%rebydx*COS(ala1)*scale_top/(1.+proj%hemi*SIN(ala1))
-------------------------------------------------------------------------^
fortcom: Error: read_wrf_nc.f, line 324: Illegal character in statement label field [E]
END SUBROUTINE llij_ps
---^
fortcom: Error: read_wrf_nc.f, line 324: Illegal character in statement label field [N]
END SUBROUTINE llij_ps
----^
fortcom: Error: read_wrf_nc.f, line 327: Illegal character in statement label field [S]
SUBROUTINE llij_lc( lat, lon, proj, i, j)
---^
fortcom: Error: read_wrf_nc.f, line 327: Illegal character in statement label field [U]
SUBROUTINE llij_lc( lat, lon, proj, i, j)
----^
fortcom: Error: read_wrf_nc.f, line 367: Syntax error, found '&' when expecting one of: ( <IDENTIFIER> <CHAR_CON_KIND_PARAM> <CHAR_NAM_KIND_PARAM> <CHARACTER_CONSTANT> <INTEGER_CONSTANT> ...
proj%rsw = proj%rebydx * ctl1r/proj%cone * &
-------------------------------------------------^
fortcom: Severe: Too many errors, exiting
compilation aborted for read_wrf_nc.f (code 1)



any suggestion on this issue?


Thanks

I use gcc/gfortran and find the similar errors.

Line 282: module_internal_header_util.f(1): error #5149: Illegal character in statement label field [M]
Line 285: module_internal_header_util.f(1): error #5149: Illegal character in statement label field [O]
Line 288: module_internal_header_util.f(1): error #5149: Illegal character in statement label field [D]
Line 291: module_internal_header_util.f(1): error #5149: Illegal character in statement label field [U]
Line 294: module_internal_header_util.f(1): error #5149: Illegal character in statement label field [L]
Line 297: module_internal_header_util.f(1): error #5118: First statement in file must not be continued
cxiao
 
Posts: 15
Joined: Wed Nov 13, 2013 11:31 am

Re: Problem compiling read_wrf_nc.f

Postby cxiao » Fri Nov 22, 2013 2:34 pm

I solved this problem by recompiling mpich using gcc/gfortran.
cxiao
 
Posts: 15
Joined: Wed Nov 13, 2013 11:31 am

Re: Problem compiling read_wrf_nc.f

Postby packard » Fri Apr 25, 2014 10:41 pm

Use -free instead of -Mfree may help.

sushant wrote:Hi
I am facing problem in compiling read_wrf.nc.f program. I am using ifort. So i use following flag

ifort read_wrf_nc.f -L/usr/local/netcdf/lib -lnetcdf -lnetcdff -L/usr/lib -lm -I/usr/local/netcdf/include -Mfree -o read_wrf_nc

but still not able to resolve the error. Error message is as :


ifort: Command line warning: ignoring unknown option '-Mfree'
fortcom: Error: Illegal character in statement label field [M]
fortcom: Error: Illegal character in statement label field [O]
fortcom: Error: Illegal character in statement label field [D]
fortcom: Error: Illegal character in statement label field [U]
fortcom: Error: Illegal character in statement label field [L]
fortcom: Error: First statement in file must not be continued
fortcom: Error: read_wrf_nc.f, line 187: Illegal character in statement label field [T]
TYPE proj_info
--^
fortcom: Error: read_wrf_nc.f, line 187: Illegal character in statement label field [Y]
TYPE proj_info
---^
fortcom: Error: read_wrf_nc.f, line 187: Illegal character in statement label field [P]
TYPE proj_info
----^
fortcom: Error: read_wrf_nc.f, line 185: Lead underscore not allowed
MODULE map_utils
----------^
fortcom: Error: read_wrf_nc.f, line 185: Syntax error, found IDENTIFIER '_UTILSPROJ_INFO' when expecting one of: <END-OF-STATEMENT> ;
MODULE map_utils
----------^
fortcom: Error: read_wrf_nc.f, line 214: Illegal character in statement label field [E]
END TYPE proj_info
--^
fortcom: Error: read_wrf_nc.f, line 214: Illegal character in statement label field [N]
END TYPE proj_info
---^
fortcom: Error: read_wrf_nc.f, line 214: Illegal character in statement label field [D]
END TYPE proj_info
----^
fortcom: Error: read_wrf_nc.f, line 216: Illegal character in statement label field [C]
CONTAINS
-^
fortcom: Error: read_wrf_nc.f, line 216: Illegal character in statement label field [O]
CONTAINS
--^
fortcom: Error: read_wrf_nc.f, line 216: Illegal character in statement label field [N]
CONTAINS
---^
fortcom: Error: read_wrf_nc.f, line 216: Illegal character in statement label field [T]
CONTAINS
----^
fortcom: Error: read_wrf_nc.f, line 219: Illegal character in statement label field [S]
SUBROUTINE latlon_to_ij(cdfid, proj, ts_ll, ts_xy )
---^
fortcom: Error: read_wrf_nc.f, line 219: Illegal character in statement label field [U]
SUBROUTINE latlon_to_ij(cdfid, proj, ts_ll, ts_xy )
----^
fortcom: Error: read_wrf_nc.f, line 266: Illegal character in statement label field [E]
END SUBROUTINE latlon_to_ij
---^
fortcom: Error: read_wrf_nc.f, line 266: Illegal character in statement label field [N]
END SUBROUTINE latlon_to_ij
----^
fortcom: Error: read_wrf_nc.f, line 269: Illegal character in statement label field [S]
SUBROUTINE llij_ps(lat,lon,proj,i,j)
---^
fortcom: Error: read_wrf_nc.f, line 269: Illegal character in statement label field [U]
SUBROUTINE llij_ps(lat,lon,proj,i,j)
----^
fortcom: Error: read_wrf_nc.f, line 308: Syntax error, found END-OF-STATEMENT when expecting one of: , )
proj%rsw = proj%rebydx*COS(ala1)*scale_top/(1.+proj%hemi*SIN(ala1))
-------------------------------------------------------------------------^
fortcom: Error: read_wrf_nc.f, line 324: Illegal character in statement label field [E]
END SUBROUTINE llij_ps
---^
fortcom: Error: read_wrf_nc.f, line 324: Illegal character in statement label field [N]
END SUBROUTINE llij_ps
----^
fortcom: Error: read_wrf_nc.f, line 327: Illegal character in statement label field [S]
SUBROUTINE llij_lc( lat, lon, proj, i, j)
---^
fortcom: Error: read_wrf_nc.f, line 327: Illegal character in statement label field [U]
SUBROUTINE llij_lc( lat, lon, proj, i, j)
----^
fortcom: Error: read_wrf_nc.f, line 367: Syntax error, found '&' when expecting one of: ( <IDENTIFIER> <CHAR_CON_KIND_PARAM> <CHAR_NAM_KIND_PARAM> <CHARACTER_CONSTANT> <INTEGER_CONSTANT> ...
proj%rsw = proj%rebydx * ctl1r/proj%cone * &
-------------------------------------------------^
fortcom: Severe: Too many errors, exiting
compilation aborted for read_wrf_nc.f (code 1)



any suggestion on this issue?


Thanks
packard
 
Posts: 6
Joined: Fri Apr 25, 2014 10:33 pm

Re: Problem compiling read_wrf_nc.f

Postby JialiFeng » Tue Jun 26, 2018 11:29 am

Hi,

I also have problems when I complied the read_wrf_nc.f file. I am using the following command:

gfortran read_wrd_nc.f -L/home/netcdf/liblib -lnetcdf -lm -I/home/netcdf/include -Mfree -o read_wrf_nc

The error showed that --
gfortran: error: unrecognized command line option '-Mfree'

Is there anyone can help me please?

Thanks a lot.

Jiali
JialiFeng
 
Posts: 2
Joined: Tue Jun 26, 2018 11:15 am

Re: Problem compiling read_wrf_nc.f

Postby dcvz » Wed Jun 27, 2018 2:04 am

First, edit read_wrf_nc.f to comment out this line:
integer, external :: iargc

Compile with gfortran:
gfortran read_wrf_nc.f -L/usr/local/netcdf/lib -lnetcdf -lm \
-I/usr/local/netcdf/include -ffree-form -o read_wrf_nc

or ifort:
ifort read_wrf_nc.f -L/usr/local/netcdf/lib -lnetcdf -lm \
-I/usr/local/netcdf/include -free -o read_wrf_nc

The compiler you should use depends on the compiler used to compile netcdf.
dcvz
 
Posts: 165
Joined: Tue Apr 15, 2008 12:02 am


Return to Miscellaneous

Who is online

Users browsing this forum: No registered users and 4 guests