1c4762a1bSJed Brown static char help[] = "Demonstrates PetscFileRetrieve().\n\n"; 2c4762a1bSJed Brown 3c4762a1bSJed Brown #include <petscsys.h> 4d71ae5a4SJacob Faibussowitsch int main(int argc, char **argv) 5d71ae5a4SJacob Faibussowitsch { 6c4762a1bSJed Brown PetscBool found; 7c4762a1bSJed Brown char localname[PETSC_MAX_PATH_LEN]; 8ae13f97fSSatish Balay const char url[] = "https://web.cels.anl.gov/projects/petsc/download/datafiles/matrices/tiny"; 9c4762a1bSJed Brown 10c4762a1bSJed Brown /* 11c4762a1bSJed Brown Every PETSc routine should begin with the PetscInitialize() routine. 12c4762a1bSJed Brown argc, argv - These command line arguments are taken to extract the options 13c4762a1bSJed Brown supplied to PETSc and options supplied to MPI. 14c4762a1bSJed Brown help - When PETSc executable is invoked with the option -help, 15c4762a1bSJed Brown it prints the various options that can be applied at 16c4762a1bSJed Brown runtime. The user can use the "help" variable place 17c4762a1bSJed Brown additional help messages in this printout. 18c4762a1bSJed Brown */ 19327415f7SBarry Smith PetscFunctionBeginUser; 20c8025a54SPierre Jolivet PetscCall(PetscInitialize(&argc, &argv, NULL, help)); 219566063dSJacob Faibussowitsch PetscCall(PetscFileRetrieve(PETSC_COMM_WORLD, url, localname, PETSC_MAX_PATH_LEN, &found)); 22*966bd95aSPierre Jolivet PetscCheck(found, PETSC_COMM_WORLD, PETSC_ERR_PLIB, "Unable to download url %s", url); 239566063dSJacob Faibussowitsch PetscCall(PetscPrintf(PETSC_COMM_WORLD, "Successfully download file %s\n", localname)); 24c4762a1bSJed Brown 259566063dSJacob Faibussowitsch PetscCall(PetscFinalize()); 26b122ec5aSJacob Faibussowitsch return 0; 27c4762a1bSJed Brown } 28c4762a1bSJed Brown 29c4762a1bSJed Brown /*TEST 30c4762a1bSJed Brown 31c4762a1bSJed Brown test: 32dfd57a17SPierre Jolivet requires: defined(PETSC_HAVE_POPEN) 33c4762a1bSJed Brown 34c4762a1bSJed Brown TEST*/ 35