1 |
guez |
61 |
module histsync_m |
2 |
|
|
|
3 |
|
|
implicit none |
4 |
|
|
|
5 |
|
|
contains |
6 |
|
|
|
7 |
|
|
SUBROUTINE histsync(file) |
8 |
|
|
|
9 |
|
|
! This subroutine will synchronise all |
10 |
|
|
! (or one if defined) opened files. |
11 |
|
|
|
12 |
|
|
! file: optional argument for fileid |
13 |
|
|
|
14 |
guez |
138 |
use histbeg_totreg_m, ONLY: nb_files |
15 |
|
|
USE histcom_var, ONLY: ncdf_ids |
16 |
guez |
61 |
USE netcdf, ONLY: nf90_sync |
17 |
|
|
|
18 |
|
|
INTEGER, INTENT(IN), OPTIONAL:: file |
19 |
|
|
|
20 |
|
|
INTEGER:: ifile, ncid, iret |
21 |
|
|
|
22 |
|
|
LOGICAL:: file_exists |
23 |
|
|
!--------------------------------------------------------------------- |
24 |
|
|
|
25 |
|
|
! 1.The loop on files to synchronise |
26 |
|
|
|
27 |
|
|
DO ifile = 1, nb_files |
28 |
|
|
|
29 |
|
|
IF (present(file)) THEN |
30 |
|
|
file_exists = (ifile==file) |
31 |
|
|
ELSE |
32 |
|
|
file_exists = .TRUE. |
33 |
|
|
END IF |
34 |
|
|
|
35 |
|
|
IF (file_exists) THEN |
36 |
|
|
ncid = ncdf_ids(ifile) |
37 |
|
|
iret = nf90_sync(ncid) |
38 |
|
|
END IF |
39 |
|
|
|
40 |
|
|
END DO |
41 |
|
|
|
42 |
|
|
END SUBROUTINE histsync |
43 |
|
|
|
44 |
|
|
end module histsync_m |