diff --git a/Inst_eddies/inst_eddies.f90 b/Inst_eddies/inst_eddies.f90 index 83cdd65d838f7ac2e4bc9d81254f7863588c516d..4c28beb2fe9a9c47577283133a42201041256d77 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)