Skip to content

Commit

Permalink
Merge pull request optados-developers#29 from ajm143/develop
Browse files Browse the repository at this point in the history
Addition of the --version command.
  • Loading branch information
jryates authored Feb 5, 2020
2 parents 8fae825 + 261fe9b commit 4f7cd30
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 5 deletions.
15 changes: 11 additions & 4 deletions optados/src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ include ../make.system

#-------------------------------------------
# T H I N G S Y O U S H O U L D
# P R O B A B L Y L E A V E T O T H E
# P R O B A B L Y L E A V E T O T H E
# D E V E L O P E R S

ifeq ($(BUILD), debug)
Expand All @@ -28,7 +28,7 @@ endif
EXTENSION:=.x

# Put object names here
OBJS=algorithms.o cell.o comms.o constants.o core.o dos.o dos_utils.o electronic.o io.o jdos.o jdos_utils.o optics.o parameters.o pdos.o pdis.o projection_utils.o xmgrace_utils.o
OBJS=build.o algorithms.o cell.o comms.o constants.o core.o dos.o dos_utils.o electronic.o io.o jdos.o jdos_utils.o optics.o parameters.o pdos.o pdis.o projection_utils.o xmgrace_utils.o

all : optados tools

Expand All @@ -38,7 +38,7 @@ od2od : od2od.f90 $(OBJS) ../make.system
$(F90) $(FFLAGS) $< $(OBJS) -o ../od2od

optados : optados.f90 $(OBJS) ../make.system
$(F90) $(FFLAGS) $< $(OBJS) -o ../optados$(EXTENSION)
$(F90) $(FFLAGS) $< $(OBJS) -o ../optados$(EXTENSION)

algorithms.o : algorithms.f90 io.o constants.o ../make.system
$(F90) -c $(FFLAGS) $<
Expand Down Expand Up @@ -91,6 +91,13 @@ projection_utils.o : projection_utils.f90 cell.o comms.o constants.o cell.o elec
xmgrace_utils.o : xmgrace_utils.f90 io.o constants.o ../make.system
$(F90) -c $(FFLAGS) $<

build.f90 :
./make_build_info.sh

build.o : build.f90 ../make.system
$(F90) -c $(FFLAGS) $<



# Utility targets
.PHONY: clean veryclean
Expand All @@ -103,5 +110,5 @@ clean:
veryclean: clean
rm -f optados$(EXTENSION) optados$(EXTENSION).debug optados$(EXTENSION).mpi od2od

install:
install:
cp optados$(EXTENSION) $(INSTALL_DIR)
30 changes: 30 additions & 0 deletions optados/src/make_build_info.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

BUILD=`git describe --tags`
COMPILER=`grep SYSTEM ../make.system | head -n 1 | awk '{print $3}'`
BUILD_TYPE=`grep BUILD ../make.system | head -n 1 | awk '{print $3}'`
COMMS_ARCH=`grep COMMS_ARCH ../make.system | head -n 1 | awk '{print $3}'`
SOURCE_TIME=`git log | grep Date | head -n 1 |awk '{print $5}'`
SOURCE_DATE=`git log | grep Date | head -n 1 |awk '{print $2, $4, $3, $6}'`
COMPILE_TIME=`date +"%R %Z"`
COMPILE_DATE=`date +"%a %e %b %Y"`

echo "module od_build" > build.f90
echo " implicit none" >> build.f90
echo " ">> build.f90
echo " private ! unless otherwise stated" >> build.f90
echo " " >> build.f90
echo " type, public :: build_info_type" >> build.f90
echo " character(len=20) :: build='"${BUILD}"'" >> build.f90
echo " character(len=20) :: compiler='"${COMPILER}"'" >> build.f90
echo " character(len=20) :: build_type='"${BUILD_TYPE}"'" >> build.f90
echo " character(len=20) :: comms_arch='"${COMMS_ARCH}"'" >> build.f90
echo " character(len=20) :: source_time='"${SOURCE_TIME}"'" >> build.f90
echo " character(len=20) :: source_date='"${SOURCE_DATE}"'" >> build.f90
echo " character(len=20) :: compile_date='"${COMPILE_DATE}"'" >> build.f90
echo " character(len=20) :: compile_time='"${COMPILE_TIME}"'" >> build.f90
echo " end type build_info_type" >> build.f90

echo " type(build_info_type), public, save :: build_info" >> build.f90

echo "endmodule od_build" >> build.f90
21 changes: 20 additions & 1 deletion optados/src/optados.f90
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ program optados
use od_pdos, only: pdos_calculate
use od_pdis, only: pdis_calculate
use od_optics, only: optics_calculate
use od_build, only: build_info
implicit none

real(kind=dp) :: time0, time1 ! Varaibles for timing
Expand All @@ -63,7 +64,7 @@ program optados
call io_get_seedname()
! If blank set to seedname='--help'
if (trim(seedname) == '-h' .or. trim(seedname) == '--help') call help_output

if (trim(seedname) == '-v' .or. trim(seedname) == '--version') call version_output
!-------------------------------------------------------------------------!
! O R G A N I S E T H E E R R O R F I L E
stderr = io_file_unit()
Expand Down Expand Up @@ -247,4 +248,22 @@ subroutine help_output
stop
end subroutine help_output

subroutine version_output
use od_build, only: build_info
use od_constants, only: optados_version, copyright
implicit none
write (*, *)
write (*, *) " OptaDOS ver.", trim(optados_version)
write (*, *)
write (*, *) " Andrew J. Morris, R. J. Nicholls, C. J. Pickard and J. R. Yates", trim(copyright)
write (*, *) " Compiled with "//trim(build_info%compiler)//" on "//trim(build_info%compile_date)&
& //" at "//trim(build_info%compile_time)//"."
write(*, *) " Compile type: "//trim(build_info%build_type)//", "//trim(build_info%comms_arch)
write(*, *) " From source "//trim(build_info%build)//" submitted on "//trim(build_info%source_date)&
&//" at " //trim(build_info%source_time)//"."


stop
end subroutine version_output

end program optados

0 comments on commit 4f7cd30

Please sign in to comment.