1 |
C $Header: /u/gcmpack/MITgcm/pkg/exf/exf_ad_dump.F,v 1.5 2012/08/28 19:17:45 gforget Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "EXF_OPTIONS.h" |
5 |
#include "AD_CONFIG.h" |
6 |
|
7 |
CBOP |
8 |
C !ROUTINE: exf_ad_dump |
9 |
C !INTERFACE: |
10 |
SUBROUTINE EXF_AD_DUMP( myTime, myIter, myThid ) |
11 |
|
12 |
C !DESCRIPTION: \bv |
13 |
C *==========================================================* |
14 |
C | SUBROUTINE exf_ad_dump | |
15 |
C *==========================================================* |
16 |
C Extract adjoint variable from TAMC/TAF-generated |
17 |
C adjoint common blocks, contained in adcommon.h |
18 |
C and write fields to file; |
19 |
C Make sure common blocks in adcommon.h are up-to-date |
20 |
C w.r.t. current adjoint code. |
21 |
C *==========================================================* |
22 |
C | SUBROUTINE exf_ad_dump | |
23 |
C *==========================================================* |
24 |
C \ev |
25 |
|
26 |
C !USES: |
27 |
IMPLICIT NONE |
28 |
|
29 |
C == Global variables === |
30 |
#include "SIZE.h" |
31 |
#include "EEPARAMS.h" |
32 |
#include "PARAMS.h" |
33 |
#include "EXF_PARAM.h" |
34 |
#ifdef ALLOW_MNC |
35 |
#include "MNC_PARAMS.h" |
36 |
#endif |
37 |
#include "GRID.h" |
38 |
#ifdef ALLOW_AUTODIFF_MONITOR |
39 |
# include "adcommon.h" |
40 |
#endif |
41 |
|
42 |
C !INPUT/OUTPUT PARAMETERS: |
43 |
C == Routine arguments == |
44 |
C myTime :: time counter for this thread |
45 |
C myIter :: iteration counter for this thread |
46 |
C myThid :: Thread number for this instance of the routine. |
47 |
_RL myTime |
48 |
INTEGER myIter |
49 |
INTEGER myThid |
50 |
|
51 |
#if (defined (ALLOW_ADJOINT_RUN) || defined (ALLOW_ADMTLM)) |
52 |
#ifdef ALLOW_AUTODIFF_MONITOR |
53 |
|
54 |
C !FUNCTIONS: |
55 |
LOGICAL DIFFERENT_MULTIPLE |
56 |
EXTERNAL DIFFERENT_MULTIPLE |
57 |
INTEGER IO_ERRCOUNT |
58 |
EXTERNAL IO_ERRCOUNT |
59 |
|
60 |
C !LOCAL VARIABLES: |
61 |
c == local variables == |
62 |
C suff :: Hold suffix part of a filename |
63 |
C msgBuf :: Error message buffer |
64 |
CHARACTER*(MAX_LEN_FNAM) suff |
65 |
c CHARACTER*(MAX_LEN_MBUF) msgBuf |
66 |
|
67 |
c == end of interface == |
68 |
CEOP |
69 |
|
70 |
CALL TIMER_START('I/O (WRITE) [EXF_AD_DUMP]', myThid ) |
71 |
|
72 |
IF ( |
73 |
& DIFFERENT_MULTIPLE(adjDumpFreq,myTime,deltaTClock) |
74 |
& ) THEN |
75 |
|
76 |
C-- Set suffix for this set of data files. |
77 |
WRITE(suff,'(I10.10)') myIter |
78 |
C ==>> Resetting run-time parameter writeBinaryPrec in the middle of a run |
79 |
C ==>> is very very very nasty !!! |
80 |
c writeBinaryPrec = writeStatePrec |
81 |
C <<== If you really want to mess-up with this at your own risk, |
82 |
C <<== uncomment the line above |
83 |
|
84 |
CALL WRITE_REC_3D_RL( |
85 |
& 'ADJhflux.'//suff, writeBinaryPrec, 1, |
86 |
& adhflux, 1, myIter, myThid ) |
87 |
CALL WRITE_REC_3D_RL( |
88 |
& 'ADJsflux.'//suff, writeBinaryPrec, 1, |
89 |
& adsflux, 1, myIter, myThid ) |
90 |
CALL WRITE_REC_3D_RL( |
91 |
& 'ADJustress.'//suff, writeBinaryPrec, 1, |
92 |
& adustress, 1, myIter, myThid ) |
93 |
CALL WRITE_REC_3D_RL( |
94 |
& 'ADJvstress.'//suff, writeBinaryPrec, 1, |
95 |
& advstress, 1, myIter, myThid ) |
96 |
|
97 |
# ifdef ALLOW_ATM_TEMP |
98 |
CALL WRITE_REC_3D_RL( |
99 |
& 'ADJatemp.'//suff, writeBinaryPrec, 1, |
100 |
& adatemp, 1, myIter, myThid ) |
101 |
CALL WRITE_REC_3D_RL( |
102 |
& 'ADJaqh.'//suff, writeBinaryPrec, 1, |
103 |
& adaqh, 1, myIter, myThid ) |
104 |
CALL WRITE_REC_3D_RL( |
105 |
& 'ADJlwflux.'//suff, writeBinaryPrec, 1, |
106 |
& adlwflux, 1, myIter, myThid ) |
107 |
CALL WRITE_REC_3D_RL( |
108 |
& 'ADJprecip.'//suff, writeBinaryPrec, 1, |
109 |
& adprecip, 1, myIter, myThid ) |
110 |
# endif |
111 |
IF ( useAtmWind ) THEN |
112 |
CALL WRITE_REC_3D_RL( |
113 |
& 'ADJuwind.'//suff, writeBinaryPrec, 1, |
114 |
& aduwind, 1, myIter, myThid ) |
115 |
CALL WRITE_REC_3D_RL( |
116 |
& 'ADJvwind.'//suff, writeBinaryPrec, 1, |
117 |
& advwind, 1, myIter, myThid ) |
118 |
ENDIF |
119 |
# ifdef ALLOW_DOWNWARD_RADIATION |
120 |
CALL WRITE_REC_3D_RL( |
121 |
& 'ADJswdown.'//suff, writeBinaryPrec, 1, |
122 |
& adswdown, 1, myIter, myThid ) |
123 |
CALL WRITE_REC_3D_RL( |
124 |
& 'ADJlwdown.'//suff, writeBinaryPrec, 1, |
125 |
& adlwdown, 1, myIter, myThid ) |
126 |
# endif |
127 |
# ifdef ATMOSPHERIC_LOADING |
128 |
cph CALL WRITE_REC_3D_RL( |
129 |
cph & 'ADJapressure.'//suff, writeBinaryPrec, 1, |
130 |
cph & adapressure, 1, myIter, myThid ) |
131 |
# endif |
132 |
# if defined(ALLOW_ATM_TEMP) || defined(SHORTWAVE_HEATING) |
133 |
cph CALL WRITE_REC_3D_RL( |
134 |
cph & 'ADJswflux.'//suff, writeBinaryPrec, 1, |
135 |
cph & adswflux, 1, myIter, myThid ) |
136 |
# endif |
137 |
# if defined(ALLOW_ATM_TEMP) || defined(EXF_READ_EVAP) |
138 |
cph CALL WRITE_REC_3D_RL( |
139 |
cph & 'ADJevap.'//suff, writeBinaryPrec, 1, |
140 |
cph & adevap, 1, myIter, myThid ) |
141 |
# endif |
142 |
|
143 |
ENDIF |
144 |
|
145 |
CALL TIMER_STOP( 'I/O (WRITE) [EXF_AD_DUMP]', myThid ) |
146 |
|
147 |
#endif /* ALLOW_AUTODIFF_MONITOR */ |
148 |
#endif /* ALLOW_ADJOINT_RUN */ |
149 |
|
150 |
RETURN |
151 |
END |