|
PISM, A Parallel Ice Sheet Model stable 0.4.1779
|
00001 // Copyright (C) 2008-2011 Ed Bueler and Constantine Khroulev 00002 // 00003 // This file is part of PISM. 00004 // 00005 // PISM is free software; you can redistribute it and/or modify it under the 00006 // terms of the GNU General Public License as published by the Free Software 00007 // Foundation; either version 2 of the License, or (at your option) any later 00008 // version. 00009 // 00010 // PISM is distributed in the hope that it will be useful, but WITHOUT ANY 00011 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00012 // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 00013 // details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with PISM; if not, write to the Free Software 00017 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00018 00019 #include "PISMComponent.hh" 00020 #include "PISMIO.hh" 00021 00023 00026 PetscErrorCode PISMComponent::find_pism_input(string &filename, 00027 bool ®rid, 00028 int &start 00029 ) { 00030 PetscErrorCode ierr; 00031 PetscTruth i_set, boot_file_set; 00032 00033 // read file names: 00034 char i_file[PETSC_MAX_PATH_LEN], boot_file_file[PETSC_MAX_PATH_LEN]; 00035 ierr = PetscOptionsGetString(PETSC_NULL, "-i", i_file, 00036 PETSC_MAX_PATH_LEN, &i_set); CHKERRQ(ierr); 00037 ierr = PetscOptionsGetString(PETSC_NULL, "-boot_file", boot_file_file, 00038 PETSC_MAX_PATH_LEN, &boot_file_set); CHKERRQ(ierr); 00039 if (i_set) { 00040 if (boot_file_set) { 00041 ierr = PetscPrintf(grid.com, 00042 "PISMClimateCoupler ERROR: both '-i' and '-boot_file' are used. Exiting...\n"); CHKERRQ(ierr); 00043 PISMEnd(); 00044 } 00045 filename = i_file; 00046 } 00047 else if (boot_file_set) { 00048 filename = boot_file_file; 00049 } 00050 00051 PISMIO nc(&grid); 00052 int last_record; 00053 ierr = nc.open_for_reading(filename.c_str()); CHKERRQ(ierr); 00054 ierr = nc.get_nrecords(last_record); CHKERRQ(ierr); 00055 last_record -= 1; 00056 ierr = nc.close(); CHKERRQ(ierr); 00057 00058 if (boot_file_set) { 00059 regrid = true; 00060 start = 0; 00061 } else { 00062 regrid = false; 00063 start = last_record; 00064 } 00065 00066 return 0; 00067 }
1.7.3