Re: [netcdfgroup] combining f77 and f90 modules with netcdf library

  • To: "Goran Georgievski" <goran@xxxxxxx>
  • Subject: Re: [netcdfgroup] combining f77 and f90 modules with netcdf library
  • From: "David Pierce" <dpierce@xxxxxxxx>
  • Date: Thu, 13 Mar 2008 08:56:45 -0700 (PDT)
Hello,

I've never used the ifort compiler so you should take this comment with a
grain of salt, but since the compiler is complaining that it cannot find
the module file, have you made sure it is able to find the module file? 
Circular reasoning, I know, but if it can't find the file, the contents of
that file are probably not the issue.  I.e., have you 1) verified that the
module file exists, and 2) told the compiler how to find it?  With g95 and
gfort, the module file has a ".mod" extension, and you tell the compiler
how to find it with a -I/dir/to/mod/file compiler flag.  The old dec alpha
fortran95 compiler had a strange syntax for telling the compiler where to
find those .mod files, maybe your compiler does too.  I suggest consulting
your compiler's docs to see how it's specified to your compiler, and
making sure the module file exists and you've told the compiler where to
find it.

Regards,

--Dave


Goran Georgievski wrote:
> Dear Dave,
>
> thank you for your answer. I have tried but it does not work, anyway. It
> seems that I have messed up something with headers of fortran files and
> with make file. I will try to fix that during the next days, but if
> somebody has a solution I will be the most thankful to hear it.
>
> Goran
>
> On Wed, 2008-03-12 at 18:03 -0600, Dave Allured wrote:
>> Gorgan,
>>
>> I believe that the statement "use netcdf" is misplaced.  It should
>> be directly below the statement "subroutine write_3d_field", and
>> *not* below the module statement.  Try that.
>>
>> Dave Allured
>> CU/CIRES Climate Diagnostics Center (CDC)
>> http://cires.colorado.edu/science/centers/cdc/
>> NOAA/ESRL/PSD, Climate Analysis Branch (CAB)
>> http://www.cdc.noaa.gov/
>>
>> Goran Georgievski wrote:
>> > Hello,
>> >
>> > I have some read/write modules written in free form fortran (Fortran
>> 90)
>> > and I have some fortran77 code that writes standard fortran binary
>> > files. However, I would prefer to have output in netcdf format. The
>> > question is if I can compile and link, fortran90 netcdf write module
>> > with the fortran 77 code. The platform that I am working on is Linux
>> > with Intel Fortran Compiler 8.1 and netcdf library version 3.6.0-p1.
>> >
>> > ifort compiles the write netcdf module (f90 code), and it compiles the
>> > main code (f77) if I comment the lines that calls netcdf write
>> > subroutines. When I am trying to compile including these lines, ifort
>> > complains that it cannot find the module for writing netcdf. (ERROR in
>> > opening the Library module file [WRITE_3D_NETCDF_FIELD])
>> >
>> > Below are the headers of my netcdf write module and headers of main
>> code
>> > that calls subroutine to write netcdf field, and the makefile that
>> > compiles everything. If somebody could tell me what I am doing wrong
>> and
>> > point me to the solution, I would be the most thankful.
>> >
>> > Goran
>> >
>> > ----netcdf write module f90 code, write_netcdf_3d_field.f90----
>> >
>> >   module write_netcdf_3d_field
>> >   use netcdf
>> >
>> >   implicit none
>> >   contains
>> >
>> >   subroutine write_3d_field(nx,x_axis,ny,y_axis,nz,z_axis,field1,
>> > netcdf_outfile)
>> >   ...
>> >   end subroutine write_3d_field
>> >  end module write_netcdf_3d_field
>> >
>> > ----main program f77 code, m_buildCLM201regionen_eval_oro.f----
>> >
>> >
>> >       PROGRAM m_buildCLM201regionen
>> >       USE write_netcdf_3d_field
>> >       IMPLICIT NONE
>> >
>> >       ....
>> >
>> >       CALL write_3d_field(nxg,x_lon,nyg,y_lat,nzg,z_lev,mask,
>> >      >netcdf_file)
>> >
>> >       STOP
>> >       END
>> >
>> > ---- makefile ----
>> >
>> > #
>> > DEVDIR             = /home/goran/clm/regiomask
>> > REMDIR             = /home/goran/clm/regiomask
>> > EXECUTABLE = buildCLM201regionen_eval_oro.exe
>> > CF         = ifort
>> > FFLAGS             = -O3
>> > NETCDFLIB       = -L/usr/local/lib
>> > NETCDFINC       = -I/usr/local/include
>> > #
>> > #Objektdateien#########################################################
>> > #
>> > OBJFILES =      m_buildCLM201regionen_eval_oro.o \
>> >    r_getcoord.o r_regiomask.o t_createmask.o w_regiomask.o \
>> >                 hnioerr.o write_netcdf_3d_field.o
>> > #
>> > $(EXECUTABLE): $(OBJFILES)
>> >  $(CF) -o $(EXECUTABLE) $(OBJFILES) $(NETCDFLIB) -lnetcdf
>> > ##
>> >
>> >  m_buildCLM201regionen_eval_oro.o:
>> > $(REMDIR)/m_buildCLM201regionen_eval_oro.f ($(CF) $(FFLAGS) -c
>> > $(REMDIR)/m_buildCLM201regionen_eval_oro.f
>> >
>> > r_getcoord.o: $(DEVDIR)/r_getcoord.f
>> >            ($(CF) $(FFLAGS) -c $(DEVDIR)/r_getcoord.f)
>> > r_regiomask.o: $(DEVDIR)/r_regiomask.f
>> >            ($(CF) $(FFLAGS) -c $(DEVDIR)/r_regiomask.f)
>> > t_createmask.o: $(REMDIR)/t_createmask.f
>> >            ($(CF) $(FFLAGS) -c $(REMDIR)/t_createmask.f)
>> > w_regiomask.o: $(DEVDIR)/w_regiomask.f
>> >                    ($(CF) $(FFLAGS) -c $(DEVDIR)/w_regiomask.f)
>> > hnioerr.o : $(DEVDIR)/hnioerr.f90
>> >                ($(CF) $(FFLAGS) -c $(DEVDIR)/hnioerr.f90 $(NETCDFINC))
>> > write_netcdf_3d_field.o : $(DEVDIR)/write_netcdf_3d_field.f90
>> >                         ($(CF) $(FFLAGS) -c
>> > $(DEVDIR)/write_netcdf_3d_field.f90 $(NETCDFINC))
>> >
>> >
>> >
>> > _______________________________________________
>> > netcdfgroup mailing list
>> > netcdfgroup@xxxxxxxxxxxxxxxx
>> > For list information or to unsubscribe,  visit:
>> http://www.unidata.ucar.edu/mailing_lists/
>>
>> _______________________________________________
>> netcdfgroup mailing list
>> netcdfgroup@xxxxxxxxxxxxxxxx
>> For list information or to unsubscribe,  visit:
>> http://www.unidata.ucar.edu/mailing_lists/
>>
>
> _______________________________________________
> netcdfgroup mailing list
> netcdfgroup@xxxxxxxxxxxxxxxx
> For list information or to unsubscribe,  visit:
> http://www.unidata.ucar.edu/mailing_lists/
>


-------------------------------------------------------------------
David W. Pierce
Division of Climate, Atmospheric Science, and Physical Oceanography
Scripps Institution of Oceanography
(858) 534-8276 (voice)  /  (858) 534-8561 (fax)    dpierce@xxxxxxxx
-------------------------------------------------------------------



  • 2008 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdfgroup archives: