123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- # 0 "<stdin>"
- # 0 "<built-in>"
- # 0 "<command-line>"
- # 1 "/usr/include/stdc-predef.h" 1 3 4
- # 17 "/usr/include/stdc-predef.h" 3 4
- # 2 "<command-line>" 2
- # 1 "<stdin>"
- # 10 "<stdin>"
- module m_get_mod_nrens
- ! Finds how many ensemble members there are by counting ocean
- ! and ice restart files.
- !
- ! If an optional integer vector 'enslist' is submitted, the
- ! numbers of the 'still living' members is returned.
- !
- use qmpi, only : stop_mpi, master
- contains
- subroutine get_mod_nrens(nrens, enslist)
- implicit none
- ! In/out
- integer, intent(inout) :: nrens
- integer, dimension(:), intent(out), optional :: enslist
- ! Local variables
- logical ex
- integer iens ! loop var
- character(len=3) :: cens ! contains '1xx' of member
- character(len=99) :: path2mod='./' ! should model output be somewhere else
- integer :: maxnrens=899 ! max nr of members we're looking for
- integer nrice ! ice file counter
- ! restart files will have been moved to path2mod and be called
- ! 'forecast_ice_XXX.nc' where XXX is the enseble identifier (101-)
- ! Count members. Assumed nrens at most 1000.
- nrens = 0
- do iens=1,maxnrens
- write(cens,'(i3.3)') iens+100
- inquire(exist=ex,file=trim(path2mod)//'forecast_oce_'//cens//'.nc')
- if (ex) then
- nrens = nrens + 1
- if (present(enslist)) enslist(nrens) = iens
- end if
- end do
- ! Warn if arbitrary max. limit of nrens is reached.
- if ( ( nrens.eq.maxnrens ).and.(master) ) then
- print *,'WARNING:'
- print *,'WARNING: Ensemble sizes above ',maxnrens,' are not recognized.'
- print *,'WARNING: Adjust m_get_mod_nrens.F90 to go bigger.'
- ! Don't forget to adjust also length of cens.
- print *,'WARNING:'
- endif
- ! Count ice members. Assumed nrens at most maxnrens.
- nrice = 0
- do iens=1,maxnrens
- write(cens,'(i3.3)') iens+100
- inquire(exist=ex,file=trim(path2mod)//'forecast_ice_'//cens//'.nc')
- if (ex) nrice = nrice + 1
- end do
- if (nrice /= nrens) then
- if (master) then
- print *,'(get_mod_nrens) Error: Different number of ocean and ice restarts!!!'
- print *,'Ocean restarts : ',nrens
- print *,'Ice restarts : ',nrice
- end if
- call stop_mpi()
- end if
- end subroutine get_mod_nrens
- end module m_get_mod_nrens
|