From 64f9032ad24910000205093edd479d481fc5c7e3 Mon Sep 17 00:00:00 2001 From: Philippe WAUTELET <philippe.wautelet@aero.obs-mip.fr> Date: Thu, 31 May 2018 17:12:00 +0200 Subject: [PATCH] Philippe 31/05/2018: lfi2cdf: add runmode option + use script in bin_tools/ --- .gitignore | 3 -- LIBTOOLS/tools/lfi2cdf/src/mode_options.f90 | 39 +++++++++++++++++---- bin_tools/cdf2cdf | 4 +++ bin_tools/cdf2lfi | 4 +++ bin_tools/lfi2cdf | 4 +++ src/Makefile | 9 +---- 6 files changed, 46 insertions(+), 17 deletions(-) create mode 100755 bin_tools/cdf2cdf create mode 100755 bin_tools/cdf2lfi create mode 100755 bin_tools/lfi2cdf diff --git a/.gitignore b/.gitignore index 8e8ebeac6..f98ca3944 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,3 @@ -bin_tools/cdf2cdf -bin_tools/cdf2lfi -bin_tools/lfi2cdf conf/profile_mesonh conf/profile_mesonh-* exe/* diff --git a/LIBTOOLS/tools/lfi2cdf/src/mode_options.f90 b/LIBTOOLS/tools/lfi2cdf/src/mode_options.f90 index 4eba3506f..709a87266 100644 --- a/LIBTOOLS/tools/lfi2cdf/src/mode_options.f90 +++ b/LIBTOOLS/tools/lfi2cdf/src/mode_options.f90 @@ -8,12 +8,12 @@ module mode_options implicit none - integer,parameter :: nbavailoptions = 8 + integer,parameter :: nbavailoptions = 9 integer,parameter :: MODEUNDEF = -11, MODECDF2CDF = 11, MODELFI2CDF = 12, MODECDF2LFI = 13 integer,parameter :: OPTCOMPRESS = 1, OPTHELP = 2, OPTLIST = 3 integer,parameter :: OPTMERGE = 4, OPTOUTPUT = 5, OPTREDUCE = 6 - integer,parameter :: OPTSPLIT = 7, OPTVAR = 8 + integer,parameter :: OPTSPLIT = 7, OPTVAR = 8, OPTMODE = 9 type option logical :: set = .false. @@ -58,8 +58,6 @@ subroutine read_commandline(options,hinfile,houtfile,runmode) runmode = MODELFI2CDF case default runmode = MODEUNDEF - print *,'Error: program started with unknown command: ',command - call help() end select deallocate(command,fullcommand) @@ -146,6 +144,11 @@ subroutine init_options(options) options(OPTVAR)%has_argument = .true. options(OPTVAR)%type = TYPECHAR + options(OPTMODE)%long_name = "runmode" + options(OPTMODE)%short_name = 'R' + options(OPTMODE)%has_argument = .true. + options(OPTMODE)%type = TYPECHAR + end subroutine init_options subroutine get_option(options,finished) @@ -228,7 +231,7 @@ subroutine check_options(options,infile,runmode) type(option),dimension(:),intent(inout) :: options character(len=:),allocatable,intent(in) :: infile - integer,intent(in) :: runmode + integer,intent(inout) :: runmode integer :: idx1, idx2 @@ -237,6 +240,26 @@ subroutine check_options(options,infile,runmode) call help() end if + !Check runmode + if (options(OPTMODE)%set) then + select case (options(OPTMODE)%cvalue) + case ('cdf2cdf') + runmode = MODECDF2CDF + case ('lfi2cdf') + runmode = MODELFI2CDF + case ('cdf2lfi') + runmode = MODECDF2LFI + case default + print *,'Error: invalid runmode option' + call help() + end select + else + if(runmode==MODEUNDEF) then + print *,'Error: program started with unknown command' + call help() + end if + end if + !Check compression level if (options(OPTCOMPRESS)%set) then if (options(OPTCOMPRESS)%ivalue < 1 .OR. options(OPTCOMPRESS)%ivalue > 9 ) then @@ -302,11 +325,13 @@ subroutine help() !TODO: -l option for cdf2cdf and cdf2lfi print *,"Usage : lfi2cdf [-h --help] [-l] [-v --var var1[,...]] [-r --reduce-precision]" print *," [-m --merge number_of_z_levels] [-s --split] [-o --output output-file.nc]" + print *," [-R --runmode mode]" print *," [-c --compress compression_level] input-file.lfi" print *," cdf2cdf [-h --help] [-v --var var1[,...]] [-r --reduce-precision]" print *," [-m --merge number_of_split_files] [-s --split] [-o --output output-file.nc]" + print *," [-R --runmode mode]" print *," [-c --compress compression_level] input-file.nc" - print *," cdf2lfi [-o --output output-file.lfi] input-file.nc" + print *," cdf2lfi [-o --output output-file.lfi] [-R --runmode mode] input-file.nc" print *,"" print *,"Options:" print *," --compress, -c compression_level" @@ -322,6 +347,8 @@ subroutine help() print *," Name of file for the output" print *," --reduce-precision, -r" print *," Reduce the precision of the floating point variables to single precision (cdf2cdf and lfi2cdf only)" + print *," --runmode, -R" + print *," Force runmode (lfi2cdf, cdf2cdf or cdf2lfi)" print *," --split, -s" print *," Split variables specified with the -v option (one per file) (cdf2cdf and lfi2cdf only)" print *," --var, -v var1[,...]" diff --git a/bin_tools/cdf2cdf b/bin_tools/cdf2cdf new file mode 100755 index 000000000..311e5248b --- /dev/null +++ b/bin_tools/cdf2cdf @@ -0,0 +1,4 @@ +#!/bin/bash + +${SRC_MESONH}/exe/LFI2CDF${XYZ} --runmode cdf2cdf $* + diff --git a/bin_tools/cdf2lfi b/bin_tools/cdf2lfi new file mode 100755 index 000000000..9518d5dea --- /dev/null +++ b/bin_tools/cdf2lfi @@ -0,0 +1,4 @@ +#!/bin/bash + +${SRC_MESONH}/exe/LFI2CDF${XYZ} --runmode cdf2lfi $* + diff --git a/bin_tools/lfi2cdf b/bin_tools/lfi2cdf new file mode 100755 index 000000000..8a23020db --- /dev/null +++ b/bin_tools/lfi2cdf @@ -0,0 +1,4 @@ +#!/bin/bash + +${SRC_MESONH}/exe/LFI2CDF${XYZ} --runmode lfi2cdf $* + diff --git a/src/Makefile b/src/Makefile index c85c2c023..f90a4c7e5 100644 --- a/src/Makefile +++ b/src/Makefile @@ -385,7 +385,7 @@ ifdef PROG_LIST prog : lib $(LIB_GRIBEX) @$(MAKE) -I$(B)$(OBJDIR) DEP=YES $(PROG_LIST) -install : $(patsubst %,%-${ARCH_XYZ},$(PROG_LIST)) install_tools +install : $(patsubst %,%-${ARCH_XYZ},$(PROG_LIST)) $(PROG_LIST) : OBJ_PROG=$(shell find $(PROG_DIR) -follow -type f -name "spll_*.f*" \ @@ -405,13 +405,6 @@ else endif rm -f $(SRC_MESONH)/exe/$(*F)_${ARCH_XYZ}~ -install_tools : -ifdef MNH_TOOLS - ln -sf $(OBJDIR)/LFI2CDF $(SRC_MESONH)/bin_tools/lfi2cdf - ln -sf $(OBJDIR)/LFI2CDF $(SRC_MESONH)/bin_tools/cdf2cdf - ln -sf $(OBJDIR)/LFI2CDF $(SRC_MESONH)/bin_tools/cdf2lfi -endif - ########################################################## # # # EXAMPLES RULES # -- GitLab