Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libcdi
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mpim-sw
libcdi
Commits
b36997dc
Commit
b36997dc
authored
13 years ago
by
Luis Kornblueh
Browse files
Options
Downloads
Patches
Plain Diff
Cleanup of Fortran ...
parent
4b2a8731
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pioExamples/collectData2003.F90
+66
-79
66 additions, 79 deletions
pioExamples/collectData2003.F90
with
66 additions
and
79 deletions
pioExamples/collectData2003.F90
+
66
−
79
View file @
b36997dc
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
PROGRAM
COLLECTDATA2003
USE
iso_c_binding
PROGRAM
collectdata2003
IMPLICIT
NONE
INCLUDE
'cdi.inc'
#ifdef USE_MPI
INCLUDE
'mpif.h'
#endif
! For parallel IO:
! Parameter and variables needed.
INTEGER
nProcsIO
,
IOMode
,
nNamespaces
PARAMETER
(
nProcsIO
=
3
)
!PARAMETER ( IOMode = PIO_NONE )
!PARAMETER ( IOMode = PIO_MPI )
!PARAMETER ( IOMode = PIO_WRITER )
!PARAMETER ( IOMode = PIO_ASYNCH )
PARAMETER
(
IOMode
=
PIO_FPGUARD
)
PARAMETER
(
nNamespaces
=
1
)
INTEGER
hasLocalFile
(
nNamespaces
)
PARAMETER
(
hasLocalFile
=
(/
0
/)
)
INTEGER
commGlob
,
commModel
,
error
INTEGER
,
PARAMETER
::
nProcsIO
=
3
! INTEGER, PARAMETER :: IOMode = PIO_NONE
! INTEGER, PARAMETER :: IOMode = PIO_MPI
! INTEGER, PARAMETER :: IOMode = PIO_WRITER
! INTEGER, PARAMETER :: IOMode = PIO_ASYNCH
INTEGER
,
PARAMETER
::
IOMode
=
PIO_FPGUARD
INTEGER
,
PARAMETER
::
nNamespaces
=
1
INTEGER
,
PARAMETER
::
hasLocalFile
(
nNamespaces
)
=
(/
0
/)
INTEGER
::
commGlob
,
commModel
,
error
! Start parallel environment
#ifdef USE_MPI
...
...
@@ -36,85 +35,83 @@ PROGRAM COLLECTDATA2003
! Initialize environment.
commModel
=
pioInit
(
commGlob
,
nProcsIO
,
IOMode
,
nNamespaces
,
hasLocalFile
)
CALL
MODELRUN
(
commModel
)
CALL
modelrun
(
commModel
)
! For parallel IO:
! Cleanup environment.
CALL
pioFinalize
()
#ifdef USE_MPI
CALL
MPI_FINALIZE
(
error
)
#endif
CONTAINS
SUBROUTINE
MODELRUN
(
commModel
)
IMPLICIT
NONE
INTEGER
,
INTENT
(
IN
)
::
commModel
INTEGER
nlon
,
nlat
,
nlev
,
nts
,
vdate
,
vtime
,
filetype
PARAMETER
(
nlon
=
12
)
! Number of longitudes
PARAMETER
(
nlat
=
6
)
! Number of latitudes
PARAMETER
(
nlev
=
5
)
! Number of levels
PARAMETER
(
nts
=
3
)
! Number of time steps
PARAMETER
(
vdate
=
19850101
)
PARAMETER
(
vtime
=
120000
)
PARAMETER
(
filetype
=
FILETYPE_GRB
)
INTEGER
gridID
,
zaxisID1
,
zaxisID2
,
taxisID
INTEGER
vlistID
,
varID1
,
varID2
,
streamID
,
tsID
INTEGER
i
,
nmiss
,
status
DOUBLE PRECISION
lons
(
nlon
),
lats
(
nlat
),
levs
(
nlev
)
DOUBLE PRECISION
var1
(
nlon
*
nlat
),
var2
(
nlon
*
nlat
*
nlev
)
SUBROUTINE
modelrun
(
commModel
)
INTEGER
,
INTENT
(
in
)
::
commModel
INTEGER
,
PARAMETER
::
nlon
=
12
! Number of longitudes
INTEGER
,
PARAMETER
::
nlat
=
6
! Number of latitudes
INTEGER
,
PARAMETER
::
nlev
=
5
! Number of levels
INTEGER
,
PARAMETER
::
nts
=
3
! Number of time steps
INTEGER
,
PARAMETER
::
vdate
=
19850101
INTEGER
,
PARAMETER
::
vtime
=
120000
INTEGER
,
PARAMETER
::
filetype
=
FILETYPE_GRB
INTEGER
::
gridID
,
zaxisID1
,
zaxisID2
,
taxisID
INTEGER
::
vlistID
,
varID1
,
varID2
,
streamID
,
tsID
INTEGER
::
i
,
nmiss
,
status
DOUBLE PRECISION
::
lons
(
nlon
),
lats
(
nlat
),
levs
(
nlev
)
DOUBLE PRECISION
::
var1
(
nlon
*
nlat
),
var2
(
nlon
*
nlat
*
nlev
)
CHARACTER
(
len
=
256
)
::
varname
INTEGER
startID
,
stopID
,
chunk
DATA
lons
/
0
,
30
,
60
,
90
,
120
,
150
,
180
,
210
,
240
,
270
,
300
,
330
/
DATA
lats
/
-75
,
-45
,
-15
,
15
,
45
,
75
/
DATA
levs
/
101300
,
92500
,
85000
,
50000
,
20000
/
INTEGER
::
startID
,
stopID
,
chunk
lons
=
(
/
0
,
30
,
60
,
90
,
120
,
150
,
180
,
210
,
240
,
270
,
300
,
330
/
)
lats
=
(
/
-75
,
-45
,
-15
,
15
,
45
,
75
/
)
levs
=
(
/
101300
,
92500
,
85000
,
50000
,
20000
/
)
nmiss
=
0
! Create a regular lon/lat grid
gridID
=
gridCreate
(
GRID_LONLAT
,
nlon
*
nlat
)
CALL
gridDefXsize
(
gridID
,
nlon
)
CALL
gridDefYsize
(
gridID
,
nlat
)
CALL
gridDefXvals
(
gridID
,
lons
)
CALL
gridDefYvals
(
gridID
,
lats
)
! Create a surface level Z-axis
zaxisID1
=
zaxisCreate
(
ZAXIS_SURFACE
,
1
)
! Create a pressure level Z-axis
zaxisID2
=
zaxisCreate
(
ZAXIS_PRESSURE
,
nlev
)
CALL
zaxisDefLevels
(
zaxisID2
,
levs
)
! Create a variable list
vlistID
=
vlistCreate
()
! Define the variables
varID1
=
vlistDefVar
(
vlistID
,
gridID
,
zaxisID1
,
TIME_VARIABLE
)
varID2
=
vlistDefVar
(
vlistID
,
gridID
,
zaxisID2
,
TIME_VARIABLE
)
! Define the variable names
varname
=
"varname1"
CALL
vlistDefVarName
(
vlistID
,
varID1
,
TRIM
(
varname
)//
C_NULL_CHAR
)
CALL
vlistDefVarName
(
vlistID
,
varID2
,
C_CHAR_"varname2"
//
C_NULL_CHAR
)
varname
=
'varname1'
CALL
vlistDefVarName
(
vlistID
,
varID1
,
varname
)
varname
=
'varname2'
CALL
vlistDefVarName
(
vlistID
,
varID2
,
varname
)
! Create a Time axis
taxisID
=
taxisCreate
(
TAXIS_ABSOLUTE
)
! Assign the Time axis to the variable list
CALL
vlistDefTaxis
(
vlistID
,
taxisID
)
streamID
=
streamOpenWrite
(
C_CHAR_"
example.grb
"
//
C_NULL_CHAR
,
filetype
)
streamID
=
streamOpenWrite
(
'
example.grb
'
,
filetype
)
IF
(
streamID
<
0
)
THEN
WRITE
(
0
,
*
)
cdiStringError
(
streamID
)
STOP
END
IF
! Assign the variable list to the dataset
CALL
streamDefVlist
(
streamID
,
vlistID
)
...
...
@@ -124,13 +121,13 @@ CONTAINS
! Decompose data on model processes for IO
! Transmit resources to the IO server.
CALL
pioEndDef
();
! Loop over the number of time steps
DO
tsID
=
0
,
nts
-1
CALL
taxisDefVdate
(
taxisID
,
vdate
+
tsID
)
CALL
taxisDefVtime
(
taxisID
,
vtime
)
status
=
streamDefTimestep
(
streamID
,
tsID
)
! For parallel IO:
! Inquire start index and chunk for IO transposition of var1
startID
=
pioInqVarDecoOff
(
vlistID
,
varID1
)
+
1
...
...
@@ -159,31 +156,21 @@ CONTAINS
! Start transmission of all data for output in this timestep to IO server.
CALL
pioWriteTimestep
(
tsID
,
vdate
,
vtime
)
END
DO
! For parallel IO:
! Preparation for local cleanup
CALL
pioEndTimestepping
()
! Close the output stream
CALL
streamClose
(
streamID
)
! Destroy the objects
CALL
vlistDestroy
(
vlistID
)
CALL
taxisDestroy
(
taxisID
)
CALL
zaxisDestroy
(
zaxisID1
)
CALL
zaxisDestroy
(
zaxisID2
)
CALL
gridDestroy
(
gridID
)
END
SUBROUTINE
MODELRUN
END
PROGRAM
COLLECTDATA2003
/
************************************************************************
/
/
*
*
Local
Variables
:
*
c
-
file
-
style
:
"Java"
*
c
-
basic
-
offset
:
2
*
indent
-
tabs
-
mode
:
nil
*
show
-
trailing
-
whitespace
:
t
*
require
-
trailing
-
newline
:
t
*
End
:
*
/
END
SUBROUTINE
modelrun
END
PROGRAM
collectdata2003
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment