FV3 Bundle
obsspace_f.cc
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2017 UCAR
3  *
4  * This software is licensed under the terms of the Apache Licence Version 2.0
5  * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6  */
7 
8 #include "ioda/obsspace_f.h"
9 
10 #include <string>
11 
12 #include "ObsSpace.h"
13 
14 namespace ioda {
15 
16 // -----------------------------------------------------------------------------
17 int obsspace_get_nobs_f(const ObsSpace & obss) {
18  return obss.nobs();
19 }
20 // -----------------------------------------------------------------------------
21 int obsspace_get_nlocs_f(const ObsSpace & obss) {
22  return obss.nlocs();
23 }
24 // -----------------------------------------------------------------------------
25 void obsspace_get_int32_f(const ObsSpace & obss, const char * group, const char * vname,
26  const std::size_t & length, int32_t* vec) {
27  ASSERT(length >= obss.nlocs());
28  obss.get_db(std::string(group), std::string(vname), length, vec);
29 }
30 // -----------------------------------------------------------------------------
31 void obsspace_get_int64_f(const ObsSpace & obss, const char * group, const char * vname,
32  const std::size_t & length, int64_t* vec) {
33  ASSERT(length >= obss.nlocs());
34 // obss.get_db(std::string(group), std::string(vname), length, vec);
35 }
36 // -----------------------------------------------------------------------------
37 void obsspace_get_real32_f(const ObsSpace & obss, const char * group, const char * vname,
38  const std::size_t & length, float* vec) {
39  ASSERT(length >= obss.nlocs());
40 // obss.get_db(std::string(group), std::string(vname), length, vec);
41 }
42 // -----------------------------------------------------------------------------
43 void obsspace_get_real64_f(const ObsSpace & obss, const char * group, const char * vname,
44  const std::size_t & length, double* vec) {
45  ASSERT(length >= obss.nlocs());
46  obss.get_db(std::string(group), std::string(vname), length, vec);
47 }
48 // -----------------------------------------------------------------------------
49 void obsspace_put_int32_f(ObsSpace & obss, const char * group, const char * vname,
50  const std::size_t & length, int32_t* vec) {
51  ASSERT(length == obss.nlocs());
52  obss.put_db(std::string(group), std::string(vname), length, vec);
53 }
54 // -----------------------------------------------------------------------------
55 void obsspace_put_int64_f(ObsSpace & obss, const char * group, const char * vname,
56  const std::size_t & length, int64_t* vec) {
57  ASSERT(length == obss.nlocs());
58 // obss.put_db(std::string(group), std::string(vname), length, vec);
59 }
60 // -----------------------------------------------------------------------------
61 void obsspace_put_real32_f(ObsSpace & obss, const char * group, const char * vname,
62  const std::size_t & length, float* vec) {
63  ASSERT(length == obss.nlocs());
64 // obss.put_db(std::string(group), std::string(vname), length, vec);
65 }
66 // -----------------------------------------------------------------------------
67 void obsspace_put_real64_f(ObsSpace & obss, const char * group, const char * vname,
68  const std::size_t & length, double* vec) {
69  ASSERT(length == obss.nlocs());
70  obss.put_db(std::string(group), std::string(vname), length, vec);
71 }
72 // -----------------------------------------------------------------------------
73 
74 } // namespace ioda
void obsspace_put_int64_f(ObsSpace &obss, const char *group, const char *vname, const std::size_t &length, int64_t *vec)
Definition: obsspace_f.cc:55
void get_db(const std::string &, const std::string &, const std::size_t &, int[]) const
Definition: ObsSpace.cc:57
void obsspace_get_int64_f(const ObsSpace &obss, const char *group, const char *vname, const std::size_t &length, int64_t *vec)
Definition: obsspace_f.cc:31
int nlocs() const
Definition: ObsSpace.cc:98
void obsspace_get_real32_f(const ObsSpace &obss, const char *group, const char *vname, const std::size_t &length, float *vec)
Definition: obsspace_f.cc:37
void obsspace_put_real64_f(ObsSpace &obss, const char *group, const char *vname, const std::size_t &length, double *vec)
Definition: obsspace_f.cc:67
Wrapper around ObsHelpQG, mostly to hide the factory.
int nobs() const
Definition: ObsSpace.cc:89
************************************************************************GNU Lesser General Public License **This file is part of the GFDL Flexible Modeling System(FMS). ! *! *FMS is free software without even the implied warranty of MERCHANTABILITY or *FITNESS FOR A PARTICULAR PURPOSE See the GNU General Public License *for more details **You should have received a copy of the GNU Lesser General Public *License along with FMS If see< http:! ***********************************************************************!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! MPP_TRANSMIT !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! subroutine MPP_TRANSMIT_(put_data, put_len, to_pe, get_data, get_len, from_pe, block, tag, recv_request, send_request)!a message-passing routine intended to be reminiscent equally of both MPI and SHMEM!put_data and get_data are contiguous MPP_TYPE_ arrays!at each call, your put_data array is put to to_pe 's get_data! your get_data array is got from from_pe 's put_data!i.e we assume that typically(e.g updating halo regions) each PE performs a put _and_ a get!special PE designations:! NULL_PE:to disable a put or a get(e.g at boundaries)! ANY_PE:if remote PE for the put or get is to be unspecific! ALL_PES:broadcast and collect operations(collect not yet implemented)!ideally we would not pass length, but this f77-style call performs better(arrays passed by address, not descriptor)!further, this permits< length > contiguous words from an array of any rank to be passed(avoiding f90 rank conformance check)!caller is responsible for completion checks(mpp_sync_self) before and after integer, intent(in) ::put_len, to_pe, get_len, from_pe MPP_TYPE_, intent(in) ::put_data(*) MPP_TYPE_, intent(out) ::get_data(*) logical, intent(in), optional ::block integer, intent(in), optional ::tag integer, intent(out), optional ::recv_request, send_request logical ::block_comm integer ::i MPP_TYPE_, allocatable, save ::local_data(:) !local copy used by non-parallel code(no SHMEM or MPI) integer ::comm_tag integer ::rsize if(.NOT.module_is_initialized) call mpp_error(FATAL, 'MPP_TRANSMIT:You must first call mpp_init.') if(to_pe.EQ.NULL_PE .AND. from_pe.EQ.NULL_PE) return block_comm=.true. if(PRESENT(block)) block_comm=block if(debug) then call SYSTEM_CLOCK(tick) write(stdout_unit,'(a, i18, a, i6, a, 2i6, 2i8)')&'T=', tick, ' PE=', pe, ' MPP_TRANSMIT begin:to_pe, from_pe, put_len, get_len=', to_pe, from_pe, put_len, get_len end if comm_tag=DEFAULT_TAG if(present(tag)) comm_tag=tag!do put first and then get if(to_pe.GE.0 .AND. to_pe.LT.npes) then!use non-blocking sends if(debug .and.(current_clock.NE.0)) call SYSTEM_CLOCK(start_tick)!z1l:truly non-blocking send.! if(request(to_pe).NE.MPI_REQUEST_NULL) then !only one message from pe-> to_pe in queue *PE waiting for to_pe ! call error else get_len so only do gets but you cannot have a pure get with MPI call a get means do a wait to ensure put on remote PE is complete error call increase mpp_nml request_multiply call MPP_TRANSMIT get_len end if return end subroutine MPP_TRANSMIT_ ! MPP_BROADCAST ! subroutine but that doesn t allow !broadcast to a subset of PEs This version and mpp_transmit will remain !backward compatible intent(inout) MPP_BROADCAST length
int obsspace_get_nlocs_f(const ObsSpace &obss)
Definition: obsspace_f.cc:21
void obsspace_get_int32_f(const ObsSpace &obss, const char *group, const char *vname, const std::size_t &length, int32_t *vec)
Definition: obsspace_f.cc:25
void obsspace_put_real32_f(ObsSpace &obss, const char *group, const char *vname, const std::size_t &length, float *vec)
Definition: obsspace_f.cc:61
void put_db(const std::string &, const std::string &, const std::size_t &, const int[]) const
Definition: ObsSpace.cc:67
void obsspace_put_int32_f(ObsSpace &obss, const char *group, const char *vname, const std::size_t &length, int32_t *vec)
Definition: obsspace_f.cc:49
int obsspace_get_nobs_f(const ObsSpace &obss)
Definition: obsspace_f.cc:17
void obsspace_get_real64_f(const ObsSpace &obss, const char *group, const char *vname, const std::size_t &length, double *vec)
Definition: obsspace_f.cc:43