Date: 2013-07-02T14:39:25+00:00

Actual source code: ex17f.F
petsc-3.4.2 2013-07-02

      1: !
      2: !
      3: !     Test for PetscFOpen() from Fortran
      4: !
      5:        program main
      6: #include <finclude/petscsys.h>

      8:       PetscErrorCode ierr
      9:       PetscMPIInt rank
     10:       PetscFortranAddr file
     11:       character*100    joe

     13:       call PetscInitialize(PETSC_NULL_CHARACTER,ierr)
     14:       call MPI_Comm_rank(PETSC_COMM_WORLD,rank,ierr)

     16:       call PetscFOpen(PETSC_COMM_WORLD,'testfile','w',file,ierr)

     18:       call PetscFPrintf(PETSC_COMM_WORLD,file,'Hi once \n',ierr)
     19:       call PetscSynchronizedFPrintf(PETSC_COMM_WORLD,file,'Hi twice \n',     &
     20:      &                              ierr)
     21:       call PetscSynchronizedFlush(PETSC_COMM_WORLD,ierr)

     23:       write (FMT=*,UNIT=joe) 'greetings from ',rank,'\n'
     24:       call PetscSynchronizedFPrintf(PETSC_COMM_WORLD,file,joe,ierr)
     25:       call PetscSynchronizedFlush(PETSC_COMM_WORLD,ierr)

     27:       call PetscFClose(PETSC_COMM_WORLD,file,ierr)

     29:       call PetscFinalize(ierr)
     30:       end