mod_analysisfields.f90 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  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. !KAL -- this module allows us to fine-tune the fields
  10. !KAL -- we wish to include in the analysis. The new
  11. !KAL -- layout of the EnKF makes it possible to specify fields
  12. !KAL -- to analyze at run-time rather than at compile-time
  13. !KAL -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  14. !KAL --
  15. !KAL -- Module variables:
  16. !KAL -- numfields - total number of fields to process
  17. !KAL -- fieldnames - the names of the fields we wish to analyze
  18. !KAL -- fieldlevel - the levels of the associated fields
  19. !KAL -- fieldtype - in which file the field can be found:
  20. !ckb -- 1: ice, 2: ocean, 3: ice parameter,
  21. !ckb -- 4: ocean parameter
  22. !KAL --
  23. !KAL -- Ex: If we only want to assimilate temperatures in layer
  24. !KAL -- one and two, numfields, fieldnames and fieldlevel
  25. !KAL -- would look like:
  26. !KAL --
  27. !KAL -- numfields=2
  28. !KAL -- fieldnames (1)='temp', fieldnames (2)='temp'
  29. !KAL -- fieldlevel (1)= 1, fieldlevel (2)=2 (???)
  30. !ckb -- fieldtype (1)= 2, fieldtype (2)=2
  31. !KAL -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  32. !KAL -- The file "analysisfields.in" specifies the fields to
  33. !KAL -- inlude in the analysis. Format of one line is fieldname
  34. !ckb -- first layer, last layer and fieldtype. For example:
  35. !KAL --
  36. !KAL -- fieldname 1 31 1
  37. !KAL -- 12345678901234567890123456789012345678901234567890
  38. !KAL --
  39. !KAL -- Fortran format for one line is '(a14,3i3)'
  40. !KAL --
  41. !KAL -- Example: to specify that we want temperature and salinity
  42. !ckb -- in layers 1-31 (ocean variables, type 2) to be
  43. !ckb -- updated, as well as ice concentration (layer 0,
  44. !ckb -- type 1), and the atmosphere-ice-drag coefficient,
  45. !ckb -- specify:
  46. !ckb --
  47. !ckb -- a_i_htc1 0 0 1
  48. !ckb -- v_i_htc1 0 0 1
  49. !ckb -- tempt_il3_htc5 0 0 1
  50. !ckb -- ub 1 31 2
  51. !ckb -- vb 1 31 2
  52. !ckb -- cai 0 0 3
  53. !KAL -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  54. ! [FM,CKB] Changed to allow for column "parameter"
  55. module mod_analysisfields
  56. character(len=*), parameter :: infile='analysisfields.in'
  57. integer,save :: numfields
  58. character(len=14), dimension(:), save, allocatable:: fieldnames
  59. integer , dimension(:), save, allocatable:: fieldlevel
  60. integer , dimension(:), save, allocatable:: fieldtype
  61. contains
  62. integer function get_nrfields()
  63. use qmpi
  64. implicit none
  65. integer :: ios,first,last,type
  66. logical :: ex
  67. character(len=14) :: char14
  68. inquire(exist=ex,file=infile)
  69. if (.not. ex) then
  70. if (master) print *,'Could not find '//infile
  71. call stop_mpi()
  72. end if
  73. open(10,status='old',form='formatted',file=infile)
  74. ios=0
  75. get_nrfields=0
  76. do while (ios==0)
  77. read(10,100,iostat=ios) char14,first,last,type
  78. if (ios==0) get_nrfields=get_nrfields+last-first+1
  79. end do
  80. close(10)
  81. 100 format (a14,3i3)
  82. end function
  83. subroutine get_analysisfields()
  84. use qmpi
  85. implicit none
  86. integer :: first,last,type,k,nfld,ios
  87. logical :: ex
  88. character(len=14) :: char14
  89. numfields=get_nrfields()
  90. if (master) print *,'numfields is ',numfields
  91. if (numfields<=0 .or.numfields > 18000) then ! FM I Changed 600 to 18000
  92. if (master) print *,'(get_analysisfields) numfields is higher than max allowed setting or = 0'
  93. call stop_mpi()
  94. end if
  95. allocate(fieldnames(numfields))
  96. allocate(fieldlevel(numfields))
  97. allocate(fieldtype(numfields))
  98. inquire(exist=ex,file=infile)
  99. if (.not. ex) then
  100. if (master) print *,'Could not find '//infile
  101. call stop_mpi()
  102. end if
  103. open(10,status='old',form='formatted',file=infile)
  104. ios=0
  105. nfld=0
  106. do while (ios==0)
  107. read(10,100,iostat=ios) char14,first,last,type
  108. if (ios==0) then
  109. do k=first,last
  110. fieldnames (nfld+k-first+1)=char14
  111. fieldlevel (nfld+k-first+1)=k
  112. fieldtype (nfld+k-first+1)=type
  113. end do
  114. nfld=nfld+last-first+1
  115. end if
  116. end do
  117. close(10)
  118. 100 format (a14,3i3)
  119. if (nfld/=numfields) then
  120. if (master) print *,'An error occured when reading '//infile
  121. call stop_mpi()
  122. end if
  123. ! List fields used in analysis
  124. print *, "(mod_analysisfields) Fields used in analysis:"
  125. print *, "(mod_analysisfields) --- removed to reduce output ---"
  126. !do k=1,numfields
  127. ! if (master) print *,fieldnames(k),fieldlevel(k),fieldtype(k)
  128. !end do
  129. end subroutine
  130. end module mod_analysisfields