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 |
|
|
USE histcom_var, ONLY: nb_files, ncdf_ids |
15 |
|
|
USE netcdf, ONLY: nf90_sync |
16 |
|
|
|
17 |
|
|
INTEGER, INTENT(IN), OPTIONAL:: file |
18 |
|
|
|
19 |
|
|
INTEGER:: ifile, ncid, iret |
20 |
|
|
|
21 |
|
|
LOGICAL:: file_exists |
22 |
|
|
!--------------------------------------------------------------------- |
23 |
|
|
|
24 |
|
|
! 1.The loop on files to synchronise |
25 |
|
|
|
26 |
|
|
DO ifile = 1, nb_files |
27 |
|
|
|
28 |
|
|
IF (present(file)) THEN |
29 |
|
|
file_exists = (ifile==file) |
30 |
|
|
ELSE |
31 |
|
|
file_exists = .TRUE. |
32 |
|
|
END IF |
33 |
|
|
|
34 |
|
|
IF (file_exists) THEN |
35 |
|
|
ncid = ncdf_ids(ifile) |
36 |
|
|
iret = nf90_sync(ncid) |
37 |
|
|
END IF |
38 |
|
|
|
39 |
|
|
END DO |
40 |
|
|
|
41 |
|
|
END SUBROUTINE histsync |
42 |
|
|
|
43 |
|
|
end module histsync_m |