-
Notifications
You must be signed in to change notification settings - Fork 1
/
asmbkg.f90
84 lines (84 loc) · 2.89 KB
/
asmbkg.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
MODULE asmbkg
USE oce
USE sbc_oce
USE zdf_oce
USE zdfddm
USE ldftra
USE ldfslp
USE tradmp
USE zdftke
USE eosbn2
USE zdfmxl
USE dom_oce, ONLY: ndastp
USE in_out_manager
USE iom
USE asmpar
USE zdfmxl
USE ice
IMPLICIT NONE
PRIVATE
PUBLIC :: asm_bkg_wri
CONTAINS
SUBROUTINE asm_bkg_wri(kt)
INTEGER, INTENT( IN ) :: kt
CHARACTER(LEN = 50) :: cl_asmbkg
CHARACTER(LEN = 50) :: cl_asmdin
LOGICAL :: llok
INTEGER :: inum
REAL(KIND = wp) :: zdate
IF (kt == nitbkg_r) THEN
WRITE(cl_asmbkg, FMT = '(A,".nc")') TRIM(c_asmbkg)
cl_asmbkg = TRIM(cl_asmbkg)
INQUIRE(FILE = cl_asmbkg, EXIST = llok)
IF (.NOT. llok) THEN
IF (lwp) WRITE(numout, FMT = *) ' Setting up assimilation background file ' // TRIM(c_asmbkg)
CALL iom_open(c_asmbkg, inum, ldwrt = .TRUE., kiolib = jprstlib)
IF (nitbkg_r == nit000 - 1) THEN
zdate = REAL(ndastp)
IF (ln_zdftke) THEN
IF (lwp) WRITE(numout, FMT = *) ' Reading TKE (en) from restart...'
CALL tke_rst(nit000, 'READ')
END IF
ELSE
zdate = REAL(ndastp)
END IF
CALL iom_rstput(kt, nitbkg_r, inum, 'rdastp', zdate)
CALL iom_rstput(kt, nitbkg_r, inum, 'un', un)
CALL iom_rstput(kt, nitbkg_r, inum, 'vn', vn)
CALL iom_rstput(kt, nitbkg_r, inum, 'tn', tsn(:, :, :, jp_tem))
CALL iom_rstput(kt, nitbkg_r, inum, 'sn', tsn(:, :, :, jp_sal))
CALL iom_rstput(kt, nitbkg_r, inum, 'sshn', sshn)
IF (ln_zdftke) CALL iom_rstput(kt, nitbkg_r, inum, 'en', en)
CALL iom_close(inum)
END IF
END IF
IF (kt == nitdin_r) THEN
WRITE(cl_asmdin, FMT = '(A,".nc")') TRIM(c_asmdin)
cl_asmdin = TRIM(cl_asmdin)
INQUIRE(FILE = cl_asmdin, EXIST = llok)
IF (.NOT. llok) THEN
IF (lwp) WRITE(numout, FMT = *) ' Setting up assimilation background file ' // TRIM(c_asmdin)
CALL iom_open(c_asmdin, inum, ldwrt = .TRUE., kiolib = jprstlib)
IF (nitdin_r == nit000 - 1) THEN
zdate = REAL(ndastp)
ELSE
zdate = REAL(ndastp)
END IF
CALL iom_rstput(kt, nitdin_r, inum, 'rdastp', zdate)
CALL iom_rstput(kt, nitdin_r, inum, 'un', un)
CALL iom_rstput(kt, nitdin_r, inum, 'vn', vn)
CALL iom_rstput(kt, nitdin_r, inum, 'tn', tsn(:, :, :, jp_tem))
CALL iom_rstput(kt, nitdin_r, inum, 'sn', tsn(:, :, :, jp_sal))
CALL iom_rstput(kt, nitdin_r, inum, 'sshn', sshn)
IF (nn_ice == 2) THEN
IF (ALLOCATED(at_i)) THEN
CALL iom_rstput(kt, nitdin_r, inum, 'iceconc', at_i(:, :))
ELSE
CALL ctl_warn('asm_bkg_wri: Ice concentration not written to background ', 'as ice variable at_i not allocated on this timestep')
END IF
END IF
CALL iom_close(inum)
END IF
END IF
END SUBROUTINE asm_bkg_wri
END MODULE asmbkg