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