| 1 | MODULE write_output_mod |
|---|
| 2 | |
|---|
| 3 | implicit none |
|---|
| 4 | |
|---|
| 5 | private |
|---|
| 6 | |
|---|
| 7 | INTERFACE write_output |
|---|
| 8 | MODULE PROCEDURE write_output_d0, write_output_d1, write_output_d2, & |
|---|
| 9 | write_output_i0, write_output_i1, write_output_i2, & |
|---|
| 10 | write_output_l0, write_output_l1, write_output_l2 |
|---|
| 11 | END INTERFACE write_output |
|---|
| 12 | |
|---|
| 13 | public write_output |
|---|
| 14 | |
|---|
| 15 | !----------------------------------------------------------------------- |
|---|
| 16 | contains |
|---|
| 17 | !----------------------------------------------------------------------- |
|---|
| 18 | |
|---|
| 19 | SUBROUTINE write_output_d0(field_name,title,units,field) |
|---|
| 20 | ! For a scalar |
|---|
| 21 | |
|---|
| 22 | #ifdef CPP_XIOS |
|---|
| 23 | use xios_output_mod, only: xios_is_active_field |
|---|
| 24 | use xios_output_mod, only: send_xios_field |
|---|
| 25 | #endif |
|---|
| 26 | |
|---|
| 27 | implicit none |
|---|
| 28 | |
|---|
| 29 | include "dimensions.h" |
|---|
| 30 | |
|---|
| 31 | integer, parameter :: ngrid = 2 + (jjm - 1)*iim - 1/jjm |
|---|
| 32 | character(*), intent(in) :: field_name |
|---|
| 33 | character(*), intent(in) :: title |
|---|
| 34 | character(*), intent(in) :: units |
|---|
| 35 | real, intent(in) :: field |
|---|
| 36 | |
|---|
| 37 | logical :: is_active ! For XIOS, should this field be sent or not |
|---|
| 38 | |
|---|
| 39 | call writediagfi(ngrid,field_name,title,units,0,(/field/)) |
|---|
| 40 | #ifdef CPP_XIOS |
|---|
| 41 | !is_active=xios_is_active_field(field_name) |
|---|
| 42 | is_active=.true. |
|---|
| 43 | ! only send the field to xios if the user asked for it |
|---|
| 44 | if (is_active) call send_xios_field(field_name,field) |
|---|
| 45 | #endif |
|---|
| 46 | |
|---|
| 47 | END SUBROUTINE write_output_d0 |
|---|
| 48 | |
|---|
| 49 | !----------------------------------------------------------------------- |
|---|
| 50 | |
|---|
| 51 | SUBROUTINE write_output_d1(field_name,title,units,field) |
|---|
| 52 | ! For a surface field |
|---|
| 53 | |
|---|
| 54 | #ifdef CPP_XIOS |
|---|
| 55 | use xios_output_mod, only: xios_is_active_field |
|---|
| 56 | use xios_output_mod, only: send_xios_field |
|---|
| 57 | #endif |
|---|
| 58 | |
|---|
| 59 | implicit none |
|---|
| 60 | |
|---|
| 61 | include "dimensions.h" |
|---|
| 62 | |
|---|
| 63 | integer, parameter :: ngrid = 2 + (jjm - 1)*iim - 1/jjm |
|---|
| 64 | character(*), intent(in) :: field_name |
|---|
| 65 | character(*), intent(in) :: title |
|---|
| 66 | character(*), intent(in) :: units |
|---|
| 67 | real, dimension(:), intent(in) :: field |
|---|
| 68 | |
|---|
| 69 | logical :: is_active ! For XIOS, should this field be sent or not |
|---|
| 70 | |
|---|
| 71 | call writediagfi(ngrid,field_name,title,units,2,field) |
|---|
| 72 | #ifdef CPP_XIOS |
|---|
| 73 | !is_active=xios_is_active_field(field_name) |
|---|
| 74 | is_active=.true. |
|---|
| 75 | ! only send the field to xios if the user asked for it |
|---|
| 76 | if (is_active) call send_xios_field(field_name,field) |
|---|
| 77 | #endif |
|---|
| 78 | |
|---|
| 79 | END SUBROUTINE write_output_d1 |
|---|
| 80 | |
|---|
| 81 | !----------------------------------------------------------------------- |
|---|
| 82 | |
|---|
| 83 | SUBROUTINE write_output_d2(field_name,title,units,field) |
|---|
| 84 | ! For a "3D" horizontal-vertical field |
|---|
| 85 | |
|---|
| 86 | #ifdef CPP_XIOS |
|---|
| 87 | use xios_output_mod, only: xios_is_active_field |
|---|
| 88 | use xios_output_mod, only: send_xios_field |
|---|
| 89 | #endif |
|---|
| 90 | |
|---|
| 91 | use comsoil_h, only: nsoilmx |
|---|
| 92 | use writediagsoil_mod, only: writediagsoil |
|---|
| 93 | |
|---|
| 94 | implicit none |
|---|
| 95 | |
|---|
| 96 | include "dimensions.h" |
|---|
| 97 | |
|---|
| 98 | integer, parameter :: ngrid = 2 + (jjm - 1)*iim - 1/jjm |
|---|
| 99 | character(*), intent(in) :: field_name |
|---|
| 100 | character(*), intent(in) :: title |
|---|
| 101 | character(*), intent(in) :: units |
|---|
| 102 | real, dimension(:,:), intent(in) :: field |
|---|
| 103 | |
|---|
| 104 | logical :: is_active ! For XIOS, should this field be sent or not |
|---|
| 105 | |
|---|
| 106 | if (size(field,2) == nsoilmx) then |
|---|
| 107 | call writediagsoil(ngrid,field_name,title,units,3,field) |
|---|
| 108 | else |
|---|
| 109 | call writediagfi(ngrid,field_name,title,units,3,field) |
|---|
| 110 | endif |
|---|
| 111 | |
|---|
| 112 | #ifdef CPP_XIOS |
|---|
| 113 | !is_active=xios_is_active_field(field_name) |
|---|
| 114 | is_active=.true. |
|---|
| 115 | ! only send the field to xios if the user asked for it |
|---|
| 116 | if (is_active) call send_xios_field(field_name,field) |
|---|
| 117 | #endif |
|---|
| 118 | |
|---|
| 119 | END SUBROUTINE write_output_d2 |
|---|
| 120 | |
|---|
| 121 | !----------------------------------------------------------------------- |
|---|
| 122 | |
|---|
| 123 | SUBROUTINE write_output_i0(field_name,title,units,field) |
|---|
| 124 | ! For a scalar |
|---|
| 125 | |
|---|
| 126 | #ifdef CPP_XIOS |
|---|
| 127 | use xios_output_mod, only: xios_is_active_field |
|---|
| 128 | use xios_output_mod, only: send_xios_field |
|---|
| 129 | #endif |
|---|
| 130 | |
|---|
| 131 | implicit none |
|---|
| 132 | |
|---|
| 133 | include "dimensions.h" |
|---|
| 134 | |
|---|
| 135 | integer, parameter :: ngrid = 2 + (jjm - 1)*iim - 1/jjm |
|---|
| 136 | character(*), intent(in) :: field_name |
|---|
| 137 | character(*), intent(in) :: title |
|---|
| 138 | character(*), intent(in) :: units |
|---|
| 139 | integer, intent(in) :: field |
|---|
| 140 | |
|---|
| 141 | logical :: is_active ! For XIOS, should this field be sent or not |
|---|
| 142 | |
|---|
| 143 | call writediagfi(ngrid,field_name,title,units,0,(/real(field)/)) |
|---|
| 144 | #ifdef CPP_XIOS |
|---|
| 145 | !is_active=xios_is_active_field(field_name) |
|---|
| 146 | is_active=.true. |
|---|
| 147 | ! only send the field to xios if the user asked for it |
|---|
| 148 | if (is_active) call send_xios_field(field_name,(/real(field)/)) |
|---|
| 149 | #endif |
|---|
| 150 | |
|---|
| 151 | END SUBROUTINE write_output_i0 |
|---|
| 152 | |
|---|
| 153 | !----------------------------------------------------------------------- |
|---|
| 154 | |
|---|
| 155 | SUBROUTINE write_output_i1(field_name,title,units,field) |
|---|
| 156 | ! For a surface field |
|---|
| 157 | |
|---|
| 158 | #ifdef CPP_XIOS |
|---|
| 159 | use xios_output_mod, only: xios_is_active_field |
|---|
| 160 | use xios_output_mod, only: send_xios_field |
|---|
| 161 | #endif |
|---|
| 162 | |
|---|
| 163 | implicit none |
|---|
| 164 | |
|---|
| 165 | include "dimensions.h" |
|---|
| 166 | |
|---|
| 167 | integer, parameter :: ngrid = 2 + (jjm - 1)*iim - 1/jjm |
|---|
| 168 | character(*), intent(in) :: field_name |
|---|
| 169 | character(*), intent(in) :: title |
|---|
| 170 | character(*), intent(in) :: units |
|---|
| 171 | integer, dimension(:), intent(in) :: field |
|---|
| 172 | |
|---|
| 173 | logical :: is_active ! For XIOS, should this field be sent or not |
|---|
| 174 | |
|---|
| 175 | call writediagfi(ngrid,field_name,title,units,2,real(field)) |
|---|
| 176 | #ifdef CPP_XIOS |
|---|
| 177 | !is_active=xios_is_active_field(field_name) |
|---|
| 178 | is_active=.true. |
|---|
| 179 | ! only send the field to xios if the user asked for it |
|---|
| 180 | if (is_active) call send_xios_field(field_name,real(field)) |
|---|
| 181 | #endif |
|---|
| 182 | |
|---|
| 183 | END SUBROUTINE write_output_i1 |
|---|
| 184 | |
|---|
| 185 | !----------------------------------------------------------------------- |
|---|
| 186 | |
|---|
| 187 | SUBROUTINE write_output_i2(field_name,title,units,field) |
|---|
| 188 | ! For a "3D" horizontal-vertical field |
|---|
| 189 | |
|---|
| 190 | #ifdef CPP_XIOS |
|---|
| 191 | use xios_output_mod, only: xios_is_active_field |
|---|
| 192 | use xios_output_mod, only: send_xios_field |
|---|
| 193 | #endif |
|---|
| 194 | |
|---|
| 195 | use comsoil_h, only: nsoilmx |
|---|
| 196 | use writediagsoil_mod, only: writediagsoil |
|---|
| 197 | |
|---|
| 198 | implicit none |
|---|
| 199 | |
|---|
| 200 | include "dimensions.h" |
|---|
| 201 | |
|---|
| 202 | integer, parameter :: ngrid = 2 + (jjm - 1)*iim - 1/jjm |
|---|
| 203 | character(*), intent(in) :: field_name |
|---|
| 204 | character(*), intent(in) :: title |
|---|
| 205 | character(*), intent(in) :: units |
|---|
| 206 | integer, dimension(:,:), intent(in) :: field |
|---|
| 207 | |
|---|
| 208 | logical :: is_active ! For XIOS, should this field be sent or not |
|---|
| 209 | |
|---|
| 210 | if (size(field,2) == nsoilmx) then |
|---|
| 211 | call writediagsoil(ngrid,field_name,title,units,3,real(field)) |
|---|
| 212 | else |
|---|
| 213 | call writediagfi(ngrid,field_name,title,units,3,real(field)) |
|---|
| 214 | endif |
|---|
| 215 | #ifdef CPP_XIOS |
|---|
| 216 | !is_active=xios_is_active_field(field_name) |
|---|
| 217 | is_active=.true. |
|---|
| 218 | ! only send the field to xios if the user asked for it |
|---|
| 219 | if (is_active) call send_xios_field(field_name,real(field)) |
|---|
| 220 | #endif |
|---|
| 221 | |
|---|
| 222 | END SUBROUTINE write_output_i2 |
|---|
| 223 | |
|---|
| 224 | !----------------------------------------------------------------------- |
|---|
| 225 | |
|---|
| 226 | SUBROUTINE write_output_l0(field_name,title,units,field) |
|---|
| 227 | ! For a scalar |
|---|
| 228 | |
|---|
| 229 | #ifdef CPP_XIOS |
|---|
| 230 | use xios_output_mod, only: xios_is_active_field |
|---|
| 231 | use xios_output_mod, only: send_xios_field |
|---|
| 232 | #endif |
|---|
| 233 | |
|---|
| 234 | implicit none |
|---|
| 235 | |
|---|
| 236 | include "dimensions.h" |
|---|
| 237 | |
|---|
| 238 | integer, parameter :: ngrid = 2 + (jjm - 1)*iim - 1/jjm |
|---|
| 239 | character(*), intent(in) :: field_name |
|---|
| 240 | character(*), intent(in) :: title |
|---|
| 241 | character(*), intent(in) :: units |
|---|
| 242 | logical, intent(in) :: field |
|---|
| 243 | ! Local argument used to convert logical to real array |
|---|
| 244 | real, dimension(1) :: field_real |
|---|
| 245 | logical :: is_active ! For XIOS, should this field be sent or not |
|---|
| 246 | |
|---|
| 247 | field_real = 0. |
|---|
| 248 | if (field) field_real = 1. |
|---|
| 249 | |
|---|
| 250 | call writediagfi(ngrid,field_name,title,units,0,field_real) |
|---|
| 251 | #ifdef CPP_XIOS |
|---|
| 252 | !is_active=xios_is_active_field(field_name) |
|---|
| 253 | is_active=.true. |
|---|
| 254 | ! only send the field to xios if the user asked for it |
|---|
| 255 | if (is_active) call send_xios_field(field_name,field_real) |
|---|
| 256 | #endif |
|---|
| 257 | |
|---|
| 258 | END SUBROUTINE write_output_l0 |
|---|
| 259 | |
|---|
| 260 | !----------------------------------------------------------------------- |
|---|
| 261 | |
|---|
| 262 | SUBROUTINE write_output_l1(field_name,title,units,field) |
|---|
| 263 | ! For a surface field |
|---|
| 264 | |
|---|
| 265 | #ifdef CPP_XIOS |
|---|
| 266 | use xios_output_mod, only: xios_is_active_field |
|---|
| 267 | use xios_output_mod, only: send_xios_field |
|---|
| 268 | #endif |
|---|
| 269 | |
|---|
| 270 | implicit none |
|---|
| 271 | |
|---|
| 272 | include "dimensions.h" |
|---|
| 273 | |
|---|
| 274 | integer, parameter :: ngrid = 2 + (jjm - 1)*iim - 1/jjm |
|---|
| 275 | character(*), intent(in) :: field_name |
|---|
| 276 | character(*), intent(in) :: title |
|---|
| 277 | character(*), intent(in) :: units |
|---|
| 278 | logical, dimension(:), intent(in) :: field |
|---|
| 279 | ! Local argument used to convert logical to real |
|---|
| 280 | real, dimension(ngrid) :: field_real |
|---|
| 281 | logical :: is_active ! For XIOS, should this field be sent or not |
|---|
| 282 | |
|---|
| 283 | field_real = 0. |
|---|
| 284 | where (field) field_real = 1. |
|---|
| 285 | |
|---|
| 286 | call writediagfi(ngrid,field_name,title,units,2,field_real) |
|---|
| 287 | #ifdef CPP_XIOS |
|---|
| 288 | !is_active=xios_is_active_field(field_name) |
|---|
| 289 | is_active=.true. |
|---|
| 290 | ! only send the field to xios if the user asked for it |
|---|
| 291 | if (is_active) call send_xios_field(field_name,field_real) |
|---|
| 292 | #endif |
|---|
| 293 | |
|---|
| 294 | END SUBROUTINE write_output_l1 |
|---|
| 295 | |
|---|
| 296 | !----------------------------------------------------------------------- |
|---|
| 297 | |
|---|
| 298 | SUBROUTINE write_output_l2(field_name,title,units,field) |
|---|
| 299 | ! For a "3D" horizontal-vertical field |
|---|
| 300 | |
|---|
| 301 | #ifdef CPP_XIOS |
|---|
| 302 | use xios_output_mod, only: xios_is_active_field |
|---|
| 303 | use xios_output_mod, only: send_xios_field |
|---|
| 304 | #endif |
|---|
| 305 | |
|---|
| 306 | use comsoil_h, only: nsoilmx |
|---|
| 307 | use writediagsoil_mod, only: writediagsoil |
|---|
| 308 | |
|---|
| 309 | implicit none |
|---|
| 310 | |
|---|
| 311 | include "dimensions.h" |
|---|
| 312 | |
|---|
| 313 | integer, parameter :: ngrid = 2 + (jjm - 1)*iim - 1/jjm |
|---|
| 314 | character(*), intent(in) :: field_name |
|---|
| 315 | character(*), intent(in) :: title |
|---|
| 316 | character(*), intent(in) :: units |
|---|
| 317 | logical, dimension(:,:), intent(in) :: field |
|---|
| 318 | ! Local argument used to convert logical to real |
|---|
| 319 | real, allocatable, dimension(:,:) :: field_real |
|---|
| 320 | logical :: is_active ! For XIOS, should this field be sent or not |
|---|
| 321 | |
|---|
| 322 | allocate(field_real(size(field,1),size(field,2))) |
|---|
| 323 | field_real = 0. |
|---|
| 324 | where (field) field_real = 1. |
|---|
| 325 | |
|---|
| 326 | if (size(field,2) == nsoilmx) then |
|---|
| 327 | call writediagsoil(ngrid,field_name,title,units,3,field_real) |
|---|
| 328 | else |
|---|
| 329 | call writediagfi(ngrid,field_name,title,units,3,field_real) |
|---|
| 330 | endif |
|---|
| 331 | |
|---|
| 332 | #ifdef CPP_XIOS |
|---|
| 333 | !is_active=xios_is_active_field(field_name) |
|---|
| 334 | is_active=.true. |
|---|
| 335 | ! only send the field to xios if the user asked for it |
|---|
| 336 | if (is_active) call send_xios_field(field_name,field_real) |
|---|
| 337 | #endif |
|---|
| 338 | |
|---|
| 339 | deallocate(field_real) |
|---|
| 340 | |
|---|
| 341 | END SUBROUTINE write_output_l2 |
|---|
| 342 | |
|---|
| 343 | END MODULE write_output_mod |
|---|