Installing ROMS on a windows XP laptop

Discussion on computers, ROMS installation and compiling

Moderators: arango, robertson

Post Reply
Message
Author
valere

Installing ROMS on a windows XP laptop

#1 Post by valere » Thu Aug 03, 2006 2:28 pm

Dear all,
I'm trying to install ROMS on a windows XP laptop.
First, I have installed the netcdf librairy for matlab and second Cygwin, with the ar, flex, yacc, makeinfo, autoconf, tcsh packages and gcc, g++ and g77 compilers. All this allowed me to install netcdf for g77 in the /usr/local directory.
Then I tried to redo the Peruvian example, as it has been provided by Pierrick Penven.
There is no problem with the matlab routines start, make_grid, make_forcing andmake_clim, that generate netcdf files.
The next step consist in compiling ROMS, thanks to jobcomp. Since I use g77, I used this jobcomp:

#!/bin/tcsh
####################################################
# COMPILATION JOB #
####################################################
#
# set source, compilation and run directories
#
set SOURCE=../Roms_Agrif
set SCRDIR=../Compile
set RUNDIR=`pwd`

#
# Linux compiler options (only relevant to Linux OS)
#
set LINUX_FC=g77
#
# set 32 or 64 Bits executable
#
set BITS=THIRTYTWO
#
# set NETCDF directories
#
set NETCDFLIB=-L/usr/local/lib/
set NETCDFINC=-I/usr/local/include/
#
# END OF USER'S MODIFICATIONS
####################################################

#
# Use GNU Make command
#
set MAKE = make
#
# clean scratch area
#
rm -rf $SCRDIR
mkdir $SCRDIR
#
# copy SOURCE code
#
cp -f ${SOURCE}/*.F $SCRDIR
cp -f ${SOURCE}/*.h $SCRDIR
cp -f ${SOURCE}/Make* $SCRDIR
cp -f ${SOURCE}/testkeys $SCRDIR
cp -f valwinrun ${SOURCE}
cp -f ${SOURCE}/jobcomp $SCRDIR
cp -f ${SOURCE}/amr.in $SCRDIR
cp -Rf ${SOURCE}/AGRIFZOOM $SCRDIR
#
# overwrite with local files
#
cp -f *.F $SCRDIR
cp -f Make* $SCRDIR
cp -f jobcomp $SCRDIR
cp -f amr.in $SCRDIR
#
# Change directory
#
cd $SCRDIR
pwd
#
# initialize LDFLAGS1
#
setenv LDFLAGS1 "$NETCDFLIB"
setenv CPPFLAGS1 "$NETCDFINC"

#
# determine operating system
#
set uname=Linux
echo $uname
echo "OPERATING SYSTEM IS:" $uname
#
# Set compilation options
#
set OS = Linux
##set CONV=conv.linux
setenv CPP1 "cpp -Wtraditional"
setenv CFT1 g77
setenv FFLAGS1 "-O3 -Wall"
setenv LDFLAGS1 "$LDFLAGS1"
#
# determine if the compilation of AGRIF is necessary
#
unset COMPILEAGRIF
if { eval `$CPP1 testkeys | grep -i -q agrif` } then
set COMPILEAGRIF = TRUE
setenv FFLAGS1 "$FFLAGS1 -IAGRIFZOOM"
setenv LDFLAGS1 "-LAGRIFZOOM -lagrif $LDFLAGS1"
endif
#echo $COMPILEAGRIF
#
# determine if the openmp compilation is necessary
#
unset COMPILEOMP
if { eval `$CPP1 testkeys | grep -i -q openmp` } then
set COMPILEOMP = TRUE
setenv FFLAGS1 "$FFLAGS1 -openmp"
endif
#
# determine if the mpi compilation is necessary
#
unset COMPILEMPI
if { eval `$CPP1 testkeys | grep -i -q mpiisdefined` } then
set COMPILEMPI = TRUE
setenv LDFLAGS1 "$LDFLAGS1 $MPILIB"
setenv FFLAGS1 "$FFLAGS1 $MPIINC"
endif
#
# write the Makedefs according to previous flags
#

echo 's?$(FFLAGS1)?'$FFLAGS1'?g' > flags.tmp
echo 's?$(LDFLAGS1)?'$LDFLAGS1'?g' >> flags.tmp
echo 's?$(CPP1)?'$CPP1'?g' >> flags.tmp
echo 's?$(CFT1)?'$CFT1'?g' >> flags.tmp
echo 's?$(CPPFLAGS1)?'$CPPFLAGS1'?g' >> flags.tmp
sed -f flags.tmp Makedefs.generic > Makedefs
rm -f flags.tmp
pwd
#
# clean scratch
#
pwd
$MAKE clobber
pwd
#
# compile the precompiling program
#
$MAKE mpc

And this last instruction does not work :(
Please, please, can somebody help me? Is there an other solution to run ROMS under windows? Thanks.
Regards,
Valere

User avatar
m.hadfield
Posts: 518
Joined: Tue Jul 01, 2003 4:12 am
Location: NIWA

#2 Post by m.hadfield » Mon Aug 07, 2006 9:20 pm

What version of ROMS are you using?

Does this version of ROMS require Fortran 90? If so, I recommend g95 to get you started:

http://www.g95.org/

Get the Cygwin-tarball version.

I have successfully built Rutgers ROMS (versions 1.x to 3.0) with g95 under Cygwin.

In what way does the final instruction "not work"? Please post all the relevant output and error messages.

skbhate

problem compiling ROMS using g95 on laptop

#3 Post by skbhate » Mon Jan 22, 2007 5:27 pm

I am having problem compiling ROMS latest version on windows XP (laptop)..
I am using g95 compiler for cygwin..

I have used all the suggestions from the forum re: re-compiling netcdf with g95, using '-Df2cFortran' flags...etc..

It compiles fine and creates all the required libs for ROMS... but it breaks at the final step while creating executable 'OceanS'... here is the last scrap..

/usr/bin/cpp -P -traditional -I/usr/local/include -DCYGWIN -DI686 -DG95 -ISWAN -IROMS/Include -IROMS/Adjoint -IROMS/Nonlinear -IROMS/Representer -IROMS/Tangent -IROMS/SeaIce -IROMS/Drivers -IMaster Master/propagator.F > propagator.f90
ROMS/Bin/cpp_clean propagator.f90
g95 -c -O3 -ffast-math propagator.f90
g95 -c -O3 -ffast-math ocean_control.f90
g95 -c -O3 -ffast-math master.f90
g95 -O3 -ffast-math master.o ocean_control.o ocean_coupler.o propagator.o refdif_couple.o libSWAN.a libADM.a libRPM.a libTLM.a libNLM.a libICE.a libUTIL.a libMODS.a /exe: /link
g95: /exe:: No such file or directory
g95: /link: No such file or directory

make: *** [.] Error 1
rm seaice.f90 sv_perturb.f90 mod_kinds.f90

...not sure ... it's g95 problem... or am I missing something from makefile.. ..

any suggestions...

User avatar
m.hadfield
Posts: 518
Joined: Tue Jul 01, 2003 4:12 am
Location: NIWA

#4 Post by m.hadfield » Mon Jan 22, 2007 9:43 pm

I don't know where /exe and /link are coming from but to me they look like command-line switches for a Windows compiler, like Compaq Visual Fortran. This would suggest that the wrong make file has become involved somehow.

I don't have any specific suggestions, except that you should delete everything from your working directory, open a new command shell with a clean environment and start again.

jcwarner
Posts: 812
Joined: Wed Dec 31, 2003 6:16 pm
Location: USGS, USA

#5 Post by jcwarner » Mon Jan 22, 2007 11:19 pm

we needed to add some special methodology to get the compilation on a windows machine with cygwin, vs a standard unix box. Look in
Drivers/Module.mk
and you will see the special rules for compiling with cygwin.

You may need to add a few lines to the end of the file
Compilers/CYGWIN-g95.mk
add the line:

BIN_WIN32 = "$$(cygpath --windows $(BIN))"

and let me know if that works.

User avatar
m.hadfield
Posts: 518
Joined: Tue Jul 01, 2003 4:12 am
Location: NIWA

#6 Post by m.hadfield » Mon Jan 22, 2007 11:39 pm

With a Cygwin shell and Cygwin executables, it's much simpler to avoid Windows-style paths completely and just talk Unix.

I build and run (Rutgers) ROMS versions 2.1, 2.2 and 3.0 (pre-release) routinely under Cygwin. The make files are (completely??) identical to the Linux ones.

skbhate

#7 Post by skbhate » Wed Jan 24, 2007 4:31 pm

There is no ROMS/Drivers/Module.mk ... but the one under Master/Module.mk has rule for cygwin...

I changed it as you said.. but it doesn't work...

what is the use of windows path and reference to /exe and /link when using cygwin..

User avatar
m.hadfield
Posts: 518
Joined: Tue Jul 01, 2003 4:12 am
Location: NIWA

#8 Post by m.hadfield » Wed Jan 24, 2007 8:37 pm

What version are you using? Let's assume the latest released version of Rutgers ROMS, version 2.2. This includes the following file: Compilers/CYGWIN-g95.mk. This file should be involved in the build process by an include statement in the top-level makefile. The code that does the inclusion is

Code: Select all

#--------------------------------------------------------------------------
#  "uname -s" should return the OS or kernel name and "uname -m" should
#  return the CPU or hardware name. In practice the results can be pretty
#  flaky. Run the results through sed to convert "/" and " " to "-",
#  then apply platform-specific conversions.
#--------------------------------------------------------------------------

OS := $(shell uname -s | sed 's/[\/ ]/-/g')
OS := $(patsubst CYGWIN_%,CYGWIN,$(OS))
OS := $(patsubst sn%,UNICOS-sn,$(OS))

CPU := $(shell uname -m | sed 's/[\/ ]/-/g')

ifndef FORT
  $(error Variable FORT not set)
endif

ifneq "$(MAKECMDGOALS)" "clean"
  include Compilers/$(OS)-$(strip $(FORT)).mk
endif

So to invoke the right file you need OS to be correct (which should be the case if you are in a Cygwin bash shell) and you need to set FORT to g95.

Now, the command that's giving you trouble, the one that's trying to link the final executable, is defined in Drivers/Module.mk, which is also involved in the build process via an include statement in the makefile:

Code: Select all

include $(addsuffix /Module.mk,$(modules))
Here's the relevant code in Drivers/Module.mk:

Code: Select all

ifeq ($(OS)-$(strip $(FORT)),CYGWIN-df)
$(BIN):	$(libraries) $(local_objs)
	$(LD) $(FFLAGS) $(local_objs) $(libraries) $(LIBS_WIN32) /exe:$(BIN_WIN32) /link $(LDFLAGS)
else
$(BIN):	$(libraries) $(local_objs)
	$(LD) $(FFLAGS) $(LDFLAGS) $(local_objs) -o $@ $(libraries) $(LIBS)
endif
Note the conditional block (ifeq ... else ... endif). The problem is that you are finding the first link command, not the second, hence the "/exe: /link" at the end. The first link command should only be invoked when FORT is set to df, which is the correct value for Compaq Visual Fortran.

That's the ultimate problem, but it's not clear how you managed to invoke the wrong link command for the compiler you think you're using. Hence my suggestion a few messages ago to start again with a clean directory and (especially important) a clean environment. You want to ensure that the G95 compiler & linker can be invoked with the command g95--this appears to be true otherwise you wouldn't have got as far as you did. You must set FORT to g95 and you must make sure that any other relevant-looking environment variables, like FC and LD, are not set.[/code]

skbhate

#9 Post by skbhate » Wed Jan 24, 2007 9:18 pm

My FC and LD are all set to g95... that is not the problem... but after reading your post I see the problem is in Module.mk ..I mean the one I have... it looks like this...

Code: Select all

#ifeq ($(OS)-$(strip $(FORT)),CYGWIN-df)

ifeq ($(OS),CYGWIN)
$(BIN): $(libraries) $(local_objs)
        $(LD) $(FFLAGS) $(local_objs) $(libraries) $(LIBS_WIN32) /exe:$(BIN_WIN32) /link $(LDFLAGS)
else
$(BIN): $(libraries) $(local_objs)
        $(LD) $(FFLAGS) $(LDFLAGS) $(local_objs) -o $@ $(libraries) $(LIBS)
endif

so... it was just checking for $OS=CYGWIN but not for df ... so it was executing the /link line... but after I corrected it..I can SUCCESSFULY compile on laptop ...thanks for your help...

gislita

#10 Post by gislita » Fri Apr 20, 2007 8:55 am

Hi,

I am trying to compile ROMS using cygwin and g95 in a Windows computer. I have built the netcdf libraries and I am compiling using jobcomp. The problem I am having is that when trying to compile, it breaks at:

Code: Select all

/cygdrive/c/roms/roms_tools/Compile
/cygdrive/c/roms/roms_tools/Compile
/bin/rm -rf core *.o AGRIFZOOM/AGRIF_YOURFILES/*.o *.i *.s *.f *.trace *.mod
/bin/rm -rf roms mpc cross_matrix cppcheck srcscheck checkkwds partit ncjoin ncr
ename ./rii_files
/cygdrive/c/roms/roms_tools/Compile
cpp -traditional -DCygwin -P -I../netcdf-3.6.1/ mpc.F > mpc_.f
g95 -O3 -i4 -r8 -fno-second-underscore  -o mpc mpc_.f
cpp -traditional -DCygwin -P -I../netcdf-3.6.1/ main.F | ./mpc > main_.f
It doesn't give me any error, it just stops for ages. Does anybody know what I am doing wrong?

Thank you

User avatar
m.hadfield
Posts: 518
Joined: Tue Jul 01, 2003 4:12 am
Location: NIWA

#11 Post by m.hadfield » Sun Apr 22, 2007 10:24 pm

Hi gislita

I don't know off-hand what the problem is. You seem to be building ROMS_AGRIF, which I haven't dealt with myself.

You might try running the offending command outside make. You say it hangs on this command?

Code: Select all

cpp -traditional -DCygwin -P -I../netcdf-3.6.1/ main.F | ./mpc > main_.f
Try running the command as above from your Bash shell, making sure you're in the correct directory. If this doesn't get you any further, then try trimming off the "> main_.f" part and then the "| ./mpc" part.

What is ./mpc supposed to do, anyway? I see that the previous two commands preprocessed mpc.F and built the executable mpc. (Cygwin g95 should have silently added the .exe extension to the executable file. Did it do so?) Mpc is obviously a filter, accepting input on stdin and sendihg output to stdout. You could try running ./mpc from the command line. It should wait for input from the console: trying typing some lines and see what output it produces.

gislita

#12 Post by gislita » Fri Apr 27, 2007 3:25 pm

Hi m.hadfield. Thank you for your answer.

Actually I am using the jobcomp below to compile ROMS_Agrif:

Code: Select all

#!/bin/tcsh 
#################################################### 
# COMPILATION JOB # 
#################################################### 
unalias rm
unalias mv
unalias cp
# 
# set source, compilation and run directories 
# 
set SOURCE=../Roms_Agrif 
set SCRDIR=../Compile 
set RUNDIR=`pwd` 

# 
# Linux compiler options (only relevant to Linux OS) 
# 
set LINUX_FC=g95 
# 
# set 32 or 64 Bits executable 
# 
set BITS=THIRTYTWO 
# 
# set NETCDF directories 
# 
set NETCDFLIB=-L../netcdf-3.6.1/
set NETCDFINC=-I../netcdf-3.6.1/
# 
# 
# END OF USER'S MODIFICATIONS 
#################################################### 

# 
# Use GNU Make command 
# 
set MAKE = make 
# 
# clean scratch area 
# 
rm -rf $SCRDIR 
mkdir $SCRDIR 
# 
# copy SOURCE code 
# 
cp -f ${SOURCE}/*.F $SCRDIR 
cp -f ${SOURCE}/*.h $SCRDIR 
cp -f ${SOURCE}/Make* $SCRDIR 
cp -f ${SOURCE}/testkeys $SCRDIR 
cp -f ${SOURCE}/jobcomp $SCRDIR 
cp -f ${SOURCE}/amr.in $SCRDIR 
cp -Rf ${SOURCE}/AGRIFZOOM $SCRDIR 
# 
# overwrite with local files 
# 
cp -f *.F $SCRDIR 
cp -f Make* $SCRDIR 
cp -f jobcomp $SCRDIR 
cp -f amr.in $SCRDIR 
#
# Change directory 
# 
cd $SCRDIR 
pwd 
# 
# initialize LDFLAGS1 
# 
setenv LDFLAGS1 "$NETCDFLIB" 
setenv CPPFLAGS1 "$NETCDFINC" 

# 
# determine operating system 
# 
set uname=Cygwin
echo $uname 
echo "OPERATING SYSTEM IS:" $uname 
#
# Set compilation options
#
set OS = Cygwin
set CONV=conv.cygwin
set MAKEAGRIF=Makefile.linux.g95
setenv CPP1 "cpp -traditional -DCygwin"
setenv CFT1 g95
setenv FFLAGS1 "-O2 -i4 -r8 -fno-second-underscore" 
setenv LDFLAGS1 "$LDFLAGS1"
# 
# determine if the compilation of AGRIF is necessary 
# 
unset COMPILEAGRIF 
if { eval `$CPP1 testkeys | grep -i -q agrif` } then 
set COMPILEAGRIF = TRUE 
setenv FFLAGS1 "$FFLAGS1 -IAGRIFZOOM" 
setenv LDFLAGS1 "-LAGRIFZOOM -lagrif $LDFLAGS1" 
endif 
#echo $COMPILEAGRIF 
# 
# determine if the openmp compilation is necessary 
# 
unset COMPILEOMP 
if { eval `$CPP1 testkeys | grep -i -q openmp` } then 
set COMPILEOMP = TRUE 
setenv FFLAGS1 "$FFLAGS1 -openmp" 
endif 
# 
# determine if the mpi compilation is necessary 
# 
unset COMPILEMPI 
if { eval `$CPP1 testkeys | grep -i -q mpiisdefined` } then 
set COMPILEMPI = TRUE 
setenv LDFLAGS1 "$LDFLAGS1 $MPILIB" 
setenv FFLAGS1 "$FFLAGS1 $MPIINC" 
endif 
# 
# write the Makedefs according to previous flags 
# 

echo 's?$(FFLAGS1)?'$FFLAGS1'?g' > flags.tmp 
echo 's?$(LDFLAGS1)?'$LDFLAGS1'?g' >> flags.tmp 
echo 's?$(CPP1)?'$CPP1'?g' >> flags.tmp 
echo 's?$(CFT1)?'$CFT1'?g' >> flags.tmp 
echo 's?$(CPPFLAGS1)?'$CPPFLAGS1'?g' >> flags.tmp 
sed -f flags.tmp Makedefs.generic > Makedefs 
rm -f flags.tmp 
pwd 
# 
# clean scratch 
# 
pwd 
$MAKE clobber 
pwd 
# 
# compile the precompiling program 
# 
$MAKE mpc



#
# prepare and compile the library
#
if ($?COMPILEAGRIF) then
  /lib/cpp amr.in | grep -v -e ! -e '#' -e % -e '*' > AGRIFZOOM/amr.scrum
  set INCLUDELIST="param.h averages.h climat.h forces.h lmd_kpp.h mixing.h ocean2d.h ocean3d.h work.h private_scratch_AMR.h scalars.h ncscrum.h coupling.h grid.h tides.h sediment.h bbl.h zoom.h floats.h sources.h buffer.h diagnostics.h boundary.h"
		    
  foreach i ($INCLUDELIST)
    echo $i
    cat cppdefs.h $i | $CPP1 -P > AGRIFZOOM/$i
  end

  mv -f AGRIFZOOM/param.h .
  mv -f AGRIFZOOM/private_scratch_AMR.h AGRIFZOOM/private_scratch.h

  cd AGRIFZOOM
  ./$CONV amr.scrum -rm -comdirout ..
  /bin/rm -f *.h
  $MAKE -f $MAKEAGRIF COMDIRIN=./ COMDIROUT=./
  cd ..
endif

#
# compile roms
#
$MAKE 
mv roms $RUNDIR
#
I have followed your advice and every other advice I have found in this forum. I think I have successfully built my netcdf library and I think g95 is working fine. However, I have been unable to build the executable as of yet. It is still breaking up in:

Code: Select all

cpp -traditional -DCygwin -P -I../netcdf-3.6.1/ main.F | ./mpc > main_.f
Any help would be appreciated.

Thank you,

Cheers,

User avatar
kate
Posts: 3700
Joined: Wed Jul 02, 2003 5:29 pm
Location: IMS/UAF, USA

#13 Post by kate » Fri Apr 27, 2007 5:28 pm

Those of us on this list still don't know what mpc is though - it is likely to be the source of your trouble. Do you have an mpc.exe instead?

gislita

#14 Post by gislita » Mon Apr 30, 2007 8:27 am

Hi Kate,
To be honest I didn't know what mpc was either. it seems it is a: "Multifunctional precompiling processor designed to work between
CPP and FORTRAN compiler"

I have found a mpc.exe in my roms_agrif and roms_tools/compile folders, but I am not sure what to do with them or why this could be the source of my problems...

Thank you

User avatar
kate
Posts: 3700
Joined: Wed Jul 02, 2003 5:29 pm
Location: IMS/UAF, USA

#15 Post by kate » Mon Apr 30, 2007 10:40 pm

The script used for compiling is looking for ./mpc. You instead have mpc.exe. Have you tried editing the script so that it has a .exe there?

User avatar
m.hadfield
Posts: 518
Joined: Tue Jul 01, 2003 4:12 am
Location: NIWA

#16 Post by m.hadfield » Tue May 01, 2007 4:45 am

If there's a file called mpc.exe in the directory where make is running then it should be invoked by ./mpc.

But the point is that make is telling you that the following command failed:

Code: Select all

cpp -traditional -DCygwin -P -I../netcdf-3.6.1/ main.F | ./mpc > main_.f
All that's happening here is that a file, main.F, is being run through the C preprocessor, cpp, then through this other preprocessor, ./mpc, and the output being trapped in main_.f. This is pretty straightforward, and it's hard to see what could go wrong, but something is going wrong so you, Gislita, need to work out what.

I suggested a strategy for investigating this problem a few messages ago. Open a shell (Bash prompt) in the directory in question and try running the above command from there. Try variations on the command, try trimming off the redirection commands, try whatever you can think of to learn what's happening. Your current strategy of drip-feeding questions onto the list is clearly not working.

Post Reply