gfortran on Mac
gfortran on Mac
I am trying to get started on using ROMS. Has anybody compiled ROMS using gfortran (f95 compiler) on a mac?
gfortran on mac
I successfully compiled ROMS on a mac using gfortran. The key for me was to use FFLAGS = -ff2c (courtesy of M. Hadfield). Also, I had to rewrite the declarations in mod_strings.f to read
character (len=80) :: my_os = "Darwin"
character (len=80) :: my_cpu = "macosx"
character (len=80) :: my_fort = "gfortran"
character (len=80) :: my_fc = "gfortran"
character (len=160) :: my_fflags = "-ff2c"
This was necessary because the assignments weren't working properly for my system.
I haven't had a chance yet to see if the compiled program actually works.
character (len=80) :: my_os = "Darwin"
character (len=80) :: my_cpu = "macosx"
character (len=80) :: my_fort = "gfortran"
character (len=80) :: my_fc = "gfortran"
character (len=160) :: my_fflags = "-ff2c"
This was necessary because the assignments weren't working properly for my system.
I haven't had a chance yet to see if the compiled program actually works.
It works for me; I build gfortran from the gcc CVS repository. The problem with mod_strings.f90 is annoying enough that I use this nasty hack.
In makefile:
Where fixString.sh contains this:
Someone who really understands GNU make will probably laugh, but it beats fixing the strings manually every time you recompile. Cleaner solutions welcome!
In makefile:
Code: Select all
%.f90: %.F
$(CPP) $(CPPFLAGS) $< > $*.f90
sh fixStrings.sh $*.f90
$(CLEAN) $*.f90
Code: Select all
#!/bin/sh
if [ $1 = "mod_strings.f90" ]; then
sed -E -e 's/(my_[a-z]+ = )(.*$)/\1'"'\2'"'/g' $1 >$1.bak
mv $1.bak $1
fi
-
- Posts: 4
- Joined: Wed Dec 22, 2004 5:50 pm
- Location: California Polytechnic State University
mod_strings on Mac
I'm compiling on a Mac, and also had problems with mod_strings.F. Here is my hack. I don't know if this is really cleaner or not, but it is a simple one-time fix that doesn't need an external shell script.amaxwell wrote:It works for me; I build gfortran from the gcc CVS repository. The problem with mod_strings.f90 is annoying enough that I use this nasty hack.
In makefile:Where fixString.sh contains this:Code: Select all
%.f90: %.F $(CPP) $(CPPFLAGS) $< > $*.f90 sh fixStrings.sh $*.f90 $(CLEAN) $*.f90
Someone who really understands GNU make will probably laugh, but it beats fixing the strings manually every time you recompile. Cleaner solutions welcome!Code: Select all
#!/bin/sh if [ $1 = "mod_strings.f90" ]; then sed -E -e 's/(my_[a-z]+ = )(.*$)/\1'"'\2'"'/g' $1 >$1.bak mv $1.bak $1 fi
In makefile:
Code: Select all
#--------------------------------------------------------------------------
# Special CPP macros for mod_strings.F
#--------------------------------------------------------------------------
# Default special macro:
#mod_strings.f90: CPPFLAGS += -DMY_OS="'$(OS)'" -DMY_CPU="'$(CPU)'" \
# -DMY_FORT="'$(FORT)'" -DMY_FC="'$(FC)'" \
# -DMY_FFLAGS="'$(FFLAGS)'"
# New and improved macro:
mod_strings.f90: CPPFLAGS += -DMY_OS='"$(OS)"' -DMY_CPU='"$(CPU)"' \
-DMY_FORT='"$(FORT)"' -DMY_FC='"$(FC)"' \
-DMY_FFLAGS='"$(FFLAGS)"'
Hope this is helpful to someone.
Re: mod_strings on Mac
It's wonderful as long as it doesn't mess up on any other system. I was having Mac troubles too and couldn't find the right quote combination.choboter wrote:
I'm compiling on a Mac, and also had problems with mod_strings.F. Here is my hack. I don't know if this is really cleaner or not, but it is a simple one-time fix that doesn't need an external shell script.
In makefile:where the default special macro was already present in the makefile, and the new macro is identical, except that the double and single quotation marks have been reversed.Code: Select all
#-------------------------------------------------------------------------- # Special CPP macros for mod_strings.F #-------------------------------------------------------------------------- # Default special macro: #mod_strings.f90: CPPFLAGS += -DMY_OS="'$(OS)'" -DMY_CPU="'$(CPU)'" \ # -DMY_FORT="'$(FORT)'" -DMY_FC="'$(FC)'" \ # -DMY_FFLAGS="'$(FFLAGS)'" # New and improved macro: mod_strings.f90: CPPFLAGS += -DMY_OS='"$(OS)"' -DMY_CPU='"$(CPU)"' \ -DMY_FORT='"$(FORT)"' -DMY_FC='"$(FC)"' \ -DMY_FFLAGS='"$(FFLAGS)"'
Hope this is helpful to someone.
Re: mod_strings on Mac
Hear hear! Better than my solution. I thought I tried just about every combination of quotes before giving up in disgust, but I must have missed at least one.kate wrote: It's wonderful as long as it doesn't mess up on any other system. I was having Mac troubles too and couldn't find the right quote combination.