Skip to content

Commit e27af6e

Browse files
Merge pull request #239 from OpenSEMBA/dev
Dev
2 parents dcc5ba1 + 28e69bb commit e27af6e

File tree

6 files changed

+2019
-2306
lines changed

6 files changed

+2019
-2306
lines changed

src_main_pub/errorreport.F90

Lines changed: 26 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -2109,70 +2109,39 @@ subroutine print11(layoutnumber,message,forceprint2)
21092109

21102110
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
21112111

2112-
function openfile_mpi(layoutnumber,nombrefich) result (thefile8)
2113-
2114-
logical :: borratedeunaputavez1,borratedeunaputavez2
2115-
2116-
integer (kind=4) :: thefile8 !for mpi file management
2112+
function openfile_mpi(layoutnumber, nombrefich) result(thefile8)
2113+
integer(4), intent(in) :: layoutnumber
2114+
character(len=BUFSIZE), intent(in) :: nombrefich
2115+
integer(4) :: thefile8, iter, ios
2116+
character(len=BUFSIZE) :: whoamishort
2117+
logical :: file_exists
21172118
#ifdef CompileWithMPI
2118-
integer(kind=MPI_OFFSET_KIND) disp
2119-
integer (kind=4) :: ierr !for mpi file management
2119+
integer(kind=MPI_OFFSET_KIND) :: disp
2120+
integer(4) :: ierr
21202121
#endif
2121-
integer (kind=4), intent(in) :: layoutnumber
2122-
character (LEN=BUFSIZE), intent(in) :: nombrefich
2123-
character (LEN=BUFSIZE) whoamishort
2124-
write(whoamishort,'(i5)') layoutnumber+1
21252122

2126-
! IF (layoutnumber == 0) THEN
2127-
669 open (newunit=thefile8,file=trim(adjustl(nombrefich))//trim(adjustl(whoamishort))//'_tmp',err=667 )
2128-
goto 668
2129-
667 print *,' '//trim(adjustl(whoamishort))//' ','--> no se pudo borrar la unidad usando open',thefile8
2130-
call sleep(2)
2131-
goto 669
2132-
668 continue
2133-
call sleep(2)
2134-
write (thefile8,'(a)') '!END'
2123+
write(whoamishort, '(i5)') layoutnumber + 1
2124+
do iter = 1, 10
2125+
ios = 0
2126+
open(newunit=thefile8, file=trim(adjustl(nombrefich)) // trim(adjustl(whoamishort)) // '_tmp', iostat=ios)
2127+
if (ios /= 0) print *, 'Error opening temporary file: ', trim(adjustl(nombrefich)) // trim(adjustl(whoamishort)) // '_tmp'
2128+
if ((layoutnumber == 0) .and. (ios == 0)) then
2129+
call sleep(2)
2130+
write(thefile8, '(a)') '!END'
2131+
call sleep(2)
2132+
ios = 0
2133+
close(thefile8, status='delete',iostat=ios)
2134+
if (ios /= 0) print *, 'Error deleting temporary file: ', trim(adjustl(nombrefich)) // trim(adjustl(whoamishort)) // '_tmp'
2135+
end if
21352136
call sleep(2)
2136-
close (thefile8,status='delete')
2137-
! endif
2137+
if (ios == 0) exit
2138+
end do
2139+
21382140
#ifdef CompileWithMPI
2139-
call MPI_Barrier(SUBCOMM_MPI,ierr)
2141+
call MPI_Barrier(SUBCOMM_MPI, ierr)
21402142
#endif
21412143

2142-
!!!#ifdef CompileWithMPI
2143-
!!!call MPI_FILE_open (SUBCOMM_MPI, trim(adjustl(nombrefich))//'_tmp', &
2144-
!!! MPI_MODE_WRONLY + MPI_MODE_CREATE, &
2145-
!!! MPI_INFO_NULL, thefile8, ierr)
2146-
!!!disp = (layoutnumber+1) * 1024 * 20000 !no creo que se den mas de 20000 escrituras por layout
2147-
!!!
2148-
!!!call MPI_FILE_SET_VIEW(thefile8, disp, MPI_CHARACTER, &
2149-
!!! MPI_CHARACTER, 'native', &
2150-
!!! MPI_INFO_NULL, ierr)
2151-
!!!#else
2152-
!pgi 666 inquire (unit=thefile8,exist=borratedeunaputavez1)
2153-
inquire (file=trim(adjustl(nombrefich))//trim(adjustl(whoamishort))//'_tmp' ,exist=borratedeunaputavez2)
2154-
!pgi if (borratedeunaputavez1) then
2155-
!pgi print *,' '//trim(adjustl(whoamishort))//' ','--> no hay cojones con inquire unidad ',thefile8
2156-
!pgi call sleep(2)
2157-
!pgi goto 666
2158-
!pgi endif
2159-
if (borratedeunaputavez2) then
2160-
print *,' '//trim(adjustl(whoamishort))//' ','--> no hay cojones con inquire file fichero ',&
2161-
trim(adjustl(nombrefich))//trim(adjustl(whoamishort))//'_tmp'
2162-
call sleep(2)
2163-
goto 669
2164-
endif
2165-
open (newunit=thefile8,file=trim(adjustl(nombrefich))//trim(adjustl(whoamishort))//'_tmp',err=767 )
2166-
goto 768
2167-
767 print *,' '//trim(adjustl(whoamishort))//' ','--> no hay cojones con open definitivo unidad ',thefile8
2168-
call sleep(2)
2169-
goto 669
2170-
768 continue
2171-
!!!#endif
2172-
return
2173-
end function openfile_mpi
2174-
2175-
2144+
end function openfile_mpi
21762145

21772146
subroutine writefile_mpi(layoutnumber, thefile8,buff2)
21782147

@@ -2192,11 +2161,8 @@ subroutine writefile_mpi(layoutnumber, thefile8,buff2)
21922161

21932162
end subroutine writefile_mpi
21942163

2195-
2196-
21972164
subroutine closefile_mpi(layoutnumber,size,nombrefich,thefile8)
21982165

2199-
22002166
integer (kind=4) :: thefile8,thefile19
22012167
#ifdef CompileWithMPI
22022168
integer (kind=4) :: ierr

0 commit comments

Comments
 (0)