Changeset 3160 for trunk/LMDZ.MARS
- Timestamp:
- Dec 19, 2023, 10:02:23 AM (11 months ago)
- Location:
- trunk/LMDZ.MARS
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LMDZ.MARS/changelog.txt
r3158 r3160 4407 4407 == 13/12/2023 == CS 4408 4408 Cleaning of conduction.F, euvheat.F90, moldiff.F and molvis.F, some commented lines referring to a local calculation of layers/levels altitudes have been removed. 4409 4410 == 19/12/2023 == JBC 4411 Fixed an issue where the gfortran compilation failed due to rank mismatch of the 'field' argument when calling 'writediagfi' + cleaning of the subroutine. -
trunk/LMDZ.MARS/libf/phymars/write_output_mod.F90
r3092 r3160 1 1 MODULE write_output_mod 2 2 3 IMPLICIT NONE 4 5 PRIVATE 3 implicit none 4 5 private 6 6 7 7 INTERFACE write_output … … 11 11 END INTERFACE write_output 12 12 13 PUBLIC write_output 14 15 !---------------------------------------------------------------------- 16 CONTAINS 17 !---------------------------------------------------------------------- 18 19 SUBROUTINE write_output_d0(field_name,title,units,field) 20 ! For a surface field 13 public write_output 14 15 !----------------------------------------------------------------------- 16 contains 17 !----------------------------------------------------------------------- 18 19 SUBROUTINE write_output_d0(field_name,title,units,field) 20 ! For a surface field 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 21 50 #ifdef CPP_XIOS 22 51 use xios_output_mod, only: xios_is_active_field 23 52 use xios_output_mod, only: send_xios_field 24 53 #endif 25 IMPLICIT NONE 26 include "dimensions.h" 27 INTEGER ngrid 28 PARAMETER( ngrid = 2+(jjm-1)*iim - 1/jjm ) 29 CHARACTER(LEN=*),INTENT(IN) :: field_name 30 CHARACTER(LEN=*),INTENT(IN) :: title 31 CHARACTER(LEN=*),INTENT(IN) :: units 32 REAL,INTENT(IN) :: field 33 34 call writediagfi(ngrid,field_name,title,units,0,field) 35 #ifdef CPP_XIOS 36 if (xios_is_active_field(field_name)) then 37 ! only send the field to xios if the user asked for it 38 call send_xios_field(field_name,field) 39 endif 40 #endif 41 42 END SUBROUTINE write_output_d0 43 44 !---------------------------------------------------------------------- 45 46 SUBROUTINE write_output_d1(field_name,title,units,field) 47 ! For a surface field 48 #ifdef CPP_XIOS 49 use xios_output_mod, only: xios_is_active_field 50 use xios_output_mod, only: send_xios_field 51 #endif 52 IMPLICIT NONE 53 include "dimensions.h" 54 INTEGER ngrid 55 PARAMETER( ngrid = 2+(jjm-1)*iim - 1/jjm ) 56 CHARACTER(LEN=*),INTENT(IN) :: field_name 57 CHARACTER(LEN=*),INTENT(IN) :: title 58 CHARACTER(LEN=*),INTENT(IN) :: units 59 REAL,INTENT(IN) :: field(:) 60 61 call writediagfi(ngrid,field_name,title,units,2,field) 62 #ifdef CPP_XIOS 63 if (xios_is_active_field(field_name)) then 64 ! only send the field to xios if the user asked for it 65 call send_xios_field(field_name,field) 66 endif 67 #endif 68 69 END SUBROUTINE write_output_d1 70 71 !---------------------------------------------------------------------- 72 73 SUBROUTINE write_output_d2(field_name,title,units,field) 74 ! For a "3D" horizontal-vertical field 75 #ifdef CPP_XIOS 76 use xios_output_mod, only: xios_is_active_field 77 use xios_output_mod, only: send_xios_field 78 #endif 79 use comsoil_h, only: nsoilmx 80 use writediagsoil_mod, only: writediagsoil 81 IMPLICIT NONE 82 include "dimensions.h" 83 INTEGER ngrid 84 PARAMETER( ngrid = 2+(jjm-1)*iim - 1/jjm ) 85 CHARACTER(LEN=*),INTENT(IN) :: field_name 86 CHARACTER(LEN=*),INTENT(IN) :: title 87 CHARACTER(LEN=*),INTENT(IN) :: units 88 REAL,INTENT(IN) :: field(:,:) 89 90 if(size(field(:,:),2).eq.nsoilmx) then 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 use comsoil_h, only: nsoilmx 83 use writediagsoil_mod, only: writediagsoil 84 85 implicit none 86 87 include "dimensions.h" 88 89 integer, parameter :: ngrid = 2 + (jjm - 1)*iim - 1/jjm 90 character(*), intent(in) :: field_name 91 character(*), intent(in) :: title 92 character(*), intent(in) :: units 93 real, dimension(:,:), intent(in) :: field 94 95 if (size(field,2) == nsoilmx) then 91 96 call writediagsoil(ngrid,field_name,title,units,3,field) 92 else 93 call writediagfi(ngrid,field_name,title,units,3,field(:,:)) 94 endif 95 #ifdef CPP_XIOS 96 if (xios_is_active_field(field_name)) then 97 ! only send the field to xios if the user asked for it 98 call send_xios_field(field_name,field) 99 endif 100 #endif 101 102 END SUBROUTINE write_output_d2 103 104 !---------------------------------------------------------------------- 105 106 SUBROUTINE write_output_i0(field_name,title,units,field) 107 ! For a surface field 108 #ifdef CPP_XIOS 109 use xios_output_mod, only: xios_is_active_field 110 use xios_output_mod, only: send_xios_field 111 #endif 112 IMPLICIT NONE 113 include "dimensions.h" 114 INTEGER ngrid 115 PARAMETER( ngrid = 2+(jjm-1)*iim - 1/jjm ) 116 CHARACTER(LEN=*),INTENT(IN) :: field_name 117 CHARACTER(LEN=*),INTENT(IN) :: title 118 CHARACTER(LEN=*),INTENT(IN) :: units 119 INTEGER,INTENT(IN) :: field 120 121 call writediagfi(ngrid,field_name,title,units,0,real(field)) 122 #ifdef CPP_XIOS 123 if (xios_is_active_field(field_name)) then 124 ! only send the field to xios if the user asked for it 125 call send_xios_field(field_name,real(field)) 126 endif 127 #endif 128 129 END SUBROUTINE write_output_i0 130 131 !---------------------------------------------------------------------- 132 133 SUBROUTINE write_output_i1(field_name,title,units,field) 134 ! For a surface field 135 #ifdef CPP_XIOS 136 use xios_output_mod, only: xios_is_active_field 137 use xios_output_mod, only: send_xios_field 138 #endif 139 IMPLICIT NONE 140 include "dimensions.h" 141 INTEGER ngrid 142 PARAMETER( ngrid = 2+(jjm-1)*iim - 1/jjm ) 143 CHARACTER(LEN=*),INTENT(IN) :: field_name 144 CHARACTER(LEN=*),INTENT(IN) :: title 145 CHARACTER(LEN=*),INTENT(IN) :: units 146 INTEGER,INTENT(IN) :: field(:) 147 148 call writediagfi(ngrid,field_name,title,units,2,real(field)) 149 #ifdef CPP_XIOS 150 if (xios_is_active_field(field_name)) then 151 ! only send the field to xios if the user asked for it 152 call send_xios_field(field_name,real(field)) 153 endif 154 #endif 155 156 END SUBROUTINE write_output_i1 157 158 !---------------------------------------------------------------------- 159 160 SUBROUTINE write_output_i2(field_name,title,units,field) 161 ! For a "3D" horizontal-vertical field 162 #ifdef CPP_XIOS 163 use xios_output_mod, only: xios_is_active_field 164 use xios_output_mod, only: send_xios_field 165 #endif 166 use comsoil_h, only: nsoilmx 167 use writediagsoil_mod, only: writediagsoil 168 IMPLICIT NONE 169 include "dimensions.h" 170 INTEGER ngrid 171 PARAMETER( ngrid = 2+(jjm-1)*iim - 1/jjm ) 172 CHARACTER(LEN=*),INTENT(IN) :: field_name 173 CHARACTER(LEN=*),INTENT(IN) :: title 174 CHARACTER(LEN=*),INTENT(IN) :: units 175 INTEGER,INTENT(IN) :: field(:,:) 176 177 if(size(field(:,:),2).eq.nsoilmx) then 97 else 98 call writediagfi(ngrid,field_name,title,units,3,field) 99 endif 100 101 #ifdef CPP_XIOS 102 ! only send the field to xios if the user asked for it 103 if (xios_is_active_field(field_name)) call send_xios_field(field_name,field) 104 #endif 105 106 END SUBROUTINE write_output_d2 107 108 !----------------------------------------------------------------------- 109 110 SUBROUTINE write_output_i0(field_name,title,units,field) 111 ! For a surface field 112 113 #ifdef CPP_XIOS 114 use xios_output_mod, only: xios_is_active_field 115 use xios_output_mod, only: send_xios_field 116 #endif 117 118 implicit none 119 120 include "dimensions.h" 121 122 integer, parameter :: ngrid = 2 + (jjm - 1)*iim - 1/jjm 123 character(*), intent(in) :: field_name 124 character(*), intent(in) :: title 125 character(*), intent(in) :: units 126 integer, intent(in) :: field 127 128 call writediagfi(ngrid,field_name,title,units,0,(/real(field)/)) 129 #ifdef CPP_XIOS 130 ! only send the field to xios if the user asked for it 131 if (xios_is_active_field(field_name)) call send_xios_field(field_name,(/real(field)/)) 132 #endif 133 134 END SUBROUTINE write_output_i0 135 136 !----------------------------------------------------------------------- 137 138 SUBROUTINE write_output_i1(field_name,title,units,field) 139 ! For a surface field 140 141 #ifdef CPP_XIOS 142 use xios_output_mod, only: xios_is_active_field 143 use xios_output_mod, only: send_xios_field 144 #endif 145 146 implicit none 147 148 include "dimensions.h" 149 150 integer, parameter :: ngrid = 2 + (jjm - 1)*iim - 1/jjm 151 character(*), intent(in) :: field_name 152 character(*), intent(in) :: title 153 character(*), intent(in) :: units 154 integer, dimension(:), intent(in) :: field 155 156 call writediagfi(ngrid,field_name,title,units,2,real(field)) 157 #ifdef CPP_XIOS 158 ! only send the field to xios if the user asked for it 159 if (xios_is_active_field(field_name)) call send_xios_field(field_name,real(field)) 160 #endif 161 162 END SUBROUTINE write_output_i1 163 164 !----------------------------------------------------------------------- 165 166 SUBROUTINE write_output_i2(field_name,title,units,field) 167 ! For a "3D" horizontal-vertical field 168 169 #ifdef CPP_XIOS 170 use xios_output_mod, only: xios_is_active_field 171 use xios_output_mod, only: send_xios_field 172 #endif 173 174 use comsoil_h, only: nsoilmx 175 use writediagsoil_mod, only: writediagsoil 176 177 implicit none 178 179 include "dimensions.h" 180 181 integer, parameter :: ngrid = 2 + (jjm - 1)*iim - 1/jjm 182 character(*), intent(in) :: field_name 183 character(*), intent(in) :: title 184 character(*), intent(in) :: units 185 integer, dimension(:,:), intent(in) :: field 186 187 if (size(field,2) == nsoilmx) then 178 188 call writediagsoil(ngrid,field_name,title,units,3,real(field)) 179 else 180 call writediagfi(ngrid,field_name,title,units,3,real(field(:,:))) 181 endif 182 #ifdef CPP_XIOS 183 if (xios_is_active_field(field_name)) then 184 ! only send the field to xios if the user asked for it 185 call send_xios_field(field_name,real(field)) 186 endif 187 #endif 188 189 END SUBROUTINE write_output_i2 190 191 !---------------------------------------------------------------------- 192 193 SUBROUTINE write_output_l0(field_name,title,units,field) 194 ! For a surface field 195 #ifdef CPP_XIOS 196 use xios_output_mod, only: xios_is_active_field 197 use xios_output_mod, only: send_xios_field 198 #endif 199 IMPLICIT NONE 200 include "dimensions.h" 201 INTEGER ngrid 202 PARAMETER( ngrid = 2+(jjm-1)*iim - 1/jjm ) 203 CHARACTER(LEN=*),INTENT(IN) :: field_name 204 CHARACTER(LEN=*),INTENT(IN) :: title 205 CHARACTER(LEN=*),INTENT(IN) :: units 206 LOGICAL,INTENT(IN) :: field 189 else 190 call writediagfi(ngrid,field_name,title,units,3,real(field)) 191 endif 192 #ifdef CPP_XIOS 193 ! only send the field to xios if the user asked for it 194 if (xios_is_active_field(field_name)) call send_xios_field(field_name,real(field)) 195 #endif 196 197 END SUBROUTINE write_output_i2 198 199 !----------------------------------------------------------------------- 200 201 SUBROUTINE write_output_l0(field_name,title,units,field) 202 ! For a surface field 203 204 #ifdef CPP_XIOS 205 use xios_output_mod, only: xios_is_active_field 206 use xios_output_mod, only: send_xios_field 207 #endif 208 209 implicit none 210 211 include "dimensions.h" 212 213 integer, parameter :: ngrid = 2 + (jjm - 1)*iim - 1/jjm 214 character(*), intent(in) :: field_name 215 character(*), intent(in) :: title 216 character(*), intent(in) :: units 217 logical, intent(in) :: field 218 ! Local argument used to convert logical to real array 219 real, dimension(1) :: field_real 220 221 field_real = 0. 222 if (field) field_real = 1. 223 224 call writediagfi(ngrid,field_name,title,units,0,field_real) 225 #ifdef CPP_XIOS 226 ! only send the field to xios if the user asked for it 227 if (xios_is_active_field(field_name)) call send_xios_field(field_name,field_real) 228 #endif 229 230 END SUBROUTINE write_output_l0 231 232 !----------------------------------------------------------------------- 233 234 SUBROUTINE write_output_l1(field_name,title,units,field) 235 ! For a surface field 236 237 #ifdef CPP_XIOS 238 use xios_output_mod, only: xios_is_active_field 239 use xios_output_mod, only: send_xios_field 240 #endif 241 242 implicit none 243 244 include "dimensions.h" 245 246 integer, parameter :: ngrid = 2 + (jjm - 1)*iim - 1/jjm 247 character(*), intent(in) :: field_name 248 character(*), intent(in) :: title 249 character(*), intent(in) :: units 250 logical, dimension(:), intent(in) :: field 207 251 ! Local argument used to convert logical to real 208 REAL :: field_real 209 210 field_real=0 211 if(field) field_real=1 212 213 call writediagfi(ngrid,field_name,title,units,0,field_real) 214 #ifdef CPP_XIOS 215 if (xios_is_active_field(field_name)) then 216 ! only send the field to xios if the user asked for it 217 call send_xios_field(field_name,field_real) 218 endif 219 #endif 220 221 END SUBROUTINE write_output_l0 222 223 !---------------------------------------------------------------------- 224 225 SUBROUTINE write_output_l1(field_name,title,units,field) 226 ! For a surface field 227 #ifdef CPP_XIOS 228 use xios_output_mod, only: xios_is_active_field 229 use xios_output_mod, only: send_xios_field 230 #endif 231 IMPLICIT NONE 232 include "dimensions.h" 233 INTEGER ngrid 234 PARAMETER( ngrid = 2+(jjm-1)*iim - 1/jjm ) 235 CHARACTER(LEN=*),INTENT(IN) :: field_name 236 CHARACTER(LEN=*),INTENT(IN) :: title 237 CHARACTER(LEN=*),INTENT(IN) :: units 238 LOGICAL,INTENT(IN) :: field(:) 252 real, dimension(ngrid) :: field_real 253 254 field_real = 0. 255 where (field) field_real = 1. 256 257 call writediagfi(ngrid,field_name,title,units,2,field_real) 258 #ifdef CPP_XIOS 259 ! only send the field to xios if the user asked for it 260 if (xios_is_active_field(field_name)) call send_xios_field(field_name,field_real) 261 #endif 262 263 END SUBROUTINE write_output_l1 264 265 !----------------------------------------------------------------------- 266 267 SUBROUTINE write_output_l2(field_name,title,units,field) 268 ! For a "3D" horizontal-vertical field 269 270 #ifdef CPP_XIOS 271 use xios_output_mod, only: xios_is_active_field 272 use xios_output_mod, only: send_xios_field 273 #endif 274 275 use comsoil_h, only: nsoilmx 276 use writediagsoil_mod, only: writediagsoil 277 278 implicit none 279 280 include "dimensions.h" 281 282 integer, parameter :: ngrid = 2 + (jjm - 1)*iim - 1/jjm 283 character(*), intent(in) :: field_name 284 character(*), intent(in) :: title 285 character(*), intent(in) :: units 286 logical, dimension(:,:), intent(in) :: field 239 287 ! Local argument used to convert logical to real 240 REAL :: field_real(ngrid) 241 INTEGER :: i 242 243 field_real(:)=0. 244 DO i=1,ngrid 245 if(field(i)) field_real(i)=1. 246 ENDDO 247 248 call writediagfi(ngrid,field_name,title,units,2,field_real(:)) 249 #ifdef CPP_XIOS 250 if (xios_is_active_field(field_name)) then 251 ! only send the field to xios if the user asked for it 252 call send_xios_field(field_name,field_real) 253 endif 254 #endif 255 256 END SUBROUTINE write_output_l1 257 258 !---------------------------------------------------------------------- 259 260 SUBROUTINE write_output_l2(field_name,title,units,field) 261 ! For a "3D" horizontal-vertical field 262 #ifdef CPP_XIOS 263 use xios_output_mod, only: xios_is_active_field 264 use xios_output_mod, only: send_xios_field 265 #endif 266 use comsoil_h, only: nsoilmx 267 use writediagsoil_mod, only: writediagsoil 268 IMPLICIT NONE 269 include "dimensions.h" 270 INTEGER ngrid 271 PARAMETER( ngrid = 2+(jjm-1)*iim - 1/jjm ) 272 CHARACTER(LEN=*),INTENT(IN) :: field_name 273 CHARACTER(LEN=*),INTENT(IN) :: title 274 CHARACTER(LEN=*),INTENT(IN) :: units 275 LOGICAL,INTENT(IN) :: field(:,:) 276 ! Local argument used to convert logical to real 277 REAL,allocatable :: field_real(:,:) 278 INTEGER :: i,j 279 280 allocate(field_real(size(field,1),size(field,2))) 281 282 field_real(:,:)=0. 283 DO i=1,size(field,1) 284 DO j=1,size(field,2) 285 if(field(i,j)) field_real(i,j)=1. 286 ENDDO 287 ENDDO 288 289 if(size(field(:,:),2).eq.nsoilmx) then 288 real, allocatable, dimension(:,:) :: field_real 289 290 allocate(field_real(size(field,1),size(field,2))) 291 field_real = 0. 292 where (field) field_real = 1. 293 294 if (size(field,2) == nsoilmx) then 290 295 call writediagsoil(ngrid,field_name,title,units,3,field_real) 291 else 292 call writediagfi(ngrid,field_name,title,units,3,field_real(:,:)) 293 endif 294 295 #ifdef CPP_XIOS 296 if (xios_is_active_field(field_name)) then 297 ! only send the field to xios if the user asked for it 298 call send_xios_field(field_name,field_real) 299 endif 300 #endif 301 302 deallocate(field_real) 303 304 END SUBROUTINE write_output_l2 296 else 297 call writediagfi(ngrid,field_name,title,units,3,field_real) 298 endif 299 300 #ifdef CPP_XIOS 301 ! only send the field to xios if the user asked for it 302 if (xios_is_active_field(field_name)) call send_xios_field(field_name,field_real) 303 #endif 304 305 deallocate(field_real) 306 307 END SUBROUTINE write_output_l2 305 308 306 309 END MODULE write_output_mod
Note: See TracChangeset
for help on using the changeset viewer.