Standard method for creating a new output file
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(out) | :: | fh |
File handle |
||
| integer, | intent(in) | :: | ix |
Index of file |
||
| character(len=*), | intent(in) | :: | extension |
Extension of file |
||
| character(len=*), | intent(in), | optional | :: | suffix |
Optional suffix |
subroutine create_output_file(fh, ix, extension, suffix) use mod_global_parameters use mod_comm_lib, only: mpistop integer, intent(out) :: fh !< File handle integer, intent(in) :: ix !< Index of file character(len=*), intent(in) :: extension !< Extension of file character(len=*), intent(in), optional :: suffix !< Optional suffix character(len=std_len) :: filename integer :: amode if (ix >= 10000) then call mpistop("Number of output files is limited to 10000 (0...9999)") end if if (present(suffix)) then write(filename,"(a,a,i4.4,a)") trim(base_filename), trim(suffix), ix,& extension else write(filename,"(a,i4.4,a)") trim(base_filename), ix, extension end if ! MPI cannot easily replace existing files open(unit=unitsnapshot,file=filename,status='replace') close(unitsnapshot, status='delete') amode = ior(MPI_MODE_CREATE, MPI_MODE_WRONLY) call MPI_FILE_OPEN(MPI_COMM_SELF,filename,amode, MPI_INFO_NULL, fh,& ierrmpi) if (ierrmpi /= 0) then print *, "Error, cannot create file ", trim(filename) call mpistop("Fatal error") end if end subroutine create_output_file