source: flexpart.git/flexpart_code/fpmetbinary_mod.F90 @ 5b3cc42

fp9.3.1-20161214-nc4
Last change on this file since 5b3cc42 was 5b3cc42, checked in by Don Morton <Don.Morton@…>, 7 years ago

Starting to code infrastructure for NC4

  • Property mode set to 100644
File size: 28.0 KB
Line 
1MODULE fpmetbinary_mod
2
3  !*****************************************************************************
4  !                                                                            *
5  !     Contains data and routines for dumping and loading processed met       *
6  !     fields.                                                                *
7  !     Authors Don Morton (Don.Morton@borealscicomp.com)                      *
8  !             Delia Arnold (deliona.arnold@gmail.com)                        *
9  !                                                                            *
10  !     07 Oct 2016                                                            *
11  !                                                                            *
12  !     Most of the data structures from com_mod.f90 that are dumped and       *
13  !     loaded have a final dimension of size two, so that they may hold data  *
14  !     from two met files.  When we dump the contents into a .fp file, we     *
15  !     need to specify which of the two to dump.  Likewise, when we load      *
16  !     from a .fp file, we need to specify which of the two possible indices  *
17  !     to load into.                                                          *
18  !                                                                            *
19  !     Note that these routines need more robustness.  For example, what      *
20  !     what happens if the filename can't be read or written.  Or, what       *
21  !     happens if a read or write fails in any way.  Right now, it's crash    *
22  !     city.                                                                  *
23  !                                                                            *
24  !     Recent enhancements (07 Oct 2016) DJM:                                 *
25  !                                                                            *
26  !     - file format changed so that compiled dimensions are output, and      *
27  !       during input these same dimensions are compared with the dimensions  *
28  !       compiled into the flexpart that is reading it.  A discrepancy        *
29  !       causes abort, so that time isn't wasted reading an incompatible      *
30  !       file.                                                                *
31  !                                                                            *
32  !     - file format changed so that first item is an 8-character string      *
33  !       depicting the version of the preprocessed file format.               *
34  !       An inconsistency between a detected and expected string results      *
35  !       in program abort.                                                    *
36  !                                                                            *
37  !       *** IMPORTANT *** - when the format of the preprocessed output is    *
38  !       modified in any way, be sure to change the version string below,     *
39  !       PREPROC_FORMAT_VERSION_STR, so that attempts to read the output      *
40  !       with a different format version will cause an abort.                 *
41  !                                                                            *
42  !*****************************************************************************
43
44    USE com_mod
45    USE conv_mod
46    USE par_mod, ONLY : nxmax, nymax, nzmax, nuvzmax, nwzmax
47
48    USE netcdf
49
50    IMPLICIT NONE
51
52    ! Users may want to change these IO Unit values if they conflict with other parts
53    ! of code
54    INTEGER, PARAMETER :: IOUNIT_DUMP = 33, IOUNIT_LOAD = 34, &
55                          IOUNIT_TEXTOUT = 35
56
57    ! When a change is made to the format of the preprocessed file, such that
58    ! this routine will not be able to read a previous version, this version
59    ! string should be modified
60    CHARACTER(LEN=12), PARAMETER :: PREPROC_FORMAT_VERSION_STR = 'FP_p-9.3.1'//char(0)
61
62    PRIVATE IOUNIT_DUMP, IOUNIT_LOAD, IOUNIT_TEXTOUT, fpio,    &
63&           PREPROC_FORMAT_VERSION_STR
64
65
66CONTAINS
67
68  !*****************************************************************************
69  !                                                                            *
70  !    Subroutines fpmetbinary_dump() and fpmetbinary_load() provide the       *
71  !    public interface to                                                     *
72  !    this module functionality.  I created the PRIVATE fpio() because I      *
73  !    wanted all interactions with variables to be in one place.  The read    *
74  !    and write operations need to be done in exactly the same sequence, so   *
75  !    I felt like keeping them in the same routine would at least allow for   *
76  !    coders to more easily compare the two sequences than if they were       *
77  !    separate.                                                               *
78  !                                                                            *
79  !    As mentioned above, the dumps and loads will, for most variables,       *
80  !    need to refer to one of two index values for the last dimension of      *
81  !    the array.                                                              *
82  !                                                                            *
83  !*****************************************************************************
84
85
86    SUBROUTINE fpmetbinary_dump(filename, cm_index)
87        CHARACTER(LEN=*), INTENT(IN) :: filename  ! Full path for file
88        INTEGER, INTENT(IN) :: cm_index           ! Index of last dimension in
89                                                  ! most com_mod variables.
90                                                  ! Should be 1 or 2
91
92        INTEGER millisecs_start, millisecs_stop, count_rate, count_max
93
94        INTEGER ncretval, ncid
95
96        CALL SYSTEM_CLOCK(millisecs_start, count_rate, count_max)
97
98        ! Create and open NC4 file for writing
99        PRINT *, 'Opening NC4 file...'
100        ncretval = nf90_create(filename // ".nc4", &
101&                              OR(NF90_CLOBBER, NF90_HDF5), &
102&                              ncid)
103
104        OPEN(IOUNIT_DUMP, file=filename, action='WRITE', status='REPLACE', form="unformatted", access="stream")
105
106
107
108
109
110
111        CALL fpio(IOUNIT_DUMP, 'DUMP', cm_index)
112        CLOSE(IOUNIT_DUMP)
113
114        PRINT *, 'Closing NC4 file...'
115        ncretval = nf90_close(ncid)
116
117        CALL SYSTEM_CLOCK(millisecs_stop, count_rate, count_max)
118
119        !PRINT *, 'Dump walltime secs: ', (millisecs_stop-millisecs_start)/1000.0
120    END SUBROUTINE fpmetbinary_dump
121
122    SUBROUTINE fpmetbinary_load(filename, cm_index)
123        CHARACTER(LEN=*), INTENT(IN) :: filename  ! Full path for file
124        INTEGER, INTENT(IN) :: cm_index           ! Index of last dimension in
125                                                  ! most com_mod variables.
126                                                  ! Should be 1 or 2
127
128        INTEGER millisecs_start, millisecs_stop, count_rate, count_max
129
130        CALL SYSTEM_CLOCK(millisecs_start, count_rate, count_max)
131        OPEN(IOUNIT_LOAD, file=filename, action='READ', status='OLD', form="unformatted", access="stream")
132        CALL fpio(IOUNIT_LOAD, 'LOAD', cm_index)
133        CLOSE(IOUNIT_LOAD)
134        CALL SYSTEM_CLOCK(millisecs_stop, count_rate, count_max)
135        !PRINT *, 'Load walltime secs: ', (millisecs_stop-millisecs_start)/1000.0
136    END SUBROUTINE fpmetbinary_load
137
138    SUBROUTINE fpmetbinary_zero(cm_index)
139        INTEGER, INTENT(IN) :: cm_index           ! Index of last dimension in
140                                                  ! most com_mod variables.
141                                                  ! Should be 1 or 2
142
143
144        ! Zeroes out, in local datastructures, the values dumped/loaded
145        ! This was written primarily as a testing mechanism.
146        ! The lines here correspond to READ and WRITE in the dump/load routines
147
148        ! Scalar values
149        nx=0.0; ny=0.0; nxmin1=0.0; nymin1=0.0; nxfield=0.0
150        nuvz=0.0; nwz=0.0; nz=0.0; nmixz=0.0; nlev_ec=0.0
151        dx=0.0; dy=0.0; xlon0=0.0; ylat0=0.0; dxconst=0.0; dyconst=0.0
152
153        ! Fixed fields, static in time
154        oro=0.0; excessoro=0.0; lsm=0.0; xlanduse=0.0; height=0.0
155
156        ! 3d fields
157        uu(:,:,:,cm_index) = 0.0
158        vv(:,:,:,cm_index) = 0.0
159        uupol(:,:,:,cm_index) = 0.0
160        vvpol(:,:,:,cm_index) = 0.0
161        ww(:,:,:,cm_index) = 0.0
162        tt(:,:,:,cm_index) = 0.0
163        qv(:,:,:,cm_index) = 0.0
164        pv(:,:,:,cm_index) = 0.0
165        rho(:,:,:,cm_index) = 0.0
166        drhodz(:,:,:,cm_index) = 0.0
167        tth(:,:,:,cm_index) = 0.0
168        qvh(:,:,:,cm_index) = 0.0
169        pplev(:,:,:,cm_index) = 0.0
170        clouds(:,:,:,cm_index) = 0.0
171        cloudsh(:,:,cm_index) = 0.0
172
173        ! 2d fields
174        ps(:,:,:,cm_index) = 0.0
175        sd(:,:,:,cm_index) = 0.0
176        msl(:,:,:,cm_index) = 0.0
177        tcc(:,:,:,cm_index) = 0.0
178        u10(:,:,:,cm_index) = 0.0
179        v10(:,:,:,cm_index) = 0.0
180        tt2(:,:,:,cm_index) = 0.0
181        td2(:,:,:,cm_index) = 0.0
182        lsprec(:,:,:,cm_index) = 0.0
183        convprec(:,:,:,cm_index) = 0.0
184        sshf(:,:,:,cm_index) = 0.0
185        ssr(:,:,:,cm_index) = 0.0
186        surfstr(:,:,:,cm_index) = 0.0
187        ustar(:,:,:,cm_index) = 0.0
188        wstar(:,:,:,cm_index) = 0.0
189        hmix(:,:,:,cm_index) = 0.0
190        tropopause(:,:,:,cm_index) = 0.0
191        oli(:,:,:,cm_index) = 0.0
192        diffk(:,:,:,cm_index) = 0.0
193        vdep(:,:,:,cm_index) = 0.0
194
195        ! 1d fields
196        z0(:) = 0.0
197        akm(:) = 0.0
198        bkm(:) = 0.0
199        akz(:) = 0.0
200        bkz(:) = 0.0
201        aknew(:) = 0.0
202        bknew(:) = 0.0
203
204        ! Nested, scalar values (for each nest)
205        nxn(:) = 0.0
206        nyn(:) = 0.0
207        dxn(:) = 0.0
208        dyn(:) = 0.0
209        xlon0n(:) = 0.0
210        ylat0n(:) = 0.0
211
212        ! Nested fields, static in time
213        oron=0.0; excessoron=0.0; lsmn=0.0; xlandusen=0.0
214
215        ! 3d nested fields
216        uun(:,:,:,cm_index,:) = 0.0
217        wwn(:,:,:,cm_index,:) = 0.0
218        ttn(:,:,:,cm_index,:) = 0.0
219        qvn(:,:,:,cm_index,:) = 0.0
220        pvn(:,:,:,cm_index,:) = 0.0
221        cloudsn(:,:,:,cm_index,:) = 0.0
222        cloudsnh(:,:,cm_index,:) = 0.0
223        rhon(:,:,:,cm_index,:) = 0.0
224        drhodzn(:,:,:,cm_index,:) = 0.0
225        tthn(:,:,:,cm_index,:) = 0.0
226        qvhn(:,:,:,cm_index,:) = 0.0
227
228        ! 2d nested fields
229        psn(:,:,:,cm_index,:) = 0.0
230        sdn(:,:,:,cm_index,:) = 0.0
231        msln(:,:,:,cm_index,:) = 0.0
232        tccn(:,:,:,cm_index,:) = 0.0
233        u10n(:,:,:,cm_index,:) = 0.0
234        v10n(:,:,:,cm_index,:) = 0.0
235        tt2n(:,:,:,cm_index,:) = 0.0
236        td2n(:,:,:,cm_index,:) = 0.0
237        lsprecn(:,:,:,cm_index,:) = 0.0
238        convprecn(:,:,:,cm_index,:) = 0.0
239        sshfn(:,:,:,cm_index,:) = 0.0
240        ssrn(:,:,:,cm_index,:) = 0.0
241        surfstrn(:,:,:,cm_index,:) = 0.0
242        ustarn(:,:,:,cm_index,:) = 0.0
243        wstarn(:,:,:,cm_index,:) = 0.0
244        hmixn(:,:,:,cm_index,:) = 0.0
245        tropopausen(:,:,:,cm_index,:) = 0.0
246        olin(:,:,:,cm_index,:) = 0.0
247        diffkn(:,:,:,cm_index,:) = 0.0
248        vdepn(:,:,:,cm_index,:) = 0.0
249
250        ! Auxiliary variables for nests
251        xresoln(:) = 0.0
252        yresoln(:) = 0.0
253        xln(:) = 0.0
254        yln(:) = 0.0
255        xrn(:) = 0.0
256        yrn(:) = 0.0
257
258        ! Variables for polar stereographic projection
259        xglobal=.FALSE.; sglobal=.FALSE.; nglobal=.FALSE.
260        switchnorthg=0.0; switchsouthg=0.0
261        southpolemap(:) = 0.0
262        northpolemap(:) = 0.0
263
264        ! Variables declared in conv_mod (convection)
265        pconv(:) = 0.0
266        phconv(:) = 0.0
267        dpr(:) = 0.0
268        pconv_hpa(:) = 0.0
269        phconv_hpa(:) = 0.0
270        ft(:) = 0.0
271        fq(:) = 0.0
272        fmass(:,:) = 0.0
273        sub(:) = 0.0
274        fmassfrac(:,:) = 0.0
275        cbaseflux(:,:) = 0.0
276        cbasefluxn(:,:,:) = 0.0
277        tconv(:) = 0.0
278        qconv(:) = 0.0
279        qsconv(:) = 0.0
280        psconv=0.0; tt2conv=0.0; td2conv=0.0
281        nconvlev=0.0; nconvtop=0.0
282
283    END SUBROUTINE fpmetbinary_zero
284
285    SUBROUTINE fpio(iounit, op, cm_index)
286        IMPLICIT NONE
287        INTEGER, INTENT(IN) :: iounit
288        CHARACTER(LEN=4), INTENT(IN) :: op        ! Operation - DUMP or LOAD
289        INTEGER, INTENT(IN) :: cm_index           ! Index of last dimension in
290                                                  ! most com_mod variables.
291                                                  ! Should be 1 or 2
292
293        ! These are temporary variables, used in the LOAD option, for
294        ! comparing against the current values in FLEXPART of nxmax, nymax, ...
295        INTEGER :: temp_nxmax, temp_nymax, temp_nzmax, &
296&                  temp_nuvzmax, temp_nwzmax
297
298        CHARACTER(LEN=12) :: temp_preproc_format_version_str
299
300        CHARACTER(LEN=128) :: errmesg
301
302        if (op == 'DUMP') THEN
303
304
305            ! Write the preprocessing format version string
306            WRITE (iounit) PREPROC_FORMAT_VERSION_STR
307
308            ! Write the compiled max dimensions from par_mod - these are
309            ! not meant to be reassigned during a LOAD, but used as "header"
310            ! information to provide the structure of arrays
311            WRITE (iounit) nxmax, nymax, nzmax, nuvzmax, nwzmax
312
313            ! Scalar values
314            WRITE(iounit) nx, ny, nxmin1, nymin1, nxfield
315            WRITE(iounit) nuvz, nwz, nz, nmixz, nlev_ec
316            WRITE(iounit) dx, dy, xlon0, ylat0, dxconst, dyconst
317
318            ! Fixed fields, static in time
319            WRITE(iounit) oro, excessoro, lsm, xlanduse, height
320
321            ! 3d fields
322            WRITE(iounit) uu(:,:,:,cm_index)
323            WRITE(iounit) vv(:,:,:,cm_index)
324            WRITE(iounit) uupol(:,:,:,cm_index)
325            WRITE(iounit) vvpol(:,:,:,cm_index)
326            WRITE(iounit) ww(:,:,:,cm_index)
327            WRITE(iounit) tt(:,:,:,cm_index)
328            WRITE(iounit) qv(:,:,:,cm_index)
329            WRITE(iounit) pv(:,:,:,cm_index)
330            WRITE(iounit) rho(:,:,:,cm_index)
331            WRITE(iounit) drhodz(:,:,:,cm_index)
332            WRITE(iounit) tth(:,:,:,cm_index)
333            WRITE(iounit) qvh(:,:,:,cm_index)
334            WRITE(iounit) pplev(:,:,:,cm_index)
335            WRITE(iounit) clouds(:,:,:,cm_index)
336            WRITE(iounit) cloudsh(:,:,cm_index)
337
338            ! 2d fields
339            WRITE(iounit) ps(:,:,:,cm_index)
340            WRITE(iounit) sd(:,:,:,cm_index)
341            WRITE(iounit) msl(:,:,:,cm_index)
342            WRITE(iounit) tcc(:,:,:,cm_index)
343            WRITE(iounit) u10(:,:,:,cm_index)
344            WRITE(iounit) v10(:,:,:,cm_index)
345            WRITE(iounit) tt2(:,:,:,cm_index)
346            WRITE(iounit) td2(:,:,:,cm_index)
347            WRITE(iounit) lsprec(:,:,:,cm_index)
348            WRITE(iounit) convprec(:,:,:,cm_index)
349            WRITE(iounit) sshf(:,:,:,cm_index)
350            WRITE(iounit) ssr(:,:,:,cm_index)
351            WRITE(iounit) surfstr(:,:,:,cm_index)
352            WRITE(iounit) ustar(:,:,:,cm_index)
353            WRITE(iounit) wstar(:,:,:,cm_index)
354            WRITE(iounit) hmix(:,:,:,cm_index)
355            WRITE(iounit) tropopause(:,:,:,cm_index)
356            WRITE(iounit) oli(:,:,:,cm_index)
357            WRITE(iounit) diffk(:,:,:,cm_index)
358            WRITE(iounit) vdep(:,:,:,cm_index)
359
360            ! 1d fields
361            WRITE(iounit) z0(:)
362            WRITE(iounit) akm(:)
363            WRITE(iounit) bkm(:)
364            WRITE(iounit) akz(:)
365            WRITE(iounit) bkz(:)
366            WRITE(iounit) aknew(:)
367            WRITE(iounit) bknew(:)
368
369            ! Nested, scalar values (for each nest)
370            WRITE(iounit) nxn(:)
371            WRITE(iounit) nyn(:)
372            WRITE(iounit) dxn(:)
373            WRITE(iounit) dyn(:)
374            WRITE(iounit) xlon0n(:)
375            WRITE(iounit) ylat0n(:)
376
377            ! Nested fields, static over time
378            WRITE(iounit) oron, excessoron, lsmn, xlandusen
379
380            ! 3d nested fields
381            WRITE(iounit) uun(:,:,:,cm_index,:)
382            WRITE(iounit) vvn(:,:,:,cm_index,:)
383            WRITE(iounit) wwn(:,:,:,cm_index,:)
384            WRITE(iounit) ttn(:,:,:,cm_index,:)
385            WRITE(iounit) qvn(:,:,:,cm_index,:)
386            WRITE(iounit) pvn(:,:,:,cm_index,:)
387            WRITE(iounit) cloudsn(:,:,:,cm_index,:)
388            WRITE(iounit) cloudsnh(:,:,cm_index,:)
389            WRITE(iounit) rhon(:,:,:,cm_index,:)
390            WRITE(iounit) drhodzn(:,:,:,cm_index,:)
391            WRITE(iounit) tthn(:,:,:,cm_index,:)
392            WRITE(iounit) qvhn(:,:,:,cm_index,:)
393
394            ! 2d nested fields
395            WRITE(iounit) psn(:,:,:,cm_index,:)
396            WRITE(iounit) sdn(:,:,:,cm_index,:)
397            WRITE(iounit) msln(:,:,:,cm_index,:)
398            WRITE(iounit) tccn(:,:,:,cm_index,:)
399            WRITE(iounit) u10n(:,:,:,cm_index,:)
400            WRITE(iounit) v10n(:,:,:,cm_index,:)
401            WRITE(iounit) tt2n(:,:,:,cm_index,:)
402            WRITE(iounit) td2n(:,:,:,cm_index,:)
403            WRITE(iounit) lsprecn(:,:,:,cm_index,:)
404            WRITE(iounit) convprecn(:,:,:,cm_index,:)
405            WRITE(iounit) sshfn(:,:,:,cm_index,:)
406            WRITE(iounit) ssrn(:,:,:,cm_index,:)
407            WRITE(iounit) surfstrn(:,:,:,cm_index,:)
408            WRITE(iounit) ustarn(:,:,:,cm_index,:)
409            WRITE(iounit) wstarn(:,:,:,cm_index,:)
410            WRITE(iounit) hmixn(:,:,:,cm_index,:)
411            WRITE(iounit) tropopausen(:,:,:,cm_index,:)
412            WRITE(iounit) olin(:,:,:,cm_index,:)
413            WRITE(iounit) diffkn(:,:,:,cm_index,:)
414            WRITE(iounit) vdepn(:,:,:,cm_index,:)
415
416            ! Auxiliary variables for nests
417            WRITE(iounit) xresoln(:)
418            WRITE(iounit) yresoln(:)
419            WRITE(iounit) xln(:)
420            WRITE(iounit) yln(:)
421            WRITE(iounit) xrn(:)
422            WRITE(iounit) yrn(:)
423
424            ! Variables for polar stereographic projection
425            WRITE(iounit) xglobal, sglobal, nglobal
426            WRITE(iounit) switchnorthg, switchsouthg
427            WRITE(iounit) southpolemap(:)
428            WRITE(iounit) northpolemap(:)
429
430            ! Variables declared in conv_mod (convection)
431            WRITE(iounit) pconv(:)
432            WRITE(iounit) phconv(:)
433            WRITE(iounit) dpr(:)
434            WRITE(iounit) pconv_hpa(:)
435            WRITE(iounit) phconv_hpa(:)
436            WRITE(iounit) ft(:)
437            WRITE(iounit) fq(:)
438            WRITE(iounit) fmass(:,:)
439            WRITE(iounit) sub(:)
440            WRITE(iounit) fmassfrac(:,:)
441            WRITE(iounit) cbaseflux(:,:)
442            WRITE(iounit) cbasefluxn(:,:,:)
443            WRITE(iounit) tconv(:)
444            WRITE(iounit) qconv(:)
445            WRITE(iounit) qsconv(:)
446            WRITE(iounit) psconv, tt2conv, td2conv
447            WRITE(iounit) nconvlev, nconvtop
448
449        ELSE IF (op == 'LOAD') THEN
450
451            ! Read the preprocessed format version string and insure it
452            ! matches this version
453            READ (iounit) temp_preproc_format_version_str
454            PRINT *, 'Reading preprocessed file format version: ', &
455&                    temp_preproc_format_version_str
456
457            IF (TRIM(temp_preproc_format_version_str) == &
458&                                        TRIM(PREPROC_FORMAT_VERSION_STR)) THEN
459                CONTINUE
460            ELSE
461                ! PRINT *, ''  GK: causes relocation truncated to fit: R_X86_64_32
462                PRINT *, 'Inconsistent preprocessing format version'
463                PRINT *, 'Expected Version: ', PREPROC_FORMAT_VERSION_STR
464                PRINT *, 'Detected Version: ', temp_preproc_format_version_str
465                ! PRINT *, ''
466                STOP
467            END IF
468
469            ! Read the compiled max dimensions that were dumped from par_mod
470            ! when creating the fp file, so that we can compare against
471            ! current FLEXPART dimensions - they need to be the same, or else
472            ! we abort.
473            READ (iounit) temp_nxmax, temp_nymax, temp_nzmax, &
474&                         temp_nuvzmax, temp_nwzmax
475
476
477            IF ( (temp_nxmax == nxmax) .AND. (temp_nymax == nymax) .AND. &
478&                   (temp_nzmax == nzmax) .AND. &
479&                   (temp_nuvzmax == nuvzmax) .AND. &
480&                   (temp_nwzmax == nwzmax) ) THEN
481                CONTINUE
482            ELSE
483                PRINT *, 'Incompatible dimensions between fp file and current FLEXPART!'
484                ! PRINT *, ''
485                PRINT *, '                  FP file     Compiled FP'
486                PRINT *, 'nxmax:     ', temp_nxmax, '    ', nxmax
487                PRINT *, 'nymax:     ', temp_nymax, '    ', nymax
488                PRINT *, 'nzmax:     ', temp_nzmax, '    ', nzmax
489                PRINT *, 'nuvzmax:     ', temp_nuvzmax, '    ', nuvzmax
490                PRINT *, 'nwzmax:     ', temp_nwzmax, '    ', nwzmax
491                ! PRINT *, ''
492                STOP
493            END IF
494
495
496            ! Scalar values
497            READ(iounit) nx, ny, nxmin1, nymin1, nxfield
498            READ(iounit) nuvz, nwz, nz, nmixz, nlev_ec
499            READ(iounit) dx, dy, xlon0, ylat0, dxconst, dyconst
500
501            ! Fixed fields, static in time
502            READ(iounit) oro, excessoro, lsm, xlanduse, height
503
504            ! 3d fields
505            READ(iounit) uu(:,:,:,cm_index)
506            READ(iounit) vv(:,:,:,cm_index)
507            READ(iounit) uupol(:,:,:,cm_index)
508            READ(iounit) vvpol(:,:,:,cm_index)
509            READ(iounit) ww(:,:,:,cm_index)
510            READ(iounit) tt(:,:,:,cm_index)
511            READ(iounit) qv(:,:,:,cm_index)
512            READ(iounit) pv(:,:,:,cm_index)
513            READ(iounit) rho(:,:,:,cm_index)
514            READ(iounit) drhodz(:,:,:,cm_index)
515            READ(iounit) tth(:,:,:,cm_index)
516            READ(iounit) qvh(:,:,:,cm_index)
517            READ(iounit) pplev(:,:,:,cm_index)
518            READ(iounit) clouds(:,:,:,cm_index)
519            READ(iounit) cloudsh(:,:,cm_index)
520
521            ! 2d fields
522            READ(iounit) ps(:,:,:,cm_index)
523            READ(iounit) sd(:,:,:,cm_index)
524            READ(iounit) msl(:,:,:,cm_index)
525            READ(iounit) tcc(:,:,:,cm_index)
526            READ(iounit) u10(:,:,:,cm_index)
527            READ(iounit) v10(:,:,:,cm_index)
528            READ(iounit) tt2(:,:,:,cm_index)
529            READ(iounit) td2(:,:,:,cm_index)
530            READ(iounit) lsprec(:,:,:,cm_index)
531            READ(iounit) convprec(:,:,:,cm_index)
532            READ(iounit) sshf(:,:,:,cm_index)
533            READ(iounit) ssr(:,:,:,cm_index)
534            READ(iounit) surfstr(:,:,:,cm_index)
535            READ(iounit) ustar(:,:,:,cm_index)
536            READ(iounit) wstar(:,:,:,cm_index)
537            READ(iounit) hmix(:,:,:,cm_index)
538            READ(iounit) tropopause(:,:,:,cm_index)
539            READ(iounit) oli(:,:,:,cm_index)
540            READ(iounit) diffk(:,:,:,cm_index)
541            READ(iounit) vdep(:,:,:,cm_index)
542
543            ! 1d fields
544            READ(iounit) z0(:)
545            READ(iounit) akm(:)
546            READ(iounit) bkm(:)
547            READ(iounit) akz(:)
548            READ(iounit) bkz(:)
549            READ(iounit) aknew(:)
550            READ(iounit) bknew(:)
551
552
553            ! Nested, scalar values (for each nest)
554            READ(iounit) nxn(:)
555            READ(iounit) nyn(:)
556            READ(iounit) dxn(:)
557            READ(iounit) dyn(:)
558            READ(iounit) xlon0n(:)
559            READ(iounit) ylat0n(:)
560
561
562            ! Nested fields, static over time
563            READ(iounit) oron, excessoron, lsmn, xlandusen
564
565            ! 3d nested fields
566            READ(iounit) uun(:,:,:,cm_index,:)
567            READ(iounit) vvn(:,:,:,cm_index,:)
568            READ(iounit) wwn(:,:,:,cm_index,:)
569            READ(iounit) ttn(:,:,:,cm_index,:)
570            READ(iounit) qvn(:,:,:,cm_index,:)
571            READ(iounit) pvn(:,:,:,cm_index,:)
572            READ(iounit) cloudsn(:,:,:,cm_index,:)
573            READ(iounit) cloudsnh(:,:,cm_index,:)
574            READ(iounit) rhon(:,:,:,cm_index,:)
575            READ(iounit) drhodzn(:,:,:,cm_index,:)
576            READ(iounit) tthn(:,:,:,cm_index,:)
577            READ(iounit) qvhn(:,:,:,cm_index,:)
578
579            ! 2d nested fields
580            READ(iounit) psn(:,:,:,cm_index,:)
581            READ(iounit) sdn(:,:,:,cm_index,:)
582            READ(iounit) msln(:,:,:,cm_index,:)
583            READ(iounit) tccn(:,:,:,cm_index,:)
584            READ(iounit) u10n(:,:,:,cm_index,:)
585            READ(iounit) v10n(:,:,:,cm_index,:)
586            READ(iounit) tt2n(:,:,:,cm_index,:)
587            READ(iounit) td2n(:,:,:,cm_index,:)
588            READ(iounit) lsprecn(:,:,:,cm_index,:)
589            READ(iounit) convprecn(:,:,:,cm_index,:)
590            READ(iounit) sshfn(:,:,:,cm_index,:)
591            READ(iounit) ssrn(:,:,:,cm_index,:)
592            READ(iounit) surfstrn(:,:,:,cm_index,:)
593            READ(iounit) ustarn(:,:,:,cm_index,:)
594            READ(iounit) wstarn(:,:,:,cm_index,:)
595            READ(iounit) hmixn(:,:,:,cm_index,:)
596            READ(iounit) tropopausen(:,:,:,cm_index,:)
597            READ(iounit) olin(:,:,:,cm_index,:)
598            READ(iounit) diffkn(:,:,:,cm_index,:)
599            READ(iounit) vdepn(:,:,:,cm_index,:)
600
601            ! Auxiliary variables for nests
602            READ(iounit) xresoln(:)
603            READ(iounit) yresoln(:)
604            READ(iounit) xln(:)
605            READ(iounit) yln(:)
606            READ(iounit) xrn(:)
607            READ(iounit) yrn(:)
608
609            ! Variables for polar stereographic projection
610            READ(iounit) xglobal, sglobal, nglobal
611            READ(iounit) switchnorthg, switchsouthg
612            READ(iounit) southpolemap(:)
613            READ(iounit) northpolemap(:)
614
615            ! Variables declared in conv_mod (convection)
616            READ(iounit) pconv(:)
617            READ(iounit) phconv(:)
618            READ(iounit) dpr(:)
619            READ(iounit) pconv_hpa(:)
620            READ(iounit) phconv_hpa(:)
621            READ(iounit) ft(:)
622            READ(iounit) fq(:)
623            READ(iounit) fmass(:,:)
624            READ(iounit) sub(:)
625            READ(iounit) fmassfrac(:,:)
626            READ(iounit) cbaseflux(:,:)
627            READ(iounit) cbasefluxn(:,:,:)
628            READ(iounit) tconv(:)
629            READ(iounit) qconv(:)
630            READ(iounit) qsconv(:)
631            READ(iounit) psconv, tt2conv, td2conv
632            READ(iounit) nconvlev, nconvtop
633
634        ELSE
635            STOP 'fpio(): Illegal operation'
636           
637        ENDIF
638    END SUBROUTINE fpio
639
640    SUBROUTINE fpmetbinary_filetext(filename, cm_index)
641
642        ! This is a utility subroutine meant to be used for testing purposes.
643        ! It facilitates the text output of variables read in from the
644        ! specified .fp file.  This routine will easily cause the program
645        ! to crash due memory allocation issues, particularly when you are
646        ! trying to text print 3d arrays in a single formatted statetment.
647       
648        CHARACTER(LEN=*), INTENT(IN) :: filename
649        INTEGER, INTENT(IN) :: cm_index           ! Index of last dimension in
650                                                  ! most com_mod variables.
651                                                  ! Should be 1 or 2
652
653        !OPEN(IOUNIT_TEXTOUT, file=filename, action='WRITE', status='REPLACE', &
654        !    form="formatted", access="stream")
655        OPEN(IOUNIT_TEXTOUT, file=filename, action='WRITE', &
656             form="formatted", access="APPEND")
657
658        WRITE(IOUNIT_TEXTOUT, *) 'oro: ', oro
659        WRITE(IOUNIT_TEXTOUT, *) 'excessoro: ', excessoro
660        WRITE(IOUNIT_TEXTOUT, *) 'lsm: ', lsm
661        WRITE(IOUNIT_TEXTOUT, *) 'xlanduse: ', xlanduse
662        WRITE(IOUNIT_TEXTOUT, *) 'height: ', height
663
664        WRITE(IOUNIT_TEXTOUT, *) 'uu: ', uu(:,:,:,cm_index)
665        WRITE(IOUNIT_TEXTOUT, *) 'vv: ', vv(:,:,:,cm_index)
666        WRITE(IOUNIT_TEXTOUT, *) 'uupol: ', uupol(:,:,:,cm_index)
667        WRITE(IOUNIT_TEXTOUT, *) 'vvpol: ', vvpol(:,:,:,cm_index)
668        WRITE(IOUNIT_TEXTOUT, *) 'ww: ', ww(:,:,:,cm_index)
669        WRITE(IOUNIT_TEXTOUT, *) 'tt: ', tt(:,:,:,cm_index)
670        WRITE(IOUNIT_TEXTOUT, *) 'qv: ', qv(:,:,:,cm_index)
671        WRITE(IOUNIT_TEXTOUT, *) 'pv: ', pv(:,:,:,cm_index)
672        WRITE(IOUNIT_TEXTOUT, *) 'rho: ', rho(:,:,:,cm_index)
673        WRITE(IOUNIT_TEXTOUT, *) 'drhodz: ', drhodz(:,:,:,cm_index)
674        WRITE(IOUNIT_TEXTOUT, *) 'tth: ', tth(:,:,:,cm_index)
675        WRITE(IOUNIT_TEXTOUT, *) 'qvh: ', qvh(:,:,:,cm_index)
676        WRITE(IOUNIT_TEXTOUT, *) 'pplev: ', pplev(:,:,:,cm_index)
677        WRITE(IOUNIT_TEXTOUT, *) 'clouds: ', clouds(:,:,:,cm_index)
678        WRITE(IOUNIT_TEXTOUT, *) 'cloudsh: ', cloudsh(:,:,cm_index)
679
680
681
682
683        CLOSE(IOUNIT_TEXTOUT)
684    END SUBROUTINE fpmetbinary_filetext
685
686
687END MODULE fpmetbinary_mod
Note: See TracBrowser for help on using the repository browser.
hosted by ZAMG