1 !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 ! Driver for the tangent linear model (TLM)
3 !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5 PROGRAM KPP_ROOT_TLM_Driver
8 USE KPP_ROOT_Initialize
, ONLY
: Initialize
10 KPP_REAL
:: T
, DVAL(NSPEC
)
11 INTEGER :: i
, j
, ind_1
= 1, ind_2
= 2
12 ! INTEGER :: ind_1 = ind_NO2, ind_2 = ind_O3
14 ! --- Number of sensitivity coefficients to compute
15 ! --- Note: this value is set for sensitivities w.r.t. all initial values
16 ! --- it may have to be changed for other applications
19 KPP_REAL
Y_TLM(NVAR
,NTLM
)
21 ! ---- TIME VARIABLES ------------------
32 !~~~> Note: the initial values below are for sensitivities
33 ! w.r.t. initial values;
34 ! they have to be changed for other applications
40 Y_TLM(ind_1
,1) = 1.0d0
41 Y_TLM(ind_2
,2) = 1.0d0
43 ! ~~~~~~~~~ BEGIN TIME LOOP ~~~~~~~~~~
49 kron
: DO WHILE (T
< TEND
)
51 CALL GetMass( C
, DVAL
)
52 WRITE(6,991) (T
-TSTART
)/(TEND
-TSTART
)*100, T
, &
53 (TRIM(SPC_NAMES(MONITOR(i
))), &
54 C(MONITOR(i
))/CFACTOR
, i
=1,NMONITOR
),&
55 (TRIM(SMASS(i
)),DVAL(i
)/CFACTOR
, i
=1,NMASS
)
59 CALL INTEGRATE_TLM( NTLM
, VAR
, Y_TLM
, T
, T
+DT
)
65 CALL GetMass( C
, DVAL
)
66 WRITE(6,991) (T
-TSTART
)/(TEND
-TSTART
)*100, T
, &
67 (TRIM(SPC_NAMES(MONITOR(i
))), &
68 C(MONITOR(i
))/CFACTOR
, i
=1,NMONITOR
), &
69 (TRIM(SMASS(i
)),DVAL(i
)/CFACTOR
, i
=1,NMASS
)
73 ! ~~~~~~~~~ END TIME LOOP ~~~~~~~~~~
75 OPEN(20, FILE
='KPP_ROOT_TLM_results.m')
76 WRITE(6,*) '**************************************************'
77 WRITE(6,*) ' Concentrations and Sensitivities at final time '
78 WRITE(6,*) ' were written in the file KPP_ROOT_TLM_results.m'
79 WRITE(6,*) '**************************************************'
81 WRITE(20,993) ( Y_TLM(i
,j
), i
=1,NVAR
)
86 WRITE(6,995) TRIM(SPC_NAMES(ind_1
)),TRIM(SPC_NAMES(ind_1
)), &
88 WRITE(6,995) TRIM(SPC_NAMES(ind_2
)),TRIM(SPC_NAMES(ind_2
)), &
90 WRITE(6,995) TRIM(SPC_NAMES(ind_1
)),TRIM(SPC_NAMES(ind_2
)), &
92 WRITE(6,995) TRIM(SPC_NAMES(ind_2
)),TRIM(SPC_NAMES(ind_1
)), &
95 991 FORMAT(F6
.1
,'%. T=',E10
.3
,3X
,20(A
,'=',E10
.4
,';',1X
))
96 993 FORMAT(1000(E24
.16
,2X
))
97 995 FORMAT('TLM: d[',A
,'](tf)/d[',A
,'](t0)=',E14
.7
)
99 END PROGRAM KPP_ROOT_TLM_Driver