From 6cf09f89d9f5332428b9de55d727c6578ad2e0f5 Mon Sep 17 00:00:00 2001
From: Philippe WAUTELET <philippe.wautelet@aero.obs-mip.fr>
Date: Thu, 24 Nov 2016 11:32:34 +0100
Subject: [PATCH] Philippe 24/11/2016: lfi2cdf: bug correction: correct name
 for output file

---
 LIBTOOLS/tools/lfi2cdf/src/mode_options.f90 | 27 ++++-----------------
 LIBTOOLS/tools/lfi2cdf/src/mode_util.f90    |  2 +-
 2 files changed, 6 insertions(+), 23 deletions(-)

diff --git a/LIBTOOLS/tools/lfi2cdf/src/mode_options.f90 b/LIBTOOLS/tools/lfi2cdf/src/mode_options.f90
index af1a84ad8..4a03b4442 100644
--- a/LIBTOOLS/tools/lfi2cdf/src/mode_options.f90
+++ b/LIBTOOLS/tools/lfi2cdf/src/mode_options.f90
@@ -31,7 +31,7 @@ subroutine read_commandline(options,hinfile,houtfile,runmode)
   character(len=:),allocatable,intent(out)          :: houtfile
   integer,intent(out)                               :: runmode
 
-  integer :: idx, ji, nbargs, status, sz
+  integer :: idx, nbargs, status, sz
   logical :: finished
   character(len=:),allocatable :: command, fullcommand
 
@@ -80,30 +80,13 @@ subroutine read_commandline(options,hinfile,houtfile,runmode)
 
   call check_options(options,hinfile,runmode)
 
+  houtfile = options(OPTOUTPUT)%cvalue
 
-  !Remove level in the filename if merging LFI splitted files
+  !Remove level in the filename if merging LFI splitted files and output name not set by option
   if (.NOT.options(OPTOUTPUT)%set) then
-    if (options(OPTMERGE)%set .AND. .NOT.options(OPTSPLIT)%set) then
-       houtfile=houtfile(1:len(houtfile)-9)//houtfile(len(houtfile)-3:)
+    if (options(OPTMERGE)%set) then
+      houtfile=hinfile(1:len(hinfile)-9)
     end if
-    if (.NOT.options(OPTMERGE)%set .AND. options(OPTSPLIT)%set) then
-       if (options(OPTCDF4)%set) then
-         ji=4
-       else
-         ji=3
-       end if
-       houtfile=houtfile(1:len(houtfile)-ji)
-    end if
-    if (options(OPTMERGE)%set .AND. options(OPTSPLIT)%set) then
-       if (options(OPTCDF4)%set) then
-         ji=9
-       else
-         ji=8
-       end if
-       houtfile=houtfile(1:len(houtfile)-ji)
-    end if
-  else
-    houtfile = options(OPTOUTPUT)%cvalue
   end if
 
 end subroutine read_commandline
diff --git a/LIBTOOLS/tools/lfi2cdf/src/mode_util.f90 b/LIBTOOLS/tools/lfi2cdf/src/mode_util.f90
index 63c87d058..af0423a5a 100644
--- a/LIBTOOLS/tools/lfi2cdf/src/mode_util.f90
+++ b/LIBTOOLS/tools/lfi2cdf/src/mode_util.f90
@@ -1268,7 +1268,7 @@ END DO
        outfiles%files(idx)%format = LFI_FORMAT
        outfiles%files(idx)%status = WRITING
        ilu = outfiles%files(idx)%lun_id
-       CALL LFIOUV(iresp,ilu,ltrue,houtfile,'NEW' ,lfalse,lfalse,iverb,inap,inaf)
+       CALL LFIOUV(iresp,ilu,ltrue,TRIM(houtfile)//'.lfi','NEW' ,lfalse,lfalse,iverb,inap,inaf)
        outfiles%files(idx)%opened  = .TRUE.
     END IF
 
-- 
GitLab