Posts Tagged ‘compiling’

dh_installdocs –link-doc when using jh_installjavadoc

Monday, January 3rd, 2011

This post exists to stop people (possibly including myself) spending hours being thoroughly confused as to why

override_dh_installdocs:
dh_installdocs --link-doc=package
l
is not working. In fact it probably is working but your package-doc.javadoc probably looks something like:

docs/api

rather than like:

docs/api /usr/share/doc/package/api

and hence jh_installjavadoc is correctly creating the /usr/share/doc/package-doc/ directory when really you didn’t want that to happen and so dh_installdocs –link-doc silently ignores your instruction as it doesn’t make sense in context.

Relatedly I have ‘finished’ packaging JEval for Debian partly using the instructions on packaging java packages using git. It just needs some further testing and to be uploaded and sponsored.
(I am packaging the dependencies of my Part II Project)

Compiling git from git fails if core.autocrlf is set to true

Monday, August 16th, 2010

If you get the following error when compiling git from a git clone of git:

: command not foundline 2: 
: command not foundline 5: 
: command not foundline 8: 
./GIT-VERSION-GEN: line 14: syntax error near unexpected token `elif'
'/GIT-VERSION-GEN: line 14: `elif test -d .git -o -f .git &&
make: *** No rule to make target `GIT-VERSION-FILE', needed by `git-am'. Stop.
make: *** Waiting for unfinished jobs....

and you have core.autocrlf set to true in your git config then consider the following “it’s probably not a good idea to convert newlines in the git repo” curtsey of wereHamster on .

So having core.autocrlf set to true may result in bad things happening in odd ways because line endings are far more complicated than they have any reason to be (thanks to decisions made before I was born). Bugs due to white space errors are irritating and happen to me far too often :-).

Today I used CVS – it was horrible, I tried to use git’s cvsimport and cvsexportcommit to deal with the fact that CVS is horrible unfortunately this did not work ;-(.

This post exists so that the next time someone is silly like me they might get a helpful response from Google.

Compiling JULES on Ubuntu Intrepid Linux

Thursday, February 5th, 2009

I have obtained the source code for JULES which is one of the components that the Met Office uses to forecast the weather. Compiling it was not straightforward and required the modification of several source files.

The modified files and .patch files can be found here.

First I will outline the route I took to the most working binary.

An almost working way

1) in Makefile:

1.1) Setting the location of the netcdf libaries (you will probably need to install these)

JULESDIR=$(PWD)
CDF_LIB_PATH=/usr/lib/
CDF_MOD_PATH=/usr/include/

1.2) and to enable the use of the gfortran compiler

ifeq ($(COMPILER),g95)
include $(JULESDIR)/Makefile.comp.g95
endif
ifeq ($(COMPILER),gfortran)
include $(JULESDIR)/Makefile.comp.gfortran
endif
ifeq ($(COMPILER),nag)
include $(JULESDIR)/Makefile.comp.nag
endif

rather than

ifeq ($(COMPILER),g95)
include $(JULESDIR)/Makefile.comp.g95
endif
ifeq ($(COMPILER),nag)
include $(JULESDIR)/Makefile.comp.nag
endif

2) in Makefile.common.mk:

GRMPATH=$(which grm)

ifneq ($(strip $(GRMPATH)),)
    RM=grm -f
endif

RMPATH=$(which rm)

ifneq ($(strip $(RMPATH)),)
    RM=rm -f
endif

ifndef RM
    $(error No rm equivalent command found)
endif

rather than

RM=grm -f

grm means GNU rm, on a linux system rm is GNU rm, so rm should be used rather than grm the conditionals mean that if the met office run the code on their setup it ‘should work’ and if someone runs it on a normal linux distribution it should still work.

cp Makefile.comp.g95 Makefile.comp.gfortran

3) in Makefile.comp.gfortran:

In order to select the gfortran compiler rather than g95, as gfortran is available for Ubutnu/debian while g95 is not.

FC=gfortran -fno-underscoring

rather than:

FC=g95

and

MOD_PUT=-J

rather than:

MOD_PUT=-fmod=

4) Then to compile

make BUILD=run COMPILER=gfortran CDFDUMMY=true

#BUILD could also be debug or fast.
#CDFDUMMY is needed even though you can install netcdf from the repositories – because if you set it false you get:

/home/daniel/dev/JULES/jules-v2-0/libjules.a(RWERR_MOD.o): In function `__rwerr_mod_MOD_rwerr':
RWERR_MOD.f90:(.text+0xaae): undefined reference to `__netcdf_MOD_nf90_inquire_dimension'
RWERR_MOD.f90:(.text+0xed7): undefined reference to `__netcdf_MOD_nf90_strerror'
/home/daniel/dev/JULES/jules-v2-0/libjules.a(JULES_NETCDF.o): In function `__jules_netcdf_MOD_closecdf':
JULES_NETCDF.f90:(.text+0xd): undefined reference to `__netcdf_MOD_nf90_close'
/home/daniel/dev/JULES/jules-v2-0/libjules.a(JULES_NETCDF.o): In function `__jules_netcdf_MOD_check_nc_dims':
JULES_NETCDF.f90:(.text+0x2e1): undefined reference to `__netcdf_MOD_nf90_inq_dimid'
/home/daniel/dev/JULES/jules-v2-0/libjules.a(JULES_NETCDF.o): In function `__jules_netcdf_MOD_readvar2dreal_ncvector_gswp2':
JULES_NETCDF.f90:(.text+0x566): undefined reference to `__netcdf_MOD_nf90_inq_varid'
JULES_NETCDF.f90:(.text+0x8b1): undefined reference to `__netcdf_MOD_nf90_get_var_1d_fourbytereal'
JULES_NETCDF.f90:(.text+0xbb9): undefined reference to `__netcdf_MOD_nf90_get_var_1d_fourbytereal'
JULES_NETCDF.f90:(.text+0xeed): undefined reference to `__netcdf_MOD_nf90_get_var_1d_fourbytereal'
JULES_NETCDF.f90:(.text+0x1160): undefined reference to `__netcdf_MOD_nf90_get_var_1d_fourbytereal'
JULES_NETCDF.f90:(.text+0x1477): undefined reference to `__netcdf_MOD_nf90_get_var_1d_fourbytereal'
/home/daniel/dev/JULES/jules-v2-0/libjules.a(JULES_NETCDF.o):JULES_NETCDF.f90:(.text+0x178e): more undefined references to `__netcdf_MOD_nf90_get_var_1d_fourbytereal' follow
/home/daniel/dev/JULES/jules-v2-0/libjules.a(JULES_NETCDF.o): In function `__jules_netcdf_MOD_opencdf':
JULES_NETCDF.f90:(.text+0x1c24): undefined reference to `__netcdf_MOD_nf90_open'
collect2: ld returned 1 exit status
make: *** [jules.exe] Error 1

Successful compilation should result in:

gfortran -fno-underscoring -o jules.exe /home/daniel/dev/JULES/jules-v2-0/JULES.o \
	    /home/daniel/dev/JULES/jules-v2-0/UTILS/netcdf_dummy/JULES_NETCDF_DUMMY.o \
	    -L/home/daniel/dev/JULES/jules-v2-0  -L/home/daniel/dev/JULES/jules-v2-0/UTILS/netcdf_dummy  \
	    -J/home/daniel/dev/JULES/jules-v2-0/MODS -I/home/daniel/dev/JULES/jules-v2-0/MODS -I/home/daniel/dev/JULES/jules-v2-0/UTILS/netcdf_dummy  \
	    -ljules

Alternatively try to use g95 as recommended

1) Install g95

From here: http://www.gfd-dennou.org/library/cc-env/g95/index.htm.en#label-5
g95 is not available in either Ubuntu or Debian repositories – for unknown reasons.

2) follow steps 1.1 and 2 from the instructions for gfortran.

3) try to compile

make BUILD=run COMPILER=g95 CDFDUMMY=true

If you do this there is no possibility of using netcdf prebuilt binaries according to: http://www.unidata.ucar.edu/support/help/MailArchives/netcdf/msg04125.html
This is because they were built for gfortran and so will only work with gfortran.

unfortunately this results in:

g95 -o jules.exe /home/daniel/dev/JULES/jules-v2-0/JULES.o \
	    /home/daniel/dev/JULES/jules-v2-0/UTILS/netcdf_dummy/JULES_NETCDF_DUMMY.o \
	    -L/home/daniel/dev/JULES/jules-v2-0  -L/home/daniel/dev/JULES/jules-v2-0/UTILS/netcdf_dummy  \
	    -fmod=/home/daniel/dev/JULES/jules-v2-0/MODS -I/home/daniel/dev/JULES/jules-v2-0/MODS -I/home/daniel/dev/JULES/jules-v2-0/UTILS/netcdf_dummy  \
	    -ljules
/home/daniel/dev/JULES/jules-v2-0/libjules.a(SOILHY7A.o):(.data+0x0): undefined reference to `darcy_'
/home/daniel/dev/JULES/jules-v2-0/libjules.a(SOILHY7A.o):(.data+0x4): undefined reference to `hyd_con__'
make: *** [jules.exe] Error 1

Running Jules

To run jules you will need to

mkdir OUTPUT

after successfully compiling

and then to run a test run using one of the shipped examples:

./jules.exe < point_loobos_example.jin

unfortunately doing this I got:

At line 152 of file SFSNOW7A.f
Fortran runtime error: Array reference out of bounds for array 'snowcanpft', upper bound of dimension 1 exceeded (6 > 5)

Also trying:

./jules.exe < grid_gswp2_example.jin

fails because:

Opening /users/global/rjel/jules/gswp2_files/lsmask_vector.nc
 fileFormat=nc
 ERROR: attempting to use a netCDF procedure, but netCDF library not available.
 This is a 'dummy' procedure.
 To use netCDF, remake model with the 'proper' netCDF library.

as we compiled with CDFDUMMY=true …

Conclusion

It is possible to compile JULES on Ubuntu Linux with a bit of work. However compiling a working version of JULES on Ubuntu Linux may be beyond my current ability (I don’t know any FORTRAN).

Hopefully this will help someone.

Thanks as always go to the denizens of #srcf on irc.srcf.ucam.org