Skip to content
Snippets Groups Projects
Commit df87f6e9 authored by WAUTELET Philippe's avatar WAUTELET Philippe
Browse files

lfi2cdf: open and close files in separate subroutines in all cases (cleaner)

parent 40df5cc0
No related branches found
No related tags found
No related merge requests found
...@@ -19,9 +19,6 @@ subroutine LFI2CDFMAIN(hinfile,iiflen,ooutname,houtfile,ioflen,hvarlist,ivlen,o ...@@ -19,9 +19,6 @@ subroutine LFI2CDFMAIN(hinfile,iiflen,ooutname,houtfile,ioflen,hvarlist,ivlen,o
INTEGER :: nbvar_tbw ! number of variables to be written INTEGER :: nbvar_tbw ! number of variables to be written
INTEGER :: nbvar ! number of defined variables INTEGER :: nbvar ! number of defined variables
INTEGER :: first_level, current_level, last_level INTEGER :: first_level, current_level, last_level
INTEGER(KIND=LFI_INT) :: iresp,iverb,inap
CHARACTER(LEN=3) :: suffix
CHARACTER(LEN=iiflen) :: filename
TYPE(cdf_files) :: cdffiles TYPE(cdf_files) :: cdffiles
TYPE(workfield), DIMENSION(:), POINTER :: tzreclist TYPE(workfield), DIMENSION(:), POINTER :: tzreclist
...@@ -87,7 +84,6 @@ subroutine LFI2CDFMAIN(hinfile,iiflen,ooutname,houtfile,ioflen,hvarlist,ivlen,o ...@@ -87,7 +84,6 @@ subroutine LFI2CDFMAIN(hinfile,iiflen,ooutname,houtfile,ioflen,hvarlist,ivlen,o
ELSE ELSE
!Treat several LFI files and merge into 1 NC file !Treat several LFI files and merge into 1 NC file
iverb = 0 !Verbosity level for LFI
!Determine first level (eg needed to find suffix of the variable name) !Determine first level (eg needed to find suffix of the variable name)
read( hinfile(len(hinfile)-6:len(hinfile)-4) , "(I3)" ) first_level read( hinfile(len(hinfile)-6:len(hinfile)-4) , "(I3)" ) first_level
...@@ -103,13 +99,11 @@ subroutine LFI2CDFMAIN(hinfile,iiflen,ooutname,houtfile,ioflen,hvarlist,ivlen,o ...@@ -103,13 +99,11 @@ subroutine LFI2CDFMAIN(hinfile,iiflen,ooutname,houtfile,ioflen,hvarlist,ivlen,o
DO current_level = first_level,last_level DO current_level = first_level,last_level
print *,'Treating level ',current_level print *,'Treating level ',current_level
IF (current_level/=first_level) THEN IF (current_level/=first_level) THEN
write(suffix,'(I3.3)') current_level CALL open_split_lfifile(ilu,hinfile,current_level)
filename=hinfile(1:len(hinfile)-7)//suffix//'.lfi'
CALL LFIOUV(iresp,ilu,ltrue,filename,'OLD',lfalse,lfalse,iverb,inap,nbvar_lfi)
CALL read_data_lfi(ilu,hvarlist,nbvar,tzreclist,ibuflen,current_level) CALL read_data_lfi(ilu,hvarlist,nbvar,tzreclist,ibuflen,current_level)
END IF END IF
CALL fill_ncdf(ilu,tzreclist,nbvar,ibuflen,cdffiles,current_level) CALL fill_ncdf(ilu,tzreclist,nbvar,ibuflen,cdffiles,current_level)
IF (current_level/=last_level) CALL LFIFER(iresp,ilu,'KEEP') IF (current_level/=last_level) CALL close_split_lfifile(ilu)
END DO END DO
END IF END IF
......
...@@ -1006,6 +1006,27 @@ print *,'lowmem: not tested!!!!!' (to be compared with no low mem version) ...@@ -1006,6 +1006,27 @@ print *,'lowmem: not tested!!!!!' (to be compared with no low mem version)
END SUBROUTINE OPEN_FILES END SUBROUTINE OPEN_FILES
SUBROUTINE OPEN_SPLIT_LFIFILE(ilu,hinfile,current_level)
INTEGER, INTENT(IN) :: ilu
CHARACTER(LEN=*), INTENT(IN) :: hinfile
INTEGER, INTENT(IN) :: current_level
INTEGER(KIND=LFI_INT) :: iresp,iverb,inap,nbvar
CHARACTER(LEN=3) :: suffix
CHARACTER(LEN=:),ALLOCATABLE :: filename
iverb = 0 !Verbosity level for LFI
ALLOCATE(character(len=len(hinfile)) :: filename)
write(suffix,'(I3.3)') current_level
filename=hinfile(1:len(hinfile)-7)//suffix//'.lfi'
CALL LFIOUV(iresp,ilu,ltrue,filename,'OLD',lfalse,lfalse,iverb,inap,nbvar)
DEALLOCATE(filename)
END SUBROUTINE OPEN_SPLIT_LFIFILE
SUBROUTINE OPEN_SPLIT_NCFILES(houtfile,nbvar,tpreclist,cdffiles,ohdf5) SUBROUTINE OPEN_SPLIT_NCFILES(houtfile,nbvar,tpreclist,cdffiles,ohdf5)
CHARACTER(LEN=*), INTENT(IN) :: houtfile CHARACTER(LEN=*), INTENT(IN) :: houtfile
INTEGER, INTENT(IN) :: nbvar INTEGER, INTENT(IN) :: nbvar
...@@ -1073,4 +1094,12 @@ print *,'lowmem: not tested!!!!!' (to be compared with no low mem version) ...@@ -1073,4 +1094,12 @@ print *,'lowmem: not tested!!!!!' (to be compared with no low mem version)
END SUBROUTINE CLOSE_files END SUBROUTINE CLOSE_files
SUBROUTINE CLOSE_SPLIT_LFIFILE(ilu)
INTEGER, INTENT(IN) :: ilu
INTEGER(KIND=LFI_INT) :: iresp
CALL LFIFER(iresp,ilu,'KEEP')
END SUBROUTINE CLOSE_SPLIT_LFIFILE
END MODULE mode_util END MODULE mode_util
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment