"Fossies" - the Fresh Open Source Software Archive

Member "fimex-1.4.1/src/mifi_mpi.c" (30 Oct 2019, 2112 Bytes) of package /linux/privat/fimex-1.4.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "mifi_mpi.c" see the Fossies "Dox" file reference documentation.

    1 /*
    2  * Fimex, mifi_mpi.c
    3  *
    4  * (C) Copyright 2015, met.no
    5  *
    6  * Project Info:  https://wiki.met.no/fimex/start
    7  *
    8  * This library is free software; you can redistribute it and/or modify it
    9  * under the terms of the GNU Lesser General Public License as published by
   10  * the Free Software Foundation; either version 2.1 of the License, or
   11  * (at your option) any later version.
   12  *
   13  * This library is distributed in the hope that it will be useful, but
   14  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
   15  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
   16  * License for more details.
   17  *
   18  * You should have received a copy of the GNU Lesser General Public
   19  * License along with this library; if not, write to the Free Software
   20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
   21  * USA.
   22  *
   23  *  Created on: Jan 5, 2015
   24  *      Author: heikok
   25  */
   26 
   27 #include "fimex_config.h"
   28 #ifdef HAVE_MPI
   29 
   30 #include "fimex/mifi_mpi.h"
   31 #include <stdio.h>
   32 
   33 static int mifi_is_initialized = 0;
   34 
   35 MPI_Comm  mifi_mpi_comm;
   36 MPI_Info mifi_mpi_info;
   37 int mifi_mpi_size;
   38 int mifi_mpi_rank;
   39 
   40 int mifi_mpi_initialized() {
   41     return mifi_is_initialized;
   42 }
   43 
   44 void mifi_initialize_mpi(MPI_Comm comm, MPI_Info info)
   45 {
   46     int mpi_namelen;
   47     char mpi_name[MPI_MAX_PROCESSOR_NAME];
   48 
   49     mifi_mpi_comm = comm;
   50     mifi_mpi_info = info;
   51 
   52     MPI_Comm_size(mifi_mpi_comm, &mifi_mpi_size);
   53     MPI_Comm_rank(mifi_mpi_comm, &mifi_mpi_rank);
   54     MPI_Get_processor_name(mpi_name, &mpi_namelen);
   55     printf("mpi_name: %s size: %d rank: %d\n",
   56            mpi_name, mifi_mpi_size, mifi_mpi_rank);
   57 
   58     mifi_is_initialized = 1;
   59 }
   60 void mifi_free_mpi()
   61 {
   62     int mpi_size, mpi_rank;
   63     int mpi_namelen;
   64     char mpi_name[MPI_MAX_PROCESSOR_NAME];
   65     if (mifi_mpi_initialized()) {
   66         mifi_is_initialized = 0;
   67         MPI_Comm_size(mifi_mpi_comm, &mpi_size);
   68         MPI_Comm_rank(mifi_mpi_comm, &mpi_rank);
   69         MPI_Get_processor_name(mpi_name, &mpi_namelen);
   70         printf("finalize: mpi_name: %s size: %d rank: %d\n",
   71                mpi_name, mpi_size, mpi_rank);
   72     }
   73 }
   74 #endif