From f31ec3da9c45cd0e880a5eb72ee2298cc619efbb Mon Sep 17 00:00:00 2001 From: Sergey Kosukhin <sergey.kosukhin@mpimet.mpg.de> Date: Fri, 14 Feb 2025 16:02:58 +0100 Subject: [PATCH] Avoid references to disassociated POINTERs in examples --- examples/example.f90 | 6 +++++- examples/repetitor.f90 | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/examples/example.f90 b/examples/example.f90 index 1ced5659..6a308057 100644 --- a/examples/example.f90 +++ b/examples/example.f90 @@ -166,7 +166,11 @@ CONTAINS CALL deallocateTimedelta(mtime_td) mtime_td => newTimedelta("PT7536.0003S") - CALL timedeltatostring(mtime_td, td_string) + IF (ASSOCIATED(mtime_td)) THEN + CALL timedeltatostring(mtime_td, td_string) + ELSE + td_string = "<null>" + END IF WRITE (0, *) "PT7536.0003S (expect <null>) = ", TRIM(td_string) CALL deallocateTimedelta(mtime_td) diff --git a/examples/repetitor.f90 b/examples/repetitor.f90 index 3ac9bc4a..d20d0d66 100644 --- a/examples/repetitor.f90 +++ b/examples/repetitor.f90 @@ -56,7 +56,11 @@ CONTAINS IF (lstart) THEN PRINT *, 'Start: ', TRIM(start) s => newDateTime(start) - CALL datetimeToString(s, dstring) + IF (ASSOCIATED(s)) THEN + CALL datetimeToString(s, dstring) + ELSE + dstring = "<null>" + END IF PRINT *, 'Start rev: ', TRIM(dstring) CALL deallocateDateTime(s) END IF -- GitLab