[8] | 1 | MODULE mod_interface_ioipsl |
---|
| 2 | |
---|
[28] | 3 | |
---|
[8] | 4 | INTEGER,PARAMETER :: id_file=1 |
---|
| 5 | |
---|
| 6 | |
---|
| 7 | CONTAINS |
---|
| 8 | |
---|
| 9 | SUBROUTINE init_interface_ioipsl |
---|
| 10 | USE xmlio |
---|
| 11 | IMPLICIT NONE |
---|
| 12 | |
---|
| 13 | |
---|
| 14 | END SUBROUTINE init_interface_ioipsl |
---|
| 15 | |
---|
| 16 | |
---|
| 17 | SUBROUTINE set_time_parameters(ini_timestep0,zjulian0,timestep0) |
---|
[28] | 18 | USE xmlio |
---|
[8] | 19 | IMPLICIT NONE |
---|
| 20 | INTEGER :: ini_timestep0 |
---|
| 21 | REAL :: zjulian0, timestep0 |
---|
| 22 | |
---|
[28] | 23 | timestep_value=timestep0 |
---|
| 24 | initial_timestep=ini_timestep0 |
---|
| 25 | initial_date=zjulian0 |
---|
[8] | 26 | |
---|
| 27 | END SUBROUTINE set_time_parameters |
---|
| 28 | |
---|
| 29 | SUBROUTINE Create_file_definition(nb_server,server_rank) |
---|
| 30 | USE ioipsl |
---|
| 31 | USE xmlio |
---|
| 32 | IMPLICIT NONE |
---|
| 33 | INTEGER,INTENT(IN) :: nb_server |
---|
| 34 | INTEGER,INTENT(IN) :: server_rank |
---|
| 35 | |
---|
| 36 | TYPE(file_dep),POINTER :: pt_file_dep |
---|
| 37 | TYPE(file),POINTER :: pt_file |
---|
| 38 | TYPE(field),POINTER :: pt_field |
---|
| 39 | TYPE(grid),POINTER :: pt_grid |
---|
[29] | 40 | TYPE(zoom),POINTER :: pt_zoom |
---|
[8] | 41 | TYPE(axis),POINTER :: pt_axis |
---|
| 42 | TYPE(domain),POINTER :: pt_domain |
---|
| 43 | |
---|
| 44 | TYPE(sorted_list),POINTER :: axis_id |
---|
| 45 | LOGICAL :: found |
---|
| 46 | INTEGER :: ioipsl_axis_id |
---|
| 47 | INTEGER :: ioipsl_file_id |
---|
| 48 | INTEGER :: ioipsl_hori_id |
---|
| 49 | INTEGER :: ioipsl_domain_id |
---|
| 50 | INTEGER :: i,j |
---|
[29] | 51 | CHARACTER(LEN=20) :: direction |
---|
[40] | 52 | CHARACTER(LEN=255) :: full_name |
---|
[8] | 53 | CALL xmlio__close_definition |
---|
| 54 | |
---|
| 55 | ALLOCATE(axis_id) |
---|
| 56 | |
---|
| 57 | DO i=1,file_enabled%size |
---|
| 58 | CALL sorted_list__new(axis_id) |
---|
| 59 | |
---|
| 60 | pt_file_dep=>file_enabled%at(i)%pt |
---|
| 61 | pt_file=>pt_file_dep%file |
---|
| 62 | |
---|
| 63 | pt_grid=>pt_file_dep%grids%at(1)%pt |
---|
| 64 | pt_domain=>pt_grid%domain |
---|
[29] | 65 | pt_zoom=>pt_file_dep%zooms%at(1)%pt |
---|
| 66 | ! print *,TRIM(pt_file%name),' ',TRIM(pt_zoom%id) |
---|
| 67 | ! print*,'Global --->',pt_zoom%ni_glo,pt_zoom%nj_glo,pt_zoom%ibegin_glo,pt_zoom%jbegin_glo |
---|
| 68 | ! print*,'Local --->',pt_zoom%ni_loc,pt_zoom%nj_loc,pt_zoom%ibegin_loc,pt_zoom%jbegin_loc |
---|
[8] | 69 | |
---|
[29] | 70 | IF (pt_zoom%ni_loc*pt_zoom%nj_loc > 0) THEN |
---|
| 71 | |
---|
[40] | 72 | full_name=TRIM(pt_file%name) |
---|
| 73 | IF (pt_file%has_name_suffix) full_name=TRIM(full_name)//TRIM(pt_file%name_suffix) |
---|
[29] | 74 | IF ( (pt_zoom%ni_loc == pt_zoom%ni_glo) .AND. (pt_zoom%nj_loc == pt_zoom%nj_glo) ) THEN |
---|
| 75 | |
---|
[40] | 76 | CALL histbeg(TRIM(full_name),pt_domain%ni,pt_domain%lon, pt_domain%nj, pt_domain%lat, & |
---|
[32] | 77 | pt_zoom%ibegin_loc, pt_zoom%ni_loc,pt_zoom%jbegin_loc,pt_zoom%nj_loc, & |
---|
| 78 | initial_timestep, initial_date, timestep_value, & |
---|
[29] | 79 | ioipsl_hori_id, ioipsl_file_id) |
---|
| 80 | ELSE |
---|
| 81 | |
---|
| 82 | CALL set_ioipsl_domain_id(pt_grid,nb_server,server_rank,ioipsl_domain_id) |
---|
[40] | 83 | CALL histbeg(TRIM(full_name),pt_domain%ni,pt_domain%lon, pt_domain%nj, pt_domain%lat, & |
---|
[32] | 84 | pt_zoom%ibegin_loc, pt_zoom%ni_loc,pt_zoom%jbegin_loc,pt_zoom%nj_loc, & |
---|
| 85 | initial_timestep, initial_date, timestep_value, & |
---|
[29] | 86 | ioipsl_hori_id, ioipsl_file_id,domain_id=ioipsl_domain_id) |
---|
| 87 | |
---|
| 88 | ENDIF |
---|
| 89 | |
---|
| 90 | |
---|
| 91 | DO j=1,pt_file_dep%axis%size |
---|
| 92 | pt_axis=>pt_file_dep%axis%at(j)%pt |
---|
| 93 | CALL sorted_list__find(axis_id,hash(Pt_axis%name),ioipsl_axis_id,found) |
---|
| 94 | IF (.NOT. found) THEN |
---|
| 95 | IF (TRIM(pt_axis%name) /= "none") THEN |
---|
| 96 | |
---|
| 97 | IF (pt_axis%has_positive) THEN |
---|
| 98 | IF (pt_axis%positive) THEN |
---|
| 99 | direction="up" |
---|
| 100 | ELSE |
---|
| 101 | direction="down" |
---|
| 102 | ENDIF |
---|
| 103 | ELSE |
---|
| 104 | direction='unknown' |
---|
| 105 | ENDIF |
---|
| 106 | |
---|
| 107 | CALL histvert(ioipsl_file_id, TRIM(pt_axis%name),TRIM(pt_axis%description), & |
---|
| 108 | TRIM(pt_axis%unit), pt_axis%size,pt_axis%values, ioipsl_axis_id, & |
---|
| 109 | pdirect=direction) |
---|
| 110 | CALL sorted_list__add(axis_id,hash(Pt_axis%name),ioipsl_axis_id) |
---|
| 111 | ENDIF |
---|
[8] | 112 | ENDIF |
---|
[29] | 113 | ENDDO |
---|
| 114 | |
---|
| 115 | DO j=1,pt_file_dep%fields%size |
---|
| 116 | pt_field=>pt_file_dep%fields%at(j)%pt |
---|
| 117 | IF (pt_field%axis%name=="none") THEN |
---|
| 118 | pt_field%internal(id_file)=ioipsl_file_id |
---|
| 119 | CALL histdef(ioipsl_file_id, TRIM(pt_field%name), pt_field%description, & |
---|
| 120 | & pt_field%unit, pt_field%grid%domain%ni, pt_field%grid%domain%nj, & |
---|
| 121 | & ioipsl_hori_id, 1, 1, 1, -99, 32, pt_field%operation, & |
---|
| 122 | & real(pt_field%freq_op), real(pt_file%output_freq) ) |
---|
| 123 | ELSE |
---|
| 124 | pt_field%internal(id_file)=ioipsl_file_id |
---|
| 125 | CALL sorted_list__find(axis_id,hash(Pt_field%axis%name),ioipsl_axis_id,found) |
---|
| 126 | CALL histdef(ioipsl_file_id, TRIM(pt_field%name), pt_field%description, & |
---|
| 127 | & pt_field%unit, pt_field%grid%domain%ni, pt_field%grid%domain%nj, & |
---|
| 128 | & ioipsl_hori_id, pt_field%axis%size, 1, pt_field%axis%size, & |
---|
| 129 | & ioipsl_axis_id, 32, pt_field%operation, real(pt_field%freq_op), & |
---|
| 130 | & real(pt_file%output_freq) ) |
---|
| 131 | ENDIF |
---|
| 132 | ENDDO |
---|
| 133 | CALL histend(ioipsl_file_id) |
---|
| 134 | ENDIF |
---|
[8] | 135 | CALL sorted_list__delete(axis_id) |
---|
| 136 | ENDDO |
---|
| 137 | |
---|
| 138 | DEALLOCATE(axis_id) |
---|
| 139 | |
---|
| 140 | END SUBROUTINE Create_file_definition |
---|
| 141 | |
---|
| 142 | |
---|
| 143 | |
---|
| 144 | SUBROUTINE write_ioipsl_2d(varname,var) |
---|
| 145 | USE ioipsl |
---|
| 146 | USE xmlio |
---|
| 147 | IMPLICIT NONE |
---|
| 148 | CHARACTER(len=*),INTENT(IN) :: varname |
---|
| 149 | REAL ,INTENT(IN) :: var(:,:) |
---|
| 150 | |
---|
| 151 | TYPE(field_dep),POINTER :: pt_field_base |
---|
| 152 | TYPE(field) ,POINTER :: pt_field |
---|
| 153 | INTEGER :: nindex(size(var)) |
---|
| 154 | INTEGER :: ioipsl_file_id |
---|
| 155 | INTEGER :: pos |
---|
| 156 | LOGICAL :: found |
---|
| 157 | INTEGER :: i |
---|
| 158 | |
---|
| 159 | CALL sorted_list__find(sorted_id,hash(varname),pos,found) |
---|
[17] | 160 | |
---|
[8] | 161 | IF (found) THEN |
---|
| 162 | pt_field_base=>field_id%at(pos)%pt |
---|
| 163 | |
---|
| 164 | DO i=1,pt_field_base%field_out%size |
---|
| 165 | pt_field=>pt_field_base%field_out%at(i)%pt%field |
---|
[29] | 166 | IF ( pt_field%zoom%ni_loc * pt_field%zoom%nj_loc > 0) THEN |
---|
| 167 | ioipsl_file_id=pt_field%internal(id_file) |
---|
| 168 | CALL histwrite(ioipsl_file_id, TRIM(pt_field%name), timestep_number, var, size(var), nindex) |
---|
| 169 | ENDIF |
---|
[8] | 170 | ENDDO |
---|
| 171 | ENDIF |
---|
| 172 | |
---|
| 173 | END SUBROUTINE write_ioipsl_2d |
---|
| 174 | |
---|
| 175 | |
---|
| 176 | SUBROUTINE write_ioipsl_3d(varname,var) |
---|
| 177 | USE ioipsl |
---|
| 178 | USE xmlio |
---|
| 179 | IMPLICIT NONE |
---|
| 180 | CHARACTER(len=*),INTENT(IN) :: varname |
---|
| 181 | REAL ,INTENT(IN) :: var(:,:,:) |
---|
| 182 | |
---|
| 183 | TYPE(field_dep),POINTER :: pt_field_base |
---|
| 184 | TYPE(field) ,POINTER :: pt_field |
---|
| 185 | INTEGER :: nindex(size(var)) |
---|
| 186 | INTEGER :: ioipsl_file_id |
---|
| 187 | INTEGER :: pos |
---|
| 188 | LOGICAL :: found |
---|
| 189 | INTEGER :: i |
---|
| 190 | |
---|
| 191 | CALL sorted_list__find(sorted_id,hash(varname),pos,found) |
---|
[17] | 192 | |
---|
| 193 | IF (found) THEN |
---|
| 194 | pt_field_base=>field_id%at(pos)%pt |
---|
[8] | 195 | |
---|
[17] | 196 | DO i=1,pt_field_base%field_out%size |
---|
| 197 | pt_field=>pt_field_base%field_out%at(i)%pt%field |
---|
[29] | 198 | IF ( pt_field%zoom%ni_loc * pt_field%zoom%nj_loc > 0) THEN |
---|
| 199 | ioipsl_file_id=pt_field%internal(id_file) |
---|
| 200 | CALL histwrite(ioipsl_file_id, TRIM(pt_field%name), timestep_number, var, size(var), nindex) |
---|
| 201 | ENDIF |
---|
[17] | 202 | ENDDO |
---|
| 203 | ENDIF |
---|
[8] | 204 | END SUBROUTINE write_ioipsl_3d |
---|
| 205 | |
---|
| 206 | |
---|
| 207 | SUBROUTINE set_timestep(timestep_nb0) |
---|
[28] | 208 | USE xmlio |
---|
[8] | 209 | IMPLICIT NONE |
---|
| 210 | INTEGER,INTENT(IN) :: timestep_nb0 |
---|
| 211 | |
---|
[28] | 212 | timestep_number=timestep_nb0 |
---|
[8] | 213 | |
---|
| 214 | END SUBROUTINE set_timestep |
---|
| 215 | |
---|
| 216 | |
---|
| 217 | SUBROUTINE set_ioipsl_domain_id(pt_grid, nb_server,server_rank,domain_id) |
---|
| 218 | USE xmlio |
---|
| 219 | USE mod_ioserver_para |
---|
| 220 | USE ioipsl |
---|
| 221 | IMPLICIT NONE |
---|
| 222 | TYPE(grid), POINTER :: pt_grid |
---|
| 223 | INTEGER,INTENT(IN) :: nb_server |
---|
| 224 | INTEGER,INTENT(IN) :: server_rank |
---|
| 225 | INTEGER,INTENT(OUT) :: domain_id |
---|
| 226 | TYPE(domain), POINTER :: pt_domain |
---|
| 227 | |
---|
| 228 | INTEGER,DIMENSION(2) :: ddid |
---|
| 229 | INTEGER,DIMENSION(2) :: dsg |
---|
| 230 | INTEGER,DIMENSION(2) :: dsl |
---|
| 231 | INTEGER,DIMENSION(2) :: dpf |
---|
| 232 | INTEGER,DIMENSION(2) :: dpl |
---|
| 233 | INTEGER,DIMENSION(2) :: dhs |
---|
| 234 | INTEGER,DIMENSION(2) :: dhe |
---|
| 235 | |
---|
| 236 | pt_domain=>pt_grid%domain |
---|
| 237 | |
---|
| 238 | ddid = (/ 1,2 /) |
---|
| 239 | dsg = (/ pt_grid%ni, pt_grid%nj /) |
---|
| 240 | dsl = (/ pt_domain%ni, pt_domain%nj /) |
---|
| 241 | dpf = (/ pt_domain%ibegin,pt_domain%jbegin /) |
---|
| 242 | dpl = (/ pt_domain%iend, pt_domain%jend /) |
---|
| 243 | dhs = (/ 0,0 /) |
---|
| 244 | dhe = (/ 0,0 /) |
---|
| 245 | |
---|
| 246 | call flio_dom_set(nb_server,server_rank,ddid,dsg,dsl,dpf,dpl,dhs,dhe, & |
---|
| 247 | 'BOX',domain_id) |
---|
| 248 | |
---|
| 249 | END SUBROUTINE set_ioipsl_domain_id |
---|
| 250 | |
---|
| 251 | |
---|
| 252 | SUBROUTINE ioipsl_finalize |
---|
| 253 | USE ioipsl |
---|
| 254 | IMPLICIT NONE |
---|
| 255 | |
---|
| 256 | CALL histclo |
---|
| 257 | |
---|
| 258 | END SUBROUTINE ioipsl_finalize |
---|
| 259 | |
---|
| 260 | END MODULE mod_interface_ioipsl |
---|