Topic: Fortran Version error

Hi,
I'm new to simply fortran (and fortran in general) so this could be a newbie mistake.  I'm trying to compile someone else's code, which I assume is in F77 (.f extension)
The first problem was module & end statements occuring at the start or the line instead of at the 6th character causing an error.  I added some spaces and the error went away.  But I'm getting this error now:

Compiling mod_param.F
Compiling mod_global.F
mod_global.F:2.10:

       USE PARAM                                                       
          1
Fatal Error: Cannot read module file 'param.mod' opened at (1), because it was created by a different version of GNU Fortran
Error(E42): Last command making (build\mod_global.o) returned a bad status
Error(E02): Make execution terminated

Yes I cleaned before building, so I don't know where the error is comming from as SF is trying to read a file it created.

Re: Fortran Version error

This error means that the Fortran compiler did find a "param.mod" that it hadn't compiled itself.  There is most likely a file in the base directory of your project named "param.mod."  Simply Fortran, by default, writes all modules into a modules subdirectory, and, when you select "Clean" from the Build menu, it will delete modules only in that directory that it had created.

When you were given the code to compile, was there a "param.mod" (or any other ".mod" file) included with it?   You'll want to delete all ".mod" files provided with the code base before attempting to compile it.

Jeff Armstrong
Approximatrix, LLC

Re: Fortran Version error

That fixed it, thanks!

I worked through a few other problems but am stuck on this one:
D:\Projects\Funwave\Code\funwave-version2.1\src/init.F:874: undefined reference to `wk_wavemaker_time_series_'

But it is in the same file:
SUBROUTINE WK_WAVEMAKER_TIME_SERIES &
               (NumWaveComp,WAVE_COMP,PeakPeriod,H_gen,delta,D_gen,beta_gen,width)

Do you have any suggestions for this one?  Is there a reason why it cant see something lower in the file?

Re: Fortran Version error

Cancel that last one, there is this before the routines that are missing:
# if defined (SAMPLES)
And so added the flag -DSAMPLES and it has worked.

As a more general question, there is a make file included with the source files:  What is the best way to handle the details in this file?  Can that make file be run from SF?  Or should I copy the flags into the project options?

Also, it would be nice to be able to run this in parallel - the original makefile is looking for mpif90.  What do I need to do to be able to enable this?


Here is the supplied make file if that helps at all:

#-----------BEGIN MAKEFILE-------------------------------------------------
            SHELL         = /bin/sh
            DEF_FLAGS     = -P -C -traditional
            EXEC          = mytvd
#==========================================================================
#--------------------------------------------------------------------------
#        PRECISION          DEFAULT PRECISION: SINGLE
#                           UNCOMMENT TO SELECT DOUBLE PRECISION
#--------------------------------------------------------------------------

#            FLAG_1 = -DDOUBLE_PRECISION
            FLAG_2 = -DPARALLEL
            FLAG_3 = -DSAMPLES
            FLAG_4 = -DCARTESIAN
#              FLAG_6 = -DINTEL
             FLAG_7 = -DMIXING
#             FLAG_8 = -DCOUPLING
#             FLAG_9 = -DZALPHA
#             FLAG_10 = -DMANNING

#--------------------------------------------------------------------------
#  mpi defs
#--------------------------------------------------------------------------
         CPP      = /usr/bin/cpp
         CPPFLAGS = $(DEF_FLAGS)
#         FC       = gfortran
         FC        = mpif90
         DEBFLGS  =
         OPT      =
         CLIB     =
#==========================================================================

         FFLAGS = $(DEBFLGS) $(OPT)
         MDEPFLAGS = --cpp --fext=f90 --file=-
         RANLIB = ranlib
#--------------------------------------------------------------------------
#  CAT Preprocessing Flags
#--------------------------------------------------------------------------
           CPPARGS = $(CPPFLAGS) $(DEF_FLAGS) $(FLAG_1) $(FLAG_2) \
            $(FLAG_3) $(FLAG_4) $(FLAG_5) $(FLAG_6) \
            $(FLAG_7) $(FLAG_8) $(FLAG_9) $(FLAG_10)  \
            $(FLAG_11) $(FLAG_12) $(FLAG_13) $(FLAG_14) \
            $(FLAG_15) $(FLAG_16) $(FLAG_17) $(FLAG_18) \
            $(FLAG_19) $(FLAG_20) $(FLAG_21) $(FLAG_22) \
            $(FLAG_23) $(FLAG_24)
#--------------------------------------------------------------------------
#  Libraries
#--------------------------------------------------------------------------

#            LIBS  = $(PV3LIB) $(CLIB)  $(PARLIB) $(IOLIBS) $(MPILIB) $(GOTMLIB)
#            INCS  = $(IOINCS) $(GOTMINCS)


#--------------------------------------------------------------------------
#  Preprocessing and Compilation Directives
#--------------------------------------------------------------------------
.SUFFIXES: .o .f90 .F .F90

.F.o:
    $(CPP) $(CPPARGS) $*.F > $*.f90
    $(FC)  -c $(FFLAGS) $(INCS) $*.f90
#    \rm $*.f90
#--------------------------------------------------------------------------
#  FUNWAVE-TVD Source Code.
#--------------------------------------------------------------------------

MODS  = mod_param.F    mod_global.F    mod_util.F \

MAIN  = main.F bc.F fluxes.F init.F io.F trid.F       \

SRCS = $(MODS)  $(MAIN)

OBJS = $(SRCS:.F=.o)

#--------------------------------------------------------------------------
#  Linking Directives
#--------------------------------------------------------------------------

$(EXEC):    $(OBJS)
        $(FC) $(FFLAGS) $(LDFLAGS) -o $(EXEC) $(OBJS) $(LIBS)
    mv $(EXEC) ../work/.
#--------------------------------------------------------------------------

#--------------------------------------------------------------------------
#  Tar Up Code
#--------------------------------------------------------------------------

tarfile:
    tar cvf funwave_tvd.tar *.F  Makefile

#--------------------------------------------------------------------------
#  Cleaning targets.
#--------------------------------------------------------------------------

clean:
        /bin/rm -f *.o *.mod

clobber:    clean
        /bin/rm -f *.f90 *.o mytvd

Re: Fortran Version error

Simply Fortran cannot use an existing makefile. When you build using Simply Fortran, it creates its own makefile, but it wouldn't be able to use a different one (generally speaking, at least).  In your case, the makefile really isn't doing anything complicated.  I would suggest adding the flags that aren't commented to the Fortran compiler flags for your project in Simply Fortran:

-DPARALLEL -DSAMPLES -DCARTESIAN -DMIXING

Simply Fortran doesn't support the MPI form of parallel coding that the compiler command mpif90 implies.  Instead, it does support OpenMP, which is generally finer-grained, single-system parallel processing.

Jeff Armstrong
Approximatrix, LLC

Re: Fortran Version error

Thanks for your patient replys Jeff.
What's involved in employing openmp?  I assume that if I simply set the -fopenmp flag will it won't make any difference.  There are sections of code that are dependant on the -dparallel flag, and apart from " use mpi" it has compiled. Is it likely that these sections of code will apply to openmp too, or do they need to be recoded for open mp?  I tried "use openmp" and it compiled, but I don't know how it will affect the program.
Really enjoying the SF by the way.  I've struggled with compiling this on Linux for some time and SF has made it seem a breeze by comparison.

Re: Fortran Version error

To enable OpenMP, you only need to either add the -fopenmp flag or, alternatively, check "Enable OpenMP" under the Fortran tab in Project Options (accessible from the Options menu). 

Using OpenMP in your code is rather easy.  Basically, you just specify OpenMP directives in specially formatted comments  that instruct the compiler and runtime how to handle certain portions of your code.  Simply Fortran does provide an example project  by default that shows a simple example of executing multiple threads.  If you're looking for some examples, this site has a nice set of examples in fixed-format Fortran.

OpenMP is not a drop-in replacement for MPI.  If your code was designed to implement MPI, you'll have some work to do to port it to OpenMP.  The -dparallel flag would be specific to your code only; it doesn't have any special meaning outside that context.   

I'm glad Simply Fortran is meeting your needs, though.   If you have any questions, feel free to post them here!

Jeff Armstrong
Approximatrix, LLC