Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add functions for getting ecTrans version and Git information #24

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/trans/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
# granted to it by virtue of its status as an intergovernmental organisation
# nor does it submit to any jurisdiction.

# Preprocess module file containing version information
configure_file( internal/ectrans_version_mod.F90.in internal/ectrans_version_mod.F90 )

## Apply workarounds for some known compilers

if(CMAKE_Fortran_COMPILER_ID MATCHES "Cray")
Expand Down Expand Up @@ -37,6 +40,7 @@ ecbuild_list_add_pattern( LIST trans_src
algor/*
internal/*
external/*
${CMAKE_CURRENT_BINARY_DIR}/internal/ectrans_version_mod.F90
QUIET
)

Expand Down
20 changes: 13 additions & 7 deletions src/trans/external/setup_trans0.F90
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,15 @@ SUBROUTINE SETUP_TRANS0(KOUT,KERR,KPRINTLEV,KMAX_RESOL,KPROMATR,&

!ifndef INTERFACE

USE TPM_GEN ,ONLY : NERR, NOUT, LMPOFF, LSYNC_TRANS, NTRANS_SYNC_LEVEL, MSETUP0, &
& NMAX_RESOL, NPRINTLEV, NPROMATR, LALLOPERM
USE TPM_DISTR ,ONLY : LEQ_REGIONS, NCOMBFLEN, NPRGPEW,NPRGPNS, NPRTRW
USE TPM_CONSTANTS ,ONLY : RA
USE TPM_GEN ,ONLY : NERR, NOUT, LMPOFF, LSYNC_TRANS, NTRANS_SYNC_LEVEL, MSETUP0, &
& NMAX_RESOL, NPRINTLEV, NPROMATR, LALLOPERM
USE TPM_DISTR ,ONLY : LEQ_REGIONS, NCOMBFLEN, NPRGPEW,NPRGPNS, NPRTRW
USE TPM_CONSTANTS ,ONLY : RA

USE SUMP_TRANS0_MOD ,ONLY : SUMP_TRANS0
USE ABORT_TRANS_MOD ,ONLY : ABORT_TRANS
USE EQ_REGIONS_MOD ,ONLY : N_REGIONS, N_REGIONS_EW, N_REGIONS_NS
USE SUMP_TRANS0_MOD ,ONLY : SUMP_TRANS0
USE ABORT_TRANS_MOD ,ONLY : ABORT_TRANS
USE EQ_REGIONS_MOD ,ONLY : N_REGIONS, N_REGIONS_EW, N_REGIONS_NS
USE ECTRANS_VERSION_MOD ,ONLY : ECTRANS_VERSION_STR, ECTRANS_GIT_SHA1

!endif INTERFACE

Expand All @@ -100,6 +101,11 @@ SUBROUTINE SETUP_TRANS0(KOUT,KERR,KPRINTLEV,KMAX_RESOL,KPROMATR,&

! ------------------------------------------------------------------

WRITE(NOUT,'(A)') "ecTrans at version:"
WRITE(NOUT,'(A)') ECTRANS_VERSION_STR()
WRITE(NOUT,'(A)') "commit:"
WRITE(NOUT,'(A)') ECTRANS_GIT_SHA1()

IF(MSETUP0 /= 0) THEN
!gr CALL ABORT_TRANS('SETUP_TRANS0: SETUP_TRANS0 MAY ONLY BE CALLED ONCE')
ENDIF
Expand Down
47 changes: 47 additions & 0 deletions src/trans/internal/ectrans_version_mod.F90.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
! (C) Copyright 2023- ECMWF.
!
! This software is licensed under the terms of the Apache Licence Version 2.0
! which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
! In applying this licence, ECMWF does not waive the privileges and immunities
! granted to it by virtue of its status as an intergovernmental organisation
! nor does it submit to any jurisdiction.
!

MODULE ECTRANS_VERSION_MOD

IMPLICIT NONE

CONTAINS

FUNCTION ECTRANS_VERSION_STR()

!**** *ECTRANS_VERSION_STR* - Return ecTrans version as a string

CHARACTER(LEN=LEN("@ectrans_VERSION_STR@")) :: ECTRANS_VERSION_STR

ECTRANS_VERSION_STR = "@ectrans_VERSION_STR@"
END FUNCTION ECTRANS_VERSION_STR

FUNCTION ECTRANS_VERSION_INT()

!**** *ECTRANS_VERSION_INT* - Return ecTrans version as an integer

USE PARKIND1 ,ONLY : JPIM

INTEGER(KIND=JPIM) :: ECTRANS_VERSION_INT

ECTRANS_VERSION_INT = 10000_JPIM * @ectrans_VERSION_MAJOR@ &
& + 100_JPIM * @ectrans_VERSION_MINOR@ &
& + 10_JPIM * @ectrans_VERSION_PATCH@
END FUNCTION ECTRANS_VERSION_INT

FUNCTION ECTRANS_GIT_SHA1()

!**** *ECTRANS_GIT_SHA1* - Return the SHA-1 hash of the latest Git commit

CHARACTER(LEN=LEN("@ectrans_GIT_SHA1@")) :: ECTRANS_GIT_SHA1

ECTRANS_GIT_SHA1 = "@ectrans_GIT_SHA1@"
END FUNCTION ECTRANS_GIT_SHA1

END MODULE ECTRANS_VERSION_MOD