m_put_mod_fld.f90 2.6 KB

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