source: palm/trunk/UTIL/read_palm_2d_netcdf_data.f90 @ 1

Last change on this file since 1 was 1, checked in by raasch, 15 years ago

Initial repository layout and content

File size: 5.2 KB
Line 
1 PROGRAM read_palm_2d_netcdf_data
2
3!------------------------------------------------------------------------------!
4! Actual revisions:
5! -----------------
6!
7!
8! Former revisions:
9! -----------------
10!
11! This routine must be compiled with:
12! decalpha:
13!    f95 -cpp -D__netcdf -fast -r8 -I/usr/local/netcdf-3.5.1/include
14!    -L/usr/local/netcdf-3.5.1/lib -lnetcdf
15! IBM-Regatta:
16!    xlf95 -qsuffix=cpp=f90 -WF,-D__netcdf -qrealsize=8 -q64 -qmaxmem=-1 -Q
17!    -I /aws/dataformats/netcdf-3.6.0-p1/64-32/include
18!    -L/aws/dataformats/netcdf-3.6.0-p1/64-32/lib -lnetcdf -O3
19! IBM-Regatta KISTI:
20!    xlf95 -qsuffix=cpp=f90 -WF,-D__netcdf -qrealsize=8 -q64 -qmaxmem=-1 -Q
21!    -I /applic/netcdf64/src/f90
22!    -L/applic/lib/NETCDF64 -lnetcdf -O3
23! IBM-Regatta Yonsei (gfdl5):
24!    xlf95 -qsuffix=cpp=f90 -WF,-D__netcdf -qrealsize=8 -q64 -qmaxmem=-1 -Q
25!    -I /usr1/users/raasch/pub/netcdf-3.6.0-p1/include
26!    -L/usr1/users/raasch/pub/netcdf-3.6.0-p1/lib -lnetcdf -O3
27! IMUK:
28!    ifort combine...f90 -o combine...x
29!    -cpp -D__netcdf -I /muksoft/packages/netcdf/linux/include -axW -r8 -nbs
30!    -Vaxlib -L /muksoft/packages/netcdf/linux/lib -lnetcdf
31! NEC-SX6:
32!    sxf90 combine...f90 -o combine...x
33!    -I /pool/SX-6/netcdf/netcdf-3.6.0-p1/include  -C hopt -Wf '-A idbl4'
34!    -D__netcdf -L/pool/SX-6/netcdf/netcdf-3.6.0-p1/lib -lnetcdf
35!------------------------------------------------------------------------------!
36
37    USE netcdf
38
39    IMPLICIT NONE
40
41!
42!-- Local variables
43    CHARACTER (LEN=10)   ::  dimname, var_name
44    CHARACTER (LEN=40)   ::  filename
45
46    CHARACTER (LEN=2000) ::  var_list
47
48    INTEGER ::  i, j, k, nc_stat, pos, time_step
49
50    INTEGER ::  current_level, current_var, id_set, id_var_time, num_var
51
52    INTEGER, DIMENSION(4) ::  id_dims_loc
53
54    INTEGER, DIMENSION(4) ::  id_dims
55
56    INTEGER, DIMENSION(1000) ::  id_var, levels
57
58!    REAL, DIMENSION(0:576,0:128,3,6) ::  pf
59    REAL, DIMENSION(0:576,2,0:64,6) ::  pf
60
61
62
63    filename = 'ibmh_rinne_xz_av.nc'
64    nc_stat = NF90_OPEN( filename, NF90_WRITE, id_set )
65    IF ( nc_stat /= NF90_NOERR )  CALL handle_netcdf_error( 1 )
66
67!
68!-- Get the list of variables (order of variables corresponds with the
69!-- order of data on the binary file)
70    var_list = ' '    ! GET_ATT does not assign trailing blanks
71    nc_stat = NF90_GET_ATT( id_set, NF90_GLOBAL, 'VAR_LIST', var_list )
72    IF ( nc_stat /= NF90_NOERR )  CALL handle_netcdf_error( 2 )
73
74!
75!-- Inquire id of the time coordinate variable
76    nc_stat = NF90_INQ_VARID( id_set, 'time', id_var_time )
77    IF ( nc_stat /= NF90_NOERR )  CALL handle_netcdf_error( 3 )
78
79!
80!-- Count number of variables; there is one more semicolon in the
81!-- string than variable names
82    num_var = -1
83    DO  i = 1, LEN( var_list )
84       IF ( var_list(i:i) == ';' )  num_var = num_var + 1
85    ENDDO
86
87!
88!-- Extract the variable names from the list and inquire their NetCDF IDs
89    pos = INDEX( var_list, ';' )
90!
91!-- Loop over all variables
92    DO  i = 1, num_var
93
94!
95!--    Extract variable name from list
96       var_list = var_list(pos+1:)
97       pos = INDEX( var_list, ';' )
98       var_name = var_list(1:pos-1)
99
100!
101!--    Get variable ID from name
102       nc_stat = NF90_INQ_VARID( id_set, TRIM( var_name ), id_var(i) )
103       IF ( nc_stat /= NF90_NOERR )  CALL handle_netcdf_error( 4 )
104
105!
106!--    Get number of x/y/z levels for that variable
107       nc_stat = NF90_INQUIRE_VARIABLE( id_set, id_var(i), &
108                                        dimids = id_dims_loc )
109       IF ( nc_stat /= NF90_NOERR )  CALL handle_netcdf_error( 5 )
110       id_dims = id_dims_loc
111
112!
113!--    Inquire dimension ID
114       DO  j = 1, 4
115          nc_stat = NF90_INQUIRE_DIMENSION( id_set, id_dims(j),&
116                                            dimname, levels(i) )
117          IF ( nc_stat /= NF90_NOERR ) CALL handle_netcdf_error( 6 )
118       ENDDO
119
120       PRINT*, '*** reading array ', i
121!       nc_stat = NF90_GET_VAR( id_set, id_var(i), pf(0:576,0:128,1:3,i), &
122!                                start = (/ 1, 1, 1, 1 /), &
123!                                count = (/ 577, 129, 3, 1 /) )
124       nc_stat = NF90_GET_VAR( id_set, id_var(i), pf(0:576,1:2,0:64,i), &
125                                start = (/ 1, 1, 1, 1 /), &
126                                count = (/ 577, 2, 65, 1 /) )
127       IF ( nc_stat /= NF90_NOERR )  CALL handle_netcdf_error( 7+i )
128                 
129    ENDDO
130
131    PRINT*, ' '
132    i = 190
133    j =  60
134
135!    DO  k = 3, 1, -1
136!       WRITE ( *, '(F5.2,1X,F5.2,1X,F6.3,1X,F6.2,1X,F6.4,1X,F6.4)' )  &
137!          pf(i,j,k,1), pf(i,j,k,2), pf(i,j,k,3), pf(i,j,k,4), pf(i,j,k,5), &
138!          pf(i,j,k,6)
139!    ENDDO
140    DO  k = 2, 0, -1
141       WRITE ( *, '(F5.2,1X,F5.2,1X,F6.3,1X,F6.2,1X,F6.4,1X,F6.4)' )  &
142          pf(i,1,k,1), pf(i,1,k,2), pf(i,1,k,3), pf(i,1,k,4), pf(i,1,k,5), &
143          pf(i,1,k,6)
144    ENDDO
145
146
147 CONTAINS
148
149
150    SUBROUTINE handle_netcdf_error( errno )
151!
152!--    Prints out a text message corresponding to the current NetCDF status
153
154       IMPLICIT NONE
155
156       INTEGER, INTENT(IN) ::  errno
157
158       IF ( nc_stat /= NF90_NOERR )  THEN
159          PRINT*, '+++ read_palm_2d_netcdf_data  netcdf: ', errno, &
160                  TRIM( nf90_strerror( nc_stat ) )
161       ENDIF
162
163    END SUBROUTINE handle_netcdf_error
164
165
166 END PROGRAM read_palm_2d_netcdf_data
167
168
169
Note: See TracBrowser for help on using the repository browser.