[2932] | 1 | MODULE write_output_mod |
---|
[3092] | 2 | |
---|
[3160] | 3 | implicit none |
---|
[3092] | 4 | |
---|
[3160] | 5 | private |
---|
[2970] | 6 | |
---|
[3092] | 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 |
---|
[2932] | 12 | |
---|
[3160] | 13 | public write_output |
---|
[3092] | 14 | |
---|
[3160] | 15 | !----------------------------------------------------------------------- |
---|
| 16 | contains |
---|
| 17 | !----------------------------------------------------------------------- |
---|
[2932] | 18 | |
---|
[3160] | 19 | SUBROUTINE write_output_d0(field_name,title,units,field) |
---|
[3161] | 20 | ! For a scalar |
---|
[3160] | 21 | |
---|
[2934] | 22 | #ifdef CPP_XIOS |
---|
[3160] | 23 | use xios_output_mod, only: xios_is_active_field |
---|
| 24 | use xios_output_mod, only: send_xios_field |
---|
[2934] | 25 | #endif |
---|
[3092] | 26 | |
---|
[3160] | 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 | |
---|
[3225] | 37 | logical :: is_active ! For XIOS, should this field be sent or not |
---|
| 38 | |
---|
[3160] | 39 | call writediagfi(ngrid,field_name,title,units,0,(/field/)) |
---|
[3092] | 40 | #ifdef CPP_XIOS |
---|
[3225] | 41 | !is_active=xios_is_active_field(field_name) |
---|
| 42 | is_active=.true. |
---|
[3055] | 43 | ! only send the field to xios if the user asked for it |
---|
[3225] | 44 | if (is_active) call send_xios_field(field_name,field) |
---|
[2932] | 45 | #endif |
---|
[3092] | 46 | |
---|
[3160] | 47 | END SUBROUTINE write_output_d0 |
---|
[2932] | 48 | |
---|
[3160] | 49 | !----------------------------------------------------------------------- |
---|
[3092] | 50 | |
---|
[3160] | 51 | SUBROUTINE write_output_d1(field_name,title,units,field) |
---|
| 52 | ! For a surface field |
---|
| 53 | |
---|
[2934] | 54 | #ifdef CPP_XIOS |
---|
[3161] | 55 | use xios_output_mod, only: xios_is_active_field |
---|
| 56 | use xios_output_mod, only: send_xios_field |
---|
[2934] | 57 | #endif |
---|
[3092] | 58 | |
---|
[3160] | 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 | |
---|
[3225] | 69 | logical :: is_active ! For XIOS, should this field be sent or not |
---|
| 70 | |
---|
[3160] | 71 | call writediagfi(ngrid,field_name,title,units,2,field) |
---|
[3092] | 72 | #ifdef CPP_XIOS |
---|
[3225] | 73 | !is_active=xios_is_active_field(field_name) |
---|
| 74 | is_active=.true. |
---|
[3055] | 75 | ! only send the field to xios if the user asked for it |
---|
[3225] | 76 | if (is_active) call send_xios_field(field_name,field) |
---|
[2932] | 77 | #endif |
---|
[3092] | 78 | |
---|
[3160] | 79 | END SUBROUTINE write_output_d1 |
---|
[2932] | 80 | |
---|
[3160] | 81 | !----------------------------------------------------------------------- |
---|
[3092] | 82 | |
---|
[3160] | 83 | SUBROUTINE write_output_d2(field_name,title,units,field) |
---|
| 84 | ! For a "3D" horizontal-vertical field |
---|
| 85 | |
---|
[2934] | 86 | #ifdef CPP_XIOS |
---|
[3160] | 87 | use xios_output_mod, only: xios_is_active_field |
---|
| 88 | use xios_output_mod, only: send_xios_field |
---|
[2934] | 89 | #endif |
---|
[3161] | 90 | |
---|
[3160] | 91 | use comsoil_h, only: nsoilmx |
---|
| 92 | use writediagsoil_mod, only: writediagsoil |
---|
[2932] | 93 | |
---|
[3160] | 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 | |
---|
[3225] | 104 | logical :: is_active ! For XIOS, should this field be sent or not |
---|
| 105 | |
---|
[3160] | 106 | if (size(field,2) == nsoilmx) then |
---|
[2932] | 107 | call writediagsoil(ngrid,field_name,title,units,3,field) |
---|
[3160] | 108 | else |
---|
| 109 | call writediagfi(ngrid,field_name,title,units,3,field) |
---|
| 110 | endif |
---|
| 111 | |
---|
[3092] | 112 | #ifdef CPP_XIOS |
---|
[3225] | 113 | !is_active=xios_is_active_field(field_name) |
---|
| 114 | is_active=.true. |
---|
[3055] | 115 | ! only send the field to xios if the user asked for it |
---|
[3225] | 116 | if (is_active) call send_xios_field(field_name,field) |
---|
[2932] | 117 | #endif |
---|
[3092] | 118 | |
---|
[3160] | 119 | END SUBROUTINE write_output_d2 |
---|
[2932] | 120 | |
---|
[3160] | 121 | !----------------------------------------------------------------------- |
---|
[3092] | 122 | |
---|
[3160] | 123 | SUBROUTINE write_output_i0(field_name,title,units,field) |
---|
[3161] | 124 | ! For a scalar |
---|
[3160] | 125 | |
---|
[2970] | 126 | #ifdef CPP_XIOS |
---|
[3160] | 127 | use xios_output_mod, only: xios_is_active_field |
---|
| 128 | use xios_output_mod, only: send_xios_field |
---|
[2970] | 129 | #endif |
---|
[3092] | 130 | |
---|
[3160] | 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 | |
---|
[3225] | 141 | logical :: is_active ! For XIOS, should this field be sent or not |
---|
| 142 | |
---|
[3160] | 143 | call writediagfi(ngrid,field_name,title,units,0,(/real(field)/)) |
---|
[3092] | 144 | #ifdef CPP_XIOS |
---|
[3225] | 145 | !is_active=xios_is_active_field(field_name) |
---|
| 146 | is_active=.true. |
---|
[3055] | 147 | ! only send the field to xios if the user asked for it |
---|
[3225] | 148 | if (is_active) call send_xios_field(field_name,(/real(field)/)) |
---|
[2970] | 149 | #endif |
---|
[3092] | 150 | |
---|
[3160] | 151 | END SUBROUTINE write_output_i0 |
---|
[2970] | 152 | |
---|
[3160] | 153 | !----------------------------------------------------------------------- |
---|
[3092] | 154 | |
---|
[3160] | 155 | SUBROUTINE write_output_i1(field_name,title,units,field) |
---|
| 156 | ! For a surface field |
---|
| 157 | |
---|
[2970] | 158 | #ifdef CPP_XIOS |
---|
[3160] | 159 | use xios_output_mod, only: xios_is_active_field |
---|
| 160 | use xios_output_mod, only: send_xios_field |
---|
[2970] | 161 | #endif |
---|
[3092] | 162 | |
---|
[3160] | 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 | |
---|
[3225] | 173 | logical :: is_active ! For XIOS, should this field be sent or not |
---|
| 174 | |
---|
[3160] | 175 | call writediagfi(ngrid,field_name,title,units,2,real(field)) |
---|
[3092] | 176 | #ifdef CPP_XIOS |
---|
[3225] | 177 | !is_active=xios_is_active_field(field_name) |
---|
| 178 | is_active=.true. |
---|
[3055] | 179 | ! only send the field to xios if the user asked for it |
---|
[3225] | 180 | if (is_active) call send_xios_field(field_name,real(field)) |
---|
[2970] | 181 | #endif |
---|
[3092] | 182 | |
---|
[3160] | 183 | END SUBROUTINE write_output_i1 |
---|
[2970] | 184 | |
---|
[3160] | 185 | !----------------------------------------------------------------------- |
---|
[3092] | 186 | |
---|
[3160] | 187 | SUBROUTINE write_output_i2(field_name,title,units,field) |
---|
| 188 | ! For a "3D" horizontal-vertical field |
---|
| 189 | |
---|
[2970] | 190 | #ifdef CPP_XIOS |
---|
[3160] | 191 | use xios_output_mod, only: xios_is_active_field |
---|
| 192 | use xios_output_mod, only: send_xios_field |
---|
[2970] | 193 | #endif |
---|
| 194 | |
---|
[3160] | 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 | |
---|
[3225] | 208 | logical :: is_active ! For XIOS, should this field be sent or not |
---|
| 209 | |
---|
[3160] | 210 | if (size(field,2) == nsoilmx) then |
---|
[2970] | 211 | call writediagsoil(ngrid,field_name,title,units,3,real(field)) |
---|
[3160] | 212 | else |
---|
| 213 | call writediagfi(ngrid,field_name,title,units,3,real(field)) |
---|
| 214 | endif |
---|
[3092] | 215 | #ifdef CPP_XIOS |
---|
[3225] | 216 | !is_active=xios_is_active_field(field_name) |
---|
| 217 | is_active=.true. |
---|
[3055] | 218 | ! only send the field to xios if the user asked for it |
---|
[3225] | 219 | if (is_active) call send_xios_field(field_name,real(field)) |
---|
[2970] | 220 | #endif |
---|
[3092] | 221 | |
---|
[3160] | 222 | END SUBROUTINE write_output_i2 |
---|
[2970] | 223 | |
---|
[3160] | 224 | !----------------------------------------------------------------------- |
---|
[3092] | 225 | |
---|
[3160] | 226 | SUBROUTINE write_output_l0(field_name,title,units,field) |
---|
[3161] | 227 | ! For a scalar |
---|
[3160] | 228 | |
---|
[2970] | 229 | #ifdef CPP_XIOS |
---|
[3160] | 230 | use xios_output_mod, only: xios_is_active_field |
---|
| 231 | use xios_output_mod, only: send_xios_field |
---|
[2970] | 232 | #endif |
---|
| 233 | |
---|
[3160] | 234 | implicit none |
---|
[3092] | 235 | |
---|
[3160] | 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 |
---|
[3225] | 245 | logical :: is_active ! For XIOS, should this field be sent or not |
---|
[3160] | 246 | |
---|
| 247 | field_real = 0. |
---|
| 248 | if (field) field_real = 1. |
---|
| 249 | |
---|
| 250 | call writediagfi(ngrid,field_name,title,units,0,field_real) |
---|
[3092] | 251 | #ifdef CPP_XIOS |
---|
[3225] | 252 | !is_active=xios_is_active_field(field_name) |
---|
| 253 | is_active=.true. |
---|
[3055] | 254 | ! only send the field to xios if the user asked for it |
---|
[3225] | 255 | if (is_active) call send_xios_field(field_name,field_real) |
---|
[2970] | 256 | #endif |
---|
[3092] | 257 | |
---|
[3160] | 258 | END SUBROUTINE write_output_l0 |
---|
[2970] | 259 | |
---|
[3160] | 260 | !----------------------------------------------------------------------- |
---|
[3092] | 261 | |
---|
[3160] | 262 | SUBROUTINE write_output_l1(field_name,title,units,field) |
---|
| 263 | ! For a surface field |
---|
| 264 | |
---|
[2970] | 265 | #ifdef CPP_XIOS |
---|
[3160] | 266 | use xios_output_mod, only: xios_is_active_field |
---|
| 267 | use xios_output_mod, only: send_xios_field |
---|
[2970] | 268 | #endif |
---|
[3160] | 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 |
---|
[2970] | 279 | ! Local argument used to convert logical to real |
---|
[3160] | 280 | real, dimension(ngrid) :: field_real |
---|
[3225] | 281 | logical :: is_active ! For XIOS, should this field be sent or not |
---|
[2970] | 282 | |
---|
[3160] | 283 | field_real = 0. |
---|
| 284 | where (field) field_real = 1. |
---|
[3092] | 285 | |
---|
[3160] | 286 | call writediagfi(ngrid,field_name,title,units,2,field_real) |
---|
[3092] | 287 | #ifdef CPP_XIOS |
---|
[3225] | 288 | !is_active=xios_is_active_field(field_name) |
---|
| 289 | is_active=.true. |
---|
[3055] | 290 | ! only send the field to xios if the user asked for it |
---|
[3225] | 291 | if (is_active) call send_xios_field(field_name,field_real) |
---|
[2970] | 292 | #endif |
---|
[3092] | 293 | |
---|
[3160] | 294 | END SUBROUTINE write_output_l1 |
---|
[2970] | 295 | |
---|
[3160] | 296 | !----------------------------------------------------------------------- |
---|
[3092] | 297 | |
---|
[3160] | 298 | SUBROUTINE write_output_l2(field_name,title,units,field) |
---|
| 299 | ! For a "3D" horizontal-vertical field |
---|
| 300 | |
---|
[2970] | 301 | #ifdef CPP_XIOS |
---|
[3160] | 302 | use xios_output_mod, only: xios_is_active_field |
---|
| 303 | use xios_output_mod, only: send_xios_field |
---|
[2970] | 304 | #endif |
---|
[3160] | 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 |
---|
[2970] | 318 | ! Local argument used to convert logical to real |
---|
[3160] | 319 | real, allocatable, dimension(:,:) :: field_real |
---|
[3225] | 320 | logical :: is_active ! For XIOS, should this field be sent or not |
---|
[2970] | 321 | |
---|
[3160] | 322 | allocate(field_real(size(field,1),size(field,2))) |
---|
| 323 | field_real = 0. |
---|
| 324 | where (field) field_real = 1. |
---|
[2970] | 325 | |
---|
[3160] | 326 | if (size(field,2) == nsoilmx) then |
---|
[2970] | 327 | call writediagsoil(ngrid,field_name,title,units,3,field_real) |
---|
[3160] | 328 | else |
---|
| 329 | call writediagfi(ngrid,field_name,title,units,3,field_real) |
---|
| 330 | endif |
---|
[2970] | 331 | |
---|
[3092] | 332 | #ifdef CPP_XIOS |
---|
[3225] | 333 | !is_active=xios_is_active_field(field_name) |
---|
| 334 | is_active=.true. |
---|
[3055] | 335 | ! only send the field to xios if the user asked for it |
---|
[3225] | 336 | if (is_active) call send_xios_field(field_name,field_real) |
---|
[2970] | 337 | #endif |
---|
[3092] | 338 | |
---|
[3160] | 339 | deallocate(field_real) |
---|
[2976] | 340 | |
---|
[3160] | 341 | END SUBROUTINE write_output_l2 |
---|
[2970] | 342 | |
---|
[2932] | 343 | END MODULE write_output_mod |
---|