m_put_mod_fld.F90 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. module m_put_mod_fld
  2. ! KAL -- This routine puts one of the fields to the restart file, specified
  3. ! KAL -- by name, vertical level and time level.
  4. ! KAL -- Its a bit dangerous to use -- indx must be updated correctly (max one
  5. ! KAL -- increment per call of this routine), otherwise there wil be a
  6. ! KAL -- inconsistency between .a and .b files
  7. contains
  8. !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  9. ! KAL - This is for the new file type
  10. subroutine put_mod_fld(memfile,fld,iens,cfld,vlevel,tlevel,indx,nx,ny)
  11. use mod_raw_io
  12. implicit none
  13. integer, intent(in) :: nx,ny
  14. integer, intent(in) :: iens ! Ensemble member to read
  15. real, dimension(nx,ny), intent(in) :: fld ! output fld
  16. character(len=*), intent(in) :: memfile! base name of input files
  17. character(len=8), intent(in) :: cfld ! name of fld
  18. integer, intent(in) :: tlevel ! time level
  19. integer, intent(in) :: vlevel ! vertical level
  20. integer, intent(in) :: indx ! index into file
  21. real*4:: amin, amax,spval
  22. real*4:: writefldr4(nx,ny)
  23. integer , parameter :: nop=123
  24. integer :: ios
  25. writefldr4 = real(fld, 4)
  26. ! Write fld into index of .a file -- Direct access file
  27. call writeraw(writefldr4, &! feltet som skal skrivast
  28. amin,amax, &! min og max (returnerast fra writeraw)
  29. nx,ny, &! dimensjon
  30. .false.,spval, &! feltet vil ikkje faa "no-value" verdiar
  31. memfile//'.a', &! forelopig filnavn...
  32. indx) ! indexen i .a fila
  33. ! Skriv header -- .b fil -- Hold tunga rett i munnen her og utanfor rutina,
  34. ! ellers blir det inkonsistens mellom .a og .b filer - dette vil fangast opp
  35. ! av postprosessering. Dette er tungvint men vanskelig aa omgaa fordi
  36. ! .b-fila er sekvensiell mens .a fila er direct access.
  37. if (indx==1) then
  38. ! forste indeks - vi overskriv evt gamle filer
  39. open(nop,file=memfile//'.b',status='replace')
  40. else
  41. ! Ellers legg vi til
  42. open(nop,file=memfile//'.b',status='old', position='append')
  43. end if
  44. ! Skriv i vei !
  45. write(nop,4100,iostat=ios) cfld,vlevel,tlevel,amin,amax
  46. close(nop)
  47. 4100 format(a,': layer,tlevel,range = ',i3,i3,2x,1p2e16.7)
  48. ! format (a8,23x,i3,i3,2x,2e16.7)
  49. end subroutine
  50. end module m_put_mod_fld