From e308ded6c9c6f3114794ac03bd9ebd8bcec8c1c7 Mon Sep 17 00:00:00 2001 From: Lionel GUEZ <guez@lmd.ens.fr> Date: Tue, 26 Jul 2022 13:18:01 +0200 Subject: [PATCH] Open or create shapefiles before computation --- Inst_eddies/inst_eddies.f90 | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/Inst_eddies/inst_eddies.f90 b/Inst_eddies/inst_eddies.f90 index 83cdd65d..4c28beb2 100644 --- a/Inst_eddies/inst_eddies.f90 +++ b/Inst_eddies/inst_eddies.f90 @@ -24,7 +24,7 @@ program inst_eddies type(snapshot) s TYPE(shpc_slice_handler) hshpc_cyclo, hshpc_anti - integer i, date + integer i, date, iostat integer unit integer nlon, nlat @@ -83,6 +83,18 @@ program inst_eddies call input_ssh(corner, step, nlon, nlat, periodic, ssh, u, v, corner_deg, & step_deg) + + ! Open or create now so we test the existence of directories: + call shpc_open(hshpc_cyclo, shpc_dir = "SHPC_cyclo", pszaccess = "rb+", & + iostat = iostat) + + if (iostat == 0) then + call shpc_open(hshpc_anti, shpc_dir = "SHPC_anti", pszaccess = "rb+") + else + call shpc_create(hshpc_cyclo, shpc_dir = "SHPC_cyclo", cyclone = .true.) + call shpc_create(hshpc_anti, shpc_dir = "SHPC_anti", cyclone = .false.) + end if + call cpu_time(t1) write(unit, fmt = *) "CPU time for input, before computation:", t1 - t0, "s" t0 = t1 @@ -133,15 +145,6 @@ program inst_eddies t0 = t1 ! Write snapshot: - - if (exist) then - call shpc_open(hshpc_cyclo, shpc_dir = "SHPC_cyclo", pszaccess = "rb+") - call shpc_open(hshpc_anti, shpc_dir = "SHPC_anti", pszaccess = "rb+") - else - call shpc_create(hshpc_cyclo, shpc_dir = "SHPC_cyclo", cyclone = .true.) - call shpc_create(hshpc_anti, shpc_dir = "SHPC_anti", cyclone = .false.) - end if - call write_snapshot(s, hshpc_cyclo, hshpc_anti, date) call write_aux(corner_deg, step_deg, nlon, nlat, hshpc_cyclo, exist) call write_aux(corner_deg, step_deg, nlon, nlat, hshpc_anti, exist) -- GitLab