File indexing completed on 2018-03-02 18:45:09 UTC
view on githubraw file Latest commit b6f3d01b on 2013-02-23 04:24:42 UTC
8702af1f36 Patr*0001 module OAD_cp
0002
0003 implicit none
0004
0005 private :: cp_file_number, cp_open
0006
b6f3d01b24 Jean*0007 public :: cp_io_unit, cp_init, cp_write_open, cp_read_open, cp_close, cp_fNumber
8702af1f36 Patr*0008
0009 integer :: cp_file_number, cp_io_unit
0010
0011 interface cp_init
0012 module procedure init_i
0013 end interface
0014
0015 interface cp_open
0016 module procedure open_i
0017 end interface
0018
0019 interface cp_write_open
0020 module procedure write_open_i
b6f3d01b24 Jean*0021 module procedure write_openX_i
8702af1f36 Patr*0022 end interface
0023
0024 interface cp_read_open
0025 module procedure read_open_i
b6f3d01b24 Jean*0026 module procedure read_openX_i
8702af1f36 Patr*0027 end interface
0028
0029 interface cp_close
0030 module procedure close_i
0031 end interface
0032
0033 interface cp_findunit
0034 module procedure findunit_i
0035 end interface
b6f3d01b24 Jean*0036
8702af1f36 Patr*0037
0038
0039 subroutine init_i
0040 implicit none
0041 cp_file_number=1
0042 end subroutine
0043
0044 subroutine write_open_i()
0045 implicit none
0046 call cp_open()
b6f3d01b24 Jean*0047
8702af1f36 Patr*0048 cp_file_number=cp_file_number+1
0049 end subroutine
0050
b6f3d01b24 Jean*0051 subroutine write_openX_i(X)
0052 implicit none
0053 integer X
0054 cp_file_number=X
0055
0056 call cp_open()
0057 end subroutine
0058
8702af1f36 Patr*0059 subroutine read_open_i()
0060 implicit none
0061 cp_file_number=cp_file_number-1
b6f3d01b24 Jean*0062
0063 call cp_open()
0064 end subroutine
0065
0066 subroutine read_openX_i(X)
0067 implicit none
0068 integer X
0069 cp_file_number=X
0070
8702af1f36 Patr*0071 call cp_open()
0072 end subroutine
0073
0074 subroutine open_i()
0075 implicit none
0076 #ifdef ALLOW_USE_MPI
0077 include "mpif.h"
0078 #endif
0079 integer rank, mpirc
0080 character*128 fname
0081
0082 rank=0
0083 call cp_findunit()
0084
0085
0086 #ifdef ALLOW_USE_MPI
0087 call mpi_comm_rank(MPI_COMM_WORLD,rank, mpirc)
0088 #endif
0089 write(fname,'(A,I3.3,A,I5.5)') 'oad_cp.',rank,'.',cp_file_number
0090 open( UNIT=cp_io_unit,FILE=TRIM(fname),FORM='unformatted',STATUS='UNKNOWN' )
0091 end subroutine
0092
0093 subroutine close_i()
0094 implicit none
0095 close( UNIT=cp_io_unit)
0096 end subroutine
0097
0098 subroutine findunit_i()
0099
0100
0101
0102 implicit none
0103
0104 integer ii
0105 logical op
0106 integer ios
0107 character*(1024) msgbuf
0108
0109 cp_io_unit=-1
0110 do ii=9,999
0111 if (cp_io_unit.eq.-1) then
0112 inquire(unit=ii,iostat=ios,opened=op)
0113 if (ios.ne.0) then
0114 write(msgbuf,'(a,i2.2)') 'OAD_cp:findunit_i: inquiring unit number = ',ii
0115 print *, msgBuf
0116 write(msgbuf,'(a)') 'OAD_cp:findunit_i: inquire statement failed!'
0117 print *, msgBuf
0118 stop 'ABNORMAL END: S/R OAD_cp:findunit_i'
0119 endif
0120 if (.NOT. op) then
0121 cp_io_unit=ii
0122 end if
0123 end if
0124 end do
0125
0126 if (cp_io_unit.eq.-1) then
0127 write(msgbuf,'(a)') 'OAD_cp:findunit_i: could not find an available unit number!'
0128 print *, msgBuf
0129 stop 'ABNORMAL END: S/R OAD_cp:findunit_i'
0130 endif
0131 end subroutine
0132
b6f3d01b24 Jean*0133 function cp_fNumber()
0134 integer cp_fNumber
0135 cp_fNumber=cp_file_number
0136 end function
0137
8702af1f36 Patr*0138 end module