Changeset 379 for XIOS/trunk
- Timestamp:
- 10/22/12 13:47:08 (12 years ago)
- Location:
- XIOS/trunk/src
- Files:
-
- 2 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/data_output.hpp
r347 r379 8 8 #include "field.hpp" 9 9 10 #include <mpi.h>11 #define MPI_INCLUDED12 #include <netcdf.h>13 10 14 11 namespace xios -
XIOS/trunk/src/node/field.cpp
r369 r379 187 187 void CField::writeField(void) 188 188 { 189 // if (! grid->domain->isEmpty() || getRelFile()->type.getValue()=="one_file")190 if (! grid->domain->isEmpty() || getRelFile()->type == CFile::type_attr::one_file)191 {192 getRelFile()->checkFile();193 this->incrementNStep();194 getRelFile()->getDataOutput()->writeFieldData(CField::get(this));195 }189 if (! getRelFile()->allDomainEmpty ) 190 if (! grid->domain->isEmpty() || getRelFile()->type == CFile::type_attr::one_file) 191 { 192 getRelFile()->checkFile(); 193 this->incrementNStep(); 194 getRelFile()->getDataOutput()->writeFieldData(CField::get(this)); 195 } 196 196 } 197 197 //---------------------------------------------------------------- … … 411 411 const CDuration toffset = this->freq_operation - freq_offset_ - context->getCalendar()->getTimeStep(); 412 412 *this->last_operation = *this->last_operation - toffset; 413 cout<<operation<<endl ; 414 413 415 414 #define DECLARE_FUNCTOR(MType, mtype) \ 416 415 if (operation.getValue().compare(#mtype) == 0) \ -
XIOS/trunk/src/node/file.cpp
r375 r379 15 15 #include "xmlioserver_spl.hpp" 16 16 #include "context_client.hpp" 17 #include <mpi.h> 17 18 18 19 namespace xios { … … 22 23 CFile::CFile(void) 23 24 : CObjectTemplate<CFile>(), CFileAttributes() 24 , vFieldGroup(), data_out(), enabledFields() 25 , vFieldGroup(), data_out(), enabledFields(), fileComm(MPI_COMM_NULL) 25 26 { setVirtualFieldGroup() ;} 26 27 27 28 CFile::CFile(const StdString & id) 28 29 : CObjectTemplate<CFile>(id), CFileAttributes() 29 , vFieldGroup(), data_out(), enabledFields() 30 , vFieldGroup(), data_out(), enabledFields(), fileComm(MPI_COMM_NULL) 30 31 { setVirtualFieldGroup() ;} 31 32 … … 146 147 CContext* context = CContext::getCurrent() ; 147 148 CDate& currentDate=context->calendar->getCurrentDate() ; 148 149 CContextServer* server=context->server ; 150 149 151 if (! sync_freq.isEmpty()) syncFreq = CDuration::FromString(sync_freq.getValue()); 150 152 if (! split_freq.isEmpty()) splitFreq = CDuration::FromString(split_freq.getValue()); … … 153 155 lastSplit=new CDate(currentDate) ; 154 156 isOpen=false ; 157 158 allDomainEmpty=true ; 159 set<CDomain*> setDomain ; 160 161 std::vector<CField*>::iterator it, end = this->enabledFields.end(); 162 for (it = this->enabledFields.begin() ;it != end; it++) 163 { 164 CField* field = *it; 165 allDomainEmpty&=field->grid->domain->isEmpty() ; 166 setDomain.insert(field->grid->domain) ; 167 } 168 nbDomain=setDomain.size() ; 169 170 // create sub communicator for file 171 int color=allDomainEmpty?0:1 ; 172 MPI_Comm_split(server->intraComm,color,server->intraCommRank,&fileComm) ; 173 if (allDomainEmpty) MPI_Comm_free(&fileComm) ; 174 // 175 155 176 } 156 177 … … 202 223 { 203 224 CContext* context = CContext::getCurrent() ; 204 CDate& currentDate=context->calendar->getCurrentDate() ; 205 206 std::vector<CField*>::iterator it, end = this->enabledFields.end(); 207 208 AllDomainEmpty=true ; 209 set<CDomain*> setDomain ; 210 for (it = this->enabledFields.begin() ;it != end; it++) 211 { 212 CField* field = *it; 213 AllDomainEmpty&=field->grid->domain->isEmpty() ; 214 setDomain.insert(field->grid->domain) ; 215 } 216 nbDomain=setDomain.size() ; 217 218 if (!AllDomainEmpty || type == type_attr::one_file) 225 CContextServer* server=context->server ; 226 227 if (!allDomainEmpty) 219 228 { 220 229 StdString filename = (!name.isEmpty()) ? name.getValue() : getId(); 221 230 StdOStringStream oss; 222 // if (! output_dir.isEmpty()) oss << output_dir.getValue();223 231 oss << filename; 224 232 if (!name_suffix.isEmpty()) oss << name_suffix.getValue(); 225 // if (!split_freq.isEmpty()) oss<<"-["<<currentDate.toString()<<"]" ;226 233 if (!split_freq.isEmpty()) oss<<"_"<<lastSplit->getStryyyymmdd()<<"-"<< (*lastSplit+(splitFreq-1*Second)).getStryyyymmdd(); 227 234 bool multifile=true ; … … 230 237 if (type==type_attr::one_file) multifile=false ; 231 238 else if (type==type_attr::multiple_file) multifile=true ; 232 else ERROR("void Context::createDataOutput(void)", 233 "incorrect file <type> attribut : must be <multi_file> or <one_file>, " 234 <<"having : <"<<type.getValue()<<">") ; 239 235 240 } 236 237 CContextServer* server=context->server ; 238 241 #ifndef USING_NETCDF_PAR 242 if (!multifile) 243 { 244 info(0)<<"!!! Warning -> Using non parallel version of netcdf, switching in multiple_file mode for file : "<<filename<<" ..."<<endl ; 245 multifile=true ; 246 } 247 #endif 239 248 if (multifile) 240 249 { 250 int commSize, commRank ; 251 MPI_Comm_size(fileComm,&commSize) ; 252 MPI_Comm_rank(fileComm,&commRank) ; 253 241 254 if (server->intraCommSize > 1) 242 255 { 243 256 oss << "_" ; 244 int width=0 ; int n= server->intraCommSize-1 ;257 int width=0 ; int n=commSize-1 ; 245 258 while(n != 0) { n=n/10 ; width++ ;} 246 259 oss.width(width) ; 247 260 oss.fill('0') ; 248 oss<<right<< server->intraCommRank;261 oss<<right<< commRank; 249 262 } 250 263 } … … 264 277 } 265 278 } 266 data_out=shared_ptr<CDataOutput>(new CNc4DataOutput(oss.str(), false, server->intraComm,multifile, isCollective));279 data_out=shared_ptr<CDataOutput>(new CNc4DataOutput(oss.str(), false, fileComm, multifile, isCollective)); 267 280 isOpen=true ; 268 281 269 282 data_out->writeFile(CFile::get(this)); 283 std::vector<CField*>::iterator it, end = this->enabledFields.end(); 270 284 for (it = this->enabledFields.begin() ;it != end; it++) 271 285 { … … 288 302 delete lastSync ; 289 303 delete lastSplit ; 290 if (! AllDomainEmpty || type==type_attr::one_file)304 if (!allDomainEmpty) 291 305 if (isOpen) 292 306 { 293 307 this->data_out->closeFile(); 294 308 } 309 if (fileComm != MPI_COMM_NULL) MPI_Comm_free(&fileComm) ; 295 310 } 296 311 //---------------------------------------------------------------- -
XIOS/trunk/src/node/file.hpp
r369 r379 10 10 #include "attribute_enum.hpp" 11 11 #include "attribute_enum_impl.hpp" 12 #include <mpi.h> 12 13 13 14 … … 93 94 static ENodeType GetType(void); 94 95 95 bool AllDomainEmpty ;96 bool allDomainEmpty ; 96 97 CField* addField(const string& id="") ; 97 98 CFieldGroup* addFieldGroup(const string& id="") ; … … 115 116 int nbDomain ; 116 117 bool isOpen ; 118 MPI_Comm fileComm ; 117 119 private : 118 120 -
XIOS/trunk/src/output/nc4_data_output.cpp
r369 r379 27 27 28 28 CNc4DataOutput::CNc4DataOutput 29 (const StdString & filename, bool exist, MPI_Comm comm_ server,bool multifile, bool isCollective)29 (const StdString & filename, bool exist, MPI_Comm comm_file,bool multifile, bool isCollective) 30 30 : SuperClass() 31 , SuperClassWriter(filename, exist, &comm_ server,multifile)32 , comm_ server(comm_server)31 , SuperClassWriter(filename, exist, &comm_file,multifile) 32 , comm_file(comm_file) 33 33 , filename(filename) 34 34 , isCollective(isCollective) -
XIOS/trunk/src/output/nc4_data_output.hpp
r369 r379 25 25 (const StdString & filename, bool exist); 26 26 CNc4DataOutput 27 (const StdString & filename, bool exist, MPI_Comm comm_ server, bool multifile, bool isCollective=true);27 (const StdString & filename, bool exist, MPI_Comm comm_file, bool multifile, bool isCollective=true); 28 28 29 29 CNc4DataOutput(const CNc4DataOutput & dataoutput); // Not implemented. … … 88 88 89 89 /// Propriétés privées /// 90 MPI_Comm comm_ server;90 MPI_Comm comm_file; 91 91 const StdString filename; 92 92 -
XIOS/trunk/src/output/onetcdf4.cpp
r369 r379 1 1 #include "onetcdf4.hpp" 2 2 #include "group_template.hpp" 3 #include <mpi.h> 4 #include "netcdf.hpp" 3 5 4 6 namespace xios … … 32 34 if (comm != NULL) 33 35 { 34 if (!multifile) CheckError( nc_create_par(filename.c_str(), NC_NETCDF4|NC_MPIIO, *comm, MPI_INFO_NULL, &this->ncidp));36 if (!multifile) CheckError(xios::nc_create_par(filename.c_str(), NC_NETCDF4|NC_MPIIO, *comm, MPI_INFO_NULL, &this->ncidp)); 35 37 else CheckError(nc_create(filename.c_str(), NC_NETCDF4, &this->ncidp)); 36 38 } … … 41 43 if (comm != NULL) 42 44 { 43 if (!multifile) CheckError( nc_open_par(filename.c_str(), NC_NETCDF4|NC_MPIIO, *comm, MPI_INFO_NULL, &this->ncidp));45 if (!multifile) CheckError(xios::nc_open_par(filename.c_str(), NC_NETCDF4|NC_MPIIO, *comm, MPI_INFO_NULL, &this->ncidp)); 44 46 else CheckError(nc_open(filename.c_str(), NC_NETCDF4, &this->ncidp)); 45 47 } -
XIOS/trunk/src/output/onetcdf4.hpp
r369 r379 7 7 #include "data_output.hpp" 8 8 #include "array_new.hpp" 9 10 9 #include <mpi.h> 11 #define MPI_INCLUDED 12 #include <netcdf.h> 13 #ifdef NETCDF_PAR_HEADER 14 extern "C" { 15 #include <netcdf_par.h> 16 } 17 #endif 18 10 #include "netcdf.hpp" 19 11 20 12 #ifndef UNLIMITED_DIM
Note: See TracChangeset
for help on using the changeset viewer.