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

Philippe 27/02/2019: IO: use recursive calls to open/close DES files

parent 2e4b4288
No related branches found
No related tags found
No related merge requests found
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
! P. Wautelet 07/02/2019: remove OPARALLELIO argument from open and close files subroutines ! P. Wautelet 07/02/2019: remove OPARALLELIO argument from open and close files subroutines
! (nsubfiles_ioz is now determined in IO_FILE_ADD2LIST) ! (nsubfiles_ioz is now determined in IO_FILE_ADD2LIST)
! P. Wautelet 19/02/2019: simplification/restructuration/cleaning of open/close subroutines (TBCto be continued) ! P. Wautelet 19/02/2019: simplification/restructuration/cleaning of open/close subroutines (TBCto be continued)
! P. Wautelet 27/02/2019: use recursive calls to open/close DES files
!----------------------------------------------------------------- !-----------------------------------------------------------------
MODULE MODE_FM MODULE MODE_FM
...@@ -50,12 +51,12 @@ IF ( IP == 1 ) PRINT *,'INIT L1D,L2D,LPACK = ',L1D,L2D,LPACK ...@@ -50,12 +51,12 @@ IF ( IP == 1 ) PRINT *,'INIT L1D,L2D,LPACK = ',L1D,L2D,LPACK
END SUBROUTINE SET_FMPACK_ll END SUBROUTINE SET_FMPACK_ll
SUBROUTINE IO_FILE_OPEN_ll(TPFILE,KRESP,HPOSITION,HSTATUS,HPROGRAM_ORIG) recursive SUBROUTINE IO_FILE_OPEN_ll(TPFILE,KRESP,HPOSITION,HSTATUS,HPROGRAM_ORIG)
! !
USE MODD_CONF, ONLY: CPROGRAM USE MODD_CONF, ONLY: CPROGRAM
USE MODD_IO_ll, ONLY: LIO_NO_WRITE, TFILEDATA USE MODD_IO_ll, ONLY: LIO_NO_WRITE, TFILEDATA
! !
USE MODE_IO_ll, ONLY: OPEN_ll USE MODE_IO_ll, ONLY: GCONFIO, OPEN_ll
USE MODE_IO_MANAGE_STRUCT, ONLY: IO_FILE_ADD2LIST, IO_FILE_FIND_BYNAME USE MODE_IO_MANAGE_STRUCT, ONLY: IO_FILE_ADD2LIST, IO_FILE_FIND_BYNAME
! !
TYPE(TFILEDATA), POINTER, INTENT(INOUT) :: TPFILE ! File structure TYPE(TFILEDATA), POINTER, INTENT(INOUT) :: TPFILE ! File structure
...@@ -74,7 +75,8 @@ CALL PRINT_MSG(NVERB_DEBUG,'IO','IO_FILE_OPEN_ll','opening '//TRIM(TPFILE%CNAME) ...@@ -74,7 +75,8 @@ CALL PRINT_MSG(NVERB_DEBUG,'IO','IO_FILE_OPEN_ll','opening '//TRIM(TPFILE%CNAME)
IF (.NOT.ASSOCIATED(TPFILE)) CALL PRINT_MSG(NVERB_FATAL,'IO','IO_FILE_OPEN_ll','TPFILE is not associated') IF (.NOT.ASSOCIATED(TPFILE)) CALL PRINT_MSG(NVERB_FATAL,'IO','IO_FILE_OPEN_ll','TPFILE is not associated')
! !
IF ( LIO_NO_WRITE .AND. TPFILE%CMODE == 'WRITE' .AND. TPFILE%CTYPE/='OUTPUTLISTING') THEN IF ( LIO_NO_WRITE .AND. TPFILE%CMODE == 'WRITE' .AND. TPFILE%CTYPE/='OUTPUTLISTING') THEN
CALL PRINT_MSG(NVERB_WARNING,'IO','IO_FILE_OPEN_ll','opening file '//TRIM(TPFILE%CNAME)//' in write mode but LIO_NO_WRITE is set') CALL PRINT_MSG(NVERB_WARNING,'IO','IO_FILE_OPEN_ll','opening file '//TRIM(TPFILE%CNAME)// &
' in write mode but LIO_NO_WRITE is set')
END IF END IF
! !
TZFILE_DES => NULL() TZFILE_DES => NULL()
...@@ -105,6 +107,11 @@ SELECT CASE(TPFILE%CTYPE) ...@@ -105,6 +107,11 @@ SELECT CASE(TPFILE%CTYPE)
CALL OPEN_ll(TPFILE,IRESP,HMODE='GLOBAL') CALL OPEN_ll(TPFILE,IRESP,HMODE='GLOBAL')
!DES files
CASE('DES')
CALL OPEN_ll(TPFILE,IRESP,HDELIM='QUOTE')
!GPS files !GPS files
CASE('GPS') CASE('GPS')
CALL OPEN_ll(TPFILE,IRESP,HMODE='SPECIFIC') CALL OPEN_ll(TPFILE,IRESP,HMODE='SPECIFIC')
...@@ -135,19 +142,22 @@ SELECT CASE(TPFILE%CTYPE) ...@@ -135,19 +142,22 @@ SELECT CASE(TPFILE%CTYPE)
CALL OPEN_ll(TPFILE,IRESP,HPOSITION=HPOSITION,HSTATUS=HSTATUS,HMODE='GLOBAL') CALL OPEN_ll(TPFILE,IRESP,HPOSITION=HPOSITION,HSTATUS=HSTATUS,HMODE='GLOBAL')
CASE DEFAULT !MesoNH files
!Remark: 'MNH' is more general than MNHBACKUP and could be in fact a MNHBACKUP file
CASE ('MNH', 'MNHBACKUP', 'MNHDIACHRONIC', 'MNHDIAG', 'MNHOUTPUT', 'PGD')
if (.not.GCONFIO) CALL PRINT_MSG(NVERB_FATAL,'IO','IO_FILE_OPEN_ll','SET_CONFIO_ll must be called before IO_FILE_OPEN_ll')
!Do not open '.des' file if OUTPUT !Do not open '.des' file if OUTPUT
IF(TPFILE%CTYPE/='MNHOUTPUT' .AND. CPROGRAM/='LFICDF') THEN IF(TPFILE%CTYPE/='MNHOUTPUT' .AND. CPROGRAM/='LFICDF') THEN
CALL IO_FILE_ADD2LIST(TZFILE_DES,TRIM(TPFILE%CNAME)//'.des','DES',TPFILE%CMODE,TPDATAFILE=TPFILE,OOLD=.TRUE.) !OOLD=T because the file may already be in the list !OOLD=T because the file may already be in the list
CALL PRINT_MSG(NVERB_DEBUG,'IO','IO_FILE_OPEN_ll','OPEN_ll for '//TRIM(TPFILE%CNAME)//'.des') CALL IO_FILE_ADD2LIST(TZFILE_DES,TRIM(TPFILE%CNAME)//'.des','DES',TPFILE%CMODE,TPDATAFILE=TPFILE,OOLD=.TRUE.)
CALL OPEN_ll(TZFILE_DES,IRESP,HDELIM='QUOTE') CALL IO_FILE_OPEN_ll(TZFILE_DES,HPROGRAM_ORIG=HPROGRAM_ORIG)
TZFILE_DES%LOPENED = .TRUE.
TZFILE_DES%NOPEN_CURRENT = TZFILE_DES%NOPEN_CURRENT + 1
TZFILE_DES%NOPEN = TZFILE_DES%NOPEN + 1
ENDIF ENDIF
! !
CALL FMOPEN_ll(TPFILE,IRESP,HPROGRAM_ORIG=HPROGRAM_ORIG) CALL FMOPEN_ll(TPFILE,IRESP,HPROGRAM_ORIG=HPROGRAM_ORIG)
CASE DEFAULT
call print_msg(NVERB_FATAL,'IO','IO_FILE_OPEN_ll','invalid type '//trim(tpfile%ctype)//' for file '//trim(tpfile%cname))
END SELECT END SELECT
! !
IF (PRESENT(KRESP)) KRESP = IRESP IF (PRESENT(KRESP)) KRESP = IRESP
...@@ -266,7 +276,7 @@ KRESP=IRESP ...@@ -266,7 +276,7 @@ KRESP=IRESP
END SUBROUTINE FMOPEN_ll END SUBROUTINE FMOPEN_ll
SUBROUTINE IO_FILE_CLOSE_ll(TPFILE,KRESP,HPROGRAM_ORIG) recursive SUBROUTINE IO_FILE_CLOSE_ll(TPFILE,KRESP,HPROGRAM_ORIG)
! !
USE MODD_CONF, ONLY: CPROGRAM USE MODD_CONF, ONLY: CPROGRAM
USE MODD_IO_ll, ONLY: TFILEDATA USE MODD_IO_ll, ONLY: TFILEDATA
...@@ -310,7 +320,7 @@ IF (TPFILE%NOPEN_CURRENT>1) THEN ...@@ -310,7 +320,7 @@ IF (TPFILE%NOPEN_CURRENT>1) THEN
END IF END IF
! !
SELECT CASE(TPFILE%CTYPE) SELECT CASE(TPFILE%CTYPE)
CASE('CHEMINPUT','CHEMTAB','GPS','METEO','NML','OUTPUTLISTING','SURFACE_DATA','TXT') CASE('CHEMINPUT','CHEMTAB','DES','GPS','METEO','NML','OUTPUTLISTING','SURFACE_DATA','TXT')
CALL CLOSE_ll(TPFILE,IRESP) CALL CLOSE_ll(TPFILE,IRESP)
! !
TPFILE%NLU = -1 TPFILE%NLU = -1
...@@ -320,15 +330,7 @@ SELECT CASE(TPFILE%CTYPE) ...@@ -320,15 +330,7 @@ SELECT CASE(TPFILE%CTYPE)
IF(TPFILE%CTYPE/='OUTPUT' .AND. CPROGRAM/='LFICDF') THEN IF(TPFILE%CTYPE/='OUTPUT' .AND. CPROGRAM/='LFICDF') THEN
CALL IO_FILE_FIND_BYNAME(TRIM(TPFILE%CNAME)//'.des',TZFILE_DES,IRESP) CALL IO_FILE_FIND_BYNAME(TRIM(TPFILE%CNAME)//'.des',TZFILE_DES,IRESP)
IF (IRESP/=0) CALL PRINT_MSG(NVERB_ERROR,'IO','IO_FILE_CLOSE_ll','file '//TRIM(TPFILE%CNAME)//'.des not in filelist') IF (IRESP/=0) CALL PRINT_MSG(NVERB_ERROR,'IO','IO_FILE_CLOSE_ll','file '//TRIM(TPFILE%CNAME)//'.des not in filelist')
! CALL IO_FILE_CLOSE_ll(TZFILE_DES,KRESP=IRESP,HPROGRAM_ORIG=HPROGRAM_ORIG)
TZFILE_DES%NOPEN_CURRENT = TZFILE_DES%NOPEN_CURRENT - 1
TZFILE_DES%NCLOSE = TZFILE_DES%NCLOSE + 1
!
IF (TZFILE_DES%NOPEN_CURRENT==0) THEN
CALL CLOSE_ll(TZFILE_DES,IRESP)
TZFILE_DES%LOPENED = .FALSE.
TZFILE_DES%NLU = -1
END IF
ENDIF ENDIF
! !
#if defined(MNH_IOCDF4) #if defined(MNH_IOCDF4)
......
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