~ubuntu-branches/ubuntu/utopic/adios/utopic

« back to all changes in this revision

Viewing changes to examples/Fortran/global-array/no_xml_write_byid.F90

  • Committer: Package Import Robot
  • Author(s): Alastair McKinstry
  • Date: 2013-12-09 15:21:31 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20131209152131-jtd4fpmdv3xnunnm
Tags: 1.5.0-1
* New upstream.
* Standards-Version: 3.9.5
* Include latest config.{sub,guess} 
* New watch file.
* Create libadios-bin for binaries.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
!  
 
2
!  ADIOS is freely available under the terms of the BSD license described
 
3
!  in the COPYING file in the top level directory of this source distribution.
 
4
!
 
5
!  Copyright (c) 2008 - 2009.  UT-BATTELLE, LLC. All rights reserved.
 
6
!
 
7
 
 
8
! ADIOS Fortran Example: write a global array from N processors using No-XML API. 
 
9
! The example also shows how to do multi-writes in ADIOS.
 
10
! How to run: mpirun -np <N> adios_global_no_xml
 
11
! Output: adios_global_no_xml.bp
 
12
! ADIOS config file: None
 
13
!
 
14
 
 
15
program no_xml_write_byid
 
16
    use adios_write_mod
 
17
    implicit none
 
18
    include 'mpif.h'
 
19
    character(len=256)      :: filename = "no_xml_write_byid.bp"
 
20
    integer                 :: rank, size, i, ierr
 
21
    integer,parameter       :: NX=10
 
22
    integer                 :: O, G
 
23
    real*8, dimension(NX)   :: t
 
24
    integer                 :: comm
 
25
 
 
26
    integer                 :: adios_err
 
27
    integer*8               :: adios_groupsize, adios_totalsize
 
28
    integer*8               :: adios_handle
 
29
    integer*8               :: m_adios_group
 
30
    integer*8               :: var_id1, var_id2
 
31
    character(len=32)       :: local, global, offset
 
32
 
 
33
    call MPI_Init (ierr)
 
34
    call MPI_Comm_dup (MPI_COMM_WORLD, comm, ierr)
 
35
    call MPI_Comm_rank (comm, rank, ierr)
 
36
    call MPI_Comm_size (comm, size, ierr)
 
37
 
 
38
    call adios_init_noxml (comm, adios_err)
 
39
    call adios_allocate_buffer (10, adios_err)
 
40
 
 
41
    call adios_declare_group (m_adios_group, "restart", "iter", 1, adios_err)
 
42
    call adios_select_method (m_adios_group, "MPI", "", "", adios_err)
 
43
 
 
44
    G = 2 * NX * size
 
45
    O = 2 * NX * rank
 
46
 
 
47
    write (local, "(I2)") NX
 
48
    write (global, "(I3)") G
 
49
    write (offset, "(I3)") O
 
50
 
 
51
    ! define a global array
 
52
    call adios_define_var (m_adios_group, "temperature" &
 
53
                          ,"", 6 &
 
54
                          ,local, global, offset, var_id1)
 
55
 
 
56
 
 
57
    write (offset, "(I3)") O + NX
 
58
 
 
59
    ! define a global array
 
60
    call adios_define_var (m_adios_group, "temperature" &
 
61
                          ,"", 6 &
 
62
                          ,local, global, offset, var_id2)
 
63
 
 
64
    call adios_open (adios_handle, "restart", filename, "w", comm, adios_err)
 
65
 
 
66
    adios_groupsize =  NX * 8 &
 
67
                    +  NX * 8
 
68
    call adios_group_size (adios_handle, adios_groupsize, adios_totalsize, adios_err)
 
69
 
 
70
    do i = 1, NX
 
71
        t(i)  = O + i - 1
 
72
    enddo
 
73
 
 
74
    call adios_write_byid (adios_handle, var_id1, t, adios_err)
 
75
 
 
76
    O = 2 * NX * rank + NX
 
77
    do i = 1, NX
 
78
        t(i)  = O + i - 1
 
79
    enddo
 
80
 
 
81
    call adios_write_byid (adios_handle, var_id2, t, adios_err)
 
82
 
 
83
    call adios_close (adios_handle, adios_err)
 
84
 
 
85
    call MPI_Barrier (comm, ierr)
 
86
 
 
87
    call adios_finalize (rank, adios_err)
 
88
 
 
89
    call MPI_Finalize (ierr)
 
90
end program