check if variable name exists (also including groups separated with "/")
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(t_ncfile), | intent(inout) | :: | sf |
self |
||
| character(len=*), | intent(in) | :: | varname_in |
name of the variable (can include "/" for groups) |
FUNCTION ncfile_var_exists(sf,varname_in) RESULT(exists) ! MODULES IMPLICIT NONE !------------------------------------------------------------------------------------------------------------------------------- ! INPUT VARIABLES CHARACTER(LEN=*),INTENT(IN) :: varname_in !! name of the variable (can include "/" for groups) !------------------------------------------------------------------------------------------------------------------------------- ! OUTPUT VARIABLES CLASS(t_ncfile),INTENT(INOUT) :: sf !! self LOGICAL :: exists !------------------------------------------------------------------------------------------------------------------------------- ! LOCAL VARIABLES CHARACTER(LEN=255) :: varname INTEGER :: grpid,varid !=============================================================================================================================== CALL mpi_check_single_access() CALL sf%enter_groups(varname_in,grpid,varname,exists) #if NETCDF IF(exists)THEN sf%ioError = nf90_INQ_VARID(grpid, TRIM(varname), varid) END IF exists=(sf%ioError.EQ.nf90_NOERR) #endif /*NETCDF*/ END FUNCTION ncfile_var_exists